FVP: Enable PIE for RESET_TO_BL31=1
authorSoby Mathew <soby.mathew@arm.com>
Sun, 14 Oct 2018 07:13:44 +0000 (08:13 +0100)
committerSoby Mathew <soby.mathew@arm.com>
Mon, 29 Oct 2018 09:54:32 +0000 (09:54 +0000)
This patch enabled PIE for FVP when RESET_TO_BL31=1. The references
to BL31_BASE are replaced by BL31_START as being a symbol exported by
the linker, will create a dynamic relocation entry in .rela.dyn and
hence will be fixed up by dynamic linker at runtime. Also, we disable
RECLAIM_INIT_CODE when PIE is enabled as the init section overlay
creates some static relocations which cannot be handled by the
dynamic linker currently.

Change-Id: I86df1b0a8b2a8bbbe7c3f3c0b9a08c86c2963ec0
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
plat/arm/board/fvp/platform.mk
plat/arm/common/arm_bl31_setup.c
plat/arm/common/arm_common.mk

index 332df4d4464d30382426d7d4ef9d3b1498583bc3..3d858c20e78815aa6fa5e681134c700ed5d56038 100644 (file)
@@ -202,7 +202,9 @@ ENABLE_AMU                  :=      1
 DYNAMIC_WORKAROUND_CVE_2018_3639       :=      1
 
 # Enable reclaiming of BL31 initialisation code for secondary cores stacks for FVP
+ifneq (${RESET_TO_BL31},1)
 RECLAIM_INIT_CODE      :=      1
+endif
 
 ifeq (${ENABLE_AMU},1)
 BL31_SOURCES           +=      lib/cpus/aarch64/cortex_a75_pubsub.c    \
index 24d55709545fd43dc2f1a6d8602e2ca83efea3b7..1b05f46e90adf372ce0d63ba2131b3b3408f3c1e 100644 (file)
 static entry_point_info_t bl32_image_ep_info;
 static entry_point_info_t bl33_image_ep_info;
 
+#if !RESET_TO_BL31
 /*
  * Check that BL31_BASE is above ARM_TB_FW_CONFIG_LIMIT. The reserved page
  * is required for SOC_FW_CONFIG/TOS_FW_CONFIG passed from BL2.
  */
 CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows);
+#endif
 
 /* Weak definitions may be overridden in specific ARM standard platform */
 #pragma weak bl31_early_platform_setup2
@@ -38,8 +40,8 @@ CASSERT(BL31_BASE >= ARM_TB_FW_CONFIG_LIMIT, assert_bl31_base_overflows);
 #pragma weak bl31_plat_get_next_image_ep_info
 
 #define MAP_BL31_TOTAL         MAP_REGION_FLAT(                        \
-                                       BL31_BASE,                      \
-                                       BL31_END - BL31_BASE,           \
+                                       BL31_START,                     \
+                                       BL31_END - BL31_START,          \
                                        MT_MEMORY | MT_RW | MT_SECURE)
 #if RECLAIM_INIT_CODE
 IMPORT_SYM(unsigned long, __INIT_CODE_START__, BL_INIT_CODE_BASE);
index 3fb1eff2d8a4b2fca94b5b666b3f7f9fff9163cd..23777fb7b7d371d767386e8a353be57ec7e32da6 100644 (file)
@@ -130,6 +130,11 @@ ARM_CRYPTOCELL_INTEG               :=      0
 $(eval $(call assert_boolean,ARM_CRYPTOCELL_INTEG))
 $(eval $(call add_define,ARM_CRYPTOCELL_INTEG))
 
+# Enable PIE support for RESET_TO_BL31 case
+ifeq (${RESET_TO_BL31},1)
+    ENABLE_PIE                 :=      1
+endif
+
 # CryptoCell integration relies on coherent buffers for passing data from
 # the AP CPU to the CryptoCell
 ifeq (${ARM_CRYPTOCELL_INTEG},1)