]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
powerpc/mm: Allocate static page tables for fixmap
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 19 May 2020 05:48:58 +0000 (05:48 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 26 May 2020 12:22:19 +0000 (22:22 +1000)
Allocate static page tables for the fixmap area. This allows
setting mappings through page tables before memblock is ready.
That's needed to use early_ioremap() early and to use standard
page mappings with fixmap.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/4f4b1412d34de6801b8e925cb88fc69d056ff536.1589866984.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/fixmap.h
arch/powerpc/kernel/setup_32.c
arch/powerpc/mm/pgtable_32.c

index 2ef155a3c8214d0a87b740bd94e6185ec216c804..ccbe2e83c95051ab2b2e0caf3147259a12b5ce9d 100644 (file)
@@ -86,6 +86,10 @@ enum fixed_addresses {
 #define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
 #define FIXADDR_START          (FIXADDR_TOP - __FIXADDR_SIZE)
 
+#define FIXMAP_ALIGNED_SIZE    (ALIGN(FIXADDR_TOP, PGDIR_SIZE) - \
+                                ALIGN_DOWN(FIXADDR_START, PGDIR_SIZE))
+#define FIXMAP_PTE_SIZE        (FIXMAP_ALIGNED_SIZE / PGDIR_SIZE * PTE_TABLE_SIZE)
+
 #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NCG
 #define FIXMAP_PAGE_IO PAGE_KERNEL_NCG
 
index 15f0a7c849445702eade29ec6a3214b9577c1506..d642e42eabb1958bcd9862c4353adf7932a19121 100644 (file)
@@ -80,7 +80,7 @@ notrace void __init machine_init(u64 dt_ptr)
        /* Configure static keys first, now that we're relocated. */
        setup_feature_keys();
 
-       early_ioremap_setup();
+       early_ioremap_init();
 
        /* Enable early debugging if any specified (see udbg.h) */
        udbg_early_init();
index f62de06e3d07c9259f1ecb0ee85830832fa03c96..9934659cb87155ba0d2797fc77d659e325a1781b 100644 (file)
 #include <asm/fixmap.h>
 #include <asm/setup.h>
 #include <asm/sections.h>
+#include <asm/early_ioremap.h>
 
 #include <mm/mmu_decl.h>
 
 extern char etext[], _stext[], _sinittext[], _einittext[];
 
+static u8 early_fixmap_pagetable[FIXMAP_PTE_SIZE] __page_aligned_data;
+
+notrace void __init early_ioremap_init(void)
+{
+       unsigned long addr = ALIGN_DOWN(FIXADDR_START, PGDIR_SIZE);
+       pte_t *ptep = (pte_t *)early_fixmap_pagetable;
+       pmd_t *pmdp = pmd_ptr_k(addr);
+
+       for (; (s32)(FIXADDR_TOP - addr) > 0;
+            addr += PGDIR_SIZE, ptep += PTRS_PER_PTE, pmdp++)
+               pmd_populate_kernel(&init_mm, pmdp, ptep);
+
+       early_ioremap_setup();
+}
+
 static void __init *early_alloc_pgtable(unsigned long size)
 {
        void *ptr = memblock_alloc(size, size);