2018-06-05 10:57:34 +08:00
|
|
|
/*
|
|
|
|
* 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;
|
2018-07-18 17:08:52 +08:00
|
|
|
uint8_t dseed_index = 0U;
|
2018-06-05 10:57:34 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-07-18 17:08:52 +08:00
|
|
|
if (seed_hob->total_seed_count == 0U) {
|
2018-06-05 10:57:34 +08:00
|
|
|
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));
|
|
|
|
|
2018-07-18 17:08:52 +08:00
|
|
|
for (i = 0U; i < seed_hob->total_seed_count; i++) {
|
2018-06-05 10:57:34 +08:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2018-07-05 13:32:01 +08:00
|
|
|
(void)memcpy_s(&dseed_list[dseed_index],
|
2018-06-05 10:57:34 +08:00
|
|
|
sizeof(struct seed_info),
|
|
|
|
entry->seed,
|
|
|
|
sizeof(struct seed_info));
|
|
|
|
dseed_index++;
|
|
|
|
|
|
|
|
/* erase original seed in seed entry */
|
2018-07-18 17:08:52 +08:00
|
|
|
(void)memset(entry->seed, 0U, sizeof(struct seed_info));
|
2018-06-05 10:57:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
entry = (struct seed_entry *)((uint8_t *)entry +
|
|
|
|
entry->seed_entry_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
trusty_set_dseed(dseed_list, dseed_index);
|
2018-07-18 17:08:52 +08:00
|
|
|
(void)memset(dseed_list, 0U, sizeof(dseed_list));
|
2018-06-05 10:57:34 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
fail:
|
2018-07-18 17:08:52 +08:00
|
|
|
trusty_set_dseed(NULL, 0U);
|
|
|
|
(void)memset(dseed_list, 0U, sizeof(dseed_list));
|
2018-06-05 10:57:34 +08:00
|
|
|
}
|