1
0
Fork 0
remarkable-linux/virt/kvm
Xiubo Li 3165159812 kvm: Fix irq route entries exceeding KVM_MAX_IRQ_ROUTES
[ Upstream commit caf1ff26e1 ]

These days, we experienced one guest crash with 8 cores and 3 disks,
with qemu error logs as bellow:

qemu-system-x86_64: /build/qemu-2.0.0/kvm-all.c:984:
kvm_irqchip_commit_routes: Assertion `ret == 0' failed.

And then we found one patch(bdf026317d) in qemu tree, which said
could fix this bug.

Execute the following script will reproduce the BUG quickly:

irq_affinity.sh
========================================================================

vda_irq_num=25
vdb_irq_num=27
while [ 1 ]
do
    for irq in {1,2,4,8,10,20,40,80}
        do
            echo $irq > /proc/irq/$vda_irq_num/smp_affinity
            echo $irq > /proc/irq/$vdb_irq_num/smp_affinity
            dd if=/dev/vda of=/dev/zero bs=4K count=100 iflag=direct
            dd if=/dev/vdb of=/dev/zero bs=4K count=100 iflag=direct
        done
done
========================================================================

The following qemu log is added in the qemu code and is displayed when
this bug reproduced:

kvm_irqchip_commit_routes: max gsi: 1008, nr_allocated_irq_routes: 1024,
irq_routes->nr: 1024, gsi_count: 1024.

That's to say when irq_routes->nr == 1024, there are 1024 routing entries,
but in the kernel code when routes->nr >= 1024, will just return -EINVAL;

The nr is the number of the routing entries which is in of
[1 ~ KVM_MAX_IRQ_ROUTES], not the index in [0 ~ KVM_MAX_IRQ_ROUTES - 1].

This patch fix the BUG above.

Cc: stable@vger.kernel.org
Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
Signed-off-by: Wei Tang <tangwei@cmss.chinamobile.com>
Signed-off-by: Zhang Zhuoyu <zhangzhuoyu@cmss.chinamobile.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
2016-07-10 20:19:58 -04:00
..
arm KVM: arm/arm64: vgic: Ensure bitmaps are long enough 2016-03-07 16:30:53 -05:00
Kconfig KVM: Disable compat ioctl for s390 2015-02-09 12:44:14 +01:00
async_pf.c KVM: async_pf: do not warn on page allocation failures 2016-03-07 16:35:16 -05:00
async_pf.h KVM: Halt vcpu if page it tries to access is swapped out 2011-01-12 11:21:39 +02:00
coalesced_mmio.c KVM: move iodev.h from virt/kvm/ to include/kvm 2015-03-26 21:43:12 +00:00
coalesced_mmio.h KVM: Make coalesced mmio use a device per zone 2011-09-25 19:17:57 +03:00
eventfd.c kvm: fix double free for fast mmio eventfd 2015-10-22 14:43:10 -07:00
irqchip.c KVM: irqfd: fix NULL pointer dereference in kvm_irq_map_gsi 2016-06-17 15:37:24 -04:00
kvm_main.c kvm: Fix irq route entries exceeding KVM_MAX_IRQ_ROUTES 2016-07-10 20:19:58 -04:00
vfio.c kvm: vfio: fix unregister kvm_device_ops of vfio 2014-10-24 13:30:47 +02:00
vfio.h kvm: vfio: fix unregister kvm_device_ops of vfio 2014-10-24 13:30:47 +02:00