lkml.org 
[lkml]   [2015]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH V4 3/4] kvm: fix zero length mmio searching
    Date
    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


    \
     
     \ /
      Last update: 2015-09-11 05:41    [W:4.129 / U:0.096 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site