patch 'vhost: fix wrapping on control virtqueue rings' has been queued to stable release 23.11.5
Xueming Li
xuemingl at nvidia.com
Thu Jun 26 14:00:35 CEST 2025
Hi,
FYI, your patch has been queued to stable release 23.11.5
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/28/25. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=62558d956aba801fa0da6fc3ce693ce8b1308cf3
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From 62558d956aba801fa0da6fc3ce693ce8b1308cf3 Mon Sep 17 00:00:00 2001
From: David Marchand <david.marchand at redhat.com>
Date: Wed, 2 Apr 2025 08:53:58 +0200
Subject: [PATCH] vhost: fix wrapping on control virtqueue rings
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit 38e640038798da92d1b7daf953f06fcd116cb952 ]
The idx field of a virtqueue available ring is increased by the driver
regardless of the ring size. It is for the device to mask this index
modulo the ring size (2.7.6 of the virtio 1.3 specification).
The same applies to the used ring.
Failing to mask triggers:
- crashes when popping message received on the cvq,
- system lockups (in the case of VDUSE) when the virtio-net driver waits
infinitely,
Fixes: 474f4d7840ad ("vhost: add control virtqueue")
Signed-off-by: David Marchand <david.marchand at redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Tested-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
lib/vhost/virtio_net_ctrl.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/lib/vhost/virtio_net_ctrl.c b/lib/vhost/virtio_net_ctrl.c
index c4847f84ed..355ab85009 100644
--- a/lib/vhost/virtio_net_ctrl.c
+++ b/lib/vhost/virtio_net_ctrl.c
@@ -40,7 +40,7 @@ virtio_net_ctrl_pop(struct virtio_net *dev, struct vhost_virtqueue *cvq,
return 0;
}
- desc_idx = cvq->avail->ring[cvq->last_avail_idx];
+ desc_idx = cvq->avail->ring[cvq->last_avail_idx & (cvq->size - 1)];
if (desc_idx >= cvq->size) {
VHOST_LOG_CONFIG(dev->ifname, ERR, "Out of range desc index, dropping\n");
goto err;
@@ -167,8 +167,6 @@ virtio_net_ctrl_pop(struct virtio_net *dev, struct vhost_virtqueue *cvq,
}
cvq->last_avail_idx++;
- if (cvq->last_avail_idx >= cvq->size)
- cvq->last_avail_idx -= cvq->size;
if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))
vhost_avail_event(cvq) = cvq->last_avail_idx;
@@ -179,8 +177,6 @@ free_err:
free(ctrl_elem->ctrl_req);
err:
cvq->last_avail_idx++;
- if (cvq->last_avail_idx >= cvq->size)
- cvq->last_avail_idx -= cvq->size;
if (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))
vhost_avail_event(cvq) = cvq->last_avail_idx;
@@ -229,13 +225,11 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
struct vhost_virtqueue *cvq = dev->cvq;
struct vring_used_elem *used_elem;
- used_elem = &cvq->used->ring[cvq->last_used_idx];
+ used_elem = &cvq->used->ring[cvq->last_used_idx & (cvq->size - 1)];
used_elem->id = ctrl_elem->head_idx;
used_elem->len = ctrl_elem->n_descs;
cvq->last_used_idx++;
- if (cvq->last_used_idx >= cvq->size)
- cvq->last_used_idx -= cvq->size;
rte_atomic_store_explicit((unsigned short __rte_atomic *)&cvq->used->idx,
cvq->last_used_idx, rte_memory_order_release);
--
2.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2025-06-26 19:59:18.348364504 +0800
+++ 0015-vhost-fix-wrapping-on-control-virtqueue-rings.patch 2025-06-26 19:59:17.218418051 +0800
@@ -1 +1 @@
-From 38e640038798da92d1b7daf953f06fcd116cb952 Mon Sep 17 00:00:00 2001
+From 62558d956aba801fa0da6fc3ce693ce8b1308cf3 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 38e640038798da92d1b7daf953f06fcd116cb952 ]
@@ -17 +19,0 @@
-Cc: stable at dpdk.org
@@ -27 +29 @@
-index 999e84db7c..63c0a06b4f 100644
+index c4847f84ed..355ab85009 100644
@@ -37 +39 @@
- VHOST_CONFIG_LOG(dev->ifname, ERR, "Out of range desc index, dropping");
+ VHOST_LOG_CONFIG(dev->ifname, ERR, "Out of range desc index, dropping\n");
@@ -45 +46,0 @@
- vhost_virtqueue_reconnect_log_split(cvq);
@@ -48 +49,2 @@
-@@ -180,8 +178,6 @@ free_err:
+ vhost_avail_event(cvq) = cvq->last_avail_idx;
+@@ -179,8 +177,6 @@ free_err:
@@ -54 +55,0 @@
- vhost_virtqueue_reconnect_log_split(cvq);
@@ -57 +58,2 @@
-@@ -231,13 +227,11 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
+ vhost_avail_event(cvq) = cvq->last_avail_idx;
+@@ -229,13 +225,11 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
More information about the stable
mailing list