mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-05 03:26:29 +00:00
hv: trusty: refine struct trusty_mem
Since "uint8_t page[CPU_PAGE_SIZE]" wants to ensure the first_page only took PAGE_SIZE memory space and aligned to PAGE_SIZE. However, it couldn't. So just make it simpler. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Qi, Yadong <yadong.qi@intel.com>
This commit is contained in:
parent
5fd6021dee
commit
d7232ebb57
@ -13,21 +13,14 @@
|
|||||||
#define TRUSTY_VERSION_2 2U
|
#define TRUSTY_VERSION_2 2U
|
||||||
|
|
||||||
struct trusty_mem {
|
struct trusty_mem {
|
||||||
/* The first page of trusty memory is reserved for key_info and
|
/* The first page of trusty memory is reserved for key_info and trusty_startup_param. */
|
||||||
* trusty_startup_param.
|
|
||||||
*/
|
|
||||||
union {
|
|
||||||
struct {
|
struct {
|
||||||
struct trusty_key_info key_info;
|
struct trusty_key_info key_info;
|
||||||
struct trusty_startup_param startup_param;
|
struct trusty_startup_param startup_param;
|
||||||
} data;
|
|
||||||
uint8_t page[PAGE_SIZE];
|
|
||||||
} first_page;
|
} first_page;
|
||||||
|
|
||||||
/* The left memory is for trusty's code/data/heap/stack
|
/* The left memory is for trusty's code/data/heap/stack */
|
||||||
*/
|
} __aligned(PAGE_SIZE);
|
||||||
uint8_t left_mem[0];
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct trusty_key_info g_key_info = {
|
static struct trusty_key_info g_key_info = {
|
||||||
.size_of_this_struct = sizeof(g_key_info),
|
.size_of_this_struct = sizeof(g_key_info),
|
||||||
@ -357,13 +350,13 @@ static bool setup_trusty_info(struct acrn_vcpu *vcpu,
|
|||||||
mem = (struct trusty_mem *)(hpa2hva(mem_base_hpa));
|
mem = (struct trusty_mem *)(hpa2hva(mem_base_hpa));
|
||||||
|
|
||||||
/* copy key_info to the first page of trusty memory */
|
/* copy key_info to the first page of trusty memory */
|
||||||
(void)memcpy_s(&mem->first_page.data.key_info, sizeof(g_key_info),
|
(void)memcpy_s(&mem->first_page.key_info, sizeof(g_key_info),
|
||||||
&g_key_info, sizeof(g_key_info));
|
&g_key_info, sizeof(g_key_info));
|
||||||
|
|
||||||
(void)memset(mem->first_page.data.key_info.dseed_list, 0U,
|
(void)memset(mem->first_page.key_info.dseed_list, 0U,
|
||||||
sizeof(mem->first_page.data.key_info.dseed_list));
|
sizeof(mem->first_page.key_info.dseed_list));
|
||||||
/* Derive dvseed from dseed for Trusty */
|
/* Derive dvseed from dseed for Trusty */
|
||||||
key_info = &mem->first_page.data.key_info;
|
key_info = &mem->first_page.key_info;
|
||||||
for (i = 0U; i < g_key_info.num_seeds; i++) {
|
for (i = 0U; i < g_key_info.num_seeds; i++) {
|
||||||
if (hkdf_sha256(key_info->dseed_list[i].seed,
|
if (hkdf_sha256(key_info->dseed_list[i].seed,
|
||||||
BUP_MKHI_BOOTLOADER_SEED_LEN,
|
BUP_MKHI_BOOTLOADER_SEED_LEN,
|
||||||
@ -386,12 +379,10 @@ static bool setup_trusty_info(struct acrn_vcpu *vcpu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare trusty startup param */
|
/* Prepare trusty startup param */
|
||||||
mem->first_page.data.startup_param.size_of_this_struct =
|
mem->first_page.startup_param.size_of_this_struct = sizeof(struct trusty_startup_param);
|
||||||
sizeof(struct trusty_startup_param);
|
mem->first_page.startup_param.mem_size = mem_size;
|
||||||
mem->first_page.data.startup_param.mem_size = mem_size;
|
mem->first_page.startup_param.tsc_per_ms = CYCLES_PER_MS;
|
||||||
mem->first_page.data.startup_param.tsc_per_ms = CYCLES_PER_MS;
|
mem->first_page.startup_param.trusty_mem_base = TRUSTY_EPT_REBASE_GPA;
|
||||||
mem->first_page.data.startup_param.trusty_mem_base =
|
|
||||||
TRUSTY_EPT_REBASE_GPA;
|
|
||||||
|
|
||||||
/* According to trusty boot protocol, it will use RDI as the
|
/* According to trusty boot protocol, it will use RDI as the
|
||||||
* address(GPA) of startup_param on boot. Currently, the startup_param
|
* address(GPA) of startup_param on boot. Currently, the startup_param
|
||||||
|
Loading…
Reference in New Issue
Block a user