[PATCH v2 0/3] KVM: riscv: Add KVM_PRE_FAULT_MEMORY support
Jinyu Tang
jinyu.tang at linux.dev
Tue Aug 11 16:03:13 PDT 2026
This series adds RISC-V support for the generic KVM_PRE_FAULT_MEMORY
vcpu ioctl and enables the existing generic KVM selftest for RISC-V.
KVM_PRE_FAULT_MEMORY lets userspace ask KVM to populate stage-2 mappings
for a GPA range before running a vCPU that is expected to access that
range. x86 already supports the ioctl; RISC-V currently falls back to
normal first-touch G-stage faults.
Patch 1 implements the RISC-V arch hook using the existing G-stage map
path. Patch 2 fixes the RISC-V selftest page-table walker for Sv57,
which can be selected as the default guest mode. Patch 3 enables
pre_fault_memory_test for RISC-V.
Tested with pre_fault_memory_test on a RISC-V KVM host.
Changes in v2:
- Drop the per-test guest_modes_append_default() call from
pre_fault_memory_test.c. RISC-V already initializes supported and
default guest modes from kvm_selftest_arch_init(), which is called by
the common kvm_selftest_init() constructor, as suggested by Sean.
Jinyu Tang (3):
KVM: riscv: Implement KVM_PRE_FAULT_MEMORY
KVM: selftests: Add RISC-V Sv57 page table indexing
KVM: selftests: Enable pre_fault_memory_test for RISC-V
arch/riscv/kvm/Kconfig | 1 +
arch/riscv/kvm/gstage.c | 3 ++
arch/riscv/kvm/mmu.c | 33 +++++++++++++++++++
arch/riscv/kvm/vm.c | 1 +
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../selftests/kvm/include/riscv/processor.h | 6 ++++
.../selftests/kvm/lib/riscv/processor.c | 2 ++
7 files changed, 47 insertions(+)
--
2.43.0
More information about the kvm-riscv
mailing list