2019-08-12 15:09:05 +08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Gao Junhao <junhao.gao@intel.com>
|
|
|
|
Date: Thu, 30 May 2019 11:22:02 +0000
|
|
|
|
Subject: [PATCH] vbs: set memory barrier for virtio_vq
|
|
|
|
|
|
|
|
When virtio backend driver gets avail_idx or sets used_idx, memory
|
|
|
|
barrier can make sure of sequence of reading and writing. It can
|
|
|
|
guarantee the accuracy of avail_idx and used_idx.
|
|
|
|
|
|
|
|
Change-Id: I4eb4a34395c215d297b24fb993dbedccfa5d95ce
|
|
|
|
Tracked-On: projectacrn/acrn-hypervisor#3207
|
|
|
|
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
|
|
|
|
Reviewed-by: Yu Wang <yu1.wang@intel.com>
|
|
|
|
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
|
|
|
|
---
|
|
|
|
drivers/vbs/vq.c | 4 ++++
|
|
|
|
1 file changed, 4 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/drivers/vbs/vq.c b/drivers/vbs/vq.c
|
2020-05-05 09:02:46 +08:00
|
|
|
index 3a714441f..180d1b223 100644
|
2019-08-12 15:09:05 +08:00
|
|
|
--- a/drivers/vbs/vq.c
|
|
|
|
+++ b/drivers/vbs/vq.c
|
|
|
|
@@ -145,6 +145,7 @@ int virtio_vq_getchain(struct virtio_vq_info *vq, uint16_t *pidx,
|
|
|
|
dev = vq->dev;
|
|
|
|
name = dev->name;
|
|
|
|
|
|
|
|
+ rmb();
|
|
|
|
/*
|
|
|
|
* Note: it's the responsibility of the guest not to
|
|
|
|
* update vq->vq_avail->va_idx until all of the descriptors
|
|
|
|
@@ -288,6 +289,8 @@ void virtio_vq_relchain(struct virtio_vq_info *vq, uint16_t idx,
|
|
|
|
vue = &vuh->ring[uidx++ & mask];
|
|
|
|
vue->id = idx;
|
|
|
|
vue->len = iolen;
|
|
|
|
+ /* Make sure buffer is written before we update index. */
|
|
|
|
+ wmb();
|
|
|
|
vuh->idx = uidx;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(virtio_vq_relchain);
|
|
|
|
@@ -322,6 +325,7 @@ void virtio_vq_endchains(struct virtio_vq_info *vq, int used_all_avail)
|
|
|
|
* In any case, though, if NOTIFY_ON_EMPTY is set and the
|
|
|
|
* entire avail was processed, we need to interrupt always.
|
|
|
|
*/
|
|
|
|
+ mb();
|
|
|
|
dev = vq->dev;
|
|
|
|
old_idx = vq->save_used;
|
|
|
|
vq->save_used = new_idx = vq->used->idx;
|
|
|
|
--
|
|
|
|
https://clearlinux.org
|
|
|
|
|