]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: selftests: Drop "vaddr_" from APIs that allocate memory for a given VM
authorSean Christopherson <seanjc@google.com>
Mon, 20 Apr 2026 21:19:56 +0000 (14:19 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 20 Apr 2026 21:54:17 +0000 (14:54 -0700)
Now that KVM selftests use gva_t instead of vm_vaddr_t, drop "vaddr_" from
the core memory allocation APIs as the information is extraneous and does
more harm than good.  E.g. the APIs don't _just_ allocate virtual memory,
they allocate backing physical memory and install mappings in the guest
page tables.  And as proven by kmalloc() and malloc(), developers generally
expect that allocations come with a working virtual address.

Opportunistically clean up the function comment for vm_alloc(), and drop
the misleading and superfluous comments for its wrappers.

No functional change intended.

Link: https://patch.msgid.link/20260420212004.3938325-12-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
28 files changed:
tools/testing/selftests/kvm/arm64/vgic_irq.c
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/lib/arm64/processor.c
tools/testing/selftests/kvm/lib/elf.c
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/loongarch/processor.c
tools/testing/selftests/kvm/lib/riscv/processor.c
tools/testing/selftests/kvm/lib/s390/processor.c
tools/testing/selftests/kvm/lib/ucall_common.c
tools/testing/selftests/kvm/lib/x86/hyperv.c
tools/testing/selftests/kvm/lib/x86/processor.c
tools/testing/selftests/kvm/lib/x86/svm.c
tools/testing/selftests/kvm/lib/x86/vmx.c
tools/testing/selftests/kvm/s390/memop.c
tools/testing/selftests/kvm/s390/tprot.c
tools/testing/selftests/kvm/x86/amx_test.c
tools/testing/selftests/kvm/x86/cpuid_test.c
tools/testing/selftests/kvm/x86/hyperv_clock.c
tools/testing/selftests/kvm/x86/hyperv_evmcs.c
tools/testing/selftests/kvm/x86/hyperv_extended_hypercalls.c
tools/testing/selftests/kvm/x86/hyperv_features.c
tools/testing/selftests/kvm/x86/hyperv_ipi.c
tools/testing/selftests/kvm/x86/hyperv_svm_test.c
tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c
tools/testing/selftests/kvm/x86/kvm_clock_test.c
tools/testing/selftests/kvm/x86/sev_smoke_test.c
tools/testing/selftests/kvm/x86/svm_nested_soft_inject_test.c
tools/testing/selftests/kvm/x86/xapic_ipi_test.c

index 8a9dd79123d47c98a8c5bc2ed73f9da8d3cbdd21..5e231998617e746a4638d6fc9055378123293508 100644 (file)
@@ -771,7 +771,7 @@ static void test_vgic(u32 nr_irqs, bool level_sensitive, bool eoi_split)
        vcpu_init_descriptor_tables(vcpu);
 
        /* Setup the guest args page (so it gets the args). */
-       args_gva = vm_vaddr_alloc_page(vm);
+       args_gva = vm_alloc_page(vm);
        memcpy(addr_gva2hva(vm, args_gva), &args, sizeof(args));
        vcpu_args_set(vcpu, 1, args_gva);
 
@@ -997,7 +997,7 @@ static void test_vgic_two_cpus(void *gcode)
        vcpu_init_descriptor_tables(vcpus[1]);
 
        /* Setup the guest args page (so it gets the args). */
-       args_gva = vm_vaddr_alloc_page(vm);
+       args_gva = vm_alloc_page(vm);
        memcpy(addr_gva2hva(vm, args_gva), &args, sizeof(args));
        vcpu_args_set(vcpus[0], 2, args_gva, 0);
        vcpu_args_set(vcpus[1], 2, args_gva, 1);
index 676e3ccb1462cd5869cc6621d81b6b258ea8f299..8f7afc34ea8d6ff42987b017737f67c4f2092ea2 100644 (file)
@@ -716,14 +716,14 @@ void vm_mem_region_delete(struct kvm_vm *vm, u32 slot);
 struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, u32 vcpu_id);
 void vm_populate_vaddr_bitmap(struct kvm_vm *vm);
 gva_t vm_vaddr_unused_gap(struct kvm_vm *vm, size_t sz, gva_t vaddr_min);
-gva_t vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min);
-gva_t __vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
-                      enum kvm_mem_region_type type);
-gva_t vm_vaddr_alloc_shared(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
-                           enum kvm_mem_region_type type);
-gva_t vm_vaddr_alloc_pages(struct kvm_vm *vm, int nr_pages);
-gva_t __vm_vaddr_alloc_page(struct kvm_vm *vm, enum kvm_mem_region_type type);
-gva_t vm_vaddr_alloc_page(struct kvm_vm *vm);
+gva_t vm_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min);
+gva_t __vm_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
+                enum kvm_mem_region_type type);
+gva_t vm_alloc_shared(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
+                     enum kvm_mem_region_type type);
+gva_t vm_alloc_pages(struct kvm_vm *vm, int nr_pages);
+gva_t __vm_alloc_page(struct kvm_vm *vm, enum kvm_mem_region_type type);
+gva_t vm_alloc_page(struct kvm_vm *vm);
 
 void virt_map(struct kvm_vm *vm, u64 vaddr, u64 paddr,
              unsigned int npages);
