diff options
| author | Jinyu Tang <jinyu.tang@linux.dev> | 2026-08-14 07:45:06 -0400 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2026-10-03 15:08:14 +0530 |
| commit | 0971048f467ef2f52f8e05ab4488705e27f9024e (patch) | |
| tree | da691060d4ba3110b70bc6e398f00c1f95f0b6d7 /tools | |
| parent | e8b32e3779513e9ceed73f09c3f53db423140193 (diff) | |
KVM: selftests: Add RISC-V Sv57 page table indexing
RISC-V selftests can create guests with five page-table levels, for
example when the selected guest mode is Sv57. The RISC-V page-table
walker only had index arrays for levels 0 through 3, so
virt_arch_pg_map() indexed past the end of the arrays when level 4 was
used.
Add the missing L4 index mask and shift so selftests can build guest
page tables for Sv57 VMs.
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Jinyu Tang <jinyu.tang@linux.dev>
Link: https://lore.kernel.org/r/20260814114507.583424-3-jinyu.tang@linux.dev
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/testing/selftests/kvm/include/riscv/processor.h | 3 | ||||
| -rw-r--r-- | tools/testing/selftests/kvm/lib/riscv/processor.c | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index 685baefebdb1..5d242f063147 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -140,6 +140,9 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector, exception_handl void vm_install_interrupt_handler(struct kvm_vm *vm, exception_handler_fn handler); +/* L4 index Bit[56:48] */ +#define PGTBL_L4_INDEX_MASK 0x01FF000000000000ULL +#define PGTBL_L4_INDEX_SHIFT 48 /* L3 index Bit[47:39] */ #define PGTBL_L3_INDEX_MASK 0x0000FF8000000000ULL #define PGTBL_L3_INDEX_SHIFT 39 diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c index d00ac997291c..8f0b619fcded 100644 --- a/tools/testing/selftests/kvm/lib/riscv/processor.c +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c @@ -48,6 +48,7 @@ static u64 pte_index_mask[] = { PGTBL_L1_INDEX_MASK, PGTBL_L2_INDEX_MASK, PGTBL_L3_INDEX_MASK, + PGTBL_L4_INDEX_MASK, }; static u32 pte_index_shift[] = { @@ -55,6 +56,7 @@ static u32 pte_index_shift[] = { PGTBL_L1_INDEX_SHIFT, PGTBL_L2_INDEX_SHIFT, PGTBL_L3_INDEX_SHIFT, + PGTBL_L4_INDEX_SHIFT, }; static u64 pte_index(struct kvm_vm *vm, gva_t gva, int level) |
