From adcb5ea53d6e34e025c2a99daa6141f75d88f9e4 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Thu, 19 Apr 2018 13:50:05 +0800 Subject: [PATCH] hv: Not to destroy ept of trusty memory if it's not initialized. If guest reboot is issued before trusty init hypercall is issued, we shouldn't destroy ept fo trusty memory because the ept is not created yet. Signed-off-by: Yin Fengwei Reviewed-by: Jason Chen CJ Acked-by: Anthony Xu --- arch/x86/ept.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/ept.c b/arch/x86/ept.c index 72f51921f..c0b4745be 100644 --- a/arch/x86/ept.c +++ b/arch/x86/ept.c @@ -125,8 +125,15 @@ void destroy_ept(struct vm *vm) { free_ept_mem(HPA2HVA(vm->arch_vm.nworld_eptp)); free_ept_mem(HPA2HVA(vm->arch_vm.m2p)); - /* Destroy Secure world ept */ - if (vm->sworld_control.sworld_enabled) + + /* + * If secure world is initialized, destroy Secure world ept. + * There are two cases secure world is not initialized: + * - trusty is not enabled. Check sworld_enabled. + * - trusty is enabled. But not initialized yet. + * Check vm->arch_vm.sworld_eptp. + */ + if (vm->sworld_control.sworld_enabled && vm->arch_vm.sworld_eptp) free_ept_mem(HPA2HVA(vm->arch_vm.sworld_eptp)); }