]> git.proxmox.com Git - qemu.git/commit
virtio: order index/descriptor reads
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 23 Apr 2012 12:46:22 +0000 (15:46 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 25 Apr 2012 07:53:47 +0000 (10:53 +0300)
commita821ce59338c79bb72dc844dd44ea53701965b2b
treed742c0d8a81491e83dcd80c58d9d80ee458216f4
parent92045d80badc43c9f95897aad675dc7ef17a3b3f
virtio: order index/descriptor reads

virtio has the equivalent of:

if (vq->last_avail_index != vring_avail_idx(vq)) {
read descriptor head at vq->last_avail_index;
}

In theory, processor can reorder descriptor head
read to happen speculatively before the index read.
this would trigger the following race:

host descriptor head read <- reads invalid head from ring
guest writes valid descriptor head
guest writes avail index
host avail index read <- observes valid index

as a result host will use an invalid head value.
This was not observed in the field by me but after
the experience with the previous two races
I think it is prudent to address this theoretical race condition.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio.c
qemu-barrier.h