|
|
586cba |
From 793d6d56190397624efdcaf6e0112bd12e39c05d Mon Sep 17 00:00:00 2001
|
|
|
586cba |
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
|
|
|
586cba |
Date: Thu, 21 Jul 2022 15:25:01 +0200
|
|
|
586cba |
Subject: [PATCH 02/32] vhost: Fix device's used descriptor dequeue
|
|
|
586cba |
MIME-Version: 1.0
|
|
|
586cba |
Content-Type: text/plain; charset=UTF-8
|
|
|
586cba |
Content-Transfer-Encoding: 8bit
|
|
|
586cba |
|
|
|
586cba |
RH-Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
RH-MergeRequest: 108: Net Control Virtqueue shadow Support
|
|
|
586cba |
RH-Commit: [2/27] b92803a0681c94c65d243dd07424522387594760 (eperezmartin/qemu-kvm)
|
|
|
586cba |
RH-Bugzilla: 1939363
|
|
|
586cba |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
586cba |
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
|
586cba |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
586cba |
|
|
|
586cba |
Bugzilla: https://bugzilla.redhat.com/1939363
|
|
|
586cba |
|
|
|
586cba |
Upstream Status: git://git.qemu.org/qemu.git
|
|
|
586cba |
|
|
|
586cba |
commit 81abfa5724c9a6502d7a1d3a67c55f2a303a1170
|
|
|
586cba |
Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
Date: Thu May 12 19:57:43 2022 +0200
|
|
|
586cba |
|
|
|
586cba |
vhost: Fix device's used descriptor dequeue
|
|
|
586cba |
|
|
|
586cba |
Only the first one of them were properly enqueued back.
|
|
|
586cba |
|
|
|
586cba |
Fixes: 100890f7ca ("vhost: Shadow virtqueue buffers forwarding")
|
|
|
586cba |
|
|
|
586cba |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
Message-Id: <20220512175747.142058-3-eperezma@redhat.com>
|
|
|
586cba |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
586cba |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
586cba |
|
|
|
586cba |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
---
|
|
|
586cba |
hw/virtio/vhost-shadow-virtqueue.c | 17 +++++++++++++++--
|
|
|
586cba |
1 file changed, 15 insertions(+), 2 deletions(-)
|
|
|
586cba |
|
|
|
586cba |
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
586cba |
index 3155801f50..31fc50907d 100644
|
|
|
586cba |
--- a/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
586cba |
+++ b/hw/virtio/vhost-shadow-virtqueue.c
|
|
|
586cba |
@@ -334,12 +334,22 @@ static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
|
|
|
586cba |
svq->vring.avail->flags |= cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
+static uint16_t vhost_svq_last_desc_of_chain(const VhostShadowVirtqueue *svq,
|
|
|
586cba |
+ uint16_t num, uint16_t i)
|
|
|
586cba |
+{
|
|
|
586cba |
+ for (uint16_t j = 0; j < (num - 1); ++j) {
|
|
|
586cba |
+ i = le16_to_cpu(svq->desc_next[i]);
|
|
|
586cba |
+ }
|
|
|
586cba |
+
|
|
|
586cba |
+ return i;
|
|
|
586cba |
+}
|
|
|
586cba |
+
|
|
|
586cba |
static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
|
|
|
586cba |
uint32_t *len)
|
|
|
586cba |
{
|
|
|
586cba |
const vring_used_t *used = svq->vring.used;
|
|
|
586cba |
vring_used_elem_t used_elem;
|
|
|
586cba |
- uint16_t last_used;
|
|
|
586cba |
+ uint16_t last_used, last_used_chain, num;
|
|
|
586cba |
|
|
|
586cba |
if (!vhost_svq_more_used(svq)) {
|
|
|
586cba |
return NULL;
|
|
|
586cba |
@@ -365,7 +375,10 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
|
|
|
586cba |
return NULL;
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
- svq->desc_next[used_elem.id] = svq->free_head;
|
|
|
586cba |
+ num = svq->ring_id_maps[used_elem.id]->in_num +
|
|
|
586cba |
+ svq->ring_id_maps[used_elem.id]->out_num;
|
|
|
586cba |
+ last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
|
|
|
586cba |
+ svq->desc_next[last_used_chain] = svq->free_head;
|
|
|
586cba |
svq->free_head = used_elem.id;
|
|
|
586cba |
|
|
|
586cba |
*len = used_elem.len;
|
|
|
586cba |
--
|
|
|
586cba |
2.31.1
|
|
|
586cba |
|