Skip to content

VCPU reset fixes

Radim Krčmář kvm kvm-riscv linux-riscv lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 8 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: RISC-V: reset smstateen in a better placearch/riscv/kvm/vcpu.c+1 -21 reply
2/2RISC-V: KVM: add KVM_CAP_RISCV_MP_STATE_RESETDocumentation/virt/kvm/api.rst arch/riscv/include/asm/kvm_host.h arch/riscv/include/asm/kvm_vcpu_sbi.h +6 more+81 -157 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] VCPU reset fixes

Hello,

v2 abandons the idea of fixing current userspaces and adds a new capability that uses MP_STATE to immediately trigger a KVM VCPU reset -- a single-purpose interface free of any unintended side effects is desirable and MP_STATE is somewhat bendable, which avoids the need for a new IOCTL. It's very dirty, though, so I'm not happy with it.

I have prepared a preview QEMU implementation [1] and only did light testing with kvm-unit-tests as I still expect a high-level discussion.

Because it didn't take much effort on top, v2 expands the goals -- userspace can now choose the same post-reset state for all VCPUs. (This is achieved by returning from userspace on sbi_hart_stop; let me
know if I should rather do that with another KVM capability.)

This series does not fully address the VCPU hot-unplug.
We still need a better KVM interface there, because the VCPU stopped by sbi_hart_stop is still assumed to be present by sbi_hart_start.

I see roughly two options, with different drawbacks:
* add a new MP_STATE for the SBI HSM acceleration in KVM
* return to userspace even on sbi_hart_start and sbi_hart_get_status

(We might want to have a better interface for handing SBI in userspace
anyway, so that could be handled later.)

v2 is based on kvm-riscv/riscv_kvm_queue, 376e3c0f8aa5 ("KVM: RISC-V:
remove unnecessary SBI reset state").

Most of the patches from v1 got merged, thanks Anup, so v2 only contains the completely redesigned approach [2/2] and a minor code style improvement that fell through the cracks when the patches got merged out of order [1/2].

---
1: https://github.com/qemu/qemu/commit/dec042841f383c6a825b1642b86d9f585778a2e7

Radim Krčmář (2):
KVM: RISC-V: reset smstateen in a better place
RISC-V: KVM: add KVM_CAP_RISCV_MP_STATE_RESET

 Documentation/virt/kvm/api.rst        | 15 +++++++++++
 arch/riscv/include/asm/kvm_host.h     |  3 +++
 arch/riscv/include/asm/kvm_vcpu_sbi.h |  1 +
 arch/riscv/kvm/vcpu.c                 | 39 ++++++++++++++++-----------
 arch/riscv/kvm/vcpu_sbi.c             | 17 ++++++++++++
 arch/riscv/kvm/vcpu_sbi_hsm.c         |  7 ++++-
 arch/riscv/kvm/vcpu_sbi_system.c      |  3 ++-
 arch/riscv/kvm/vm.c                   | 13 +++++++++
 include/uapi/linux/kvm.h              |  1 +
 9 files changed, 82 insertions(+), 17 deletions(-)
Signature · 1 line
2.49.0