Skip to content

Commit

Permalink
KVM: arm/arm64: vgic: Use READ_ONCE fo cmpxchg
Browse files Browse the repository at this point in the history
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 <catalin.marinas@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
  • Loading branch information
Christoffer Dall authored and Marc Zyngier committed Aug 3, 2017
1 parent 7e5a672 commit 3af4e41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions virt/kvm/arm/vgic/vgic-mmio-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3af4e41

Please sign in to comment.