index 7ba3a48911e3d4e0e0dc6b7075e5d05c2fbc2dc0..c4f0e37f29077a9f8c28b4013f501fd51405385b 100644 (file)
@@ -422,9 +422,9 @@ static struct kvm_vcpu *__aarch64_vcpu_add(struct kvm_vm *vm, u32 vcpu_id,
 
        stack_size = vm->page_size == 4096 ? DEFAULT_STACK_PGS * vm->page_size :
                                             vm->page_size;
-       stack_vaddr = __vm_vaddr_alloc(vm, stack_size,
-                                      DEFAULT_ARM64_GUEST_STACK_VADDR_MIN,
-                                      MEM_REGION_DATA);
+       stack_vaddr = __vm_alloc(vm, stack_size,
+                                DEFAULT_ARM64_GUEST_STACK_VADDR_MIN,
+                                MEM_REGION_DATA);
 
        aarch64_vcpu_setup(vcpu, init);
 
@@ -536,8 +536,8 @@ unexpected_exception:
 
 void vm_init_descriptor_tables(struct kvm_vm *vm)
 {
-       vm->handlers = __vm_vaddr_alloc(vm, sizeof(struct handlers),
-                                       vm->page_size, MEM_REGION_DATA);
+       vm->handlers = __vm_alloc(vm, sizeof(struct handlers), vm->page_size,
+                                 MEM_REGION_DATA);
 
        *(gva_t *)addr_gva2hva(vm, (gva_t)(&exception_handlers)) = vm->handlers;
 }
index 0f2710cda9d835e6351320c594dd3a3e5f3c2fd7..2288480f4e1e548b66f9b5cf39d21903f865b6f8 100644 (file)
@@ -162,8 +162,7 @@ void kvm_vm_elf_load(struct kvm_vm *vm, const char *filename)
                seg_vend |= vm->page_size - 1;
                size_t seg_size = seg_vend - seg_vstart + 1;
 
-               gva_t vaddr = __vm_vaddr_alloc(vm, seg_size, seg_vstart,
-                                                   MEM_REGION_CODE);
+               gva_t vaddr = __vm_alloc(vm, seg_size, seg_vstart, MEM_REGION_CODE);
                TEST_ASSERT(vaddr == seg_vstart, "Unable to allocate "
                        "virtual memory for segment at requested min addr,\n"
                        "  segment idx: %u\n"
index 050ae9c92681ef870c472af8f6017268fdbcfce0..b304c0e54837283971e74ce6b1d3001983dfdfce 100644 (file)
@@ -1450,8 +1450,8 @@ va_found:
        return pgidx_start * vm->page_size;
 }
 
-static gva_t ____vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
-                               enum kvm_mem_region_type type, bool protected)
+static gva_t ____vm_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
+                         enum kvm_mem_region_type type, bool protected)
 {
        u64 pages = (sz >> vm->page_shift) + ((sz % vm->page_size) != 0);
 
@@ -1476,84 +1476,44 @@ static gva_t ____vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
        return vaddr_start;
 }
 
-gva_t __vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
-                      enum kvm_mem_region_type type)
+gva_t __vm_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
+                enum kvm_mem_region_type type)
 {
-       return ____vm_vaddr_alloc(vm, sz, vaddr_min, type,
-                                 vm_arch_has_protected_memory(vm));
+       return ____vm_alloc(vm, sz, vaddr_min, type,
+                           vm_arch_has_protected_memory(vm));
 }
 
-gva_t vm_vaddr_alloc_shared(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
-                           enum kvm_mem_region_type type)
+gva_t vm_alloc_shared(struct kvm_vm *vm, size_t sz, gva_t vaddr_min,
+                     enum kvm_mem_region_type type)
 {
-       return ____vm_vaddr_alloc(vm, sz, vaddr_min, type, false);
+       return ____vm_alloc(vm, sz, vaddr_min, type, false);
 }
 
 /*
- * VM Virtual Address Allocate
- *
- * Input Args:
- *   vm - Virtual Machine
- *   sz - Size in bytes
- *   vaddr_min - Minimum starting virtual address
- *
- * Output Args: None
- *
- * Return:
- *   Starting guest virtual address
- *
- * Allocates at least sz bytes within the virtual address space of the vm
- * given by vm.  The allocated bytes are mapped to a virtual address >=
- * the address given by vaddr_min.  Note that each allocation uses a
- * a unique set of pages, with the minimum real allocation being at least
- * a page. The allocated physical space comes from the TEST_DATA memory region.
+ * Allocates at least sz bytes within the virtual address space of the VM
+ * given by @vm.  The allocated bytes are mapped to a virtual address >= the
+ * address given by @vaddr_min.  Note that each allocation uses a a unique set
+ * of pages, with the minimum real allocation being at least a page. The
+ * allocated physical space comes from the TEST_DATA memory region.
  */
-gva_t vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min)
+gva_t vm_alloc(struct kvm_vm *vm, size_t sz, gva_t vaddr_min)
 {
-       return __vm_vaddr_alloc(vm, sz, vaddr_min, MEM_REGION_TEST_DATA);
+       return __vm_alloc(vm, sz, vaddr_min, MEM_REGION_TEST_DATA);
 }
 
