From 0081393d79c2ce08564d83638ae579c079f50a69 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Wed, 29 Jun 2016 14:40:43 +0000 Subject: [PATCH] Do not rely on firmware having pre-enabled the MMU in a reasonable way for late boot: enable it explicitly after installing the page tables. If booting from an FDT, also make sure to escape the firmware's MMU context early before overwriting firmware page tables. Approved by: re (gjb) --- sys/powerpc/aim/mmu_oea.c | 2 +- sys/powerpc/powerpc/machdep.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c index ceb81d6e4dda..4aef628a0a23 100644 --- a/sys/powerpc/aim/mmu_oea.c +++ b/sys/powerpc/aim/mmu_oea.c @@ -921,7 +921,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) Maxmem = powerpc_btop(phys_avail[i + 1]); moea_cpu_bootstrap(mmup,0); - + mtmsr(mfmsr() | PSL_DR | PSL_IR); pmap_bootstrapped++; /* diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index 4aa6e7f9f6d9..c6960cc38d81 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -251,6 +251,18 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp) if (mdp == (void *)0x65504150) mdp = NULL; +#if AIM + /* + * If running from an FDT, make sure we are in real mode to avoid + * tromping on firmware page tables. Everything in the kernel assumes + * 1:1 mappings out of firmware, so this won't break anything not + * already broken. This doesn't work if there is live OF, since OF + * may internally use non-1:1 mappings. + */ + if (ofentry == 0) + mtmsr(mfmsr() & ~(PSL_IR | PSL_DR)); +#endif + /* * Parse metadata if present and fetch parameters. Must be done * before console is inited so cninit gets the right value of