Skip to content

Commit 8a55f03

Browse files
lifeixEddie Dong
authored andcommitted
hv: coding style: refine hcall_initialize_trusty to one exit
Fix procedure has more than one exit point. Tracked-On: #2120 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent 1d1d243 commit 8a55f03

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

hypervisor/common/trusty_hypercall.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,26 @@ int32_t hcall_world_switch(struct acrn_vcpu *vcpu)
6666
*/
6767
int32_t hcall_initialize_trusty(struct acrn_vcpu *vcpu, uint64_t param)
6868
{
69-
if (vcpu->vm->sworld_control.flag.supported == 0UL) {
70-
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
71-
"Secure World is not supported!\n");
72-
return -EPERM;
73-
}
74-
75-
if (vcpu->vm->sworld_control.flag.active != 0UL) {
76-
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
77-
"Trusty already initialized!\n");
78-
return -EPERM;
79-
}
69+
int32_t ret = 0;
8070

81-
if (vcpu->arch.cur_context != NORMAL_WORLD) {
82-
dev_dbg(ACRN_DBG_TRUSTY_HYCALL,
83-
"%s, must initialize Trusty from Normal World!\n",
84-
__func__);
85-
return -EPERM;
86-
}
87-
88-
if (!initialize_trusty(vcpu, param)) {
89-
return -ENODEV;
71+
if (vcpu->vm->sworld_control.flag.supported == 0UL) {
72+
pr_err("Secure World is not supported!\n");
73+
ret = -EPERM;
74+
} else if (vcpu->vm->sworld_control.flag.active != 0UL) {
75+
pr_err("Trusty already initialized!\n");
76+
ret = -EPERM;
77+
} else if (vcpu->arch.cur_context != NORMAL_WORLD) {
78+
pr_err("%s, must initialize Trusty from Normal World!\n", __func__);
79+
ret = -EPERM;
80+
} else {
81+
if (!initialize_trusty(vcpu, param)) {
82+
ret = -ENODEV;
83+
} else {
84+
vcpu->vm->sworld_control.flag.active = 1UL;
85+
}
9086
}
9187

92-
vcpu->vm->sworld_control.flag.active = 1UL;
93-
94-
return 0;
88+
return ret;
9589
}
9690

9791
/**

0 commit comments

Comments
 (0)