-/*
- * VM Virtual Address Allocate Pages
- *
- * Input Args:
- *   vm - Virtual Machine
- *
- * Output Args: None
- *
- * Return:
- *   Starting guest virtual address
- *
- * Allocates at least N system pages worth of bytes within the virtual address
- * space of the vm.
- */
-gva_t vm_vaddr_alloc_pages(struct kvm_vm *vm, int nr_pages)
+gva_t vm_alloc_pages(struct kvm_vm *vm, int nr_pages)
 {
-       return vm_vaddr_alloc(vm, nr_pages * getpagesize(), KVM_UTIL_MIN_VADDR);
+       return vm_alloc(vm, nr_pages * getpagesize(), KVM_UTIL_MIN_VADDR);
 }
 
-gva_t __vm_vaddr_alloc_page(struct kvm_vm *vm, enum kvm_mem_region_type type)
+gva_t __vm_alloc_page(struct kvm_vm *vm, enum kvm_mem_region_type type)
 {
-       return __vm_vaddr_alloc(vm, getpagesize(), KVM_UTIL_MIN_VADDR, type);
+       return __vm_alloc(vm, getpagesize(), KVM_UTIL_MIN_VADDR, type);
 }
 
-/*
- * VM Virtual Address Allocate Page
- *
- * Input Args:
- *   vm - Virtual Machine
- *
- * Output Args: None
- *
- * Return:
- *   Starting guest virtual address
- *
- * Allocates at least one system page worth of bytes within the virtual address
- * space of the vm.
- */
-gva_t vm_vaddr_alloc_page(struct kvm_vm *vm)
+gva_t vm_alloc_page(struct kvm_vm *vm)
 {
-       return vm_vaddr_alloc_pages(vm, 1);
+       return vm_alloc_pages(vm, 1);
 }
 
 /*
index 2982196db3b2d452d8b2792a3110d292dc1dcda8..318520f1f1b9431c0f93a6dcca29d70268159ed8 100644 (file)
@@ -206,8 +206,9 @@ void vm_init_descriptor_tables(struct kvm_vm *vm)
 {
        void *addr;
 
-       vm->handlers = __vm_vaddr_alloc(vm, sizeof(struct handlers),
-                       LOONGARCH_GUEST_STACK_VADDR_MIN, MEM_REGION_DATA);
+       vm->handlers = __vm_alloc(vm, sizeof(struct handlers),
+                                 LOONGARCH_GUEST_STACK_VADDR_MIN,
+                                 MEM_REGION_DATA);
 
        addr = addr_gva2hva(vm, vm->handlers);
        memset(addr, 0, vm->page_size);
@@ -354,8 +355,8 @@ void loongarch_vcpu_setup(struct kvm_vcpu *vcpu)
        loongarch_set_csr(vcpu, LOONGARCH_CSR_STLBPGSIZE, PS_DEFAULT_SIZE);
 
        /* LOONGARCH_CSR_KS1 is used for exception stack */
-       val = __vm_vaddr_alloc(vm, vm->page_size,
-                       LOONGARCH_GUEST_STACK_VADDR_MIN, MEM_REGION_DATA);
+       val = __vm_alloc(vm, vm->page_size, LOONGARCH_GUEST_STACK_VADDR_MIN,
+                        MEM_REGION_DATA);
        TEST_ASSERT(val != 0,  "No memory for exception stack");
        val = val + vm->page_size;
        loongarch_set_csr(vcpu, LOONGARCH_CSR_KS1, val);
@@ -378,8 +379,8 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, u32 vcpu_id)
 
        vcpu = __vm_vcpu_add(vm, vcpu_id);
        stack_size = vm->page_size;
-       stack_vaddr = __vm_vaddr_alloc(vm, stack_size,
-                       LOONGARCH_GUEST_STACK_VADDR_MIN, MEM_REGION_DATA);
+       stack_vaddr = __vm_alloc(vm, stack_size,
+                                LOONGARCH_GUEST_STACK_VADDR_MIN, MEM_REGION_DATA);
        TEST_ASSERT(stack_vaddr != 0,  "No memory for vm stack");
 
        loongarch_vcpu_setup(vcpu);
index 7336d5a20419d2daddbdce4b1b0e507c0a0a2465..38eb8302922a8f94cba7e945323f670c322b219f 100644 (file)
@@ -322,7 +322,7 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, u32 vcpu_id)
 
        stack_size = vm->page_size == 4096 ? DEFAULT_STACK_PGS * vm->page_size :
                                             vm->page_size;
