[PATCH master 1/3] virtio: ring: fix stale data in queue after reset

Ahmad Fatoum a.fatoum at barebox.org
Mon Jan 12 00:55:39 PST 2026


When resetting barebox for QEMU Virt or chainloading it, the log is
spammed with:

  virtio_net virtio1: id 65536 out of range

This is because we have two ways to allocate the vrings, either via
dma_alloc_coherent or memalign and the latter doesn't zero the queues.

A better fix that makes use of the DMA APIs unconditionally will follow
in a later release.

Co-developed-by: Claude <noreply at claude.ai>
[ahmad: Claude was pointed at QEMU, Linux and U-Boot implementations
 and found the discrepancy, but had a different less efficient fix]

Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 drivers/virtio/virtio_ring.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index c1c84e49615f..8b6469f54d2a 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -369,6 +369,8 @@ static void *vring_alloc_queue(struct virtio_device *vdev,
 			phys_addr_t phys_addr = virt_to_phys(queue);
 			*dma_handle = (dma_addr_t)phys_addr;
 
+			memset(queue, 0x00, PAGE_ALIGN(size));
+
 			/*
 			 * Sanity check: make sure we dind't truncate
 			 * the address.  The only arches I can find that
-- 
2.47.3




More information about the barebox mailing list