Message ID | 20170802142842.9494-1-cdall@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Aug 02, 2017 at 04:28:42PM +0200, Christoffer Dall wrote: > There is a small chance that the compiler could generate separate loads > for the dist->propbaser which could be modified from another CPU. As we > want to make sure we atomically update the entire value, and don't race > with other updates, guarantee that the cmpxchg operation compares > against the original value. > > Cc: Catalin Marinas <catalin.marinas@arm.com> > Signed-off-by: Christoffer Dall <cdall@linaro.org> FWIW: Acked-by: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index 714fa39..408ef06 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -369,7 +369,7 @@ static void vgic_mmio_write_propbase(struct kvm_vcpu *vcpu, return; do { - old_propbaser = dist->propbaser; + old_propbaser = READ_ONCE(dist->propbaser); propbaser = old_propbaser; propbaser = update_64bit_reg(propbaser, addr & 4, len, val); propbaser = vgic_sanitise_propbaser(propbaser); @@ -397,7 +397,7 @@ static void vgic_mmio_write_pendbase(struct kvm_vcpu *vcpu, return; do { - old_pendbaser = vgic_cpu->pendbaser; + old_pendbaser = READ_ONCE(vgic_cpu->pendbaser); pendbaser = old_pendbaser; pendbaser = update_64bit_reg(pendbaser, addr & 4, len, val); pendbaser = vgic_sanitise_pendbaser(pendbaser);
There is a small chance that the compiler could generate separate loads for the dist->propbaser which could be modified from another CPU. As we want to make sure we atomically update the entire value, and don't race with other updates, guarantee that the cmpxchg operation compares against the original value. Cc: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Christoffer Dall <cdall@linaro.org> --- virt/kvm/arm/vgic/vgic-mmio-v3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)