-       stack_vaddr = __vm_vaddr_alloc(vm, stack_size,
+       stack_vaddr = __vm_alloc(vm, stack_size,
                                       DEFAULT_RISCV_GUEST_STACK_VADDR_MIN,
                                       MEM_REGION_DATA);
 
@@ -449,8 +449,8 @@ void vcpu_init_vector_tables(struct kvm_vcpu *vcpu)
 
 void vm_init_vector_tables(struct kvm_vm *vm)
 {
-       vm->handlers = __vm_vaddr_alloc(vm, sizeof(struct handlers),
-                                  vm->page_size, MEM_REGION_DATA);
+       vm->handlers = __vm_alloc(vm, sizeof(struct handlers), vm->page_size,
+                                 MEM_REGION_DATA);
 
        *(gva_t *)addr_gva2hva(vm, (gva_t)(&exception_handlers)) = vm->handlers;
 }
index d35f23a4db124a0949af48aa9e78d68817c0e590..4ae0a39f426f301398c62942bcced8dec8d167b5 100644 (file)
@@ -171,7 +171,7 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, u32 vcpu_id)
        TEST_ASSERT(vm->page_size == PAGE_SIZE, "Unsupported page size: 0x%x",
                    vm->page_size);
 
-       stack_vaddr = __vm_vaddr_alloc(vm, stack_size,
+       stack_vaddr = __vm_alloc(vm, stack_size,
                                       DEFAULT_GUEST_STACK_VADDR_MIN,
                                       MEM_REGION_DATA);
 
index b16b5c5b3a1e555de84ca39b87ea342cfc2d3c88..4a8a5bc40a451b5176d9e2ee06fcc25bfee6c0e9 100644 (file)
@@ -32,8 +32,8 @@ void ucall_init(struct kvm_vm *vm, gpa_t mmio_gpa)
        gva_t vaddr;
        int i;
 
-       vaddr = vm_vaddr_alloc_shared(vm, sizeof(*hdr), KVM_UTIL_MIN_VADDR,
-                                     MEM_REGION_DATA);
+       vaddr = vm_alloc_shared(vm, sizeof(*hdr), KVM_UTIL_MIN_VADDR,
+                               MEM_REGION_DATA);
        hdr = (struct ucall_header *)addr_gva2hva(vm, vaddr);
        memset(hdr, 0, sizeof(*hdr));
 
index c2806bed43c9f50f7d90fdb69b8e2af77c7df6b1..d200c5c26e2eaa74dece1556b6c0d27ee1b9c1bb 100644 (file)
@@ -78,21 +78,21 @@ bool kvm_hv_cpu_has(struct kvm_x86_cpu_feature feature)
 struct hyperv_test_pages *vcpu_alloc_hyperv_test_pages(struct kvm_vm *vm,
                                                       gva_t *p_hv_pages_gva)
 {
-       gva_t hv_pages_gva = vm_vaddr_alloc_page(vm);
+       gva_t hv_pages_gva = vm_alloc_page(vm);
        struct hyperv_test_pages *hv = addr_gva2hva(vm, hv_pages_gva);
 
        /* Setup of a region of guest memory for the VP Assist page. */
-       hv->vp_assist = (void *)vm_vaddr_alloc_page(vm);
+       hv->vp_assist = (void *)vm_alloc_page(vm);
        hv->vp_assist_hva = addr_gva2hva(vm, (uintptr_t)hv->vp_assist);
        hv->vp_assist_gpa = addr_gva2gpa(vm, (uintptr_t)hv->vp_assist);
 
        /* Setup of a region of guest memory for the partition assist page. */
-       hv->partition_assist = (void *)vm_vaddr_alloc_page(vm);
+       hv->partition_assist = (void *)vm_alloc_page(vm);
        hv->partition_assist_hva = addr_gva2hva(vm, (uintptr_t)hv->partition_assist);
        hv->partition_assist_gpa = addr_gva2gpa(vm, (uintptr_t)hv->partition_assist);
 
        /* Setup of a region of guest memory for the enlightened VMCS. */
-       hv->enlightened_vmcs = (void *)vm_vaddr_alloc_page(vm);
+       hv->enlightened_vmcs = (void *)vm_alloc_page(vm);
        hv->enlightened_vmcs_hva = addr_gva2hva(vm, (uintptr_t)hv->enlightened_vmcs);
        hv->enlightened_vmcs_gpa = addr_gva2gpa(vm, (uintptr_t)hv->enlightened_vmcs);
 
index 723a5200c4bb9e690c46191c1e0ccb22e04b639d..50848112932ca269e47a455b2994c3c3d00dba02 100644 (file)
@@ -746,10 +746,10 @@ static void vm_init_descriptor_tables(struct kvm_vm *vm)
        struct kvm_segment seg;
        int i;
 
-       vm->arch.gdt = __vm_vaddr_alloc_page(vm, MEM_REGION_DATA);
-       vm->arch.idt = __vm_vaddr_alloc_page(vm, MEM_REGION_DATA);
-       vm->handlers = __vm_vaddr_alloc_page(vm, MEM_REGION_DATA);
-       vm->arch.tss = __vm_vaddr_alloc_page(vm, MEM_REGION_DATA);
+       vm->arch.gdt = __vm_alloc_page(vm, MEM_REGION_DATA);
+       vm->arch.idt = __vm_alloc_page(vm, MEM_REGION_DATA);
+       vm->handlers = __vm_alloc_page(vm, MEM_REGION_DATA);
+       vm->arch.tss = __vm_alloc_page(vm, MEM_REGION_DATA);
 
        /* Handlers have the same address in both address spaces.*/
        for (i = 0; i < NUM_INTERRUPTS; i++)
@@ -828,7 +828,7 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, u32 vcpu_id)
        gva_t stack_vaddr;
        struct kvm_vcpu *vcpu;
 
-       stack_vaddr = __vm_vaddr_alloc(vm, DEFAULT_STACK_PGS * getpagesize(),
+       stack_vaddr = __vm_alloc(vm, DEFAULT_STACK_PGS * getpagesize(),
                                       DEFAULT_GUEST_STACK_VADDR_MIN,
                                       MEM_REGION_DATA);
 
@@ -844,7 +844,7 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, u32 vcpu_id)
         * may need to subtract 4 bytes instead of 8 bytes.
         */
        TEST_ASSERT(IS_ALIGNED(stack_vaddr, PAGE_SIZE),
-                   "__vm_vaddr_alloc() did not provide a page-aligned address");
+                   "__vm_alloc() did not provide a page-aligned address");
        stack_vaddr -= 8;
 
        vcpu = __vm_vcpu_add(vm, vcpu_id);
