qemu/include/hw/virtio
Laurent Vivier 0c9753ebda virtio-pci: fix virtio_pci_queue_enabled()
In legacy mode, virtio_pci_queue_enabled() falls back to
virtio_queue_enabled() to know if the queue is enabled.

But virtio_queue_enabled() calls again virtio_pci_queue_enabled()
if k->queue_enabled is set. This ends in a crash after a stack
overflow.

The problem can be reproduced with
"-device virtio-net-pci,disable-legacy=off,disable-modern=true
 -net tap,vhost=on"

And a look to the backtrace is very explicit:

    ...
    #4  0x000000010029a438 in virtio_queue_enabled ()
    #5  0x0000000100497a9c in virtio_pci_queue_enabled ()
    ...
    #130902 0x000000010029a460 in virtio_queue_enabled ()
    #130903 0x0000000100497a9c in virtio_pci_queue_enabled ()
    #130904 0x000000010029a460 in virtio_queue_enabled ()
    #130905 0x0000000100454a20 in vhost_net_start ()
    ...

This patch fixes the problem by introducing a new function
for the legacy case and calls it from virtio_pci_queue_enabled().
It also calls it from virtio_queue_enabled() to avoid code duplication.

Fixes: f19bcdfedd ("virtio-pci: implement queue_enabled method")
Cc: Jason Wang <jasowang@redhat.com>
Cc: Cindy Lu <lulu@redhat.com>
CC: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20200727153319.43716-1-lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2020-07-27 11:34:50 -04:00
..
vhost-backend.h vhost-vdpa: introduce vhost-vdpa backend 2020-07-07 07:59:51 -04:00
vhost-scsi-common.h
vhost-scsi.h
vhost-user-blk.h
vhost-user-fs.h
vhost-user-scsi.h
vhost-user-vsock.h virtio: add vhost-user-vsock base device 2020-06-12 10:17:06 -04:00
vhost-user.h Add VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 2020-06-12 10:17:06 -04:00
vhost-vdpa.h vhost-vdpa: introduce vhost-vdpa backend 2020-07-07 07:59:51 -04:00
vhost-vsock-common.h vhost-vsock: add vhost-vsock-common abstraction 2020-06-12 10:17:06 -04:00
vhost-vsock.h vhost-vsock: add vhost-vsock-common abstraction 2020-06-12 10:17:06 -04:00
vhost.h vhost-vdpa: introduce vhost-vdpa backend 2020-07-07 07:59:51 -04:00
virtio-access.h
virtio-balloon.h virtio-balloon: Replace free page hinting references to 'report' with 'hint' 2020-07-22 07:57:07 -04:00
virtio-blk.h virtio-blk: On restart, process queued requests in the proper context 2020-06-17 14:53:39 +02:00
virtio-bus.h virtio-bus: introduce queue_enabled method 2020-07-03 07:57:04 -04:00
virtio-crypto.h
virtio-gpu-bswap.h
virtio-gpu-pci.h
virtio-gpu-pixman.h
virtio-gpu.h
virtio-input.h
virtio-iommu.h virtio-iommu: Implement RESV_MEM probe request 2020-07-03 16:59:42 +01:00
virtio-mem.h virtio-mem: Exclude unplugged memory during migration 2020-07-03 07:57:04 -04:00
virtio-mmio.h
virtio-net.h virtio-net: reference implementation of hash report 2020-06-18 21:05:50 +08:00
virtio-pmem.h
virtio-rng.h
virtio-scsi.h
virtio-serial.h
virtio.h virtio-pci: fix virtio_pci_queue_enabled() 2020-07-27 11:34:50 -04:00