HV: Parse SeedList HOB

Retrieve dseed from SeedList HOB(Hand-Off-Block).
SBL passes SeedList HOB to ACRN by MBI modules.

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>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Qi Yadong
2018-06-05 10:57:34 +08:00
committed by lijinxia
parent d1e281f6eb
commit 03f5cbdd7a
6 changed files with 139 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hypervisor.h>
#include <hob_parse.h>
void parse_seed_list(struct seed_list_hob *seed_hob)
{
uint8_t i;
uint8_t dseed_index = 0;
struct seed_entry *entry;
struct seed_info dseed_list[BOOTLOADER_SEED_MAX_ENTRIES];
if (!seed_hob) {
pr_warn("Invalid seed_list hob pointer. Use fake seed!");
goto fail;
}
if (seed_hob->total_seed_count == 0) {
pr_warn("Total seed count is 0. Use fake seed!");
goto fail;
}
entry = (struct seed_entry *)((uint8_t *)seed_hob +
sizeof(struct seed_list_hob));
for (i = 0; i < seed_hob->total_seed_count; i++) {
/* retrieve dseed */
if ((SEED_ENTRY_TYPE_SVNSEED == entry->type) &&
(SEED_ENTRY_USAGE_DSEED == entry->usage)) {
/* The seed_entry with same type/usage are always
* arranged by index in order of 0~3.
*/
if (entry->index != dseed_index) {
pr_warn("Index mismatch. Use fake seed!");
goto fail;
}
if (entry->index >= BOOTLOADER_SEED_MAX_ENTRIES) {
pr_warn("Index exceed max number!");
goto fail;
}
memcpy_s(&dseed_list[dseed_index],
sizeof(struct seed_info),
entry->seed,
sizeof(struct seed_info));
dseed_index++;
/* erase original seed in seed entry */
memset(entry->seed, 0, sizeof(struct seed_info));
}
entry = (struct seed_entry *)((uint8_t *)entry +
entry->seed_entry_size);
}
trusty_set_dseed(dseed_list, dseed_index);
memset(dseed_list, 0, sizeof(dseed_list));
return;
fail:
trusty_set_dseed(NULL, 0);
memset(dseed_list, 0, sizeof(dseed_list));
}

View File

@@ -7,6 +7,7 @@
#include <hypervisor.h>
#include <multiboot.h>
#include <zeropage.h>
#include <hob_parse.h>
#define BOOT_ARGS_LOAD_ADDR 0x24EFC000
@@ -19,7 +20,7 @@
*/
static char kernel_cmdline[MEM_2K];
/*now modules support: FIRMWARE & RAMDISK */
/* now modules support: FIRMWARE & RAMDISK & SeedList */
static void parse_other_modules(struct vm *vm,
struct multiboot_module *mods, int mods_count)
{
@@ -73,6 +74,8 @@ static void parse_other_modules(struct vm *vm,
vm->sw.linux_info.ramdisk_src_addr = mod_addr;
vm->sw.linux_info.ramdisk_load_addr = mod_addr;
vm->sw.linux_info.ramdisk_size = mod_size;
} else if (strncmp("SeedList", start, type_len) == 0) {
parse_seed_list(mod_addr);
} else {
pr_warn("not support mod, cmd: %s", start);
}