[PATCH] net/virtio: fix packed queue device event address

Liangxing Wang wangliangxing at hygon.cn
Thu Dec 3 09:34:10 CET 2026


The modern PCI queue setup uses the split ring layout to calculate
the Device Event address for packed virtqueues. For queue sizes of 256,
512, and 1024 descriptors, the extra split available ring entries fit
within the padding before the next 4 KiB boundary, so the computed
address matches the packed layout.

At a queue size of 2048 descriptors, the extra entries push the
programmed offset from 0x9000 to 0xa000, outside the allocated vring
memory.

Derive the Driver Event and Device Event IOVAs from the offsets of the
packed ring pointers initialized by vring_init_packed().

Bugzilla ID: 1800
Fixes: f803734b0f2e ("net/virtio: vring init for packed queues")
Cc: stable at dpdk.org

Signed-off-by: Liangxing Wang <wangliangxing at hygon.cn>
---
 drivers/net/virtio/virtio_pci.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 44e4400af7..baf4f7413b 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -427,10 +427,18 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
 	uint16_t notify_off;
 
 	desc_addr = vq->vq_ring_mem;
-	avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
-	used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
-							 ring[vq->vq_nentries]),
-				   VIRTIO_VRING_ALIGN);
+	if (virtio_with_packed_queue(hw)) {
+		const struct vring_packed *vr = &vq->vq_packed.ring;
+		uintptr_t base = (uintptr_t)vr->desc;
+
+		avail_addr = desc_addr + ((uintptr_t)vr->driver - base);
+		used_addr = desc_addr + ((uintptr_t)vr->device - base);
+	} else {
+		avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
+		used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
+								 ring[vq->vq_nentries]),
+					   VIRTIO_VRING_ALIGN);
+	}
 
 	rte_write16(vq->vq_queue_index, &dev->common_cfg->queue_select);
 
-- 
2.43.0




More information about the stable mailing list