From 38e2e45d83b100e0269c246d3a9f3b2301d5764d Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Tue, 17 Jul 2018 16:33:10 +0800 Subject: [PATCH] hv: ept: move EPT PML4 table allocation to create_vm Signed-off-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/arch/x86/ept.c | 4 ---- hypervisor/arch/x86/guest/vm.c | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hypervisor/arch/x86/ept.c b/hypervisor/arch/x86/ept.c index 33887d4ad..8808b8d7a 100644 --- a/hypervisor/arch/x86/ept.c +++ b/hypervisor/arch/x86/ept.c @@ -495,10 +495,6 @@ int ept_mmap(struct vm *vm, uint64_t hpa, /* Setup memory map parameters */ map_params.page_table_type = PTT_EPT; - if (vm->arch_vm.nworld_eptp == NULL) { - vm->arch_vm.nworld_eptp = alloc_paging_struct(); - vm->arch_vm.m2p = alloc_paging_struct(); - } map_params.pml4_base = vm->arch_vm.nworld_eptp; map_params.pml4_inverted = vm->arch_vm.m2p; diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index a9757b944..a791a7930 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -110,6 +110,15 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm) /* gpa_lowtop are used for system start up */ vm->hw.gpa_lowtop = 0UL; + + vm->arch_vm.nworld_eptp = alloc_paging_struct(); + vm->arch_vm.m2p = alloc_paging_struct(); + if ((vm->arch_vm.nworld_eptp == NULL) || + (vm->arch_vm.m2p == NULL)) { + pr_fatal("%s, alloc memory for EPTP failed\n", __func__); + return -ENOMEM; + } + /* Only for SOS: Configure VM software information */ /* For UOS: This VM software information is configure in DM */ if (is_vm0(vm)) {