index 620bdc5d3cc2d8f0f3319b07c57e59c8016caae2..3b01605ab016c03b7b7d76f24064b7df9dff4572 100644 (file)
@@ -30,18 +30,18 @@ u64 rflags;
 struct svm_test_data *
 vcpu_alloc_svm(struct kvm_vm *vm, gva_t *p_svm_gva)
 {
-       gva_t svm_gva = vm_vaddr_alloc_page(vm);
+       gva_t svm_gva = vm_alloc_page(vm);
        struct svm_test_data *svm = addr_gva2hva(vm, svm_gva);
 
-       svm->vmcb = (void *)vm_vaddr_alloc_page(vm);
+       svm->vmcb = (void *)vm_alloc_page(vm);
        svm->vmcb_hva = addr_gva2hva(vm, (uintptr_t)svm->vmcb);
        svm->vmcb_gpa = addr_gva2gpa(vm, (uintptr_t)svm->vmcb);
 
-       svm->save_area = (void *)vm_vaddr_alloc_page(vm);
+       svm->save_area = (void *)vm_alloc_page(vm);
        svm->save_area_hva = addr_gva2hva(vm, (uintptr_t)svm->save_area);
        svm->save_area_gpa = addr_gva2gpa(vm, (uintptr_t)svm->save_area);
 
-       svm->msr = (void *)vm_vaddr_alloc_page(vm);
+       svm->msr = (void *)vm_alloc_page(vm);
        svm->msr_hva = addr_gva2hva(vm, (uintptr_t)svm->msr);
        svm->msr_gpa = addr_gva2gpa(vm, (uintptr_t)svm->msr);
        memset(svm->msr_hva, 0, getpagesize());
index b2f83c3f7f16ca94c5d76be5d5d679031fc249ff..67642759e4a05f1faae9f6dcc9cc89c1d9417c6a 100644 (file)
@@ -81,37 +81,37 @@ void vm_enable_ept(struct kvm_vm *vm)
 struct vmx_pages *
 vcpu_alloc_vmx(struct kvm_vm *vm, gva_t *p_vmx_gva)
 {
-       gva_t vmx_gva = vm_vaddr_alloc_page(vm);
+       gva_t vmx_gva = vm_alloc_page(vm);
        struct vmx_pages *vmx = addr_gva2hva(vm, vmx_gva);
 
        /* Setup of a region of guest memory for the vmxon region. */
-       vmx->vmxon = (void *)vm_vaddr_alloc_page(vm);
+       vmx->vmxon = (void *)vm_alloc_page(vm);
        vmx->vmxon_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmxon);
        vmx->vmxon_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmxon);
 
        /* Setup of a region of guest memory for a vmcs. */
-       vmx->vmcs = (void *)vm_vaddr_alloc_page(vm);
+       vmx->vmcs = (void *)vm_alloc_page(vm);
        vmx->vmcs_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmcs);
        vmx->vmcs_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmcs);
 
        /* Setup of a region of guest memory for the MSR bitmap. */
-       vmx->msr = (void *)vm_vaddr_alloc_page(vm);
+       vmx->msr = (void *)vm_alloc_page(vm);
        vmx->msr_hva = addr_gva2hva(vm, (uintptr_t)vmx->msr);
        vmx->msr_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->msr);
        memset(vmx->msr_hva, 0, getpagesize());
 
        /* Setup of a region of guest memory for the shadow VMCS. */
-       vmx->shadow_vmcs = (void *)vm_vaddr_alloc_page(vm);
+       vmx->shadow_vmcs = (void *)vm_alloc_page(vm);
        vmx->shadow_vmcs_hva = addr_gva2hva(vm, (uintptr_t)vmx->shadow_vmcs);
        vmx->shadow_vmcs_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->shadow_vmcs);
 
        /* Setup of a region of guest memory for the VMREAD and VMWRITE bitmaps. */
-       vmx->vmread = (void *)vm_vaddr_alloc_page(vm);
+       vmx->vmread = (void *)vm_alloc_page(vm);
        vmx->vmread_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmread);
        vmx->vmread_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmread);
        memset(vmx->vmread_hva, 0, getpagesize());
 
-       vmx->vmwrite = (void *)vm_vaddr_alloc_page(vm);
+       vmx->vmwrite = (void *)vm_alloc_page(vm);
        vmx->vmwrite_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmwrite);
        vmx->vmwrite_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmwrite);
        memset(vmx->vmwrite_hva, 0, getpagesize());
