fvp_bl1_measured_boot.c 1.9 KB

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