aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2022-02-11 11:29:36 +0000
committerTom Rini <trini@konsulko.com>2022-03-02 13:59:29 -0500
commit7ed340a8283bea57e5b535efee2365bc6a05bd11 (patch)
tree867727e03f70eac7868c9cdd46d6091f2d2ec134
parent6c7691edd55bc13c221d7283c238d305f6923236 (diff)
downloadu-boot-7ed340a8283bea57e5b535efee2365bc6a05bd11.zip
u-boot-7ed340a8283bea57e5b535efee2365bc6a05bd11.tar.gz
u-boot-7ed340a8283bea57e5b535efee2365bc6a05bd11.tar.bz2
armv8: Force SP_ELx stack pointer usage
In ARMv8 we have the choice between two stack pointers to use: SP_EL0 or SP_ELx, which is banked per exception level. This choice is stored in the SP field of PState, and can be read and set via the SPSel special register. When the CPU takes an exception, it automatically switches to the SP_ELx stack pointer. Trusted Firmware enters U-Boot typically with SPSel set to 1, so we use SP_ELx all along as our sole stack pointer, both for normal operation and for exceptions. But if we now for some reason enter U-Boot with SPSel cleared, we will setup and use SP_EL0, which is fine, but leaves SP_ELx uninitialised. When we now take an exception, we try to save the GPRs to some undefined location, which will usually end badly. To make sure we always have SP_ELx pointing to some memory, set SPSel to 1 in the early boot code, to ensure safe operation at all times. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r--arch/arm/cpu/armv8/start.S1
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index d9610a5..e1461f2 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -192,6 +192,7 @@ slave_cpu:
br x0 /* branch to the given address */
#endif /* CONFIG_ARMV8_MULTIENTRY */
master_cpu:
+ msr SPSel, #1 /* make sure we use SP_ELx */
bl _main
/*-----------------------------------------------------------------------*/