From 7f96465407bccca3cf9f6e92bc67cf2a6b794901 Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Wed, 11 Dec 2019 15:34:40 +0800 Subject: [PATCH] hv:remove need_cleanup flag in create_vm remove this redundancy flag. Tracked-On: #1842 Signed-off-by: Mingqiang Chi Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vm.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index 593e519b2..0be4d12a4 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -460,7 +460,6 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_ { struct acrn_vm *vm = NULL; int32_t status = 0; - bool need_cleanup = false; uint32_t i; uint16_t pcpu_id; @@ -483,9 +482,6 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_ prepare_sos_vm_memmap(vm); status = init_vm_boot_info(vm); - if (status != 0) { - need_cleanup = true; - } } else { /* For PRE_LAUNCHED_VM and POST_LAUNCHED_VM */ if ((vm_config->guest_flags & GUEST_FLAG_SECURE_WORLD_ENABLED) != 0U) { @@ -560,14 +556,6 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_ status = set_vcpuid_entries(vm); if (status == 0) { vm->state = VM_CREATED; - } else { - need_cleanup = true; - } - } - - if (need_cleanup) { - if (vm->arch_vm.nworld_eptp != NULL) { - (void)memset(vm->arch_vm.nworld_eptp, 0U, PAGE_SIZE); } } @@ -585,6 +573,10 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_ } } + if ((status != 0) && (vm->arch_vm.nworld_eptp != NULL)) { + (void)memset(vm->arch_vm.nworld_eptp, 0U, PAGE_SIZE); + } + return status; }