driver/net/virtio
). During our testing of the packed queue
feature with desc_event_flags
enabled, Testpmd consistently crashes after running for a short period. Below is a detailed description of the scenario, observation, root cause analysis, and a proposed fix—we hope to get clarification on whether this is a usage error or a potential driver issue.librte_pmd_virtio.so
).desc_event_flags
functionality of Virtio packed queue
mode.vq_descx
(within struct virtqueue
) is being modified unexpectedly—likely due to address mismatches in the queue memory layout.modern_setup_queue
interface) of the physical addresses for the driver
and device
regions of the packed queue.driver
and device
regions for the driver’s own use (via vring_init_packed
).device
queue, causing unintended overwrites of vq_descx
.modern_setup_queue
(Hardware-facing)modern_setup_queue
function configures the queue addresses and passes them to the hardware. For packed queues, it calculates desc_addr
, avail_addr
(driver region), and used_addr
(device region) as follows:vq_nentries = 0x1000
(4096 entries)sizeof(struct vring_desc) = 16
(0x10 in hex)offsetof(struct vring_avail, ring[vq->vq_nentries]) = 4 + (0x1000 * 2)
(base offset 4 + 2 bytes per ring entry)VIRTIO_PCI_VRING_ALIGN = 4096
(0x1000 in hex)desc_addr = 0x0
):avail_addr = 0x0 + (0x1000 * 0x10) = 0x10000
(driver region address passed to hardware)used_addr = RTE_ALIGN_CEIL(0x10000 + 4 + (0x1000 * 2), 0x1000) = RTE_ALIGN_CEIL(0x12004, 0x1000) = 0x13000
(device region address passed to hardware)vring_init_packed
(Driver-internal)vring_init_packed
function calculates the driver-internal virtual addresses for the packed queue’s driver
and device
regions:desc_addr = 0x0
, p = 0x0
):vr->driver = 0x0 + (0x1000 * 0x10) = 0x10000
(matches avail_addr
from modern_setup_queue
)vr->device = RTE_ALIGN_CEIL(0x10000 + sizeof(struct vring_packed_desc_event), 0x1000)
sizeof(struct vring_packed_desc_event) = 4
(standard definition), this becomes RTE_ALIGN_CEIL(0x10004, 0x1000) = 0x11000
(driver-internal device region address)0x13000
as the device
region address.0x11000
as the device
region address.modern_setup_queue
to use the same address logic as vring_init_packed
for packed queues. After this change, Testpmd runs stably without crashes:virtio-user
and vhost-user
drivers already use the same logic as our modified modern_setup_queue
for packed queues. For example, in virtio_user_setup_queue_packed
:modern_setup_queue
and vring_init_packed
use different logic to calculate the device region address?······ 1104121601@qq.com |