From fa1fdb223cdc0b01ef944b5fe9664a16867dfa34 Mon Sep 17 00:00:00 2001 From: Alexei Fedorov Date: Tue, 21 Jul 2020 17:07:45 +0100 Subject: [PATCH] plat/arm: Reduce size of BL31 binary BL31 binary size is aligned to 4KB because of the code in include\plat\arm\common\arm_reclaim_init.ld.S: __INIT_CODE_UNALIGNED__ = .; . = ALIGN(PAGE_SIZE); __INIT_CODE_END__ = .; with all the zero data after the last instruction of BL31 code to the end of the page. This causes increase in size of BL31 binary stored in FIP and its loading time by BL2. This patch reduces the size of BL31 image by moving page alignment from __INIT_CODE_END__ to __STACKS_END__ which also increases the stack size for secondary CPUs. Change-Id: Ie2ec503fc774c22c12ec506d74fd3ef2b0b183a9 Signed-off-by: Alexei Fedorov --- include/plat/arm/common/arm_reclaim_init.ld.S | 3 +-- plat/arm/common/arm_bl31_setup.c | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/plat/arm/common/arm_reclaim_init.ld.S b/include/plat/arm/common/arm_reclaim_init.ld.S index 03976f34f..e4d4f1254 100644 --- a/include/plat/arm/common/arm_reclaim_init.ld.S +++ b/include/plat/arm/common/arm_reclaim_init.ld.S @@ -13,8 +13,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); __INIT_CODE_START__ = .; *(*text.init*); - __INIT_CODE_UNALIGNED__ = .; - . = ALIGN(PAGE_SIZE); __INIT_CODE_END__ = .; } >RAM @@ -42,6 +40,7 @@ SECTIONS /* Offset mask */ \ MASK = ABS(SIGN >> 63) - 1; \ . += ABS(OFFSET) & ABS(MASK); \ + . = ALIGN(PAGE_SIZE); \ __STACKS_END__ = .; \ /* Total stack size */ \ SIZE = ABS(. - __STACKS_START__); \ diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c index 58ccf0e51..fc238b1d8 100644 --- a/plat/arm/common/arm_bl31_setup.c +++ b/plat/arm/common/arm_bl31_setup.c @@ -46,7 +46,10 @@ CASSERT(BL31_BASE >= ARM_FW_CONFIG_LIMIT, assert_bl31_base_overflows); MT_MEMORY | MT_RW | MT_SECURE) #if RECLAIM_INIT_CODE IMPORT_SYM(unsigned long, __INIT_CODE_START__, BL_INIT_CODE_BASE); -IMPORT_SYM(unsigned long, __INIT_CODE_END__, BL_INIT_CODE_END); +IMPORT_SYM(unsigned long, __INIT_CODE_END__, BL_CODE_END_UNALIGNED); + +#define BL_INIT_CODE_END ((BL_CODE_END_UNALIGNED + PAGE_SIZE - 1) & \ + ~(PAGE_SIZE - 1)) #define MAP_BL_INIT_CODE MAP_REGION_FLAT( \ BL_INIT_CODE_BASE, \