@@ -390,7 +390,7 @@ bool kvm_cpu_has_ept(void)
 
 void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm)
 {
-       vmx->apic_access = (void *)vm_vaddr_alloc_page(vm);
+       vmx->apic_access = (void *)vm_alloc_page(vm);
        vmx->apic_access_hva = addr_gva2hva(vm, (uintptr_t)vmx->apic_access);
        vmx->apic_access_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->apic_access);
 }
index 9855b5bfb5ed55b29921d572cb2593665f8f0b1f..0244848621b349c652791afdc30a3248f326741e 100644 (file)
@@ -880,8 +880,8 @@ static void test_copy_key_fetch_prot_override(void)
        struct test_default t = test_default_init(guest_copy_key_fetch_prot_override);
        gva_t guest_0_page, guest_last_page;
 
-       guest_0_page = vm_vaddr_alloc(t.kvm_vm, PAGE_SIZE, 0);
-       guest_last_page = vm_vaddr_alloc(t.kvm_vm, PAGE_SIZE, last_page_addr);
+       guest_0_page = vm_alloc(t.kvm_vm, PAGE_SIZE, 0);
+       guest_last_page = vm_alloc(t.kvm_vm, PAGE_SIZE, last_page_addr);
        if (guest_0_page != 0 || guest_last_page != last_page_addr) {
                print_skip("did not allocate guest pages at required positions");
                goto out;
@@ -919,8 +919,8 @@ static void test_errors_key_fetch_prot_override_not_enabled(void)
        struct test_default t = test_default_init(guest_copy_key_fetch_prot_override);
        gva_t guest_0_page, guest_last_page;
 
-       guest_0_page = vm_vaddr_alloc(t.kvm_vm, PAGE_SIZE, 0);
-       guest_last_page = vm_vaddr_alloc(t.kvm_vm, PAGE_SIZE, last_page_addr);
+       guest_0_page = vm_alloc(t.kvm_vm, PAGE_SIZE, 0);
+       guest_last_page = vm_alloc(t.kvm_vm, PAGE_SIZE, last_page_addr);
        if (guest_0_page != 0 || guest_last_page != last_page_addr) {
                print_skip("did not allocate guest pages at required positions");
                goto out;
@@ -940,8 +940,8 @@ static void test_errors_key_fetch_prot_override_enabled(void)
        struct test_default t = test_default_init(guest_copy_key_fetch_prot_override);
        gva_t guest_0_page, guest_last_page;
 
-       guest_0_page = vm_vaddr_alloc(t.kvm_vm, PAGE_SIZE, 0);
-       guest_last_page = vm_vaddr_alloc(t.kvm_vm, PAGE_SIZE, last_page_addr);
+       guest_0_page = vm_alloc(t.kvm_vm, PAGE_SIZE, 0);
+       guest_last_page = vm_alloc(t.kvm_vm, PAGE_SIZE, last_page_addr);
        if (guest_0_page != 0 || guest_last_page != last_page_addr) {
                print_skip("did not allocate guest pages at required positions");
                goto out;
index e021e198b28e365c597deed00f8483c59bbbd92a..8054d2b178f050d591663f771c32c56d8ac58b83 100644 (file)
@@ -146,7 +146,7 @@ static enum stage perform_next_stage(int *i, bool mapped_0)
                /*
                 * Some fetch protection override tests require that page 0
                 * be mapped, however, when the hosts tries to map that page via
-                * vm_vaddr_alloc, it may happen that some other page gets mapped
+                * vm_alloc, it may happen that some other page gets mapped
                 * instead.
                 * In order to skip these tests we detect this inside the guest
                 */
@@ -219,7 +219,7 @@ int main(int argc, char *argv[])
        mprotect(addr_gva2hva(vm, (gva_t)pages), PAGE_SIZE * 2, PROT_READ);
        HOST_SYNC(vcpu, TEST_SIMPLE);
 
-       guest_0_page = vm_vaddr_alloc(vm, PAGE_SIZE, 0);
+       guest_0_page = vm_alloc(vm, PAGE_SIZE, 0);
        if (guest_0_page != 0) {
                /* Use NO_TAP so we don't get a PASS print */
                HOST_SYNC_NO_TAP(vcpu, STAGE_INIT_FETCH_PROT_OVERRIDE);
index 9ecf7515442bbb134086d378b044cad88943d878..4e63da2b1889cbda1bb2917d24254fcade0ff999 100644 (file)
@@ -263,15 +263,15 @@ int main(int argc, char *argv[])
        vcpu_regs_get(vcpu, &regs1);
 
        /* amx cfg for guest_code */
-       amx_cfg = vm_vaddr_alloc_page(vm);
+       amx_cfg = vm_alloc_page(vm);
        memset(addr_gva2hva(vm, amx_cfg), 0x0, getpagesize());
 
        /* amx tiledata for guest_code */
-       tiledata = vm_vaddr_alloc_pages(vm, 2);
+       tiledata = vm_alloc_pages(vm, 2);
        memset(addr_gva2hva(vm, tiledata), rand() | 1, 2 * getpagesize());
 
        /* XSAVE state for guest_code */
-       xstate = vm_vaddr_alloc_pages(vm, DIV_ROUND_UP(XSAVE_SIZE, PAGE_SIZE));
+       xstate = vm_alloc_pages(vm, DIV_ROUND_UP(XSAVE_SIZE, PAGE_SIZE));
        memset(addr_gva2hva(vm, xstate), 0, PAGE_SIZE * DIV_ROUND_UP(XSAVE_SIZE, PAGE_SIZE));
        vcpu_args_set(vcpu, 3, amx_cfg, tiledata, xstate);
 
index 3c45249a42c4c418869141d627e1b34c074ddfe6..ef0ddd240887462f7e00c4355985382310a5a3e6 100644 (file)
@@ -143,7 +143,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu, int stage)
 struct kvm_cpuid2 *vcpu_alloc_cpuid(struct kvm_vm *vm, gva_t *p_gva, struct kvm_cpuid2 *cpuid)
 {
        int size = sizeof(*cpuid) + cpuid->nent * sizeof(cpuid->entries[0]);
-       gva_t gva = vm_vaddr_alloc(vm, size, KVM_UTIL_MIN_VADDR);
+       gva_t gva = vm_alloc(vm, size, KVM_UTIL_MIN_VADDR);
        struct kvm_cpuid2 *guest_cpuids = addr_gva2hva(vm, gva);
 
        memcpy(guest_cpuids, cpuid, size);
index 6bb1ca11256ff6a33645b9d5a717d0e79ae04954..c083cea546dcec2a29a7a7940124f01d96d63824 100644 (file)
@@ -218,7 +218,7 @@ int main(void)
 
        vcpu_set_hv_cpuid(vcpu);
 
-       tsc_page_gva = vm_vaddr_alloc_page(vm);
+       tsc_page_gva = vm_alloc_page(vm);
        memset(addr_gva2hva(vm, tsc_page_gva), 0x0, getpagesize());
        TEST_ASSERT((addr_gva2gpa(vm, tsc_page_gva) & (getpagesize() - 1)) == 0,
                "TSC page has to be page aligned");
index 061d9e1f02c03a583d291a660abf4f4b6d984ee8..c7fa114aee20fc98969381f5408bdb9d0d24223f 100644 (file)
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
 
        vm = vm_create_with_one_vcpu(&vcpu, guest_code);
 
-       hcall_page = vm_vaddr_alloc_pages(vm, 1);
+       hcall_page = vm_alloc_pages(vm, 1);
        memset(addr_gva2hva(vm, hcall_page), 0x0,  getpagesize());
 
        vcpu_set_hv_cpuid(vcpu);
index be7a2a631789f5a247e9c71feaa28bc6eb65d924..ae047db7b1be03b5c526e51fd213d4bb3fdee4d4 100644 (file)
@@ -57,11 +57,11 @@ int main(void)
        vcpu_set_hv_cpuid(vcpu);
 
        /* Hypercall input */
-       hcall_in_page = vm_vaddr_alloc_pages(vm, 1);
+       hcall_in_page = vm_alloc_pages(vm, 1);
        memset(addr_gva2hva(vm, hcall_in_page), 0x0, vm->page_size);
 
        /* Hypercall output */
-       hcall_out_page = vm_vaddr_alloc_pages(vm, 1);
+       hcall_out_page = vm_alloc_pages(vm, 1);
        memset(addr_gva2hva(vm, hcall_out_page), 0x0, vm->page_size);
 
        vcpu_args_set(vcpu, 3, addr_gva2gpa(vm, hcall_in_page),
index 52dbd52ce606c44aabad74b9e533b0fdf92eccc5..7347f1fe515738960091ac9b484e37efd228bd26 100644 (file)
@@ -141,7 +141,7 @@ static void guest_test_msrs_access(void)
        while (true) {
                vm = vm_create_with_one_vcpu(&vcpu, guest_msr);
 
-               msr_gva = vm_vaddr_alloc_page(vm);
+               msr_gva = vm_alloc_page(vm);
                memset(addr_gva2hva(vm, msr_gva), 0x0, getpagesize());
                msr = addr_gva2hva(vm, msr_gva);
 
@@ -530,10 +530,10 @@ static void guest_test_hcalls_access(void)
                vm = vm_create_with_one_vcpu(&vcpu, guest_hcall);
 
                /* Hypercall input/output */
-               hcall_page = vm_vaddr_alloc_pages(vm, 2);
+               hcall_page = vm_alloc_pages(vm, 2);
                memset(addr_gva2hva(vm, hcall_page), 0x0, 2 * getpagesize());
 
-               hcall_params = vm_vaddr_alloc_page(vm);
+               hcall_params = vm_alloc_page(vm);
                memset(addr_gva2hva(vm, hcall_params), 0x0, getpagesize());
                hcall = addr_gva2hva(vm, hcall_params);
 
index beafcfa4043a9efc8cde4ca4094e299d97c9270d..771535f9aad3c30fa56c5a3642cb764108f35188 100644 (file)
@@ -253,7 +253,7 @@ int main(int argc, char *argv[])
        vm = vm_create_with_one_vcpu(&vcpu[0], sender_guest_code);
 
        /* Hypercall input/output */
-       hcall_page = vm_vaddr_alloc_pages(vm, 2);
+       hcall_page = vm_alloc_pages(vm, 2);
        memset(addr_gva2hva(vm, hcall_page), 0x0, 2 * getpagesize());
 
 
index 77b774b5041c196a63fbad459a84de9a41f90031..7a62f6a9d606d2097e3cef3e7dbc3457edd7d700 100644 (file)
@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
        vcpu_alloc_svm(vm, &nested_gva);
        vcpu_alloc_hyperv_test_pages(vm, &hv_pages_gva);
 
-       hcall_page = vm_vaddr_alloc_pages(vm, 1);
+       hcall_page = vm_alloc_pages(vm, 1);
        memset(addr_gva2hva(vm, hcall_page), 0x0,  getpagesize());
 
        vcpu_args_set(vcpu, 3, nested_gva, hv_pages_gva, addr_gva2gpa(vm, hcall_page));
index a4fb63112cace16ec8d10f5d587173f887d4f648..6adf765749218c73fbb621a1177a69c9e19488e5 100644 (file)
@@ -593,11 +593,11 @@ int main(int argc, char *argv[])
        vm = vm_create_with_one_vcpu(&vcpu[0], sender_guest_code);
 
        /* Test data page */
-       test_data_page = vm_vaddr_alloc_page(vm);
+       test_data_page = vm_alloc_page(vm);
        data = (struct test_data *)addr_gva2hva(vm, test_data_page);
 
        /* Hypercall input/output */
-       data->hcall_gva = vm_vaddr_alloc_pages(vm, 2);
+       data->hcall_gva = vm_alloc_pages(vm, 2);
        data->hcall_gpa = addr_gva2gpa(vm, data->hcall_gva);
        memset(addr_gva2hva(vm, data->hcall_gva), 0x0, 2 * PAGE_SIZE);
 
@@ -606,7 +606,7 @@ int main(int argc, char *argv[])
         * and the test will swap their mappings. The third page keeps the indication
         * about the current state of mappings.
         */
-       data->test_pages = vm_vaddr_alloc_pages(vm, NTEST_PAGES + 1);
+       data->test_pages = vm_alloc_pages(vm, NTEST_PAGES + 1);
        for (i = 0; i < NTEST_PAGES; i++)
                memset(addr_gva2hva(vm, data->test_pages + PAGE_SIZE * i),
                       (u8)(i + 1), PAGE_SIZE);
index 2b8a3feee1f8cd34eed29e48e4cc723c0afabb08..5ad4aeb8e373b6bf83476fd75952467e63796133 100644 (file)
@@ -147,7 +147,7 @@ int main(void)
 
        vm = vm_create_with_one_vcpu(&vcpu, guest_main);
 
-       pvti_gva = vm_vaddr_alloc(vm, getpagesize(), 0x10000);
+       pvti_gva = vm_alloc(vm, getpagesize(), 0x10000);
        pvti_gpa = addr_gva2gpa(vm, pvti_gva);
        vcpu_args_set(vcpu, 2, pvti_gpa, pvti_gva);
 
index 4e037795dc332ad7a4cf4cfcdb0d47247b08402f..1a49ee3915864ebb1884d92ba0c6dcf8fee08025 100644 (file)
@@ -115,8 +115,8 @@ static void test_sync_vmsa(u32 type, u64 policy)
        struct kvm_xsave __attribute__((aligned(64))) xsave = { 0 };
 
        vm = vm_sev_create_with_one_vcpu(type, guest_code_xsave, &vcpu);
-       gva = vm_vaddr_alloc_shared(vm, PAGE_SIZE, KVM_UTIL_MIN_VADDR,
-                                   MEM_REGION_TEST_DATA);
+       gva = vm_alloc_shared(vm, PAGE_SIZE, KVM_UTIL_MIN_VADDR,
+                             MEM_REGION_TEST_DATA);
        hva = addr_gva2hva(vm, gva);
 
        vcpu_args_set(vcpu, 1, gva);
index 5fefb319d9be8c5d784d4e5543b25acb2a8dad5a..f72f11d4c4f8375eebfe7f4e305bc66e418d3478 100644 (file)
@@ -161,7 +161,7 @@ static void run_test(bool is_nmi)
        if (!is_nmi) {
                void *idt, *idt_alt;
 
-               idt_alt_vm = vm_vaddr_alloc_page(vm);
+               idt_alt_vm = vm_alloc_page(vm);
                idt_alt = addr_gva2hva(vm, idt_alt_vm);
                idt = addr_gva2hva(vm, vm->arch.idt);
                memcpy(idt_alt, idt, getpagesize());
index 3df6df2a1b55e71fc4123557f667625fb6228611..d2e2410f748b27333518cbdb9543d78d619376fd 100644 (file)
@@ -414,7 +414,7 @@ int main(int argc, char *argv[])
 
        params[1].vcpu = vm_vcpu_add(vm, 1, sender_guest_code);
 
-       test_data_page_vaddr = vm_vaddr_alloc_page(vm);
+       test_data_page_vaddr = vm_alloc_page(vm);
        data = addr_gva2hva(vm, test_data_page_vaddr);
        memset(data, 0, sizeof(*data));
        params[0].data = data;