kvm: fix zero length mmio searching
authorJason Wang <jasowang@redhat.com>
Tue, 15 Sep 2015 06:41:57 +0000 (14:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Oct 2015 21:39:16 +0000 (14:39 -0700)
commit28b5dc064ae410801e1aed8ea66b1a1bd5556cbb
tree5399c016f416f4d221ee4d26f0ed265a6184acf0
parent1230ae0e99e05ced8a945a1a2c5762ce5c6c97c9
kvm: fix zero length mmio searching

commit 8f4216c7d28976f7ec1b2bcbfa0a9f787133c45e upstream.

Currently, if we had a zero length mmio eventfd assigned on
KVM_MMIO_BUS. It will never be found by kvm_io_bus_cmp() since it
always compares the kvm_io_range() with the length that guest
wrote. This will cause e.g for vhost, kick will be trapped by qemu
userspace instead of vhost. Fixing this by using zero length if an
iodevice is zero length.

Cc: Gleb Natapov <gleb@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/kvm_main.c