diff mbox series

[03/20] KVM: selftests: Use vm_alloc_page_table() to allocate LoongArch page tables

Message ID 20260826230511.972824-4-seanjc@google.com
State New
Headers show
Series KVM: selftests: PPC pre-enabling | expand

Commit Message

Sean Christopherson Aug. 26, 2026, 11:04 p.m. UTC
Now that KVM_GUEST_PAGE_TABLE_MIN_PADDR == LOONGARCH_PAGE_TABLE_PHYS_MIN,
use the common vm_alloc_page_table() instead of open coding the same.

Opportunistically drop the assert that the allocation succeeded, as the
allocator itself guarantees success.

For all intents and purposes, no functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 tools/testing/selftests/kvm/lib/loongarch/processor.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Bibo Mao Aug. 27, 2026, 6:43 a.m. UTC | #1
On 2026/8/27 上午7:04, Sean Christopherson wrote:
> Now that KVM_GUEST_PAGE_TABLE_MIN_PADDR == LOONGARCH_PAGE_TABLE_PHYS_MIN,
> use the common vm_alloc_page_table() instead of open coding the same.
> 
> Opportunistically drop the assert that the allocation succeeded, as the
> allocator itself guarantees success.
> 
> For all intents and purposes, no functional change intended.
> 
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>   tools/testing/selftests/kvm/lib/loongarch/processor.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/loongarch/processor.c b/tools/testing/selftests/kvm/lib/loongarch/processor.c
> index 47bbde3e205a..fcd41bc6fbda 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,9 +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,
> -				vm->memslots[MEM_REGION_PT]);
> -		TEST_ASSERT(table, "Fail to allocate page tale at level %d\n", i);
> +		table = vm_alloc_page_table(vm);
>   		virt_set_pgtable(vm, table, child);
>   		child = table;
>   	}
> 
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/lib/loongarch/processor.c b/tools/testing/selftests/kvm/lib/loongarch/processor.c
index 47bbde3e205a..fcd41bc6fbda 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,9 +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,
-				vm->memslots[MEM_REGION_PT]);
-		TEST_ASSERT(table, "Fail to allocate page tale at level %d\n", i);
+		table = vm_alloc_page_table(vm);
 		virt_set_pgtable(vm, table, child);
 		child = table;
 	}