]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
feat(fvp): add Event Log maximum size property in DT
authorManish V Badarkhe <Manish.Badarkhe@arm.com>
Mon, 20 Mar 2023 14:58:06 +0000 (14:58 +0000)
committerSandrine Bailleux <sandrine.bailleux@arm.com>
Tue, 18 Apr 2023 15:13:17 +0000 (17:13 +0200)
Updated the code to get and set the 'tpm_event_log_max_size' property
in the event_log.dtsi.

In this change, the maximum Event Log buffer size allocated by BL1 is
passed to BL2, rather than both relying on the maximum Event Log buffer
size macro.

Change-Id: I7aa6256390872171e362b6f166f3f7335aa6e425
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
docs/components/measured_boot/event_log.rst
include/plat/arm/common/plat_arm.h
plat/arm/board/fvp/fdts/event_log.dtsi
plat/arm/board/fvp/fvp_bl1_measured_boot.c
plat/arm/board/fvp/fvp_bl2_measured_boot.c
plat/arm/common/arm_dyn_cfg_helpers.c

index 088124825cacb4175ce9d7890ffc57dbf2381b05..c102bea96809242af1ce9a4d6d412ebcc51b3c63 100644 (file)
@@ -33,3 +33,11 @@ and this property should be removed when this feature is supported.
 - tpm_event_log_size [mandatory]
     - value type: <u32>
     - Event Log size.
+
+- tpm_event_log_max_size [mandatory]
+    - value type: <u32>
+    - Event Log maximum size.
+
+--------------
+
+*Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.*
index 34f913bed8b1c7bd52eab446e90217fab0f0a812..ffbd4ca13b655c4ea0ccadd8f669397c728d9884 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2022, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -267,8 +267,10 @@ int arm_set_nt_fw_info(
                        uintptr_t log_addr,
 #endif
                        size_t log_size, uintptr_t *ns_log_addr);
-int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size);
-int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size);
+int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size,
+                      size_t log_max_size);
+int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size,
+                      size_t *log_max_size);
 #endif /* MEASURED_BOOT */
 
 /*
index 47af672dff43325eabdefab48b830ff18587aa5a..8e265420916756264023ca1369f50e8c2f0a35ee 100644 (file)
@@ -9,4 +9,5 @@ event_log: tpm_event_log {
        compatible = "arm,tpm_event_log";
        tpm_event_log_addr = <0x0 0x0>;
        tpm_event_log_size = <0x0>;
+       tpm_event_log_max_size = <0x0>;
 };
index 76cd918243a0b247ce0437e525fe00d6c1e3615a..72fdfef89738f06b4846bdbcbd402bccdaabaf55 100644 (file)
@@ -63,7 +63,8 @@ void bl1_plat_mboot_finish(void)
 
        event_log_cur_size = event_log_get_cur_size(event_log);
        int rc = arm_set_tb_fw_info((uintptr_t)event_log,
-                                   event_log_cur_size);
+                                   event_log_cur_size,
+                                   PLAT_ARM_EVENT_LOG_MAX_SIZE);
        if (rc != 0) {
                /*
                 * It is a fatal error because on FVP platform, BL2 software
index 7b0673a14a6acff5ef98eee1e62cec8963291529..e6b9192824740cd733664a3284e3c32e620f1834 100644 (file)
@@ -90,9 +90,11 @@ void bl2_plat_mboot_init(void)
        uint8_t *event_log_start;
        uint8_t *event_log_finish;
        size_t bl1_event_log_size;
+       size_t event_log_max_size;
        int rc;
 
-       rc = arm_get_tb_fw_info(&event_log_base, &bl1_event_log_size);
+       rc = arm_get_tb_fw_info(&event_log_base, &bl1_event_log_size,
+                               &event_log_max_size);
        if (rc != 0) {
                ERROR("%s(): Unable to get Event Log info from TB_FW_CONFIG\n",
                      __func__);
@@ -111,7 +113,7 @@ void bl2_plat_mboot_init(void)
        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_max_size);
 
        event_log_init((uint8_t *)event_log_start, event_log_finish);
 
index e88ea657fcb0217f89a06ac5c46a2ad35ac25ffe..5dc11151d01218c62b2e23c1221fcffe9aeff9dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2023, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
  * Currently OP-TEE does not support reading DTBs from Secure memory
  * and this property should be removed when this feature is supported.
  */
-#define DTB_PROP_HW_SM_LOG_ADDR        "tpm_event_log_sm_addr"
+#define DTB_PROP_HW_SM_LOG_ADDR                "tpm_event_log_sm_addr"
 #endif /* SPD_opteed */
-#define DTB_PROP_HW_LOG_ADDR   "tpm_event_log_addr"
-#define DTB_PROP_HW_LOG_SIZE    "tpm_event_log_size"
+#define DTB_PROP_HW_LOG_ADDR           "tpm_event_log_addr"
+#define DTB_PROP_HW_LOG_SIZE           "tpm_event_log_size"
+#define DTB_PROP_HW_LOG_MAX_SIZE       "tpm_event_log_max_size"
 #endif /* MEASURED_BOOT */
 
+static size_t event_log_max_size __unused;
+
 /*******************************************************************************
  * Validate the tb_fw_config is a valid DTB file and returns the node offset
  * to "arm,tb_fw" property.
@@ -180,6 +183,16 @@ static int arm_set_event_log_info(uintptr_t config_base,
                return err;
        }
 
+       assert(event_log_max_size != 0U);
+       err = fdtw_write_inplace_cells(dtb, node,
+                                      DTB_PROP_HW_LOG_MAX_SIZE, 1,
+                                      &event_log_max_size);
+       if (err < 0) {
+               ERROR("%sDTB property '%s'\n",
+                     "Unable to write ", DTB_PROP_HW_LOG_MAX_SIZE);
+               return err;
+       }
+
        err = fdtw_write_inplace_cells(dtb, node,
                DTB_PROP_HW_LOG_SIZE, 1, &log_size);
        if (err < 0) {
@@ -294,7 +307,7 @@ int arm_set_nt_fw_info(
  *     0 = success
  *   < 0 = error
  */
-int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size)
+int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size, size_t log_max_size)
 {
        /*
         * Read tb_fw_config device tree for Event Log properties
@@ -309,6 +322,8 @@ int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size)
 
        tb_fw_cfg_dtb = tb_fw_config_info->config_addr;
 
+       event_log_max_size = log_max_size;
+
        err = arm_set_event_log_info(tb_fw_cfg_dtb,
 #ifdef SPD_opteed
                                     0UL,
@@ -329,7 +344,8 @@ int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size)
  * Alongside returns Event Log address and its size.
  */
 
-int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size)
+int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size,
+                      size_t *log_max_size)
 {
        /* As libfdt uses void *, we can't avoid this cast */
        const struct dyn_cfg_dtb_info_t *tb_fw_config_info;
@@ -362,6 +378,17 @@ int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size)
        if (rc != 0) {
                ERROR("%s%s", DTB_PROP_HW_LOG_SIZE,
                      " not specified in TB_FW config.\n");
+               return rc;
+       }
+
+       rc = fdt_read_uint32(dtb, node, DTB_PROP_HW_LOG_MAX_SIZE,
+                            (uint32_t *)log_max_size);
+       if (rc != 0) {
+               ERROR("%s%s", DTB_PROP_HW_LOG_MAX_SIZE,
+                     " not specified in TB_FW config.\n");
+               return rc;
+       } else {
+               event_log_max_size = *log_max_size;
        }
 
        return rc;