[PATCH 050/112] ARM: mmu-early: gracefully handle already enabled MMU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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@xxxxxxxxxxxxxx>
 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;
 	/* 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();

[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux