Skip to content

Commit

Permalink
virtio: order used ring after used index read
Browse files Browse the repository at this point in the history
On SMP guests, reads from the ring might bypass used index reads. This
causes guest crashes because host writes to used index to signal ring
data readiness.  Fix this by inserting rmb before used ring reads.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: stable@kernel.org
  • Loading branch information
Michael S. Tsirkin authored and Rusty Russell committed Oct 28, 2009
1 parent 0b22bd0 commit 2d61ba9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ static void *vring_get_buf(struct virtqueue *_vq, unsigned int *len)
return NULL;
}

/* Only get used array entries after they have been exposed by host. */
rmb();

i = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].id;
*len = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].len;

Expand Down

0 comments on commit 2d61ba9

Please sign in to comment.