[PATCH v2 3/3] KVM: selftests: Enable pre_fault_memory_test for RISC-V
Nutty.Liu
nutty.liu at hotmail.com
Thu Aug 13 20:51:37 PDT 2026
On 8/12/2026 7:03 AM, Jinyu Tang wrote:
> RISC-V now supports KVM_PRE_FAULT_MEMORY, so include the generic
> pre_fault_memory_test in the RISC-V KVM selftest build.
>
> The test uses PAGE_SIZE from the architecture processor header. Define
> the normal 4K RISC-V selftest page size so the generic test can build
> for RISC-V.
>
> Signed-off-by: Jinyu Tang <jinyu.tang at linux.dev>
Reviewed-by: Nutty Liu <nutty.liu at hotmail.com>
Thanks,
Nutty
> ---
> v1 -> 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.
>
> tools/testing/selftests/kvm/Makefile.kvm | 1 +
> tools/testing/selftests/kvm/include/riscv/processor.h | 3 +++
> 2 files changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm
> index 6fc34e9bf8e1..ac64ac92fd4b 100644
> --- a/tools/testing/selftests/kvm/Makefile.kvm
> +++ b/tools/testing/selftests/kvm/Makefile.kvm
> @@ -225,6 +225,7 @@ TEST_GEN_PROGS_riscv += coalesced_io_test
> TEST_GEN_PROGS_riscv += dirty_log_perf_test
> TEST_GEN_PROGS_riscv += get-reg-list
> TEST_GEN_PROGS_riscv += mmu_stress_test
> +TEST_GEN_PROGS_riscv += pre_fault_memory_test
> TEST_GEN_PROGS_riscv += rseq_test
> TEST_GEN_PROGS_riscv += steal_time
>
> diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h
> index abde3c71c891..70487c8ed155 100644
> --- a/tools/testing/selftests/kvm/include/riscv/processor.h
> +++ b/tools/testing/selftests/kvm/include/riscv/processor.h
> @@ -12,6 +12,9 @@
> #include <asm/vdso/processor.h>
> #include "kvm_util.h"
>
> +#define PAGE_SHIFT 12
> +#define PAGE_SIZE BIT_ULL(PAGE_SHIFT)
> +
> #define INSN_OPCODE_MASK 0x007c
> #define INSN_OPCODE_SHIFT 2
> #define INSN_OPCODE_SYSTEM 28
More information about the linux-riscv
mailing list