mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 04:26:38 +00:00
Virtio: Add fence(Acquire) after avail_index read
Driver use virtio_wmb() before avail_index updating, here fence() is compared with it, this guarantee that the descriptor_index is read after avail_index. BUG=none TEST=run fio_read and fio_write in guest Change-Id: I6a5e1bc7c915effd433b05aca246302c5a3e313c Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035079 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
bc7728f69b
commit
5c51e05282
1 changed files with 2 additions and 0 deletions
|
@ -317,6 +317,8 @@ impl Queue {
|
|||
let queue_size = self.actual_size();
|
||||
let avail_index_addr = mem.checked_offset(self.avail_ring, 2).unwrap();
|
||||
let avail_index: u16 = mem.read_obj_from_addr(avail_index_addr).unwrap();
|
||||
// make sure desc_index read doesn't bypass avail_index read
|
||||
fence(Ordering::Acquire);
|
||||
let avail_len = Wrapping(avail_index) - self.next_avail;
|
||||
|
||||
if avail_len.0 > queue_size || self.next_avail == Wrapping(avail_index) {
|
||||
|
|
Loading…
Reference in a new issue