Browse files

virtio: correct the memory barrier in virtqueue_kick_prepare()

Use virtio_mb() to make sure the available index to be exposed before
checking the the avail event. Otherwise we may get stale value of
avail event in guest and never kick the host after.

Note: this fixes a bug introduced by ee7cd89.

Signed-off-by: Jason Wang <>
Acked-by: Michael S. Tsirkin <>
Signed-off-by: Rusty Russell <>
  • Loading branch information...
1 parent 4dbc5d9 commit a72caae21803b74e04e2afda5e035f149d4ea118 @jasowang jasowang committed with rustyrussell Jan 20, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 drivers/virtio/virtio_ring.c
6 drivers/virtio/virtio_ring.c
@@ -308,9 +308,9 @@ bool virtqueue_kick_prepare(struct virtqueue *_vq)
bool needs_kick;
- /* Descriptors and available array need to be set before we expose the
- * new available array entries. */
- virtio_wmb(vq);
+ /* We need to expose available array entries before checking avail
+ * event. */
+ virtio_mb(vq);
old = vq->vring.avail->idx - vq->num_added;
new = vq->vring.avail->idx;

0 comments on commit a72caae

Please sign in to comment.