summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-10-25 15:28:53 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2009-11-09 16:22:28 -0800
commit48fe10afb355d88be5a9c0b7d5a198c5e5b9b4aa (patch)
tree2c5a5cd8ca0d0e0821b31177883bf727f85be0d6 /drivers
parentbed202356361d3620a51974eadca78261e049ef0 (diff)
virtio: order used ring after used index read
commit 2d61ba95034f1abbdec7729d52c740870a5eddb6 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/virtio/virtio_ring.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index a882f2606515..0ffff9ed4eb0 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -281,6 +281,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;