Skip to content

Accelerate KVM RISC-V when running as a guest

Anup Patel kvm kvm-riscv linux-riscv lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest13 patches 2 repliesIn review
  2. v113 patches 15 repliesSuperseded

Changes in v2 from the cover letter

- Dropped nacl_shmem_fast() macro from PATCH8
- Added comments in PATCH8 about which back-to-back ncsr_xyz() macros are sub-optimal
- Moved nacl_scratch_xyz() macros to PATCH8

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13RISC-V: KVM: Order the object files alphabeticallyarch/riscv/kvm/Makefile+14 -120 replies
2/13RISC-V: KVM: Save/restore HSTATUS in C sourcearch/riscv/kvm/vcpu.c arch/riscv/kvm/vcpu_switch.S+22 -230 replies
3/13RISC-V: KVM: Save/restore SCOUNTEREN in C sourcearch/riscv/kvm/vcpu.c arch/riscv/kvm/vcpu_switch.S+23 -310 replies
4/13RISC-V: KVM: Break down the __kvm_riscv_switch_to() into macrosarch/riscv/kvm/vcpu_switch.S+40 -120 replies
5/13RISC-V: KVM: Replace aia_set_hvictl() with aia_hvictl_value()arch/riscv/kvm/aia.c+5 -50 replies
6/13RISC-V: KVM: Don't setup SGEI for zero guest external interruptsarch/riscv/kvm/aia.c+9 -00 replies
7/13RISC-V: Add defines for the SBI nested acceleration extensionarch/riscv/include/asm/sbi.h+120 -00 replies
8/13RISC-V: KVM: Add common nested acceleration supportarch/riscv/include/asm/kvm_nacl.h arch/riscv/kvm/Makefile arch/riscv/kvm/main.c +1 more+441 -20 replies
9/13RISC-V: KVM: Use nacl_csr_xyz() for accessing H-extension CSRsarch/riscv/kvm/mmu.c arch/riscv/kvm/vcpu.c arch/riscv/kvm/vcpu_timer.c+87 -480 replies
10/13RISC-V: KVM: Use nacl_csr_xyz() for accessing AIA CSRsarch/riscv/kvm/aia.c+63 -340 replies
11/13RISC-V: KVM: Use SBI sync SRET call when availablearch/riscv/include/asm/kvm_nacl.h arch/riscv/kvm/vcpu.c arch/riscv/kvm/vcpu_switch.S+79 -40 replies
12/13RISC-V: KVM: Save trap CSRs in kvm_riscv_vcpu_enter_exit()arch/riscv/kvm/vcpu.c+21 -130 replies
13/13RISC-V: KVM: Use NACL HFENCEs for KVM request based HFENCEsarch/riscv/kvm/tlb.c+40 -171 reply

Reviews trailers per patch

All 13 patches have a Reviewed-by or Acked-by.

PatchAtish Patra
1/13R-b
2/13R-b
3/13R-b
4/13R-b
5/13R-b
6/13R-b
7/13R-b
8/13R-b
9/13R-b
10/13R-b
11/13R-b
12/13R-b
13/13R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/13] Accelerate KVM RISC-V when running as a guest

The KVM RISC-V hypervisor might be running as a guest under some other host hypervisor in which case the complete H-extension functionality will be trap-n-emulated by the host hypervisor. In this case, the KVM RISC-V performance can be accelerated using the SBI nested acceleration (NACL) extension if the host hypervisor provides it.

These series extends KVM RISC-V to use SBI NACL extension whenever underlying SBI implementation (aka host hypervisor) provides it.

These patches can also be found in the riscv_sbi_nested_v2 branch at:
https://github.com/avpatel/linux.git

To test these patches, run KVM RISC-V as Guest under latest Xvisor found at: https://github.com/xvisor/xvisor.git

For the steps to test on Xvisor, refer the Xvisor documentation <xvisor_source>/docs/riscv/riscv64-qemu.txt with two small changes:

1) In step#11, make sure compressed kvm.ko, guest kernel image, and kvmtool are present in the rootfs.img
2) In step#14, make sure AIA is available to Xvisor by using "virt,aia=aplic-imsic" as the QEMU machine name.

Changes since v1:
- Dropped nacl_shmem_fast() macro from PATCH8
- Added comments in PATCH8 about which back-to-back ncsr_xyz() macros are sub-optimal
- Moved nacl_scratch_xyz() macros to PATCH8

Anup Patel (13):
RISC-V: KVM: Order the object files alphabetically
RISC-V: KVM: Save/restore HSTATUS in C source
RISC-V: KVM: Save/restore SCOUNTEREN in C source
RISC-V: KVM: Break down the __kvm_riscv_switch_to() into macros
RISC-V: KVM: Replace aia_set_hvictl() with aia_hvictl_value()
RISC-V: KVM: Don't setup SGEI for zero guest external interrupts
RISC-V: Add defines for the SBI nested acceleration extension
RISC-V: KVM: Add common nested acceleration support
RISC-V: KVM: Use nacl_csr_xyz() for accessing H-extension CSRs
RISC-V: KVM: Use nacl_csr_xyz() for accessing AIA CSRs
RISC-V: KVM: Use SBI sync SRET call when available
RISC-V: KVM: Save trap CSRs in kvm_riscv_vcpu_enter_exit()
RISC-V: KVM: Use NACL HFENCEs for KVM request based HFENCEs

 arch/riscv/include/asm/kvm_nacl.h | 245 ++++++++++++++++++++++++++++++
 arch/riscv/include/asm/sbi.h      | 120 +++++++++++++++
 arch/riscv/kvm/Makefile           |  27 ++--
 arch/riscv/kvm/aia.c              | 114 +++++++++-----
 arch/riscv/kvm/main.c             |  51 ++++++-
 arch/riscv/kvm/mmu.c              |   4 +-
 arch/riscv/kvm/nacl.c             | 152 ++++++++++++++++++
 arch/riscv/kvm/tlb.c              |  57 ++++---
 arch/riscv/kvm/vcpu.c             | 184 ++++++++++++++++------
 arch/riscv/kvm/vcpu_switch.S      | 137 +++++++++++------
 arch/riscv/kvm/vcpu_timer.c       |  28 ++--
 11 files changed, 941 insertions(+), 178 deletions(-)
 create mode 100644 arch/riscv/include/asm/kvm_nacl.h
 create mode 100644 arch/riscv/kvm/nacl.c
Signature · 1 line
2.43.0