net/virtio: add barrier before reading the flags
authorIlya Maximets <i.maximets@samsung.com>
Wed, 9 Jan 2019 14:50:13 +0000 (17:50 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 Jan 2019 16:44:29 +0000 (17:44 +0100)
commitd21d05c7a9c1c49ec927f961c4ab797a598af5ca
treed33e23547162566fffe0634e1fab7ecf28bc2202
parent352cf50d9a9d95ca8207ce526d4fa7cd9894dba6
net/virtio: add barrier before reading the flags

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>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
drivers/net/virtio/virtqueue.h