Add RISC-V support for the generic KVM_PRE_FAULT_MEMORY ioctl. Patch 1 and patch 2 fix existing G-stage huge-page corner cases. They are included first because the prefault hook relies on the map path reporting the mapping that actually covers the requested GPA.
Patch 3 adds the RISC-V arch hook for KVM_PRE_FAULT_MEMORY. Patch 4 adds Sv57 indexing support to the RISC-V KVM selftest helpers, and patch 5 enables the generic pre_fault_memory_test for RISC-V. Patch 1 folds the previously posted standalone G-stage table overwrite fix into this series: https://lore.kernel.org/kvm-riscv/[email protected]/T/#u Changes in v4 resend: - Resend the full series because the previous v4 send was interrupted and the kvm-riscv list archive did not show a complete thread. No code changes. Changes in v4: - Fold the standalone G-stage non-leaf overwrite fix into this series. - Avoid THP adjustment when the original faulting GPA already has an existing 4K G-stage leaf. - Return an error for HWPOISON instead of reporting success without a visible G-stage mapping. (Sashiko) Changes in v3: - Retry internally when the map path returns success without a visible G-stage mapping, instead of exposing -EAGAIN. (Sashiko) Changes in v2: - Drop the per-test guest_modes_append_default() call from pre_fault_memory_test.c. (Sean) Jinyu Tang (5): KVM: riscv: Avoid overwriting G-stage tables with huge leaves KVM: riscv: Avoid THP adjustment for existing 4K G-stage leaves 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 | 9 ++ arch/riscv/kvm/mmu.c | 83 ++++++++++++++++++- 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, 100 insertions(+), 3 deletions(-) -- 2.43.0

