Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1222511

[PATCH V4 3/4] kvm: fix zero length mmio searching

From Jason Wang <jasowang@redhat.com>
Newsgroups linux.kernel
Subject [PATCH V4 3/4] kvm: fix zero length mmio searching
Date 2015-09-11 05:20 +0200
Message-ID <q7n2y-645-11@gated-at.bofh.it> (permalink)
References <q7n2x-645-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently, if we had a zero length mmio eventfd assigned on
KVM_MMIO_BUS. It will never found by kvm_io_bus_cmp() since it always
compare the kvm_io_range() with the length that guest wrote. This will
lead 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>
---
 virt/kvm/kvm_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d8db2f8f..d4c3b66 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3071,9 +3071,11 @@ static void kvm_io_bus_destroy(struct kvm_io_bus *bus)
 static inline int kvm_io_bus_cmp(const struct kvm_io_range *r1,
 				 const struct kvm_io_range *r2)
 {
+	int len = r2->len ? r1->len : 0;
+
 	if (r1->addr < r2->addr)
 		return -1;
-	if (r1->addr + r1->len > r2->addr + r2->len)
+	if (r1->addr + len > r2->addr + r2->len)
 		return 1;
 	return 0;
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V4 0/4] Fast MMIO eventfd fixes Jason Wang <jasowang@redhat.com> - 2015-09-11 05:20 +0200
  [PATCH V4 3/4] kvm: fix zero length mmio searching Jason Wang <jasowang@redhat.com> - 2015-09-11 05:20 +0200
    Re: [PATCH V4 3/4] kvm: fix zero length mmio searching Paolo Bonzini <pbonzini@redhat.com> - 2015-09-11 10:30 +0200
      Re: [PATCH V4 3/4] kvm: fix zero length mmio searching Cornelia Huck <cornelia.huck@de.ibm.com> - 2015-09-11 10:40 +0200
        Re: [PATCH V4 3/4] kvm: fix zero length mmio searching Jason Wang <jasowang@redhat.com> - 2015-09-11 11:30 +0200
  Re: [PATCH V4 0/4] Fast MMIO eventfd fixes "Michael S. Tsirkin" <mst@redhat.com> - 2015-09-11 10:20 +0200
    Re: [PATCH V4 0/4] Fast MMIO eventfd fixes Paolo Bonzini <pbonzini@redhat.com> - 2015-09-11 10:40 +0200
      Re: [PATCH V4 0/4] Fast MMIO eventfd fixes Jason Wang <jasowang@redhat.com> - 2015-09-11 11:30 +0200
        Re: [PATCH V4 0/4] Fast MMIO eventfd fixes "Michael S. Tsirkin" <mst@redhat.com> - 2015-09-13 11:00 +0200
      Re: [PATCH V4 0/4] Fast MMIO eventfd fixes "Michael S. Tsirkin" <mst@redhat.com> - 2015-09-13 11:00 +0200

csiph-web