Skip to content

Commit 39fde06

Browse files
lifeixwenlingz
authored andcommitted
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>
1 parent 70ddca3 commit 39fde06

File tree

3 files changed

+1
-21
lines changed

3 files changed

+1
-21
lines changed

hypervisor/arch/x86/ept.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ void destroy_ept(struct vm *vm)
5858
if (vm->arch_vm.nworld_eptp != NULL) {
5959
free_ept_mem((uint64_t *)vm->arch_vm.nworld_eptp);
6060
}
61-
if (vm->arch_vm.m2p != NULL) {
62-
free_ept_mem((uint64_t *)vm->arch_vm.m2p);
63-
}
6461
}
6562
/* using return value INVALID_HPA as error code */
6663
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,
238235
}
239236

240237
mmu_add(pml4_page, hpa, gpa, size, prot, PTT_EPT);
241-
/* No need to create inverted page tables for trusty memory */
242-
if ((void *)pml4_page == vm->arch_vm.nworld_eptp) {
243-
mmu_add((uint64_t *)vm->arch_vm.m2p,
244-
gpa, hpa, size, prot, PTT_EPT);
245-
}
246238

247239
foreach_vcpu(i, vm, vcpu) {
248240
vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH);
@@ -271,17 +263,12 @@ void ept_mr_del(struct vm *vm, uint64_t *pml4_page,
271263
{
272264
struct vcpu *vcpu;
273265
uint16_t i;
274-
uint64_t hpa = gpa2hpa(vm, gpa);
275266

276267
dev_dbg(ACRN_DBG_EPT, "%s,vm[%d] gpa 0x%llx size 0x%llx\n",
277268
__func__, vm->vm_id, gpa, size);
278269

279270
mmu_modify_or_del(pml4_page, gpa, size,
280271
0UL, 0UL, PTT_EPT, MR_DEL);
281-
if ((void *)pml4_page == vm->arch_vm.nworld_eptp) {
282-
mmu_modify_or_del((uint64_t *)vm->arch_vm.m2p,
283-
hpa, size, 0UL, 0UL, PTT_EPT, MR_DEL);
284-
}
285272

286273
foreach_vcpu(i, vm, vcpu) {
287274
vcpu_make_request(vcpu, ACRN_REQUEST_EPT_FLUSH);

hypervisor/arch/x86/guest/vm.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
8888
vm->hw.gpa_lowtop = 0UL;
8989

9090
vm->arch_vm.nworld_eptp = alloc_paging_struct();
91-
vm->arch_vm.m2p = alloc_paging_struct();
92-
if ((vm->arch_vm.nworld_eptp == NULL) ||
93-
(vm->arch_vm.m2p == NULL)) {
91+
if (vm->arch_vm.nworld_eptp == NULL) {
9492
pr_fatal("%s, alloc memory for EPTP failed\n", __func__);
9593
status = -ENOMEM;
9694
goto err;
@@ -179,10 +177,6 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
179177

180178
vioapic_cleanup(vm_ioapic(vm));
181179

182-
if (vm->arch_vm.m2p != NULL) {
183-
free(vm->arch_vm.m2p);
184-
}
185-
186180
if (vm->arch_vm.nworld_eptp != NULL) {
187181
free(vm->arch_vm.nworld_eptp);
188182
}

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct vm_arch {
9797
* but Normal World can not access Secure World's memory.
9898
*/
9999
void *sworld_eptp;
100-
void *m2p; /* machine address to guest physical address */
101100
void *tmp_pg_array; /* Page array for tmp guest paging struct */
102101
struct acrn_vioapic vioapic; /* Virtual IOAPIC base address */
103102
struct acrn_vpic vpic; /* Virtual PIC */

0 commit comments

Comments
 (0)