[PATCH] RISC-V: KVM: lock the correct mp_state during reset
Anup Patel
anup at brainfault.org
Sat May 24 08:58:51 PDT 2025
On Fri, May 23, 2025 at 4:22 PM Radim Krčmář <rkrcmar at ventanamicro.com> wrote:
>
> We're writing to *tmp, but locking *vcpu.
>
> Fixes: 2121cadec45a ("RISCV: KVM: Introduce mp_state_lock to avoid lock inversion")
> Signed-off-by: Radim Krčmář <rkrcmar at ventanamicro.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Improved commit description at the time of queuing.
Queued this patch for Linux-6.16
Thanks,
Anup
> ---
> arch/riscv/kvm/vcpu_sbi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c
> index 31fd3cc98d66..6e09b518a5d1 100644
> --- a/arch/riscv/kvm/vcpu_sbi.c
> +++ b/arch/riscv/kvm/vcpu_sbi.c
> @@ -143,9 +143,9 @@ void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,
> struct kvm_vcpu *tmp;
>
> kvm_for_each_vcpu(i, tmp, vcpu->kvm) {
> - spin_lock(&vcpu->arch.mp_state_lock);
> + spin_lock(&tmp->arch.mp_state_lock);
> WRITE_ONCE(tmp->arch.mp_state.mp_state, KVM_MP_STATE_STOPPED);
> - spin_unlock(&vcpu->arch.mp_state_lock);
> + spin_unlock(&tmp->arch.mp_state_lock);
> }
> kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP);
>
> --
> 2.49.0
>
More information about the linux-riscv
mailing list