[dpdk-stable] patch 'net/virtio: add barrier before reading the flags' has been queued to LTS release 18.11.1

Kevin Traynor ktraynor at redhat.com
Thu Jan 31 16:48:49 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 02/07/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 60b2f24165822233009a22a81e2bfa2d90650f12 Mon Sep 17 00:00:00 2001
From: Ilya Maximets <i.maximets at samsung.com>
Date: Wed, 9 Jan 2019 17:50:13 +0300
Subject: [PATCH] net/virtio: add barrier before reading the flags

[ upstream commit d21d05c7a9c1c49ec927f961c4ab797a598af5ca ]

Reading the used->flags could be reordered with avail->idx update.
vhost in kernel disables notifications for the time of packets
receiving, like this:

    1. disable notify
    2. process packets
    3. enable notify
    4. has more packets ? goto 1

In case of reordering, virtio driver could read the flags on
step 2 while notifications disabled and update avail->idx after
the step 4, i.e. vhost will exit the loop on step 4 with
notifications enabled, but virtio will not notify.

Fixes: c1f86306a026 ("virtio: add new driver")

Reported-by: Shahaf Shuler <shahafs at mellanox.com>
Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Acked-by: Michael S. Tsirkin <mst at redhat.com>
---
 drivers/net/virtio/virtqueue.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 26518ed98..2e2abf15b 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -337,4 +337,9 @@ static inline int
 virtqueue_kick_prepare(struct virtqueue *vq)
 {
+	/*
+	 * Ensure updated avail->idx is visible to vhost before reading
+	 * the used->flags.
+	 */
+	virtio_mb();
 	return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY);
 }
-- 
2.19.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-01-31 15:44:06.699131544 +0000
+++ 0041-net-virtio-add-barrier-before-reading-the-flags.patch	2019-01-31 15:44:05.000000000 +0000
@@ -1,8 +1,10 @@
-From d21d05c7a9c1c49ec927f961c4ab797a598af5ca Mon Sep 17 00:00:00 2001
+From 60b2f24165822233009a22a81e2bfa2d90650f12 Mon Sep 17 00:00:00 2001
 From: Ilya Maximets <i.maximets at samsung.com>
 Date: Wed, 9 Jan 2019 17:50:13 +0300
 Subject: [PATCH] net/virtio: add barrier before reading the flags
 
+[ upstream commit d21d05c7a9c1c49ec927f961c4ab797a598af5ca ]
+
 Reading the used->flags could be reordered with avail->idx update.
 vhost in kernel disables notifications for the time of packets
 receiving, like this:
@@ -18,21 +20,20 @@
 notifications enabled, but virtio will not notify.
 
 Fixes: c1f86306a026 ("virtio: add new driver")
-Cc: stable at dpdk.org
 
 Reported-by: Shahaf Shuler <shahafs at mellanox.com>
 Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
 Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
 Acked-by: Michael S. Tsirkin <mst at redhat.com>
 ---
- drivers/net/virtio/virtqueue.h | 8 ++++++++
- 1 file changed, 8 insertions(+)
+ drivers/net/virtio/virtqueue.h | 5 +++++
+ 1 file changed, 5 insertions(+)
 
 diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
-index d8ae5cdec..dffa03669 100644
+index 26518ed98..2e2abf15b 100644
 --- a/drivers/net/virtio/virtqueue.h
 +++ b/drivers/net/virtio/virtqueue.h
-@@ -416,4 +416,9 @@ static inline int
+@@ -337,4 +337,9 @@ static inline int
  virtqueue_kick_prepare(struct virtqueue *vq)
  {
 +	/*
@@ -42,14 +43,6 @@
 +	virtio_mb();
  	return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY);
  }
-@@ -424,4 +429,7 @@ virtqueue_kick_prepare_packed(struct virtqueue *vq)
- 	uint16_t flags;
- 
-+	/*
-+	 * Ensure updated data is visible to vhost before reading the flags.
-+	 */
- 	virtio_mb();
- 	flags = vq->ring_packed.device_event->desc_event_flags;
 -- 
 2.19.0
 


More information about the stable mailing list