[dpdk-stable] patch 'vhost: enforce avail index and desc read ordering' has been queued to LTS release 18.11.1

Kevin Traynor ktraynor at redhat.com
Fri Jan 4 14:24:47 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 01/11/19. 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.

Thanks.

Kevin Traynor

---
>From a6efdbe836abe20ce0cc425fe5683fbd34d62d8c Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Wed, 19 Dec 2018 09:21:10 +0100
Subject: [PATCH] vhost: enforce avail index and desc read ordering

[ upstream commit d4ff2135ebb6c7f55af783846fa8e7ea4379c71b ]

A read barrier is required to ensure the ordering between
available index and the descriptor reads is enforced.

1. read avail_head = avail->idx
2. read cur_idx = last_avail_idx
if (cur_idx != avail_head) {
    3. read idx = avail->ring[cur_idx]
    4. read desc[idx]
}

There is a control dependency between step 1 and steps 3 & 4,
3 could be speculatively executed before 1, which could result
in 'idx' to not being updated yet.

Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application")

Reported-by: Jason Wang <jasowang at redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Acked-by: Ilya Maximets <i.maximets at samsung.com>
Acked-by: Michael S. Tsirkin <mst at redhat.com>
Acked-by: Tiwei Bie <tiwei.bie at intel.com>
---
 lib/librte_vhost/virtio_net.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 5e1a1a727..f11ebb54f 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -792,4 +792,10 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	avail_head = *((volatile uint16_t *)&vq->avail->idx);
 
+	/*
+	 * The ordering between avail index and
+	 * desc reads needs to be enforced.
+	 */
+	rte_smp_rmb();
+
 	for (pkt_idx = 0; pkt_idx < count; pkt_idx++) {
 		uint32_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen;
@@ -1374,4 +1380,10 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
 		return 0;
 
+	/*
+	 * The ordering between avail index and
+	 * desc reads needs to be enforced.
+	 */
+	rte_smp_rmb();
+
 	VHOST_LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->vid, __func__);
 
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-01-04 13:23:09.030258468 +0000
+++ 0065-vhost-enforce-avail-index-and-desc-read-ordering.patch	2019-01-04 13:23:07.000000000 +0000
@@ -1,8 +1,10 @@
-From d4ff2135ebb6c7f55af783846fa8e7ea4379c71b Mon Sep 17 00:00:00 2001
+From a6efdbe836abe20ce0cc425fe5683fbd34d62d8c Mon Sep 17 00:00:00 2001
 From: Maxime Coquelin <maxime.coquelin at redhat.com>
 Date: Wed, 19 Dec 2018 09:21:10 +0100
 Subject: [PATCH] vhost: enforce avail index and desc read ordering
 
+[ upstream commit d4ff2135ebb6c7f55af783846fa8e7ea4379c71b ]
+
 A read barrier is required to ensure the ordering between
 available index and the descriptor reads is enforced.
 
@@ -18,7 +20,6 @@
 in 'idx' to not being updated yet.
 
 Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application")
-Cc: stable at dpdk.org
 
 Reported-by: Jason Wang <jasowang at redhat.com>
 Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
@@ -30,10 +31,10 @@
  1 file changed, 12 insertions(+)
 
 diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
-index 8c657a101..7f37bbbed 100644
+index 5e1a1a727..f11ebb54f 100644
 --- a/lib/librte_vhost/virtio_net.c
 +++ b/lib/librte_vhost/virtio_net.c
-@@ -753,4 +753,10 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
+@@ -792,4 +792,10 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
  	avail_head = *((volatile uint16_t *)&vq->avail->idx);
  
 +	/*
@@ -44,7 +45,7 @@
 +
  	for (pkt_idx = 0; pkt_idx < count; pkt_idx++) {
  		uint32_t pkt_len = pkts[pkt_idx]->pkt_len + dev->vhost_hlen;
-@@ -1335,4 +1341,10 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
+@@ -1374,4 +1380,10 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
  		return 0;
  
 +	/*


More information about the stable mailing list