Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 1 | /* |
Tamas Ban | b0f8325 | 2022-02-11 09:49:36 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | #include <drivers/measured_boot/event_log/event_log.h> |
Tamas Ban | b0f8325 | 2022-02-11 09:49:36 +0100 | [diff] [blame] | 10 | #include <drivers/measured_boot/rss/rss_measured_boot.h> |
Manish V Badarkhe | 4edf4bd | 2021-08-11 10:45:03 +0100 | [diff] [blame] | 11 | #include <plat/arm/common/plat_arm.h> |
Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 12 | |
| 13 | /* Event Log data */ |
| 14 | static uint8_t event_log[PLAT_ARM_EVENT_LOG_MAX_SIZE]; |
| 15 | |
| 16 | /* FVP table with platform specific image IDs, names and PCRs */ |
| 17 | const event_log_metadata_t fvp_event_log_metadata[] = { |
Manish V Badarkhe | 72e0369 | 2021-09-08 20:04:24 +0100 | [diff] [blame] | 18 | { FW_CONFIG_ID, EVLOG_FW_CONFIG_STRING, PCR_0 }, |
| 19 | { TB_FW_CONFIG_ID, EVLOG_TB_FW_CONFIG_STRING, PCR_0 }, |
| 20 | { BL2_IMAGE_ID, EVLOG_BL2_STRING, PCR_0 }, |
Manish V Badarkhe | 67009c3 | 2021-10-31 14:47:49 +0000 | [diff] [blame] | 21 | |
| 22 | { EVLOG_INVALID_ID, NULL, (unsigned int)(-1) } /* Terminator */ |
Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 23 | }; |
| 24 | |
Tamas Ban | b0f8325 | 2022-02-11 09:49:36 +0100 | [diff] [blame] | 25 | /* FVP table with platform specific image IDs and metadata. Intentionally not a |
| 26 | * const struct, some members might set by bootloaders during trusted boot. |
| 27 | */ |
| 28 | struct rss_mboot_metadata fvp_rss_mboot_metadata[] = { |
| 29 | { |
| 30 | .id = FW_CONFIG_ID, |
| 31 | .slot = U(6), |
| 32 | .signer_id_size = SIGNER_ID_MIN_SIZE, |
| 33 | .sw_type = RSS_MBOOT_FW_CONFIG_STRING, |
| 34 | .lock_measurement = true }, |
| 35 | { |
| 36 | .id = TB_FW_CONFIG_ID, |
| 37 | .slot = U(7), |
| 38 | .signer_id_size = SIGNER_ID_MIN_SIZE, |
| 39 | .sw_type = RSS_MBOOT_TB_FW_CONFIG_STRING, |
| 40 | .lock_measurement = true }, |
| 41 | { |
| 42 | .id = BL2_IMAGE_ID, |
| 43 | .slot = U(8), |
| 44 | .signer_id_size = SIGNER_ID_MIN_SIZE, |
| 45 | .sw_type = RSS_MBOOT_BL2_STRING, |
| 46 | .lock_measurement = true }, |
| 47 | |
| 48 | { |
| 49 | .id = RSS_MBOOT_INVALID_ID } |
| 50 | }; |
| 51 | |
Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 52 | void bl1_plat_mboot_init(void) |
| 53 | { |
Manish V Badarkhe | 4edf4bd | 2021-08-11 10:45:03 +0100 | [diff] [blame] | 54 | event_log_init(event_log, event_log + sizeof(event_log)); |
| 55 | event_log_write_header(); |
Tamas Ban | b0f8325 | 2022-02-11 09:49:36 +0100 | [diff] [blame] | 56 | |
| 57 | rss_measured_boot_init(); |
Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | void bl1_plat_mboot_finish(void) |
| 61 | { |
Manish V Badarkhe | 4edf4bd | 2021-08-11 10:45:03 +0100 | [diff] [blame] | 62 | size_t event_log_cur_size; |
| 63 | |
| 64 | event_log_cur_size = event_log_get_cur_size(event_log); |
| 65 | int rc = arm_set_tb_fw_info((uintptr_t)event_log, |
Manish V Badarkhe | 6e6df44 | 2023-03-20 14:58:06 +0000 | [diff] [blame] | 66 | event_log_cur_size, |
| 67 | PLAT_ARM_EVENT_LOG_MAX_SIZE); |
Manish V Badarkhe | 4edf4bd | 2021-08-11 10:45:03 +0100 | [diff] [blame] | 68 | if (rc != 0) { |
| 69 | /* |
| 70 | * It is a fatal error because on FVP platform, BL2 software |
| 71 | * assumes that a valid Event Log buffer exist and it will use |
| 72 | * same Event Log buffer to append image measurements. |
| 73 | */ |
| 74 | panic(); |
| 75 | } |
Manish V Badarkhe | a74d963 | 2021-09-14 23:12:42 +0100 | [diff] [blame] | 76 | } |