RISC-V: KVM: lock the correct mp_state during reset
Subsystems (3)
PATCH 1/1 RISC-V: KVM: lock the correct mp_state during reset
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ář <[email protected]>
--- arch/riscv/kvm/vcpu_sbi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kvm/vcpu_sbi.c +2 -2
@@ -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 );
Signature · 1 line
2.49.0
Quoted 5 lines · Radim Krčmář
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ář <[email protected]>
LGTM.
Reviewed-by Anup Patel <[email protected]>
Improved commit description at the time of queuing.
Queued this patch for Linux-6.16
Thanks,
Anup
Quoted 23 lines
--- arch/riscv/kvm/vcpu_sbi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/riscv/kvm/vcpu_sbi.c +2
-3@@ -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
This patch was applied to riscv/linux.git (fixes) by Anup Patel <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (fixes)
by Anup Patel <[email protected]>:
Quoted 7 lines · On Fri, 23 May 2025 12:47:28 +0200 you 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ář <[email protected]>--- arch/riscv/kvm/vcpu_sbi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Here is the summary with links:
- RISC-V: KVM: lock the correct mp_state during reset
https://git.kernel.org/riscv/c/7917be170928
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html