trusty: implement hypercall to initialize trusty

UOS_Loader will trigger boot of Trusty-OS by HC_INITIALIZE_TRUSTY.
UOS_Loader will load trusty image and alloc runtime memory for
trusty. UOS_Loader will transfer these information include
trusty runtime memory base address, entry address and memory
size to hypervisor by trusty_boot_param structure.

In hypervisor, once HC_INITIALIZE_TRUSTY received, it will create
EPT for Secure World, save Normal World vCPU context, init
Secure World vCPU context and switch World state to Secure World.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
This commit is contained in:
Qi Yadong
2018-03-27 17:27:51 +08:00
committed by Jack Ren
parent 1fd07ba349
commit b124e0da28
7 changed files with 208 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ int64_t hcall_world_switch(struct vcpu *vcpu)
}
if (!vcpu->vm->arch_vm.sworld_eptp) {
pr_err("Trusty is not launched!\n");
pr_err("Trusty is not initialized!\n");
return -1;
}
@@ -61,3 +61,31 @@ int64_t hcall_world_switch(struct vcpu *vcpu)
switch_world(vcpu, next_world_id);
return 0;
}
int64_t hcall_initialize_trusty(struct vcpu *vcpu, uint64_t param)
{
if (!is_hypercall_from_ring0()) {
pr_err("%s() is only allowed from RING-0!\n", __func__);
return -1;
}
if (!vcpu->vm->sworld_control.sworld_enabled) {
pr_err("Secure World is not enabled!\n");
return -1;
}
if (vcpu->vm->arch_vm.sworld_eptp) {
pr_err("Trusty already initialized!\n");
return -1;
}
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;
}
return 0;
}