[3/3] net/virtio: add missing read barrier for packed dequeue

Message ID 20190124165902.24178-4-i.maximets@samsung.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: missing/wrong read barriers. |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ilya Maximets Jan. 24, 2019, 4:59 p.m. UTC
  Read barrier is required between reading the flags (desc_is_used)
and the content of descriptor to ensure the ordering.
Otherwise, speculative read of desc.id could be reordered with
reading of the desc.flags.

Fixes: a76290c8f1cf ("net/virtio: implement Rx path for packed queues")
Cc: stable@dpdk.org

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 drivers/net/virtio/virtio_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Jens Freimann Jan. 25, 2019, 12:44 p.m. UTC | #1
On Thu, Jan 24, 2019 at 07:59:02PM +0300, Ilya Maximets wrote:
>Read barrier is required between reading the flags (desc_is_used)
>and the content of descriptor to ensure the ordering.
>Otherwise, speculative read of desc.id could be reordered with
>reading of the desc.flags.
>
>Fixes: a76290c8f1cf ("net/virtio: implement Rx path for packed queues")
>Cc: stable@dpdk.org
>
>Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
>---
> drivers/net/virtio/virtio_rxtx.c | 1 +
> 1 file changed, 1 insertion(+)
>

Reviewed-by: Jens Freimann <jfreimann@redhat.com>
  
Jens Freimann Jan. 25, 2019, 12:48 p.m. UTC | #2
On Thu, Jan 24, 2019 at 07:59:02PM +0300, Ilya Maximets wrote:
>Read barrier is required between reading the flags (desc_is_used)
>and the content of descriptor to ensure the ordering.
>Otherwise, speculative read of desc.id could be reordered with
>reading of the desc.flags.
>
>Fixes: a76290c8f1cf ("net/virtio: implement Rx path for packed queues")
>Cc: stable@dpdk.org

I don't thing cc stable is required as a76290c8f1cf is only in
v19.02-rc1 and newer.

regards,
Jens
  

Patch

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 5ffed6a51..4c701c514 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -124,6 +124,7 @@  virtqueue_dequeue_burst_rx_packed(struct virtqueue *vq,
 		used_idx = vq->vq_used_cons_idx;
 		if (!desc_is_used(&desc[used_idx], vq))
 			return i;
+		virtio_rmb(vq->hw->weak_barriers);
 		len[i] = desc[used_idx].len;
 		id = desc[used_idx].id;
 		cookie = (struct rte_mbuf *)vq->vq_descx[id].cookie;