1 /* 2 * Copyright (c) 2025, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <stdint.h> 8 9 #if TRANSFER_LIST 10 #include <tpm_event_log.h> 11 #endif 12 #include <plat/arm/common/plat_arm.h> 13 14 #include <drivers/auth/crypto_mod.h> 15 #include <drivers/measured_boot/metadata.h> 16 #include <event_measure.h> 17 #include <event_print.h> 18 #include <tools_share/zero_oid.h> 19 20 static const struct event_log_hash_info crypto_hash_info = { 21 .func = crypto_mod_calc_hash, 22 .ids = (const uint32_t[]){ CRYPTO_MD_ID }, 23 .count = 1U, 24 }; 25 26 /* Event Log data */ 27 static uint8_t *event_log; 28 29 /* Juno table with platform specific image IDs, names and PCRs */ 30 const event_log_metadata_t juno_event_log_metadata[] = { 31 { FW_CONFIG_ID, MBOOT_FW_CONFIG_STRING, PCR_0 }, 32 { TB_FW_CONFIG_ID, MBOOT_TB_FW_CONFIG_STRING, PCR_0 }, 33 { BL2_IMAGE_ID, MBOOT_BL2_IMAGE_STRING, PCR_0 }, 34 { EVLOG_INVALID_ID, NULL, (unsigned int)(-1) } /* Terminator */ 35 }; 36 37 void bl1_plat_mboot_init(void) 38 { 39 #if TRANSFER_LIST 40 size_t event_log_max_size = PLAT_ARM_EVENT_LOG_MAX_SIZE; 41 int rc; 42 43 event_log = 44 transfer_list_event_log_extend(secure_tl, event_log_max_size); 45 assert(event_log != NULL); 46 47 rc = event_log_init_and_reg(event_log, event_log + event_log_max_size, 48 &crypto_hash_info); 49 if (rc < 0) { 50 ERROR("Failed to initialize event log (%d).\n", rc); 51 panic(); 52 } 53 54 rc = event_log_write_header(); 55 if (rc < 0) { 56 ERROR("Failed to write event log header (%d).\n", rc); 57 panic(); 58 } 59 #endif 60 } 61 62 void bl1_plat_mboot_finish(void) 63 { 64 #if TRANSFER_LIST 65 uint8_t *rc __unused; 66 size_t event_log_cur_size = event_log_get_cur_size(event_log); 67 68 rc = transfer_list_event_log_finish( 69 secure_tl, (uintptr_t)event_log + event_log_cur_size); 70 71 if (rc != NULL) 72 return; 73 74 /* 75 * Panic if we fail to set up the event log for the next stage. 76 * This is a fatal error because, on the Juno platform, 77 * BL2 software assumes that a valid event Log buffer exists and 78 * will use the same event Log buffer to append image 79 * measurements. 80 */ 81 panic(); 82 #endif 83 } 84