From: Ilya Maximets <i.maximets@samsung.com>
To: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Xiao Wang <xiao.w.wang@intel.com>
Cc: Tiwei Bie <tiwei.bie@intel.com>,
Zhihong Wang <zhihong.wang@intel.com>,
jfreimann@redhat.com, Jason Wang <jasowang@redhat.com>,
xiaolong.ye@intel.com, alejandro.lucero@netronome.com,
Ilya Maximets <i.maximets@samsung.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH v3 1/3] net/virtio: add missing barrier before reading the flags
Date: Wed, 9 Jan 2019 17:50:13 +0300 [thread overview]
Message-ID: <20190109145015.3010-2-i.maximets@samsung.com> (raw)
In-Reply-To: <20190109145015.3010-1-i.maximets@samsung.com>
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")
CC: stable@dpdk.org
Reported-by: Shahaf Shuler <shahafs@mellanox.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
drivers/net/virtio/virtqueue.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index d8ae5cdec..dffa03669 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -415,6 +415,11 @@ vq_update_avail_ring(struct virtqueue *vq, uint16_t desc_idx)
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);
}
@@ -423,6 +428,9 @@ 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.17.1
next prev parent reply other threads:[~2019-01-09 14:50 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20181214153817eucas1p19a41cdd791879252e1f3a5d77c427845@eucas1p1.samsung.com>
2018-12-14 15:38 ` [dpdk-dev] [PATCH] net/virtio: add platform memory ordering feature support Ilya Maximets
2018-12-14 17:00 ` Michael S. Tsirkin
2018-12-14 17:23 ` Ilya Maximets
[not found] ` <CGME20181226163717eucas1p15276eb45e35abe2c9cf3e7c1e0050823@eucas1p1.samsung.com>
2018-12-26 16:37 ` [dpdk-dev] [PATCH v2] " Ilya Maximets
2018-12-27 10:07 ` Shahaf Shuler
2019-01-09 14:34 ` Ilya Maximets
2019-01-09 15:50 ` Michael S. Tsirkin
2019-01-10 20:36 ` Shahaf Shuler
2019-01-15 6:33 ` Shahaf Shuler
2019-01-15 8:29 ` Ilya Maximets
2019-01-15 8:55 ` Shahaf Shuler
2019-01-15 10:23 ` Ilya Maximets
2019-02-12 17:50 ` Michael S. Tsirkin
[not found] ` <CGME20190109145021eucas1p1bfe194ffafaaaa5df62243c92b2ed6cd@eucas1p1.samsung.com>
2019-01-09 14:50 ` [dpdk-dev] [PATCH v3 0/3] Missing barriers and VIRTIO_F_ORDER_PLATFORM Ilya Maximets
[not found] ` <CGME20190109145027eucas1p2437215de0df4c691eb84d4e84bfc71e5@eucas1p2.samsung.com>
2019-01-09 14:50 ` Ilya Maximets [this message]
2019-01-10 14:31 ` [dpdk-dev] [PATCH v3 1/3] net/virtio: add missing barrier before reading the flags Maxime Coquelin
[not found] ` <CGME20190109145034eucas1p2183e275e316b87917b96fa184fc7d7cb@eucas1p2.samsung.com>
2019-01-09 14:50 ` [dpdk-dev] [PATCH v3 2/3] net/virtio: update memory ordering comment for vq notify Ilya Maximets
2019-01-10 8:19 ` Gavin Hu (Arm Technology China)
2019-01-10 9:18 ` Maxime Coquelin
2019-01-10 9:55 ` Ilya Maximets
2019-01-10 14:56 ` Michael S. Tsirkin
2019-01-10 14:31 ` Maxime Coquelin
[not found] ` <CGME20190109145040eucas1p2d9afc678ef94986544bde07b77373e6f@eucas1p2.samsung.com>
2019-01-09 14:50 ` [dpdk-dev] [PATCH v3 3/3] net/virtio: add platform memory ordering feature support Ilya Maximets
2019-01-10 14:31 ` Maxime Coquelin
2019-01-09 14:55 ` [dpdk-dev] [PATCH v3 0/3] Missing barriers and VIRTIO_F_ORDER_PLATFORM Michael S. Tsirkin
2019-01-09 15:24 ` Ilya Maximets
2019-01-09 16:53 ` Ferruh Yigit
2019-01-10 15:19 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190109145015.3010-2-i.maximets@samsung.com \
--to=i.maximets@samsung.com \
--cc=alejandro.lucero@netronome.com \
--cc=dev@dpdk.org \
--cc=jasowang@redhat.com \
--cc=jfreimann@redhat.com \
--cc=maxime.coquelin@redhat.com \
--cc=mst@redhat.com \
--cc=stable@dpdk.org \
--cc=tiwei.bie@intel.com \
--cc=xiao.w.wang@intel.com \
--cc=xiaolong.ye@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).