[PATCH 050/112] ARM: mmu-early: gracefully handle already enabled MMU
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 3 10:12:10 PST 2024
arm_cpu_lowlevel_init will disable the MMU, but there are valid cases to
not call it on startup, e.g. when barebox is being run as EFI payload.
To allow booting an EFI-stubbed barebox both as primary bootloader and
as EFI payload, teach mmu_early_enable() to bail out when the MMU is
already set up.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/arm/cpu/mmu_32.c | 3 +++
arch/arm/cpu/mmu_64.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
index c6eecf9c9d2d..3a8d025ecdee 100644
--- a/arch/arm/cpu/mmu_32.c
+++ b/arch/arm/cpu/mmu_32.c
@@ -597,6 +597,9 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize)
pr_debug("enabling MMU, ttb @ 0x%p\n", ttb);
+ if (get_cr() & CR_M)
+ return;
+
set_ttbr(ttb);
/* For the XN bit to take effect, we can't be using DOMAIN_MANAGER. */
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 3e182f70ccb1..a392789ab696 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -313,6 +313,9 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize)
int el;
unsigned long ttb = arm_mem_ttb(membase + memsize);
+ if (get_cr() & CR_M)
+ return;
+
pr_debug("enabling MMU, ttb @ 0x%08lx\n", ttb);
el = current_el();
--
2.39.2
More information about the barebox
mailing list