Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The page table dump function `pte_dump()` is missing the 'p4d' string for 5-level paging.
--
commit a04aa92b1663291806024b3dd2c32f253a43baf3
Author: Itaru Kitayama <[email protected]>
KVM: selftest: arm64: Support 5-level paging in stage 1 translation table
Add p4d_index() for when 5-level paging required, i.e., V52 guest mode
IDs. With the index helper function, _virt_pg_map() handles 5-level
paging case, and aarch64_vcpu_setup() now is aware of the new V52 guest
mode IDs.
> diff --git a/tools/testing/selftests/kvm/lib/arm64/processor.c b/tools/testing/selftests/kvm/lib/arm64/processor.c
> index 01325bf4d36fc..9108e14a9b5be 100644
> --- a/tools/testing/selftests/kvm/lib/arm64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/arm64/processor.c
[ ... ]
> @@ -182,18 +200,35 @@ void virt_arch_pg_map(struct kvm_vm *vm, gva_t gva, gpa_t gpa)
>
> u64 *virt_get_pte_hva_at_level(struct kvm_vm *vm, gva_t gva, int level)
> {
> + int start_level = 4 - vm->mmu.pgtable_levels;
> u64 *ptep;
>
> + TEST_ASSERT(level >= start_level && level <= 3,
> + "Invalid translation level %d, valid range is %d-3",
> + level, start_level);
> +
> if (!vm->mmu.pgd_created)
> goto unmapped_gva;
>
> ptep = addr_gpa2hva(vm, vm->mmu.pgd) + pgd_index(vm, gva) * 8;
> if (!ptep)
> goto unmapped_gva;
> - if (level == 0)
> + /*
> + * Stage-1 translation starts at level -1 for a five-level page
> + * table, and at levels 0, 1, or 2 for four-, three-, or two-level
> + * page tables, respectively.
> + */
> + if (level == start_level)
> return ptep;
>
> switch (vm->mmu.pgtable_levels) {
> + case 5:
> + ptep = addr_gpa2hva(vm, pte_addr(vm, *ptep)) + p4d_index(vm, gva) * 8;
> + if (!ptep)
> + goto unmapped_gva;
> + if (level == 0)
> + break;
> + /* fall through */
> case 4:
[Severity: Low]
Does pte_dump() also need to be updated to handle the new p4d level?
In tools/testing/selftests/kvm/lib/arm64/processor.c:pte_dump():
static const char * const type[] = { "", "pud", "pmd", "pte" };
With 5-level paging enabled, virt_arch_dump() starts with level 0. The
pte_dump() function will access index 0 and print an empty string instead
of "p4d".
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.