Initial nested virtualization support for KVM RISC-V. Using this series, we can boot Xvisor inside KVM guest and KVM RISC-V insmod also works inside KVM guest but we can't run nested guest at the moment due to work-in-progress G-stage emulation (or G-stage page table walker).
Patch01-to-Patch09: Fixes and preparatory changes Patch10-to-Patch23: Actual nested virtualization support Patch24-to-Patch27: ONE_REG interface and get-reg-list selftest Upcoming work on-top-of this series include: * Software MMU emulation for nested guest (aka swtlb) * HLV/HSV emulation * Sstc emulation for nested guest * SBI NACL for guest hypervisor * ... and more ... These patches can also be found in the riscv_kvm_nested_v1 branch at: https://github.com/avpatel/linux.git Anup Patel (27): RISC-V: KVM: Fix error code returned for Smstateen ONE_REG RISC-V: KVM: Fix error code returned for Ssaia ONE_REG RISC-V: KVM: Check host Ssaia extension when creating AIA irqchip RISC-V: KVM: Introduce common kvm_riscv_isa_check_host() RISC-V: KVM: Factor-out ISA checks into separate sources RISC-V: KVM: Move timer state defines closer to struct in UAPI header RISC-V: KVM: Add hideleg to struct kvm_vcpu_config RISC-V: KVM: Factor-out VCPU config into separate sources RISC-V: KVM: Don't check hstateen0 when updating sstateen0 CSR RISC-V: KVM: Initial skeletal nested virtualization support RISC-V: KVM: Use half VMID space for nested guest RISC-V: KVM: Extend kvm_riscv_mmu_update_hgatp() for nested virtualization RISC-V: KVM: Extend kvm_riscv_vcpu_config_load() for nested virtualization RISC-V: KVM: Extend kvm_riscv_vcpu_update_timedelta() for nested virt RISC-V: KVM: Extend trap redirection for nested virtualization RISC-V: KVM: Check and inject nested virtual interrupts RISC-V: KVM: Extend kvm_riscv_isa_check_host() for nested virt RISC-V: KVM: Trap-n-emulate SRET for Guest HS-mode RISC-V: KVM: Redirect nested supervisor ecall and breakpoint traps RISC-V: KVM: Redirect nested WFI and WRS traps RISC-V: KVM: Implement remote HFENCE SBI calls for guest RISC-V: KVM: Add CSR emulation for nested virtualization RISC-V: KVM: Add HFENCE emulation for nested virtualization RISC-V: KVM: Add ONE_REG interface for nested virtualization state RISC-V: KVM: selftests: Add nested virt state to get-reg-list test RISC-V: KVM: Add ONE_REG interface for nested virtualization CSRs RISC-V: KVM: selftests: Add nested virt CSRs to get-reg-list test arch/riscv/include/asm/csr.h | 17 + arch/riscv/include/asm/insn.h | 9 + arch/riscv/include/asm/kvm_gstage.h | 2 + arch/riscv/include/asm/kvm_host.h | 29 +- arch/riscv/include/asm/kvm_isa.h | 20 + arch/riscv/include/asm/kvm_mmu.h | 2 +- arch/riscv/include/asm/kvm_tlb.h | 37 +- arch/riscv/include/asm/kvm_vcpu_config.h | 25 ++ arch/riscv/include/asm/kvm_vcpu_nested.h | 163 ++++++++ arch/riscv/include/asm/kvm_vcpu_timer.h | 1 + arch/riscv/include/asm/kvm_vmid.h | 1 + arch/riscv/include/uapi/asm/kvm.h | 36 +- arch/riscv/kvm/Makefile | 6 + arch/riscv/kvm/aia.c | 4 + arch/riscv/kvm/aia_device.c | 5 + arch/riscv/kvm/gstage.c | 14 + arch/riscv/kvm/isa.c | 259 ++++++++++++ arch/riscv/kvm/main.c | 13 +- arch/riscv/kvm/mmu.c | 18 +- arch/riscv/kvm/tlb.c | 135 +++++- arch/riscv/kvm/vcpu.c | 117 ++---- arch/riscv/kvm/vcpu_config.c | 130 ++++++ arch/riscv/kvm/vcpu_exit.c | 62 ++- arch/riscv/kvm/vcpu_fp.c | 9 +- arch/riscv/kvm/vcpu_insn.c | 46 +++ arch/riscv/kvm/vcpu_nested.c | 258 ++++++++++++ arch/riscv/kvm/vcpu_nested_csr.c | 389 ++++++++++++++++++ arch/riscv/kvm/vcpu_nested_insn.c | 140 +++++++ arch/riscv/kvm/vcpu_nested_swtlb.c | 146 +++++++ arch/riscv/kvm/vcpu_onereg.c | 334 +++------------ arch/riscv/kvm/vcpu_pmu.c | 5 +- arch/riscv/kvm/vcpu_sbi_replace.c | 63 ++- arch/riscv/kvm/vcpu_timer.c | 24 +- arch/riscv/kvm/vcpu_vector.c | 5 +- arch/riscv/kvm/vmid.c | 33 +- .../selftests/kvm/riscv/get-reg-list.c | 106 ++++- 36 files changed, 2244 insertions(+), 419 deletions(-) create mode 100644 arch/riscv/include/asm/kvm_isa.h create mode 100644 arch/riscv/include/asm/kvm_vcpu_config.h create mode 100644 arch/riscv/include/asm/kvm_vcpu_nested.h create mode 100644 arch/riscv/kvm/isa.c create mode 100644 arch/riscv/kvm/vcpu_config.c create mode 100644 arch/riscv/kvm/vcpu_nested.c create mode 100644 arch/riscv/kvm/vcpu_nested_csr.c create mode 100644 arch/riscv/kvm/vcpu_nested_insn.c create mode 100644 arch/riscv/kvm/vcpu_nested_swtlb.c -- 2.43.0

