On 29/05/2025 14:55, Joey Gouly wrote:
Don't rely on the value of SCTLR_ELx when booting via EFI.
Signed-off-by: Joey Gouly <joey.gouly@xxxxxxx>
---
lib/arm/setup.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/arm/setup.c b/lib/arm/setup.c
index 67b5db07..0a22dbab 100644
--- a/lib/arm/setup.c
+++ b/lib/arm/setup.c
@@ -349,6 +349,11 @@ efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo)
{
efi_status_t status;
+
+ // EFI exits boot services with SCTLR_ELx.M=1, so keep
+ // the MMU enabled.
+ write_sysreg(INIT_SCTLR_EL1_MMU_OFF | SCTLR_EL1_M, sctlr_el1);
minor nit: Given this is in a common file for arm/arm64, may be worth
adding a helper function that does this on arm64. I understand EFI
cannot enabled for arm32, still keeping this file generic would be
cleaner. e.g.,
mmu_on(); or even setup_sctlr();
Suzuki