[PATCH 3/3] ARM: Map the lowmem and kernel separately
Linus Walleij
linus.walleij at linaro.org
Wed Aug 4 03:05:54 PDT 2021
On Tue, Aug 3, 2021 at 12:49 PM Russell King (Oracle)
<linux at armlinux.org.uk> wrote:
> > It should be called on all keystone 2 platforms by default (LAPE is default mode for K2).
> >
> > Huh. Below as I remember it:
> > - K2 starts using memory window (aliased memory) at 00 8000 0000 (No IO coherency is supported)
> > - K2, early at boot, is switching to LPAE memory window 08 0000 0000 (IO coherency is supported)
> > so all, already mapped memory, has to be fixed - phys addresses.
>
> If I remember correctly, the code that fixes that up assumes that
> (a) the kernel is mapped using section mappings in the lowmem mapping
> at PAGE_OFFSET.._end-1
> (b) that no other RAM is mapped (iow, it's called before the kernel
> starts building the real page mappings in paging_init()).
>
> It looks to me like Linus missed the code in arch/arm/mm/pv-fixup-asm.S
> and as the kernel is no longer mapped in the lowmem mapping, this
> likely writes a load of entries in the page tables that are random...
I looked into this!
Indeed early_mm_init() is called before paging_init() and early_mm_init()
calls lpae_pgtables_remap_asm() in pv-fixup-asm.S to add the offset
to all the section mappings over the kernel.
The section mappings we have at this point are coming from head.S,
so those get modified with the offset.
What I don't understand is what map_lowmem() was doing with the
kernel mappings on the Keystone 2 before my patch.
If it actually overwrites the kernel mapping with a new one, it will
undo what lpae_pgtables_remap_asm() has done without applying
the offset.
So I suppose map_lowmem(), due to the memory ranges passed,
would just bail the kernel mappings and leave them as-is.
Nishanth: what happens if you simply comment out map_kernel
like this?
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 7583bda5ea7d..25aa7d05a931 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1727,7 +1727,7 @@ void __init paging_init(const struct machine_desc *mdesc)
* After this point early_alloc(), i.e. the memblock allocator, can
* be used
*/
- map_kernel();
+ // map_kernel();
dma_contiguous_remap();
early_fixmap_shutdown();
devicemaps_init(mdesc);
Yours,
Linus Walleij
More information about the linux-arm-kernel
mailing list