Skip to content

Commit 7917be1

Browse files
radimkrcmaravpatel
authored andcommitted
RISC-V: KVM: lock the correct mp_state during reset
Currently, the kvm_riscv_vcpu_sbi_system_reset() function locks vcpu->arch.mp_state_lock when updating tmp->arch.mp_state.mp_state which is incorrect hence fix it. Fixes: 2121cad ("RISCV: KVM: Introduce mp_state_lock to avoid lock inversion") Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250523104725.2894546-4-rkrcmar@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent 5b9db9c commit 7917be1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/kvm/vcpu_sbi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,
143143
struct kvm_vcpu *tmp;
144144

145145
kvm_for_each_vcpu(i, tmp, vcpu->kvm) {
146-
spin_lock(&vcpu->arch.mp_state_lock);
146+
spin_lock(&tmp->arch.mp_state_lock);
147147
WRITE_ONCE(tmp->arch.mp_state.mp_state, KVM_MP_STATE_STOPPED);
148-
spin_unlock(&vcpu->arch.mp_state_lock);
148+
spin_unlock(&tmp->arch.mp_state_lock);
149149
}
150150
kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP);
151151

0 commit comments

Comments
 (0)