vhost: add a memory barrier after incrementing used->idx

Ensure the used->idx changes are visible to
the guest at the time of interrupt.

Change-Id: I245b91c7fbe2e21600aa94d8314271ea5b987343
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/396929
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2018-01-29 17:32:00 +01:00 committed by Jim Harris
parent 85a0a63eff
commit a78c896369

View File

@ -286,9 +286,17 @@ spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_dev *vdev, struct spdk_vhost_v
used->ring[last_idx].id = id;
used->ring[last_idx].len = len;
spdk_wmb();
/* Ensure the used ring is updated before we increment used->idx. */
spdk_smp_wmb();
* (volatile uint16_t *) &used->idx = vring->last_used_idx;
/* Ensure all our used ring changes are visible to the guest at the time
* of interrupt.
* TODO: this is currently an sfence on x86. For other architectures we
* will most likely need an smp_mb(), but smp_mb() is an overkill for x86.
*/
spdk_wmb();
virtqueue->used_req_cnt++;
/* We need to signal every last_used_idx overflow. */