]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0014-virtio-fix-descriptor-counting-in-virtqueue_pop.patch
lower debhelper dependency to version 9
[pve-qemu.git] / debian / patches / extra / 0014-virtio-fix-descriptor-counting-in-virtqueue_pop.patch
CommitLineData
fb8b489c
WB
1From 3474ad551f5ff8c550d388251c9555882d9beb5d Mon Sep 17 00:00:00 2001
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Tue, 19 Sep 2017 14:20:28 +0200
4Subject: [PATCH 14/14] virtio: fix descriptor counting in virtqueue_pop
5
6While changing the s/g list allocation, commit 3b3b0628
7also changed the descriptor counting to count iovec entries
8as split by cpu_physical_memory_map(). Previously only the
9actual descriptor entries were counted and the split into
10the iovec happened afterwards in virtqueue_map().
11Count the entries again instead to avoid erroneous
12"Looped descriptor" errors.
13
14Reported-by: Hans Middelhoek <h.middelhoek@ospito.nl>
15Link: https://forum.proxmox.com/threads/vm-crash-with-memory-hotplug.35904/
16Fixes: 3b3b0628217e ("virtio: slim down allocation of VirtQueueElements")
17Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
18---
19 hw/virtio/virtio.c | 6 +++---
20 1 file changed, 3 insertions(+), 3 deletions(-)
21
22diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
23index 890b4d7eb7..33bb770177 100644
24--- a/hw/virtio/virtio.c
25+++ b/hw/virtio/virtio.c
26@@ -834,7 +834,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
27 int64_t len;
28 VirtIODevice *vdev = vq->vdev;
29 VirtQueueElement *elem = NULL;
30- unsigned out_num, in_num;
31+ unsigned out_num, in_num, elem_entries;
32 hwaddr addr[VIRTQUEUE_MAX_SIZE];
33 struct iovec iov[VIRTQUEUE_MAX_SIZE];
34 VRingDesc desc;
35@@ -852,7 +852,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
36 smp_rmb();
37
38 /* When we start there are none of either input nor output. */
39- out_num = in_num = 0;
40+ out_num = in_num = elem_entries = 0;
41
42 max = vq->vring.num;
43
44@@ -922,7 +922,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
45 }
46
47 /* If we've got too many, that implies a descriptor loop. */
48- if ((in_num + out_num) > max) {
49+ if (++elem_entries > max) {
50 virtio_error(vdev, "Looped descriptor");
51 goto err_undo_map;
52 }
53--
542.11.0
55