79c4324644
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
63 lines
2.1 KiB
Diff
63 lines
2.1 KiB
Diff
From d76e2c5a5213d51dd8c48315e26c277423ade99f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
|
|
Date: Wed, 20 Jul 2022 08:59:35 +0200
|
|
Subject: [PATCH] vhost: Track number of descs in SVQDescState
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
A guest's buffer continuos on GPA may need multiple descriptors on
|
|
qemu's VA, so SVQ should track its length sepparatedly.
|
|
|
|
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
Signed-off-by: fangyi <eric.fangyi@huawei.com>
|
|
---
|
|
hw/virtio/vhost-shadow-virtqueue.c | 4 ++--
|
|
hw/virtio/vhost-shadow-virtqueue.h | 6 ++++++
|
|
2 files changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
|
|
index 5ddc04e9d6..c10c74b91f 100644
|
|
--- a/hw/virtio/vhost-shadow-virtqueue.c
|
|
+++ b/hw/virtio/vhost-shadow-virtqueue.c
|
|
@@ -256,6 +256,7 @@ static int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
|
|
}
|
|
|
|
svq->desc_state[qemu_head].elem = elem;
|
|
+ svq->desc_state[qemu_head].ndescs = ndescs;
|
|
vhost_svq_kick(svq);
|
|
return 0;
|
|
}
|
|
@@ -417,8 +418,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
|
|
return NULL;
|
|
}
|
|
|
|
- num = svq->desc_state[used_elem.id].elem->in_num +
|
|
- svq->desc_state[used_elem.id].elem->out_num;
|
|
+ num = svq->desc_state[used_elem.id].ndescs;
|
|
last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
|
|
svq->desc_next[last_used_chain] = svq->free_head;
|
|
svq->free_head = used_elem.id;
|
|
diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
|
|
index d646c35054..5c7e7cbab6 100644
|
|
--- a/hw/virtio/vhost-shadow-virtqueue.h
|
|
+++ b/hw/virtio/vhost-shadow-virtqueue.h
|
|
@@ -17,6 +17,12 @@
|
|
|
|
typedef struct SVQDescState {
|
|
VirtQueueElement *elem;
|
|
+
|
|
+ /*
|
|
+ * Number of descriptors exposed to the device. May or may not match
|
|
+ * guest's
|
|
+ */
|
|
+ unsigned int ndescs;
|
|
} SVQDescState;
|
|
|
|
/* Shadow virtqueue to relay notifications */
|
|
--
|
|
2.27.0
|
|
|