diff --git a/hypervisor/common/trusty_hypercall.c b/hypervisor/common/trusty_hypercall.c index 9f60730a1..8243a9014 100644 --- a/hypervisor/common/trusty_hypercall.c +++ b/hypervisor/common/trusty_hypercall.c @@ -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) { + int32_t ret = 0; + if (vcpu->vm->sworld_control.flag.supported == 0UL) { - dev_dbg(ACRN_DBG_TRUSTY_HYCALL, - "Secure World is not supported!\n"); - return -EPERM; + 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; + } } - if (vcpu->vm->sworld_control.flag.active != 0UL) { - dev_dbg(ACRN_DBG_TRUSTY_HYCALL, - "Trusty already initialized!\n"); - return -EPERM; - } - - 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; - } - - vcpu->vm->sworld_control.flag.active = 1UL; - - return 0; + return ret; } /**