On Fri, Jun 24, 2022 at 02:32:47PM -0700, Ricardo Koller wrote: > Add a library function to allocate a page-table physical page in a > particular memslot. The default behavior is to create new page-table > pages in memslot 0. > > Reviewed-by: Oliver Upton <oupton@xxxxxxxxxx> > Reviewed-by: Ben Gardon <bgardon@xxxxxxxxxx> > Signed-off-by: Ricardo Koller <ricarkol@xxxxxxxxxx> > --- > tools/testing/selftests/kvm/include/kvm_util_base.h | 1 + > tools/testing/selftests/kvm/lib/kvm_util.c | 8 +++++++- > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > index 7ebfc8c7de17..54ede9fc923c 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > @@ -579,6 +579,7 @@ vm_paddr_t vm_phy_page_alloc(struct kvm_vm *vm, vm_paddr_t paddr_min, > vm_paddr_t vm_phy_pages_alloc(struct kvm_vm *vm, size_t num, > vm_paddr_t paddr_min, uint32_t memslot); > vm_paddr_t vm_alloc_page_table(struct kvm_vm *vm); > +vm_paddr_t vm_alloc_page_table_in_memslot(struct kvm_vm *vm, uint32_t pt_memslot); > > /* > * ____vm_create() does KVM_CREATE_VM and little else. __vm_create() also > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > index f8c104dba258..5ee20d4da222 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -1784,9 +1784,15 @@ vm_paddr_t vm_phy_page_alloc(struct kvm_vm *vm, vm_paddr_t paddr_min, > /* Arbitrary minimum physical address used for virtual translation tables. */ > #define KVM_GUEST_PAGE_TABLE_MIN_PADDR 0x180000 > > +vm_paddr_t vm_alloc_page_table_in_memslot(struct kvm_vm *vm, uint32_t pt_memslot) > +{ > + return vm_phy_page_alloc(vm, KVM_GUEST_PAGE_TABLE_MIN_PADDR, > + pt_memslot); > +} > + > vm_paddr_t vm_alloc_page_table(struct kvm_vm *vm) > { > - return vm_phy_page_alloc(vm, KVM_GUEST_PAGE_TABLE_MIN_PADDR, 0); > + return vm_alloc_page_table_in_memslot(vm, 0); > } > > /* > -- > 2.37.0.rc0.161.g10f37bed90-goog > Reviewed-by: Andrew Jones <andrew.jones@xxxxxxxxx>