[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/26] virtio: fix descriptor counting in virtqueue_p
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 22/26] virtio: fix descriptor counting in virtqueue_pop |
Date: |
Sun, 15 Oct 2017 06:23:58 +0300 |
From: Wolfgang Bumiller <address@hidden>
While changing the s/g list allocation, commit 3b3b0628
also changed the descriptor counting to count iovec entries
as split by cpu_physical_memory_map(). Previously only the
actual descriptor entries were counted and the split into
the iovec happened afterwards in virtqueue_map().
Count the entries again instead to avoid erroneous
"Looped descriptor" errors.
Reported-by: Hans Middelhoek <address@hidden>
Link: https://forum.proxmox.com/threads/vm-crash-with-memory-hotplug.35904/
Fixes: 3b3b0628217e ("virtio: slim down allocation of VirtQueueElements")
Signed-off-by: Wolfgang Bumiller <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 311929e..5884ce3 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -834,7 +834,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
int64_t len;
VirtIODevice *vdev = vq->vdev;
VirtQueueElement *elem = NULL;
- unsigned out_num, in_num;
+ unsigned out_num, in_num, elem_entries;
hwaddr addr[VIRTQUEUE_MAX_SIZE];
struct iovec iov[VIRTQUEUE_MAX_SIZE];
VRingDesc desc;
@@ -852,7 +852,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
smp_rmb();
/* When we start there are none of either input nor output. */
- out_num = in_num = 0;
+ out_num = in_num = elem_entries = 0;
max = vq->vring.num;
@@ -922,7 +922,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
}
/* If we've got too many, that implies a descriptor loop. */
- if ((in_num + out_num) > max) {
+ if (++elem_entries > max) {
virtio_error(vdev, "Looped descriptor");
goto err_undo_map;
}
--
MST
- [Qemu-devel] [PULL 11/26] pci: allow 32-bit PCI IO accesses to pass through the PCI bridge, (continued)
- [Qemu-devel] [PULL 11/26] pci: allow 32-bit PCI IO accesses to pass through the PCI bridge, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 12/26] hw/pci-bridge/pcie_pci_bridge: properly handle MSI unavailability case, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 13/26] virtio/pci/migration: Convert to VMState, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 14/26] PCI: PCIe access should always be little endian, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 15/26] pci: conventional-pci-device and pci-express-device interfaces, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 16/26] pci: Add interface names to hybrid PCI devices, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 17/26] pci: Add INTERFACE_PCIE_DEVICE to all PCIe devices, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 19/26] xen/pt: Mark TYPE_XEN_PT_DEVICE as hybrid, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 20/26] pci: Validate interfaces on base_class_init, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 21/26] hw/gen_pcie_root_port: make IO RO 0 on IO disabled, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 22/26] virtio: fix descriptor counting in virtqueue_pop,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 24/26] isapc: Remove unnecessary migration compatibility code, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 23/26] virtio-pci: Replace modern_as with direct access to modern_bar, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 25/26] pc: remove useless hot_add_cpu initialisation, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 26/26] tests/pxe: Test more NICs when running in SPEED=slow mode, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 18/26] pci: Add INTERFACE_CONVENTIONAL_PCI_DEVICE to Conventional PCI devices, Michael S. Tsirkin, 2017/10/14
- Re: [Qemu-devel] [PULL 00/26] pc, pci, virtio: fixes, features, Peter Maydell, 2017/10/16