Skip to content

Commit 75c1573

Browse files
JasonChenCJlijinxia
authored andcommitted
ept: set trusty eptp to 0 after destroy and only invalidate it when exist
set trusty eptp to 0 after destroy, and only invalidate trusty eptp when it exist. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com> Acked-by: Xu, Anthony <anthony.xu@intel.com>
1 parent fb723ef commit 75c1573

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hypervisor/arch/x86/ept.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ void destroy_ept(struct vm *vm)
103103
* - trusty is enabled. But not initialized yet.
104104
* Check vm->arch_vm.sworld_eptp.
105105
*/
106-
if (vm->sworld_control.sworld_enabled && vm->arch_vm.sworld_eptp)
106+
if (vm->sworld_control.sworld_enabled && vm->arch_vm.sworld_eptp) {
107107
free_ept_mem(HPA2HVA(vm->arch_vm.sworld_eptp));
108+
vm->arch_vm.sworld_eptp = 0;
109+
}
108110
}
109111

110112
uint64_t _gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size)

hypervisor/arch/x86/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ void invept(struct vcpu *vcpu)
180180
if (cpu_has_vmx_ept_cap(VMX_EPT_INVEPT_SINGLE_CONTEXT)) {
181181
desc.eptp = vcpu->vm->arch_vm.nworld_eptp | (3 << 3) | 6;
182182
_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
183-
if (vcpu->vm->sworld_control.sworld_enabled) {
183+
if (vcpu->vm->sworld_control.sworld_enabled &&
184+
vcpu->vm->arch_vm.sworld_eptp) {
184185
desc.eptp = vcpu->vm->arch_vm.sworld_eptp
185186
| (3 << 3) | 6;
186187
_invept(INVEPT_TYPE_SINGLE_CONTEXT, desc);
187-
188188
}
189189
} else if (cpu_has_vmx_ept_cap(VMX_EPT_INVEPT_GLOBAL_CONTEXT))
190190
_invept(INVEPT_TYPE_ALL_CONTEXTS, desc);

0 commit comments

Comments
 (0)