2020-07-13 14:59:02 +01:00
|
|
|
/*
|
2021-09-14 22:41:46 +01:00
|
|
|
* Copyright (c) 2021, Arm Limited. All rights reserved.
|
2020-07-13 14:59:02 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
2021-08-06 09:26:20 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2021-07-07 13:47:08 +01:00
|
|
|
#include <drivers/measured_boot/event_log/event_log.h>
|
2020-07-13 14:59:02 +01:00
|
|
|
#include <plat/arm/common/plat_arm.h>
|
2021-09-14 22:41:46 +01:00
|
|
|
|
|
|
|
/* Event Log data */
|
2021-08-11 10:45:03 +01:00
|
|
|
static uint64_t event_log_base;
|
2020-07-13 14:59:02 +01:00
|
|
|
|
|
|
|
/* FVP table with platform specific image IDs, names and PCRs */
|
2021-09-14 22:41:46 +01:00
|
|
|
const event_log_metadata_t fvp_event_log_metadata[] = {
|
2021-09-08 20:04:24 +01:00
|
|
|
{ BL31_IMAGE_ID, EVLOG_BL31_STRING, PCR_0 },
|
|
|
|
{ BL32_IMAGE_ID, EVLOG_BL32_STRING, PCR_0 },
|
|
|
|
{ BL32_EXTRA1_IMAGE_ID, EVLOG_BL32_EXTRA1_STRING, PCR_0 },
|
|
|
|
{ BL32_EXTRA2_IMAGE_ID, EVLOG_BL32_EXTRA2_STRING, PCR_0 },
|
|
|
|
{ BL33_IMAGE_ID, EVLOG_BL33_STRING, PCR_0 },
|
|
|
|
{ HW_CONFIG_ID, EVLOG_HW_CONFIG_STRING, PCR_0 },
|
|
|
|
{ NT_FW_CONFIG_ID, EVLOG_NT_FW_CONFIG_STRING, PCR_0 },
|
|
|
|
{ SCP_BL2_IMAGE_ID, EVLOG_SCP_BL2_STRING, PCR_0 },
|
|
|
|
{ SOC_FW_CONFIG_ID, EVLOG_SOC_FW_CONFIG_STRING, PCR_0 },
|
|
|
|
{ TOS_FW_CONFIG_ID, EVLOG_TOS_FW_CONFIG_STRING, PCR_0 },
|
2021-10-31 14:47:49 +00:00
|
|
|
|
|
|
|
{ EVLOG_INVALID_ID, NULL, (unsigned int)(-1) } /* Terminator */
|
2020-07-13 14:59:02 +01:00
|
|
|
};
|
|
|
|
|
2021-08-06 09:26:20 +01:00
|
|
|
void bl2_plat_mboot_init(void)
|
|
|
|
{
|
2021-08-11 10:45:03 +01:00
|
|
|
uint8_t *event_log_start;
|
|
|
|
uint8_t *event_log_finish;
|
|
|
|
size_t bl1_event_log_size;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = arm_get_tb_fw_info(&event_log_base, &bl1_event_log_size);
|
|
|
|
if (rc != 0) {
|
|
|
|
ERROR("%s(): Unable to get Event Log info from TB_FW_CONFIG\n",
|
|
|
|
__func__);
|
|
|
|
/*
|
|
|
|
* It is a fatal error because on FVP platform, BL2 software
|
|
|
|
* assumes that a valid Event Log buffer exist and it will use
|
|
|
|
* same Event Log buffer to append image measurements.
|
|
|
|
*/
|
|
|
|
panic();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BL1 and BL2 share the same Event Log buffer and that BL2 will
|
|
|
|
* append its measurements after BL1's
|
|
|
|
*/
|
|
|
|
event_log_start = (uint8_t *)((uintptr_t)event_log_base +
|
|
|
|
bl1_event_log_size);
|
|
|
|
event_log_finish = (uint8_t *)((uintptr_t)event_log_base +
|
|
|
|
PLAT_ARM_EVENT_LOG_MAX_SIZE);
|
|
|
|
|
|
|
|
event_log_init((uint8_t *)event_log_start, event_log_finish);
|
2021-08-06 09:26:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void bl2_plat_mboot_finish(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2021-09-14 22:41:46 +01:00
|
|
|
/* Event Log address in Non-Secure memory */
|
|
|
|
uintptr_t ns_log_addr;
|
|
|
|
|
|
|
|
/* Event Log filled size */
|
|
|
|
size_t event_log_cur_size;
|
|
|
|
|
2021-08-11 10:45:03 +01:00
|
|
|
event_log_cur_size = event_log_get_cur_size((uint8_t *)event_log_base);
|
2021-09-14 22:41:46 +01:00
|
|
|
|
|
|
|
rc = arm_set_nt_fw_info(
|
|
|
|
#ifdef SPD_opteed
|
2021-08-11 10:45:03 +01:00
|
|
|
(uintptr_t)event_log_base,
|
2021-09-14 22:41:46 +01:00
|
|
|
#endif
|
|
|
|
event_log_cur_size, &ns_log_addr);
|
2021-08-06 09:26:20 +01:00
|
|
|
if (rc != 0) {
|
2021-09-14 22:41:46 +01:00
|
|
|
ERROR("%s(): Unable to update %s_FW_CONFIG\n",
|
|
|
|
__func__, "NT");
|
2021-08-06 09:26:20 +01:00
|
|
|
/*
|
|
|
|
* It is a fatal error because on FVP secure world software
|
|
|
|
* assumes that a valid event log exists and will use it to
|
2021-09-14 22:41:46 +01:00
|
|
|
* record the measurements into the fTPM.
|
|
|
|
* Note: In FVP platform, OP-TEE uses nt_fw_config to get the
|
|
|
|
* secure Event Log buffer address.
|
2021-08-06 09:26:20 +01:00
|
|
|
*/
|
|
|
|
panic();
|
|
|
|
}
|
|
|
|
|
2021-09-14 22:41:46 +01:00
|
|
|
/* Copy Event Log to Non-secure memory */
|
2021-08-11 10:45:03 +01:00
|
|
|
(void)memcpy((void *)ns_log_addr, (const void *)event_log_base,
|
2021-09-14 22:41:46 +01:00
|
|
|
event_log_cur_size);
|
|
|
|
|
|
|
|
/* Ensure that the Event Log is visible in Non-secure memory */
|
|
|
|
flush_dcache_range(ns_log_addr, event_log_cur_size);
|
|
|
|
|
|
|
|
#if defined(SPD_tspd) || defined(SPD_spmd)
|
|
|
|
/* Set Event Log data in TOS_FW_CONFIG */
|
2021-08-11 10:45:03 +01:00
|
|
|
rc = arm_set_tos_fw_info((uintptr_t)event_log_base,
|
2021-09-14 22:41:46 +01:00
|
|
|
event_log_cur_size);
|
|
|
|
if (rc != 0) {
|
|
|
|
ERROR("%s(): Unable to update %s_FW_CONFIG\n",
|
|
|
|
__func__, "TOS");
|
|
|
|
panic();
|
|
|
|
}
|
2021-08-11 10:45:03 +01:00
|
|
|
#endif /* defined(SPD_tspd) || defined(SPD_spmd) */
|
2021-09-14 22:41:46 +01:00
|
|
|
|
2021-08-11 10:45:03 +01:00
|
|
|
dump_event_log((uint8_t *)event_log_base, event_log_cur_size);
|
2021-08-06 09:26:20 +01:00
|
|
|
}
|