diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index a500cc798..abbdcdafd 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -503,7 +503,7 @@ int32_t create_vm(uint16_t vm_id, uint64_t pcpu_bitmap, struct acrn_vm_config *v vm->hw.created_vcpus = 0U; init_ept_pgtable(&vm->arch_vm.ept_pgtable, vm->vm_id); - vm->arch_vm.nworld_eptp = alloc_ept_page(vm); + vm->arch_vm.nworld_eptp = pgtable_create_root(&vm->arch_vm.ept_pgtable); sanitize_pte((uint64_t *)vm->arch_vm.nworld_eptp, &vm->arch_vm.ept_pgtable); (void)memcpy_s(&vm->uuid[0], sizeof(vm->uuid), diff --git a/hypervisor/arch/x86/mmu.c b/hypervisor/arch/x86/mmu.c index 0c8376d8d..2e4e3e11b 100644 --- a/hypervisor/arch/x86/mmu.c +++ b/hypervisor/arch/x86/mmu.c @@ -307,7 +307,7 @@ void init_paging(void) } /* Allocate memory for Hypervisor PML4 table */ - ppt_mmu_pml4_addr = alloc_page(ppt_pgtable.pool); + ppt_mmu_pml4_addr = pgtable_create_root(&ppt_pgtable); /* Map all memory regions to UC attribute */ pgtable_add_map((uint64_t *)ppt_mmu_pml4_addr, 0UL, 0UL, high64_max_ram - 0UL, attr_uc, &ppt_pgtable); diff --git a/hypervisor/arch/x86/pagetable.c b/hypervisor/arch/x86/pagetable.c index 723542b38..c21df70b1 100644 --- a/hypervisor/arch/x86/pagetable.c +++ b/hypervisor/arch/x86/pagetable.c @@ -430,6 +430,11 @@ void pgtable_add_map(uint64_t *pml4_page, uint64_t paddr_base, uint64_t vaddr_ba } } +void *pgtable_create_root(const struct pgtable *table) +{ + return (uint64_t *)alloc_page(table->pool); +} + /** * @pre (pml4_page != NULL) && (pg_size != NULL) */ diff --git a/hypervisor/include/arch/x86/pgtable.h b/hypervisor/include/arch/x86/pgtable.h index d146971ab..055f51c43 100644 --- a/hypervisor/include/arch/x86/pgtable.h +++ b/hypervisor/include/arch/x86/pgtable.h @@ -304,6 +304,7 @@ static inline uint64_t pdpte_large(uint64_t pdpte) return pdpte & PAGE_PSE; } +void *pgtable_create_root(const struct pgtable *table); /** *@pre (pml4_page != NULL) && (pg_size != NULL) */