diff options
author | Yann Gautier <yann.gautier@st.com> | 2020-10-05 11:02:54 +0200 |
---|---|---|
committer | Yann Gautier <yann.gautier@foss.st.com> | 2021-04-21 15:05:57 +0200 |
commit | 4324a14bf548f5c56edc48128aba1aca0da2edf5 (patch) | |
tree | 04388b3318cc52a2109733f20ace432f3a653a6e /include/arch | |
parent | fb4f511f9b454ea9e03f6391790693a834d8a830 (diff) | |
download | trusted-firmware-a-4324a14bf548f5c56edc48128aba1aca0da2edf5.tar.gz |
Add PIE support for AARCH32
Only BL32 (SP_min) is supported at the moment, BL1 and BL2_AT_EL3 are just
stubbed with _pie_fixup_size=0.
The changes are an adaptation for AARCH32 on what has been done for
PIE support on AARCH64.
The RELA_SECTION is redefined for AARCH32, as the created section is
.rel.dyn and the symbols are .rel*.
Change-Id: I92bafe70e6b77735f6f890f32f2b637b98cf01b9
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Diffstat (limited to 'include/arch')
-rw-r--r-- | include/arch/aarch32/el3_common_macros.S | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/include/arch/aarch32/el3_common_macros.S b/include/arch/aarch32/el3_common_macros.S index 6caebf8272..7fff4c754e 100644 --- a/include/arch/aarch32/el3_common_macros.S +++ b/include/arch/aarch32/el3_common_macros.S @@ -10,6 +10,9 @@ #include <arch.h> #include <asm_macros.S> #include <assert_macros.S> +#include <lib/xlat_tables/xlat_tables_defs.h> + +#define PAGE_START_MASK ~(PAGE_SIZE_MASK) /* * Helper macro to initialise EL3 registers we care about. @@ -199,11 +202,18 @@ * * _exception_vectors: * Address of the exception vectors to program in the VBAR_EL3 register. + * + * _pie_fixup_size: + * Size of memory region to fixup Global Descriptor Table (GDT). + * + * A non-zero value is expected when firmware needs GDT to be fixed-up. + * * ----------------------------------------------------------------------------- */ .macro el3_entrypoint_common \ _init_sctlr, _warm_boot_mailbox, _secondary_cold_boot, \ - _init_memory, _init_c_runtime, _exception_vectors + _init_memory, _init_c_runtime, _exception_vectors, \ + _pie_fixup_size /* Make sure we are in Secure Mode */ #if ENABLE_ASSERTIONS @@ -259,6 +269,27 @@ bxne r0 .endif /* _warm_boot_mailbox */ + .if \_pie_fixup_size +#if ENABLE_PIE + /* + * ------------------------------------------------------------ + * If PIE is enabled fixup the Global descriptor Table only + * once during primary core cold boot path. + * + * Compile time base address, required for fixup, is calculated + * using "pie_fixup" label present within first page. + * ------------------------------------------------------------ + */ + pie_fixup: + ldr r0, =pie_fixup + ldr r1, =PAGE_START_MASK + and r0, r0, r1 + mov_imm r1, \_pie_fixup_size + add r1, r1, r0 + bl fixup_gdt_reloc +#endif /* ENABLE_PIE */ + .endif /* _pie_fixup_size */ + /* --------------------------------------------------------------------- * Set the exception vectors (VBAR/MVBAR). * --------------------------------------------------------------------- |