[RFC PATCH v2 25/43] arm64: Size and align the zero page and FDT ptes for PAGE_SIZE_MAX

Eric Curtin ericcurtin17 at gmail.com
Mon Nov 30 17:51:57 PST 2026


From: Ryan Roberts <ryan.roberts at arm.com>

The zero page and the page table buffer used to map the FDT during early
boot have to be big enough and aligned for whichever page size is
selected at boot, so declare them for PAGE_SIZE_MAX instead of
PAGE_SIZE. This affects empty_zero_page and its declaration in
linux/pgtable.h, and the ptes array in map_fdt().

For a compile-time page size PAGE_SIZE_MAX equals PAGE_SIZE and there is
no functional change. For a boot-time page size, unused memory could be
freed once the page size is known, but that is not done here.

Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
Signed-off-by: Eric Curtin <eric.curtin at docker.com>
(cherry picked from commit 5394b3c8ab37b41a0e4943c2b0f8220fc63a07a6)
---
 arch/arm64/kernel/pi/map_kernel.c | 2 +-
 include/linux/pgtable.h           | 2 +-
 mm/mm_init.c                      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/pi/map_kernel.c b/arch/arm64/kernel/pi/map_kernel.c
index fa3549701927..16f12fa8c890 100644
--- a/arch/arm64/kernel/pi/map_kernel.c
+++ b/arch/arm64/kernel/pi/map_kernel.c
@@ -213,7 +213,7 @@ static void __init remap_idmap(bool use_lpa2, int page_shift)
 
 static void *__init map_fdt(phys_addr_t fdt, int page_shift)
 {
-	static u8 ptes[INIT_IDMAP_FDT_SIZE_MAX] __initdata __aligned(PAGE_SIZE);
+	static u8 ptes[INIT_IDMAP_FDT_SIZE_MAX] __initdata __aligned(PAGE_SIZE_MAX);
 	static bool first_time __initdata = true;
 	u64 limit = (u64)&ptes[INIT_IDMAP_FDT_SIZE_MAX];
 	phys_addr_t efdt = fdt + MAX_FDT_SIZE;
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 66d369870a74..e3544dd7871d 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -2075,7 +2075,7 @@ static inline unsigned long zero_pfn(unsigned long addr)
 	return zero_page_pfn;
 }
 
-extern const uint8_t empty_zero_page[PAGE_SIZE];
+extern const uint8_t empty_zero_page[PAGE_SIZE_MAX];
 extern struct page *__zero_page;
 
 static inline struct page *_zero_page(unsigned long addr)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index d99af80ec752..0abbe36f5667 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -62,7 +62,7 @@ unsigned long zero_page_pfn __ro_after_init;
 EXPORT_SYMBOL(zero_page_pfn);
 
 #ifndef __HAVE_COLOR_ZERO_PAGE
-const uint8_t empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE);
+const uint8_t empty_zero_page[PAGE_SIZE_MAX] __aligned(PAGE_SIZE_MAX);
 EXPORT_SYMBOL(empty_zero_page);
 
 struct page *__zero_page __ro_after_init;



More information about the linux-arm-kernel mailing list