public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] KVM: RISC-V: VCPU reset fixes
@ 2025-04-03 11:25 Radim Krčmář
  2025-04-03 11:25 ` [PATCH 1/5] KVM: RISC-V: refactor vector state reset Radim Krčmář
                   ` (4 more replies)
  0 siblings, 5 replies; 35+ messages in thread
From: Radim Krčmář @ 2025-04-03 11:25 UTC (permalink / raw)
  To: kvm-riscv
  Cc: kvm, linux-riscv, linux-kernel, Anup Patel, Atish Patra,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Andrew Jones, Mayuresh Chitale

Hello,

this series started with a simple fix [5/5], which sadly didn't fix
enough without [4/5].  [1-3/5] are refactors to make the reset a bit
easier to follow.  ([1-3,5/5] are applicable without [4/5].)

[4/5] changes the userspace ABI and I'd like to gather your opinions on
how the ABI is supposed to work.

As another proposal, what do you think about an IOCTL that allows
userspace to invoke any KVM SBI ecall?
Userspace could call the KVM HSM implementation to reset and start a
VCPU, but I think that kvm_mp_state is an SBI HSM interface, so we have
an obscure IOCTL for it already.
I was also thinking about using KVM_MP_STATE_UNINITIALIZED to
distinguish that KVM should reset the state when becoming runnable.

I recommend to start with the following hunk in [4/5], as it's the only
significant part of this series:

  @@ -520,6 +525,10 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
   
   	switch (mp_state->mp_state) {
   	case KVM_MP_STATE_RUNNABLE:
  +		if (riscv_vcpu_supports_sbi_ext(vcpu, KVM_RISCV_SBI_EXT_HSM) &&
  +				vcpu->arch.ran_atleast_once &&
  +				kvm_riscv_vcpu_stopped(vcpu))
  +			kvm_riscv_vcpu_sbi_request_reset_from_userspace(vcpu);

Thanks.

Radim Krčmář (5):
  KVM: RISC-V: refactor vector state reset
  KVM: RISC-V: refactor sbi reset request
  KVM: RISC-V: remove unnecessary SBI reset state
  KVM: RISC-V: reset VCPU state when becoming runnable
  KVM: RISC-V: reset smstateen CSRs

 arch/riscv/include/asm/kvm_aia.h         |  3 --
 arch/riscv/include/asm/kvm_host.h        | 13 +++--
 arch/riscv/include/asm/kvm_vcpu_sbi.h    |  5 ++
 arch/riscv/include/asm/kvm_vcpu_vector.h |  6 +--
 arch/riscv/kvm/aia_device.c              |  4 +-
 arch/riscv/kvm/vcpu.c                    | 69 +++++++++++++++---------
 arch/riscv/kvm/vcpu_sbi.c                | 28 ++++++++++
 arch/riscv/kvm/vcpu_sbi_hsm.c            | 13 +----
 arch/riscv/kvm/vcpu_sbi_system.c         | 10 +---
 arch/riscv/kvm/vcpu_vector.c             | 13 ++---
 10 files changed, 97 insertions(+), 67 deletions(-)

-- 
2.48.1


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

end of thread, other threads:[~2025-05-08 13:11 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-03 11:25 [PATCH 0/5] KVM: RISC-V: VCPU reset fixes Radim Krčmář
2025-04-03 11:25 ` [PATCH 1/5] KVM: RISC-V: refactor vector state reset Radim Krčmář
2025-04-25 12:56   ` Andrew Jones
2025-05-07 11:43   ` Anup Patel
2025-04-03 11:25 ` [PATCH 2/5] KVM: RISC-V: refactor sbi reset request Radim Krčmář
2025-04-25 12:58   ` Andrew Jones
2025-05-07 12:01   ` Anup Patel
2025-05-07 17:28     ` Radim Krčmář
2025-05-08  5:02       ` Anup Patel
2025-04-03 11:25 ` [PATCH 3/5] KVM: RISC-V: remove unnecessary SBI reset state Radim Krčmář
2025-04-25 13:05   ` Andrew Jones
2025-04-28 12:16   ` Anup Patel
2025-04-28 18:00     ` Radim Krčmář
2025-04-29  5:50       ` Anup Patel
2025-05-08  6:18   ` Anup Patel
2025-05-08 10:02     ` Radim Krčmář
2025-05-08 13:11       ` Anup Patel
2025-04-03 11:25 ` [PATCH 4/5] KVM: RISC-V: reset VCPU state when becoming runnable Radim Krčmář
2025-04-25 13:26   ` Andrew Jones
2025-04-25 16:04     ` Radim Krčmář
2025-04-28 12:22   ` Anup Patel
2025-04-28 17:45     ` Radim Krčmář
2025-04-29  5:55       ` Anup Patel
2025-04-29 10:25         ` Radim Krčmář
2025-04-29 15:01           ` Anup Patel
2025-04-29 16:21             ` Radim Krčmář
2025-04-30  4:22               ` Anup Patel
2025-04-30  5:26                 ` Anup Patel
2025-04-30  8:29                   ` Radim Krčmář
2025-04-30 10:17                     ` Anup Patel
2025-04-30 11:45                       ` Radim Krčmář
2025-04-30 13:02                         ` Anup Patel
2025-04-30 14:38                           ` Radim Krčmář
2025-04-03 11:25 ` [PATCH 5/5] KVM: RISC-V: reset smstateen CSRs Radim Krčmář
2025-04-25 12:38   ` Anup Patel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox