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

@@ -129,6 +129,7 @@ struct secure_world_control {
};
void switch_world(struct vcpu *vcpu, int next_world);
bool initialize_trusty(struct vcpu *vcpu, uint64_t param);
#endif /* TRUSTY_H_ */

View File

@@ -335,6 +335,17 @@ int64_t hcall_setup_sbuf(struct vm *vm, uint64_t param);
*/
int64_t hcall_world_switch(struct vcpu *vcpu);
/**
* @brief Initialize environment for Trusty-OS on a VCPU.
*
* @param VCPU Pointer to VCPU data structure
* @param param's guest physical address. This gpa points to
* struct trusty_boot_param
*
* @return 0 on success, non-zero on error.
*/
int64_t hcall_initialize_trusty(struct vcpu *vcpu, uint64_t param);
/**
* @}
*/

View File

@@ -95,7 +95,7 @@
/* Trusty */
#define HC_ID_TRUSTY_BASE 0x70UL
#define HC_LAUNCH_TRUSTY _HC_ID(HC_ID, HC_ID_TRUSTY_BASE + 0x00)
#define HC_INITIALIZE_TRUSTY _HC_ID(HC_ID, HC_ID_TRUSTY_BASE + 0x00)
#define HC_WORLD_SWITCH _HC_ID(HC_ID, HC_ID_TRUSTY_BASE + 0x01)
#define HC_GET_SEC_INFO _HC_ID(HC_ID, HC_ID_TRUSTY_BASE + 0x02)
@@ -226,6 +226,26 @@ struct hc_api_version {
uint32_t minor_version;
} __aligned(8);
/**
* Trusty boot params, used for HC_INITIALIZE_TRUSTY
*/
struct trusty_boot_param {
/** sizeof this structure */
uint32_t size_of_this_struct;
/** version of this structure */
uint32_t version;
/** trusty runtime memory base address */
uint32_t base_addr;
/** trusty entry point */
uint32_t entry_point;
/** trusty runtime memory size */
uint32_t mem_size;
} __aligned(8);
/**
* @}
*/