arm64: mm: Move fixmap region above vmemmap region
authorArd Biesheuvel <ardb@kernel.org>
Wed, 13 Dec 2023 08:40:27 +0000 (09:40 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 9 Feb 2024 10:56:11 +0000 (10:56 +0000)
Move the fixmap region above the vmemmap region, so that the start of
the vmemmap delineates the end of the region available for vmalloc and
vmap allocations and the randomized placement of the kernel and modules.

In a subsequent patch, we will take advantage of this to reclaim most of
the vmemmap area when running a 52-bit VA capable build with 52-bit
virtual addressing disabled at runtime.

Note that the existing guard region of 256 MiB covers the fixmap and PCI
I/O regions as well, so we can reduce it 8 MiB, which is what we use in
other places too.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20231213084024.2367360-11-ardb@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
arch/arm64/include/asm/memory.h
arch/arm64/include/asm/pgtable.h
arch/arm64/mm/fixmap.c
arch/arm64/mm/ptdump.c

index b04fa8a8a262b4ec9b1f9cccbfd002f6f54954b4..f3be3ea74138ebfaeecc8fb86639254d7935722b 100644 (file)
@@ -51,7 +51,7 @@
 #define VMEMMAP_END            (VMEMMAP_START + VMEMMAP_SIZE)
 #define PCI_IO_START           (VMEMMAP_END + SZ_8M)
 #define PCI_IO_END             (PCI_IO_START + PCI_IO_SIZE)
-#define FIXADDR_TOP            (VMEMMAP_START - SZ_32M)
+#define FIXADDR_TOP            (-UL(SZ_8M))
 
 #if VA_BITS > 48
 #define VA_BITS_MIN            (48)
index 79ce70fbb751c616074fe24f0ea9772391a12ea9..2aa2e3c961d7b77daa4988a3d13ef1c54dd1852a 100644 (file)
@@ -22,7 +22,7 @@
  *     and fixed mappings
  */
 #define VMALLOC_START          (MODULES_END)
-#define VMALLOC_END            (VMEMMAP_START - SZ_256M)
+#define VMALLOC_END            (VMEMMAP_START - SZ_8M)
 
 #define vmemmap                        ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT))
 
index c0a3301203bdf7070c33a60d126a40b556686c1e..6fc17b2e1714e5f1e858c27d511000e6200c11ae 100644 (file)
@@ -16,6 +16,9 @@
 #include <asm/pgalloc.h>
 #include <asm/tlbflush.h>
 
+/* ensure that the fixmap region does not grow down into the PCI I/O region */
+static_assert(FIXADDR_TOT_START > PCI_IO_END);
+
 #define NR_BM_PTE_TABLES \
        SPAN_NR_ENTRIES(FIXADDR_TOT_START, FIXADDR_TOP, PMD_SHIFT)
 #define NR_BM_PMD_TABLES \
index 46acb2a24da083f98ab907bca263fc5c225c885b..a929b5a321dbacb42e299a9f926b4f39ab22590a 100644 (file)
@@ -45,12 +45,12 @@ static struct addr_marker address_markers[] = {
        { MODULES_END,                  "Modules end" },
        { VMALLOC_START,                "vmalloc() area" },
        { VMALLOC_END,                  "vmalloc() end" },
-       { FIXADDR_TOT_START,            "Fixmap start" },
-       { FIXADDR_TOP,                  "Fixmap end" },
        { VMEMMAP_START,                "vmemmap start" },
        { VMEMMAP_END,                  "vmemmap end" },
        { PCI_IO_START,                 "PCI I/O start" },
        { PCI_IO_END,                   "PCI I/O end" },
+       { FIXADDR_TOT_START,            "Fixmap start" },
+       { FIXADDR_TOP,                  "Fixmap end" },
        { -1,                           NULL },
 };