hv: move panic out of hypercall

Just return the errno to the caller.

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
Li, Fei1
2018-05-29 15:47:23 +08:00
committed by lijinxia
parent da662fae62
commit b6c5e0efdd
2 changed files with 46 additions and 29 deletions

View File

@@ -35,19 +35,22 @@ int64_t hcall_world_switch(struct vcpu *vcpu)
{
int next_world_id = !(vcpu->arch_vcpu.cur_context);
if (next_world_id >= NR_WORLD) {
pr_err("%s world_id %d exceed max number of Worlds\n",
__func__, next_world_id);
return -EINVAL;
}
if (!vcpu->vm->sworld_control.sworld_enabled) {
pr_err("Secure World is not enabled!\n");
return -1;
pr_err("%s, Secure World is not enabled!\n", __func__);
return -EPERM;
}
if (!vcpu->vm->arch_vm.sworld_eptp) {
pr_err("Trusty is not initialized!\n");
return -1;
pr_err("%s, Trusty is not initialized!\n", __func__);
return -EPERM;
}
ASSERT(next_world_id < NR_WORLD,
"world_id exceed max number of Worlds");
switch_world(vcpu, next_world_id);
return 0;
}
@@ -55,22 +58,23 @@ int64_t hcall_world_switch(struct vcpu *vcpu)
int64_t hcall_initialize_trusty(struct vcpu *vcpu, uint64_t param)
{
if (!vcpu->vm->sworld_control.sworld_enabled) {
pr_err("Secure World is not enabled!\n");
return -1;
pr_err("%s, Secure World is not enabled!\n", __func__);
return -EPERM;
}
if (vcpu->vm->arch_vm.sworld_eptp) {
pr_err("Trusty already initialized!\n");
return -1;
pr_err("%s, Trusty already initialized!\n", __func__);
return -EPERM;
}
ASSERT(vcpu->arch_vcpu.cur_context == NORMAL_WORLD,
"The Trusty Initialize hypercall must be from Normal World");
if (!initialize_trusty(vcpu, param)) {
pr_err("Failed to initialize trusty!\n");
return -1;
if (vcpu->arch_vcpu.cur_context != NORMAL_WORLD) {
pr_err("%s, must initialize Trusty from Normal World!\n",
__func__);
return -EPERM;
}
if (!initialize_trusty(vcpu, param))
return -ENODEV;
return 0;
}