Skip to content

Commit 4ff910b

Browse files
reijiw-kvmMarc Zyngier
authored andcommitted
KVM: arm64: Acquire mp_state_lock in kvm_arch_vcpu_ioctl_vcpu_init()
kvm_arch_vcpu_ioctl_vcpu_init() doesn't acquire mp_state_lock when setting the mp_state to KVM_MP_STATE_RUNNABLE. Fix the code to acquire the lock. Signed-off-by: Reiji Watanabe <reijiw@google.com> [maz: minor refactor] Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230419021852.2981107-2-reijiw@google.com
1 parent 49e5d16 commit 4ff910b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

arch/arm64/kvm/arm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,11 +1241,15 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
12411241
/*
12421242
* Handle the "start in power-off" case.
12431243
*/
1244+
spin_lock(&vcpu->arch.mp_state_lock);
1245+
12441246
if (test_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features))
1245-
kvm_arm_vcpu_power_off(vcpu);
1247+
__kvm_arm_vcpu_power_off(vcpu);
12461248
else
12471249
WRITE_ONCE(vcpu->arch.mp_state.mp_state, KVM_MP_STATE_RUNNABLE);
12481250

1251+
spin_unlock(&vcpu->arch.mp_state_lock);
1252+
12491253
return 0;
12501254
}
12511255

0 commit comments

Comments
 (0)