KVM: arm64: Have kvm_psci_vcpu_on() use WRITE_ONCE() to update mp_state
authorReiji Watanabe <reijiw@google.com>
Wed, 19 Apr 2023 02:18:52 +0000 (19:18 -0700)
committerMarc Zyngier <maz@kernel.org>
Thu, 20 Apr 2023 08:06:20 +0000 (09:06 +0100)
All accessors of kvm_vcpu_arch::mp_state should be {READ,WRITE}_ONCE(),
since readers of the mp_state don't acquire the mp_state_lock.
Nonetheless, kvm_psci_vcpu_on() updates the mp_state without using
WRITE_ONCE(). So, fix the code to update the mp_state using WRITE_ONCE.

Signed-off-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230419021852.2981107-3-reijiw@google.com
arch/arm64/kvm/psci.c

index 5767e6baa61a2870c2ba13e2bb9daaa5b0871b6a..d046e82e37239ce8ba62c65ff1310a734b1c84e3 100644 (file)
@@ -110,7 +110,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
         */
        smp_wmb();
 
-       vcpu->arch.mp_state.mp_state = KVM_MP_STATE_RUNNABLE;
+       WRITE_ONCE(vcpu->arch.mp_state.mp_state, KVM_MP_STATE_RUNNABLE);
        kvm_vcpu_wake_up(vcpu);
 
 out_unlock: