| Message ID | 20260902164123.2546762-3-seanjc@google.com |
|---|---|
| State | New |
| Headers | show |
| Series | KVM: selftests: PPC pre-enabling | expand |
On 2026/9/3 上午12:41, Sean Christopherson wrote: > Use the common minimum GPA for page tables (0x180000) on LoongArch instead > of LoongArch's custom minimum of 0x200000, so that LoongArch can use > vm_alloc_page_table() instead of open coding a rough equivalent. There are > no known reasons why LoongArch can't use a lower, less-aligned minimum. > The more-aligned value was originally selected to support huge pages for > the guest, but that only requires the address of the final allocation to be > aligned, the addresses of page table pages is irrelevant on that front. > > Signed-off-by: Sean Christopherson <seanjc@google.com> > --- > tools/testing/selftests/kvm/lib/loongarch/processor.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/kvm/lib/loongarch/processor.c b/tools/testing/selftests/kvm/lib/loongarch/processor.c > index 47bbde3e205a..057a77713542 100644 > --- a/tools/testing/selftests/kvm/lib/loongarch/processor.c > +++ b/tools/testing/selftests/kvm/lib/loongarch/processor.c > @@ -9,7 +9,6 @@ > #include "processor.h" > #include "ucall_common.h" > > -#define LOONGARCH_PAGE_TABLE_PHYS_MIN 0x200000 > #define LOONGARCH_GUEST_STACK_VADDR_MIN 0x200000 > > static gpa_t invalid_pgtable[4]; > @@ -57,7 +56,7 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm) > child = table = 0; > for (i = 0; i < vm->mmu.pgtable_levels; i++) { > invalid_pgtable[i] = child; > - table = vm_phy_page_alloc(vm, LOONGARCH_PAGE_TABLE_PHYS_MIN, > + table = vm_phy_page_alloc(vm, KVM_GUEST_PAGE_TABLE_MIN_PADDR, > vm->memslots[MEM_REGION_PT]); > TEST_ASSERT(table, "Fail to allocate page tale at level %d\n", i); > virt_set_pgtable(vm, table, child); > Reviewed-by: Bibo Mao <maobibo@loongson.cn>
diff --git a/tools/testing/selftests/kvm/lib/loongarch/processor.c b/tools/testing/selftests/kvm/lib/loongarch/processor.c index 47bbde3e205a..057a77713542 100644 --- a/tools/testing/selftests/kvm/lib/loongarch/processor.c +++ b/tools/testing/selftests/kvm/lib/loongarch/processor.c @@ -9,7 +9,6 @@ #include "processor.h" #include "ucall_common.h" -#define LOONGARCH_PAGE_TABLE_PHYS_MIN 0x200000 #define LOONGARCH_GUEST_STACK_VADDR_MIN 0x200000 static gpa_t invalid_pgtable[4]; @@ -57,7 +56,7 @@ void virt_arch_pgd_alloc(struct kvm_vm *vm) child = table = 0; for (i = 0; i < vm->mmu.pgtable_levels; i++) { invalid_pgtable[i] = child; - table = vm_phy_page_alloc(vm, LOONGARCH_PAGE_TABLE_PHYS_MIN, + table = vm_phy_page_alloc(vm, KVM_GUEST_PAGE_TABLE_MIN_PADDR, vm->memslots[MEM_REGION_PT]); TEST_ASSERT(table, "Fail to allocate page tale at level %d\n", i); virt_set_pgtable(vm, table, child);
Use the common minimum GPA for page tables (0x180000) on LoongArch instead of LoongArch's custom minimum of 0x200000, so that LoongArch can use vm_alloc_page_table() instead of open coding a rough equivalent. There are no known reasons why LoongArch can't use a lower, less-aligned minimum. The more-aligned value was originally selected to support huge pages for the guest, but that only requires the address of the final allocation to be aligned, the addresses of page table pages is irrelevant on that front. Signed-off-by: Sean Christopherson <seanjc@google.com> --- tools/testing/selftests/kvm/lib/loongarch/processor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)