Add cache flush after BL1 writes heap info to DTB
authorJohn Tsichritzis <john.tsichritzis@arm.com>
Fri, 7 Sep 2018 09:52:12 +0000 (10:52 +0100)
committerJohn Tsichritzis <john.tsichritzis@arm.com>
Fri, 7 Sep 2018 10:45:55 +0000 (11:45 +0100)
A cache flush is added in BL1, in Mbed TLS shared heap code. Thus, we
ensure that the heap info written to the DTB always gets written back to
memory.  Hence, sharing this info with other images is guaranteed.

Change-Id: I0faada31fe7a83854cd5e2cf277ba519e3f050d5
Signed-off-by: John Tsichritzis <john.tsichritzis@arm.com>
plat/arm/common/arm_dyn_cfg.c

index 58b0d4876a4497b1020e2869f8be5fcc0fe9c973..95fe2c534afb23c3c82ff09f5ac83263bc82f73e 100644 (file)
@@ -21,6 +21,7 @@
 
 /* Variable to store the address of TB_FW_CONFIG file */
 static void *tb_fw_cfg_dtb;
+static size_t tb_fw_cfg_dtb_size;
 
 
 #if TRUSTED_BOARD_BOOT
@@ -105,6 +106,13 @@ void arm_bl1_set_mbedtls_heap(void)
                        ERROR("BL1: unable to write shared Mbed TLS heap information to DTB\n");
                        panic();
                }
+               /*
+                * Ensure that the info written to the DTB is visible to other
+                * images. It's critical because BL2 won't be able to proceed
+                * without the heap info.
+                */
+               flush_dcache_range((uintptr_t)tb_fw_cfg_dtb,
+                       tb_fw_cfg_dtb_size);
        }
 }
 
@@ -125,7 +133,8 @@ void arm_load_tb_fw_config(void)
                SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
                                VERSION_2, image_info_t, 0),
                .image_info.image_base = ARM_TB_FW_CONFIG_BASE,
-               .image_info.image_max_size = ARM_TB_FW_CONFIG_LIMIT - ARM_TB_FW_CONFIG_BASE,
+               .image_info.image_max_size =
+                       ARM_TB_FW_CONFIG_LIMIT - ARM_TB_FW_CONFIG_BASE
        };
 
        VERBOSE("BL1: Loading TB_FW_CONFIG\n");
@@ -139,6 +148,7 @@ void arm_load_tb_fw_config(void)
        /* At this point we know that a DTB is indeed available */
        config_base = arm_tb_fw_info.image_info.image_base;
        tb_fw_cfg_dtb = (void *)config_base;
+       tb_fw_cfg_dtb_size = (size_t)arm_tb_fw_info.image_info.image_max_size;
 
        /* The BL2 ep_info arg0 is modified to point to TB_FW_CONFIG */
        image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID);