by implementing and calling an arch_disable_mmu routine.

Linux wants the MMU to be disabled. Disable it before handing control
over to Linux.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 inmates/tools/arm/linux-loader.c   | 8 +++++++-
 inmates/tools/arm64/linux-loader.c | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/inmates/tools/arm/linux-loader.c b/inmates/tools/arm/linux-loader.c
index 0fe56b63..50f145c6 100644
--- a/inmates/tools/arm/linux-loader.c
+++ b/inmates/tools/arm/linux-loader.c
@@ -12,15 +12,21 @@
  * the COPYING file in the top-level directory.
  */
 
+#include <asm/sysregs.h>
 #include <inmate.h>
 
 void inmate_main(void)
 {
        void register (*entry)(unsigned long, unsigned long, unsigned long);
-       unsigned long register dtb;
+       unsigned long register dtb, sctlr;
 
        entry = (void *)(unsigned long)cmdline_parse_int("kernel", 0);
        dtb = cmdline_parse_int("dtb", 0);
 
+       /* Linux wants the MMU and D-Caches to be disabled */
+       arm_read_sysreg(SCTLR, sctlr);
+       sctlr &= ~(SCTLR_C | SCTLR_M);
+       arm_write_sysreg(SCTLR, sctlr);
+
        entry(0, -1, dtb);
 }
diff --git a/inmates/tools/arm64/linux-loader.c 
b/inmates/tools/arm64/linux-loader.c
index ca952ae7..da84a5cc 100644
--- a/inmates/tools/arm64/linux-loader.c
+++ b/inmates/tools/arm64/linux-loader.c
@@ -10,15 +10,21 @@
  * the COPYING file in the top-level directory.
  */
 
+#include <asm/sysregs.h>
 #include <inmate.h>
 
 void inmate_main(void)
 {
-       unsigned long dtb;
+       unsigned long dtb, sctlr;
        void (*entry)(u64 dtb, u64 x1, u64 x2, u64 x3);
 
        entry = (void *)cmdline_parse_int("kernel", 0);
        dtb = cmdline_parse_int("dtb", 0);
 
+       /* Linux wants the MMU to be disabled */
+       arm_read_sysreg(SCTLR_EL1, sctlr);
+       sctlr &= ~SCTLR_EL1_M;
+       arm_write_sysreg(SCTLR_EL1, sctlr);
+
        entry(dtb, 0, 0, 0);
 }
-- 
2.17.0

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to