Skip to contentSkip to conversation

libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick

PATCH In review Zheyu Ma 3 participants 3 messages Mar 20, 2024

lore
Share & tools
lore

Zheyu Ma

author
#0 lore raw

PATCH 1/1 libqos/virtio.c: Correct 'flags' reading in qvirtqueue_kick

In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from vq->avail instead of the correct vq->used location. This update ensures 'flags' are read from the correct location as per the virtio standard.

---
 tests/qtest/libqos/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/libqos/virtio.c +1 -1
index 82a6e122bf..a21b6eee9c 100644
@@ -394,7 +394,7 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
     qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
 
     /* Must read after idx is updated */
-    flags = qvirtio_readw(d, qts, vq->avail);
+    flags = qvirtio_readw(d, qts, vq->used);
     avail_event = qvirtio_readw(d, qts, vq->used + 4 +
                                 sizeof(struct vring_used_elem) * vq->size);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Cc'ing Marc & Stefan for commit 1053587c3f ("libqos: Added EVENT_IDX support").

Quoted 14 lines · Zheyu Ma

In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from vq->avail instead of the correct vq->used location. This update ensures 'flags' are read from the correct location as per the virtio standard.

---
  tests/qtest/libqos/virtio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/libqos/virtio.c +0 -0
index 82a6e122bf..a21b6eee9c 100644

tests/qtest/libqos/virtio.c void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, · line 400

Quoted 8 lines
tests/qtest/libqos/virtio.c +1 -1
@@ -394,7 +394,7 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
      qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
 
      /* Must read after idx is updated */
-    flags = qvirtio_readw(d, qts, vq->avail);
+    flags = qvirtio_readw(d, qts, vq->used);
      avail_event = qvirtio_readw(d, qts, vq->used + 4 +
                                  sizeof(struct vring_used_elem) * vq->size);
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Zheyu Ma
Quoted 9 lines · Zheyu Ma

In qvirtqueue_kick(), the 'flags' were previously being incorrectly read from vq->avail instead of the correct vq->used location. This update ensures 'flags' are read from the correct location as per the virtio standard.

---
 tests/qtest/libqos/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines
tests/qtest/libqos/virtio.c +1 -2
index 82a6e122bf..a21b6eee9c 100644
@@ -394,7 +394,7 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
     qvirtio_writew(d, qts, vq->avail + 2, idx + 1);
 
     /* Must read after idx is updated */
-    flags = qvirtio_readw(d, qts, vq->avail);
+    flags = qvirtio_readw(d, qts, vq->used);
     avail_event = qvirtio_readw(d, qts, vq->used + 4 +
                                 sizeof(struct vring_used_elem) * vq->size);
 
--

2.34.1