From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 285E91B489 for ; Fri, 4 Jan 2019 14:28:32 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5698C5A1FF; Fri, 4 Jan 2019 13:28:31 +0000 (UTC) Received: from ktraynor.remote.csb (ovpn-117-13.ams2.redhat.com [10.36.117.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DFEA5C1A1; Fri, 4 Jan 2019 13:28:24 +0000 (UTC) From: Kevin Traynor To: Maxime Coquelin Cc: Jason Wang , Ilya Maximets , "Michael S . Tsirkin" , Tiwei Bie , dpdk stable Date: Fri, 4 Jan 2019 13:24:47 +0000 Message-Id: <20190104132455.15170-65-ktraynor@redhat.com> In-Reply-To: <20190104132455.15170-1-ktraynor@redhat.com> References: <20190104132455.15170-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 04 Jan 2019 13:28:31 +0000 (UTC) Subject: [dpdk-stable] patch 'vhost: enforce avail index and desc read ordering' has been queued to LTS release 18.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2019 13:28:32 -0000 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 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 Signed-off-by: Maxime Coquelin Acked-by: Ilya Maximets Acked-by: Michael S. Tsirkin Acked-by: Tiwei Bie --- 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 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@dpdk.org Reported-by: Jason Wang Signed-off-by: Maxime Coquelin @@ -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; + /*