Skip to content

Commit a4be10f

Browse files
lifeixwenlingz
authored andcommitted
hv: mmu: unmap the trusty EPT when destroy_secure_world
Unmap the trusty EPT mapping when destroy_secure_world. The reason is now the normal world and trusty will share the PD and PT page. Before we add the mapping for each world, we should unmap it from another world. Besides, fix a minor bug for condition priority. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent e822987 commit a4be10f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

hypervisor/arch/x86/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void init_paging(void)
280280
*/
281281
hv_hpa = get_hv_image_base();
282282
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, hv_hpa & PDE_MASK,
283-
CONFIG_HV_RAM_SIZE + ((hv_hpa & (PDE_SIZE - 1UL)) != 0UL) ? PDE_SIZE : 0UL,
283+
CONFIG_HV_RAM_SIZE + (((hv_hpa & (PDE_SIZE - 1UL)) != 0UL) ? PDE_SIZE : 0UL),
284284
PAGE_CACHE_WB, PAGE_CACHE_MASK | PAGE_USER,
285285
&ppt_mem_ops, MR_MODIFY);
286286

hypervisor/arch/x86/trusty.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ void destroy_secure_world(struct vm *vm, bool need_clr_mem)
166166
(void)memset(hpa2hva(hpa), 0U, size);
167167
}
168168

169+
ept_mr_del(vm, vm->arch_vm.sworld_eptp, gpa_uos, size);
170+
/* sanitize trusty ept page-structures */
171+
sanitize_pte((uint64_t *)vm->arch_vm.sworld_eptp);
172+
vm->arch_vm.sworld_eptp = NULL;
173+
169174
/* restore memory to SOS ept mapping */
170175
ept_mr_add(vm0, vm0->arch_vm.nworld_eptp,
171176
hpa, gpa_sos, size, EPT_RWX | EPT_WB);
@@ -174,9 +179,6 @@ void destroy_secure_world(struct vm *vm, bool need_clr_mem)
174179
ept_mr_add(vm, vm->arch_vm.nworld_eptp,
175180
hpa, gpa_uos, size, EPT_RWX | EPT_WB);
176181

177-
/* sanitize trusty ept page-structures */
178-
sanitize_pte((uint64_t *)vm->arch_vm.sworld_eptp);
179-
vm->arch_vm.sworld_eptp = NULL;
180182
}
181183

182184
static void save_world_ctx(struct vcpu *vcpu, struct ext_context *ext_ctx)

0 commit comments

Comments
 (0)