Skip to content

Commit

Permalink
hv: coding style: refine hcall_initialize_trusty to one exit
Browse files Browse the repository at this point in the history
Fix procedure has more than one exit point.

Tracked-On: #2120
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
  • Loading branch information
lifeix authored and dongyaozu committed Dec 20, 2018
1 parent 1d1d243 commit 8a55f03
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions hypervisor/common/trusty_hypercall.c
Expand Up @@ -66,32 +66,26 @@ int32_t hcall_world_switch(struct acrn_vcpu *vcpu)
*/
int32_t hcall_initialize_trusty(struct acrn_vcpu *vcpu, uint64_t param)
{
if (vcpu->vm->sworld_control.flag.supported == 0UL) {
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
"Secure World is not supported!\n");
return -EPERM;
}

if (vcpu->vm->sworld_control.flag.active != 0UL) {
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
"Trusty already initialized!\n");
return -EPERM;
}
int32_t ret = 0;

if (vcpu->arch.cur_context != NORMAL_WORLD) {
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
"%s, must initialize Trusty from Normal World!\n",
__func__);
return -EPERM;
}

if (!initialize_trusty(vcpu, param)) {
return -ENODEV;
if (vcpu->vm->sworld_control.flag.supported == 0UL) {
pr_err("Secure World is not supported!\n");
ret = -EPERM;
} else if (vcpu->vm->sworld_control.flag.active != 0UL) {
pr_err("Trusty already initialized!\n");
ret = -EPERM;
} else if (vcpu->arch.cur_context != NORMAL_WORLD) {
pr_err("%s, must initialize Trusty from Normal World!\n", __func__);
ret = -EPERM;
} else {
if (!initialize_trusty(vcpu, param)) {
ret = -ENODEV;
} else {
vcpu->vm->sworld_control.flag.active = 1UL;
}
}

vcpu->vm->sworld_control.flag.active = 1UL;

return 0;
return ret;
}

/**
Expand Down

0 comments on commit 8a55f03

Please sign in to comment.