HV: trusty: Get rpmb_key from OSloader when init trusty

Extend struct trusty_boot_param to hold rpmb_key.
Copy rpmb_key from trusty_boot_param when initialize
trusty.

Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Reviewed-by: Zhu Bing <bing.zhu@intel.com>
Reviewed-by: Wang Kai <kai.z.wang@intel.com>
This commit is contained in:
Qi Yadong 2018-06-25 10:59:49 +08:00 committed by lijinxia
parent 260e84769d
commit 3e2d1fba6b
2 changed files with 23 additions and 2 deletions

View File

@ -7,7 +7,8 @@
#include <hypervisor.h>
#include <hkdf.h>
#define TRUSTY_VERSION 1
#define TRUSTY_VERSION 1U
#define TRUSTY_VERSION_2 2U
struct trusty_mem {
/* The first page of trusty memory is reserved for key_info and
@ -425,14 +426,20 @@ bool initialize_trusty(struct vcpu *vcpu, uint64_t param)
return false;
}
/* FIXME: Temporarily comments out the size check since need to extend
* the interface, need to add back after the integration done.
*/
/*
if (sizeof(struct trusty_boot_param) !=
boot_param.size_of_this_struct) {
pr_err("%s: sizeof(struct trusty_boot_param) mismatch!\n",
__func__);
return false;
}
*/
if (boot_param.version != TRUSTY_VERSION) {
if ((boot_param.version != TRUSTY_VERSION) &&
(boot_param.version != TRUSTY_VERSION_2)) {
pr_err("%s: version of(trusty_boot_param) mismatch!\n",
__func__);
return false;
@ -461,6 +468,14 @@ bool initialize_trusty(struct vcpu *vcpu, uint64_t param)
/* save Normal World context */
save_world_ctx(&vcpu->arch_vcpu.contexts[NORMAL_WORLD]);
if (boot_param.version == TRUSTY_VERSION_2) {
/* copy rpmb_key from OSloader */
memcpy_s(&g_key_info.rpmb_key[0][0], 64U,
&boot_param.rpmb_key[0], 64U);
memset(&boot_param.rpmb_key[0], 0U, 64U);
/* OSloader must clear the rpmb_key after switched back */
}
/* init secure world environment */
if (init_secure_world_env(vcpu,
trusty_entry_gpa - trusty_base_gpa + TRUSTY_EPT_REBASE_GPA,

View File

@ -256,6 +256,12 @@ struct trusty_boot_param {
/** trusty runtime memory size */
uint32_t mem_size;
/** padding */
uint32_t padding;
/** rpmb key */
uint8_t rpmb_key[64];
} __aligned(8);
/**