hv:remove need_cleanup flag in create_vm
remove this redundancy flag.
Acked-by: Eddie Dong
@@ -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;
}
