From: Christoffer Dall Date: Wed, 2 Aug 2017 14:28:42 +0000 (+0200) Subject: KVM: arm/arm64: vgic: Use READ_ONCE fo cmpxchg X-Git-Tag: v5.15~10721^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3af4e414af5ce014d1f88cd816d997048298b310;p=platform%2Fkernel%2Flinux-starfive.git KVM: arm/arm64: vgic: Use READ_ONCE fo cmpxchg 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. Acked-by: Catalin Marinas Signed-off-by: Christoffer Dall Signed-off-by: Marc Zyngier --- diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index 714fa3933546..408ef06638fc 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);