Messages in this thread | | | Date | Tue, 8 Aug 2017 21:50:45 +0800 | From | "Longpeng (Mike)" <> | Subject | Re: [PATCH] KVM: X86: expand ->arch.apic_arb_prio to u64 |
| |
On 2017/8/8 21:08, Paolo Bonzini wrote:
> On 08/08/2017 13:37, Longpeng(Mike) wrote: >> Currently 'apic_arb_prio' is int32_t, it's too short for long >> time running. In our environment, it overflowed and then the >> UBSAN was angry: >> >> signed integer overflow: >> 2147483647 + 1 cannot be represented in type 'int' >> CPU: 22 PID: 31237 Comm: qemu-kvm Tainted: ... >> ... >> Call Trace: >> [<ffffffff81f030b6>] dump_stack+0x1e/0x20 >> [<ffffffff81f03173>] ubsan_epilogue+0x12/0x55 >> [<ffffffff81f04658>] handle_overflow+0x1ba/0x215 >> [<ffffffff81f046dd>] __ubsan_handle_add_overflow+0x2a/0x31 >> [<ffffffffa126cb1a>] __apic_accept_irq+0x57a/0x5d0 [kvm] >> [<ffffffffa126d14f>] kvm_apic_set_irq+0x9f/0xf0 [kvm] >> [<ffffffffa126db20>] kvm_irq_delivery_to_apic_fast+0x450/0x910 [kvm] >> [<ffffffffa127d8ea>] kvm_irq_delivery_to_apic+0xfa/0x7a0 [kvm] >> [<ffffffffa127e039>] kvm_set_msi+0xa9/0x100 [kvm] >> [<ffffffffa12871ed>] kvm_send_userspace_msi+0x14d/0x1f0 [kvm] >> [<ffffffffa11ed56e>] kvm_vm_ioctl+0x4ee/0xdd0 [kvm] >> ... >> >> We expand it to u64, this is large enough. Suppose the vcpu receives >> 1000 irqs per second, then it won't overflow in 584942417 years. >> ( 18446744073709551615/1000/3600/24/365 = 584942417 ) > > Since you only look at the difference, changing it to uint32_t should be > enough.
Hi Paolo,
I'm afraid uint32_t isn't enough. For 1000 irqs per second, it can only holds 49 days ( although the overflow won't cause any corruption ).
4294967295/1000/3600/24 = 49
> > Paolo >
> . >
-- Regards, Longpeng(Mike)
| |