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