Skip to content

Commit

Permalink
hv: ept: remove EPT paging table for HPA to GPA
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lifeix authored and wenlingz committed Oct 23, 2018
1 parent 70ddca3 commit 39fde06
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
13 changes: 0 additions & 13 deletions hypervisor/arch/x86/ept.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 1 addition & 7 deletions hypervisor/arch/x86/guest/vm.c
Expand Up @@ -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;
Expand Down Expand Up @@ -179,10 +177,6 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)

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);
}
Expand Down
1 change: 0 additions & 1 deletion hypervisor/include/arch/x86/guest/vm.h
Expand Up @@ -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 */
Expand Down

0 comments on commit 39fde06

Please sign in to comment.