From 39fde060c391427aa7029c5a663c06692e943260 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Wed, 17 Oct 2018 20:05:56 +0800 Subject: [PATCH] hv: ept: remove EPT paging table for HPA to GPA There's no need to walk these paging tables to transfer HPA to GPA for a VM, so remove it. Tracked-On: #1124 Signed-off-by: Li, Fei1 Acked-by: Eddie Dong --- hypervisor/arch/x86/ept.c | 13 ------------- hypervisor/arch/x86/guest/vm.c | 8 +------- hypervisor/include/arch/x86/guest/vm.h | 1 - 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/hypervisor/arch/x86/ept.c b/hypervisor/arch/x86/ept.c index 8b09a19cc..4952d95c3 100644 --- a/hypervisor/arch/x86/ept.c +++ b/hypervisor/arch/x86/ept.c @@ -58,9 +58,6 @@ void destroy_ept(struct vm *vm) if (vm->arch_vm.nworld_eptp != NULL) { free_ept_mem((uint64_t *)vm->arch_vm.nworld_eptp); } - if (vm->arch_vm.m2p != NULL) { - free_ept_mem((uint64_t *)vm->arch_vm.m2p); - } } /* using return value INVALID_HPA as error code */ uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size) @@ -238,11 +235,6 @@ void ept_mr_add(struct vm *vm, uint64_t *pml4_page, } mmu_add(pml4_page, hpa, gpa, size, prot, PTT_EPT); - /* No need to create inverted page tables for trusty memory */ - if ((void *)pml4_page == vm->arch_vm.nworld_eptp) { - mmu_add((uint64_t *)vm->arch_vm.m2p, - gpa, hpa, size, prot, PTT_EPT); - } foreach_vcpu(i, vm, vcpu) { vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH); @@ -271,17 +263,12 @@ void ept_mr_del(struct vm *vm, uint64_t *pml4_page, { struct vcpu *vcpu; uint16_t i; - uint64_t hpa = gpa2hpa(vm, gpa); dev_dbg(ACRN_DBG_EPT, "%s,vm[%d] gpa 0x%llx size 0x%llx\n", __func__, vm->vm_id, gpa, size); mmu_modify_or_del(pml4_page, gpa, size, 0UL, 0UL, PTT_EPT, MR_DEL); - if ((void *)pml4_page == vm->arch_vm.nworld_eptp) { - mmu_modify_or_del((uint64_t *)vm->arch_vm.m2p, - hpa, size, 0UL, 0UL, PTT_EPT, MR_DEL); - } foreach_vcpu(i, vm, vcpu) { vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH); diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 36fd193db..4d04f7e17 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -88,9 +88,7 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm) 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)) { + if (vm->arch_vm.nworld_eptp == NULL) { pr_fatal("%s, alloc memory for EPTP failed\n", __func__); status = -ENOMEM; goto err; @@ -179,10 +177,6 @@ err: vioapic_cleanup(vm_ioapic(vm)); - if (vm->arch_vm.m2p != NULL) { - free(vm->arch_vm.m2p); - } - if (vm->arch_vm.nworld_eptp != NULL) { free(vm->arch_vm.nworld_eptp); } diff --git a/hypervisor/include/arch/x86/guest/vm.h b/hypervisor/include/arch/x86/guest/vm.h index a14269cea..d2d65fe35 100644 --- a/hypervisor/include/arch/x86/guest/vm.h +++ b/hypervisor/include/arch/x86/guest/vm.h @@ -97,7 +97,6 @@ struct vm_arch { * but Normal World can not access Secure World's memory. */ void *sworld_eptp; - void *m2p; /* machine address to guest physical address */ void *tmp_pg_array; /* Page array for tmp guest paging struct */ struct acrn_vioapic vioapic; /* Virtual IOAPIC base address */ struct acrn_vpic vpic; /* Virtual PIC */