diff --git a/include/lib/fconf/fconf_tbbr_getter.h b/include/lib/fconf/fconf_tbbr_getter.h index 32e1b6594..eddc0c4b5 100644 --- a/include/lib/fconf/fconf_tbbr_getter.h +++ b/include/lib/fconf/fconf_tbbr_getter.h @@ -16,6 +16,8 @@ struct tbbr_dyn_config_t { uint32_t disable_auth; + void *mbedtls_heap_addr; + size_t mbedtls_heap_size; }; extern struct tbbr_dyn_config_t tbbr_dyn_config; diff --git a/include/plat/arm/common/arm_dyn_cfg_helpers.h b/include/plat/arm/common/arm_dyn_cfg_helpers.h index 61f876f82..2dc94abe3 100644 --- a/include/plat/arm/common/arm_dyn_cfg_helpers.h +++ b/include/plat/arm/common/arm_dyn_cfg_helpers.h @@ -11,8 +11,6 @@ /* Function declarations */ int arm_dyn_tb_fw_cfg_init(void *dtb, int *node); -int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr, - size_t *heap_size); int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size); diff --git a/lib/fconf/fconf_tbbr_getter.c b/lib/fconf/fconf_tbbr_getter.c index 29f67caec..c6df9c876 100644 --- a/lib/fconf/fconf_tbbr_getter.c +++ b/lib/fconf/fconf_tbbr_getter.c @@ -47,8 +47,27 @@ int fconf_populate_tbbr_dyn_config(uintptr_t config) dyn_disable_auth(); #endif + /* Retrieve the Mbed TLS heap details from the DTB */ + err = fdtw_read_cells(dtb, node, + "mbedtls_heap_addr", 2, &tbbr_dyn_config.mbedtls_heap_addr); + if (err < 0) { + ERROR("FCONF: Read cell failed for mbedtls_heap\n"); + return err; + } + + err = fdtw_read_cells(dtb, node, + "mbedtls_heap_size", 1, &tbbr_dyn_config.mbedtls_heap_size); + if (err < 0) { + ERROR("FCONF: Read cell failed for mbedtls_heap\n"); + return err; + } + VERBOSE("FCONF:tbbr.disable_auth cell found with value = %d\n", tbbr_dyn_config.disable_auth); + VERBOSE("FCONF:tbbr.mbedtls_heap_addr cell found with value = %p\n", + tbbr_dyn_config.mbedtls_heap_addr); + VERBOSE("FCONF:tbbr.mbedtls_heap_size cell found with value = %zu\n", + tbbr_dyn_config.mbedtls_heap_size); return 0; } diff --git a/plat/arm/common/arm_dyn_cfg.c b/plat/arm/common/arm_dyn_cfg.c index d373dedc8..b9361a479 100644 --- a/plat/arm/common/arm_dyn_cfg.c +++ b/plat/arm/common/arm_dyn_cfg.c @@ -18,6 +18,7 @@ #endif #include #include +#include #include #include #include @@ -56,24 +57,10 @@ int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size) #elif defined(IMAGE_BL2) - int err; - void *tb_fw_cfg_dtb; - - /* fconf FW_CONFIG and TB_FW_CONFIG are currently the same DTB*/ - tb_fw_cfg_dtb = (void *)FCONF_GET_PROPERTY(fconf, dtb, base_addr); - /* If in BL2, retrieve the already allocated heap's info from DTB */ - if (tb_fw_cfg_dtb != NULL) { - err = arm_get_dtb_mbedtls_heap_info(tb_fw_cfg_dtb, heap_addr, - heap_size); - if (err < 0) { - ERROR("BL2: unable to retrieve shared Mbed TLS heap information from DTB\n"); - panic(); - } - } else { - ERROR("BL2: DTB missing, cannot get Mbed TLS heap\n"); - panic(); - } + *heap_addr = FCONF_GET_PROPERTY(tbbr, dyn_config, mbedtls_heap_addr); + *heap_size = FCONF_GET_PROPERTY(tbbr, dyn_config, mbedtls_heap_size); + #endif return 0; diff --git a/plat/arm/common/arm_dyn_cfg_helpers.c b/plat/arm/common/arm_dyn_cfg_helpers.c index db6f26073..909c4a671 100644 --- a/plat/arm/common/arm_dyn_cfg_helpers.c +++ b/plat/arm/common/arm_dyn_cfg_helpers.c @@ -46,47 +46,6 @@ int arm_dyn_tb_fw_cfg_init(void *dtb, int *node) return 0; } -/* - * Reads and returns the Mbed TLS shared heap information from the DTB. - * This function is supposed to be called *only* when a DTB is present. - * This function is supposed to be called only by BL2. - * - * Returns: - * 0 = success - * -1 = error. In this case the values of heap_addr, heap_size should be - * considered as garbage by the caller. - */ -int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr, - size_t *heap_size) -{ - int err, dtb_root; - - /* Verify the DTB is valid and get the root node */ - err = arm_dyn_tb_fw_cfg_init(dtb, &dtb_root); - if (err < 0) { - ERROR("Invalid TB_FW_CONFIG. Cannot retrieve Mbed TLS heap information from DTB\n"); - return -1; - } - - /* Retrieve the Mbed TLS heap details from the DTB */ - err = fdtw_read_cells(dtb, dtb_root, - DTB_PROP_MBEDTLS_HEAP_ADDR, 2, heap_addr); - if (err < 0) { - ERROR("Error while reading %s from DTB\n", - DTB_PROP_MBEDTLS_HEAP_ADDR); - return -1; - } - err = fdtw_read_cells(dtb, dtb_root, - DTB_PROP_MBEDTLS_HEAP_SIZE, 1, heap_size); - if (err < 0) { - ERROR("Error while reading %s from DTB\n", - DTB_PROP_MBEDTLS_HEAP_SIZE); - return -1; - } - return 0; -} - - /* * This function writes the Mbed TLS heap address and size in the DTB. When it * is called, it is guaranteed that a DTB is available. However it is not