linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RISC-V: KVM: lock the correct mp_state during reset
@ 2025-05-23 10:47 Radim Krčmář
  2025-05-24 15:58 ` Anup Patel
  2025-06-10 16:28 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: Radim Krčmář @ 2025-05-23 10:47 UTC (permalink / raw)
  To: kvm-riscv
  Cc: kvm, linux-riscv, linux-kernel, Anup Patel, Atish Patra,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Yong-Xuan Wang

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@ventanamicro.com>
---
 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


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] RISC-V: KVM: lock the correct mp_state during reset
  2025-05-23 10:47 [PATCH] RISC-V: KVM: lock the correct mp_state during reset Radim Krčmář
@ 2025-05-24 15:58 ` Anup Patel
  2025-06-10 16:28 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2025-05-24 15:58 UTC (permalink / raw)
  To: Radim Krčmář
  Cc: kvm-riscv, kvm, linux-riscv, linux-kernel, Atish Patra,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Yong-Xuan Wang

On Fri, May 23, 2025 at 4:22 PM Radim Krčmář <rkrcmar@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@ventanamicro.com>

LGTM.

Reviewed-by: Anup Patel <anup@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
>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] RISC-V: KVM: lock the correct mp_state during reset
  2025-05-23 10:47 [PATCH] RISC-V: KVM: lock the correct mp_state during reset Radim Krčmář
  2025-05-24 15:58 ` Anup Patel
@ 2025-06-10 16:28 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-06-10 16:28 UTC (permalink / raw)
  To: =?utf-8?b?UmFkaW0gS3LEjW3DocWZIDxya3JjbWFyQHZlbnRhbmFtaWNyby5jb20+?=
  Cc: linux-riscv, kvm-riscv, kvm, linux-kernel, anup, atishp,
	paul.walmsley, palmer, aou, alex, yongxuan.wang

Hello:

This patch was applied to riscv/linux.git (fixes)
by Anup Patel <anup@brainfault.org>:

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ář <rkrcmar@ventanamicro.com>
> ---
>  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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-10 19:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23 10:47 [PATCH] RISC-V: KVM: lock the correct mp_state during reset Radim Krčmář
2025-05-24 15:58 ` Anup Patel
2025-06-10 16:28 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).