diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-05-31 10:29:14 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-01 11:51:27 +0200 |
commit | 631529d766a1f2f8d1a370deb8ac5e25da624839 (patch) | |
tree | e2b1215e5169f791903beb60befc6bb8c9683e10 /Documentation | |
parent | 768f9f5ef9df3e9a162176cedf3e76a9d4e7cd1b (diff) | |
download | barebox-631529d766a1f2f8d1a370deb8ac5e25da624839.tar.gz barebox-631529d766a1f2f8d1a370deb8ac5e25da624839.tar.xz |
ARM: cpu: don't clobber sp when booted in HYP mode
arm_cpu_lowlevel_init() is usually called first thing and will ensure
barebox runs in SVC mode. If barebox is started in HYP mode instead,
like is the case on Raspberry Pi 2-3, it will do an exception return
into SVC mode, which will bank the previously used SP_Hyp and
restore SP_Svc that may not have been properly initialized by barebox.
This wasn't too bad so far, because arm_setup_stack was usually called
after arm_cpu_lowlevel_init, but with ENTRY_FUNCTION_WITHSTACK, SP is
initialized early on in the naked entry point with
arm_cpu_lowlevel_init() being called after that.
This can lead to spurious boot hangs in the Raspberry Pi 2 and 3 entry
points. Fix this by always saving sp to r3 and restoring it, like we do
with lr. This is safe to do, because r3 isn't clobbered by any
instruction in arm_cpu_lowlevel_init() and because it's an argument
register, callers have to expect it being overwritten by the callee.
Fixes: b267578d0567 ("ARM: rpi: use ENTRY_FUNCTION_WITHSTACK to prepare for ARM64 support")
Fixes: 41292192c01b ("ARM: safely switch from HYP to SVC mode if required")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220531082914.1654316-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'Documentation')
0 files changed, 0 insertions, 0 deletions