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 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li, Fei1 2018-10-17 20:05:56 +08:00 committed by wenlingz
parent 70ddca3a87
commit 39fde060c3
3 changed files with 1 additions and 21 deletions

View File

@ -58,9 +58,6 @@ void destroy_ept(struct vm *vm)
if (vm->arch_vm.nworld_eptp != NULL) { if (vm->arch_vm.nworld_eptp != NULL) {
free_ept_mem((uint64_t *)vm->arch_vm.nworld_eptp); 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 */ /* using return value INVALID_HPA as error code */
uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size) 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); 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) { foreach_vcpu(i, vm, vcpu) {
vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH); 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; struct vcpu *vcpu;
uint16_t i; uint16_t i;
uint64_t hpa = gpa2hpa(vm, gpa);
dev_dbg(ACRN_DBG_EPT, "%s,vm[%d] gpa 0x%llx size 0x%llx\n", dev_dbg(ACRN_DBG_EPT, "%s,vm[%d] gpa 0x%llx size 0x%llx\n",
__func__, vm->vm_id, gpa, size); __func__, vm->vm_id, gpa, size);
mmu_modify_or_del(pml4_page, gpa, size, mmu_modify_or_del(pml4_page, gpa, size,
0UL, 0UL, PTT_EPT, MR_DEL); 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) { foreach_vcpu(i, vm, vcpu) {
vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH); vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH);

View File

@ -88,9 +88,7 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
vm->hw.gpa_lowtop = 0UL; vm->hw.gpa_lowtop = 0UL;
vm->arch_vm.nworld_eptp = alloc_paging_struct(); vm->arch_vm.nworld_eptp = alloc_paging_struct();
vm->arch_vm.m2p = alloc_paging_struct(); if (vm->arch_vm.nworld_eptp == NULL) {
if ((vm->arch_vm.nworld_eptp == NULL) ||
(vm->arch_vm.m2p == NULL)) {
pr_fatal("%s, alloc memory for EPTP failed\n", __func__); pr_fatal("%s, alloc memory for EPTP failed\n", __func__);
status = -ENOMEM; status = -ENOMEM;
goto err; goto err;
@ -179,10 +177,6 @@ err:
vioapic_cleanup(vm_ioapic(vm)); vioapic_cleanup(vm_ioapic(vm));
if (vm->arch_vm.m2p != NULL) {
free(vm->arch_vm.m2p);
}
if (vm->arch_vm.nworld_eptp != NULL) { if (vm->arch_vm.nworld_eptp != NULL) {
free(vm->arch_vm.nworld_eptp); free(vm->arch_vm.nworld_eptp);
} }

View File

@ -97,7 +97,6 @@ struct vm_arch {
* but Normal World can not access Secure World's memory. * but Normal World can not access Secure World's memory.
*/ */
void *sworld_eptp; void *sworld_eptp;
void *m2p; /* machine address to guest physical address */
void *tmp_pg_array; /* Page array for tmp guest paging struct */ void *tmp_pg_array; /* Page array for tmp guest paging struct */
struct acrn_vioapic vioapic; /* Virtual IOAPIC base address */ struct acrn_vioapic vioapic; /* Virtual IOAPIC base address */
struct acrn_vpic vpic; /* Virtual PIC */ struct acrn_vpic vpic; /* Virtual PIC */