summaryrefslogtreecommitdiff
path: root/bl2
diff options
context:
space:
mode:
authorBoyan Karatotev <boyan.karatotev@arm.com>2025-08-13 09:35:10 +0100
committerBoyan Karatotev <boyan.karatotev@arm.com>2025-09-10 16:15:26 +0100
commit04cf04c72d403e0c057505882fac9002d39d4102 (patch)
tree9c380f30372286d37f62eba08ec67c7635068e82 /bl2
parent205352cac01b54e73b587d13866efb06b487267a (diff)
downloadarm-trusted-firmware-04cf04c72d403e0c057505882fac9002d39d4102.tar.gz
arm-trusted-firmware-04cf04c72d403e0c057505882fac9002d39d4102.zip
fix(bl2): unify the BL2 EL3 and RME entrypoints
BL2 has 3(!) entrypoints: 1) the regular EL1 entrypoint (once per AArch) 2) an EL3 entrypoint 3) an EL3 entrypoint with RME The EL1 and EL3 entrypoints are quite distinct so it's useful to keep them separate. But the EL3 and RME entrypoints are conceptually identical just configured differently and having slightly different assumptions (eg whether we can rely on BL1). So put them together with only the configuration as a difference. This has a few benefits: * makes the naming consistent - BL2 always runs at EL1, BL2_EL3 always runs at EL3. This is most important for the linker script. * paves the way for ENABLE_RME and RESET_TO_BL2 to coexist. * allows for more general refactors Currently, ENABLE_RME and RESET_TO_BL2 are mutually exclusive (from a makefile constraint) so the checks are simplified to one or the other as there is no danger of their simultaneous use. Change-Id: Iecffab2ff3a0bd7823f8277d9f66e22e4f42cc8c Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Diffstat (limited to 'bl2')
-rw-r--r--bl2/aarch64/bl2_el3_entrypoint.S22
-rw-r--r--bl2/aarch64/bl2_rme_entrypoint.S67
-rw-r--r--bl2/bl2.ld.S6
-rw-r--r--bl2/bl2.mk24
-rw-r--r--bl2/bl2_el3.ld.S5
5 files changed, 29 insertions, 95 deletions
diff --git a/bl2/aarch64/bl2_el3_entrypoint.S b/bl2/aarch64/bl2_el3_entrypoint.S
index 45bac7da1..77c43f939 100644
--- a/bl2/aarch64/bl2_el3_entrypoint.S
+++ b/bl2/aarch64/bl2_el3_entrypoint.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -13,7 +13,7 @@
.globl bl2_entrypoint
-#if BL2_IN_XIP_MEM
+#if BL2_IN_XIP_MEM || ENABLE_RME
#define FIXUP_SIZE 0
#else
#define FIXUP_SIZE ((BL2_LIMIT) - (BL2_BASE))
@@ -26,13 +26,13 @@ func bl2_entrypoint
mov x22, x2
mov x23, x3
- el3_entrypoint_common \
- _init_sctlr=1 \
- _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \
- _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \
- _init_memory=1 \
- _init_c_runtime=1 \
- _exception_vectors=bl2_el3_exceptions \
+ el3_entrypoint_common \
+ _init_sctlr=RESET_TO_BL2 \
+ _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS && RESET_TO_BL2 \
+ _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU && RESET_TO_BL2 \
+ _init_memory=RESET_TO_BL2 \
+ _init_c_runtime=1 \
+ _exception_vectors=bl2_el3_exceptions \
_pie_fixup_size=FIXUP_SIZE
/* ---------------------------------------------
@@ -48,7 +48,11 @@ func bl2_entrypoint
* Perform BL2 setup
* ---------------------------------------------
*/
+#if RESET_TO_BL2
bl bl2_el3_setup
+#else
+ bl bl2_setup
+#endif
#if ENABLE_PAUTH
/* ---------------------------------------------
diff --git a/bl2/aarch64/bl2_rme_entrypoint.S b/bl2/aarch64/bl2_rme_entrypoint.S
deleted file mode 100644
index 076e3267d..000000000
--- a/bl2/aarch64/bl2_rme_entrypoint.S
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <platform_def.h>
-
-#include <arch.h>
-#include <asm_macros.S>
-#include <common/bl_common.h>
-#include <el3_common_macros.S>
-
- .globl bl2_entrypoint
-
-
-func bl2_entrypoint
- /* Save arguments x0-x3 from previous Boot loader */
- mov x20, x0
- mov x21, x1
- mov x22, x2
- mov x23, x3
-
- el3_entrypoint_common \
- _init_sctlr=0 \
- _warm_boot_mailbox=0 \
- _secondary_cold_boot=0 \
- _init_memory=0 \
- _init_c_runtime=1 \
- _exception_vectors=bl2_el3_exceptions \
- _pie_fixup_size=0
-
- /* ---------------------------------------------
- * Restore parameters of boot rom
- * ---------------------------------------------
- */
- mov x0, x20
- mov x1, x21
- mov x2, x22
- mov x3, x23
-
- /* ---------------------------------------------
- * Perform BL2 setup
- * ---------------------------------------------
- */
- bl bl2_setup
-
-#if ENABLE_PAUTH
- /* ---------------------------------------------
- * Program APIAKey_EL1 and enable pointer authentication.
- * ---------------------------------------------
- */
- bl pauth_init_enable_el3
-#endif /* ENABLE_PAUTH */
-
- /* ---------------------------------------------
- * Jump to main function.
- * ---------------------------------------------
- */
- bl bl2_main
-
- /* ---------------------------------------------
- * Should never reach this point.
- * ---------------------------------------------
- */
- no_ret plat_panic_handler
-endfunc bl2_entrypoint
diff --git a/bl2/bl2.ld.S b/bl2/bl2.ld.S
index 310e6fe78..be30e015f 100644
--- a/bl2/bl2.ld.S
+++ b/bl2/bl2.ld.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -30,11 +30,7 @@ SECTIONS {
__TEXT_START__ = .;
-#if ENABLE_RME
- *bl2_rme_entrypoint.o(.text*)
-#else /* ENABLE_RME */
*bl2_entrypoint.o(.text*)
-#endif /* ENABLE_RME */
*(SORT_BY_ALIGNMENT(.text*))
*(.vectors)
diff --git a/bl2/bl2.mk b/bl2/bl2.mk
index 2a212e135..36be877ed 100644
--- a/bl2/bl2.mk
+++ b/bl2/bl2.mk
@@ -22,28 +22,26 @@ else ifneq ($(filter llvm-lld gnu-ld,$($(ARCH)-ld-id)),)
endif
ifeq (${ENABLE_RME},1)
-# Using RME, run BL2 at EL3
include lib/gpt_rme/gpt_rme.mk
-BL2_SOURCES += bl2/${ARCH}/bl2_rme_entrypoint.S \
+BL2_SOURCES += ${GPT_LIB_SRCS}
+endif
+
+ifeq (${BL2_RUNS_AT_EL3},1)
+BL2_SOURCES += bl2/${ARCH}/bl2_el3_entrypoint.S \
bl2/${ARCH}/bl2_el3_exceptions.S \
- bl2/${ARCH}/bl2_run_next_image.S \
- ${GPT_LIB_SRCS}
-BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2.ld.S
+ bl2/${ARCH}/bl2_run_next_image.S
-else ifeq (${RESET_TO_BL2},0)
+BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2_el3.ld.S
+else
# Normal operation, no RME, no BL2 at EL3
BL2_SOURCES += bl2/${ARCH}/bl2_entrypoint.S
BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2.ld.S
+endif
-else
+ifeq (${RESET_TO_BL2},1)
# BL2 at EL3, no RME
-BL2_SOURCES += bl2/${ARCH}/bl2_el3_entrypoint.S \
- bl2/${ARCH}/bl2_el3_exceptions.S \
- bl2/${ARCH}/bl2_run_next_image.S \
- lib/cpus/${ARCH}/cpu_helpers.S
-
-BL2_DEFAULT_LINKER_SCRIPT_SOURCE := bl2/bl2_el3.ld.S
+BL2_SOURCES += lib/cpus/${ARCH}/cpu_helpers.S
endif
ifeq (${ENABLE_PMF},1)
diff --git a/bl2/bl2_el3.ld.S b/bl2/bl2_el3.ld.S
index 811f41e14..0190355dd 100644
--- a/bl2/bl2_el3.ld.S
+++ b/bl2/bl2_el3.ld.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -123,8 +123,11 @@ SECTIONS {
} >ROM
#endif /* SEPARATE_CODE_AND_RODATA */
+/* BL1 will have done this if it's built */
+#if RESET_TO_BL2
ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
"cpu_ops not defined for this platform.")
+#endif
#if BL2_IN_XIP_MEM
ROM_REGION_END = .;