]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arch, mm: consolidate empty_zero_page
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Wed, 11 Feb 2026 10:31:40 +0000 (12:31 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:01 +0000 (13:53 -0700)
Reduce 22 declarations of empty_zero_page to 3 and 23 declarations of
ZERO_PAGE() to 4.

Every architecture defines empty_zero_page that way or another, but for the
most of them it is always a page aligned page in BSS and most definitions
of ZERO_PAGE do virt_to_page(empty_zero_page).

Move Linus vetted x86 definition of empty_zero_page and ZERO_PAGE() to the
core MM and drop these definitions in architectures that do not implement
colored zero page (MIPS and s390).

ZERO_PAGE() remains a macro because turning it to a wrapper for a static
inline causes severe pain in header dependencies.

For the most part the change is mechanical, with these being noteworthy:

* alpha: aliased empty_zero_page with ZERO_PGE that was also used for boot
  parameters. Switching to a generic empty_zero_page removes the aliasing
  and keeps ZERO_PGE for boot parameters only
* arm64: uses __pa_symbol() in ZERO_PAGE() so that definition of
  ZERO_PAGE() is kept intact.
* m68k/parisc/um: allocated empty_zero_page from memblock,
  although they do not support zero page coloring and having it in BSS
  will work fine.
* sparc64 can have empty_zero_page in BSS rather allocate it, but it
  can't use virt_to_page() for BSS. Keep it's definition of ZERO_PAGE()
  but instead of allocating it, make mem_map_zero point to
  empty_zero_page.
* sh: used empty_zero_page for boot parameters at the very early boot.
  Rename the parameters page to boot_params_page and let sh use the generic
  empty_zero_page.
* hexagon: had an amusing comment about empty_zero_page

/* A handy thing to have if one has the RAM. Declared in head.S */

  that unfortunately had to go :)

Link: https://lkml.kernel.org/r/20260211103141.3215197-4-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Helge Deller <deller@gmx.de> [parisc]
Tested-by: Helge Deller <deller@gmx.de> [parisc]
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Magnus Lindholm <linmag7@gmail.com> [alpha]
Acked-by: Dinh Nguyen <dinguyen@kernel.org> [nios2]
Acked-by: Andreas Larsson <andreas@gaisler.com> [sparc]
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
59 files changed:
arch/alpha/include/asm/pgtable.h
arch/arc/include/asm/pgtable.h
arch/arc/mm/init.c
arch/arm/include/asm/pgtable.h
arch/arm/mm/mmu.c
arch/arm/mm/nommu.c
arch/arm64/include/asm/pgtable.h
arch/arm64/mm/mmu.c
arch/csky/include/asm/pgtable.h
arch/csky/mm/init.c
arch/hexagon/include/asm/pgtable.h
arch/hexagon/kernel/head.S
arch/hexagon/kernel/hexagon_ksyms.c
arch/loongarch/include/asm/pgtable.h
arch/loongarch/mm/init.c
arch/m68k/include/asm/pgtable_mm.h
arch/m68k/include/asm/pgtable_no.h
arch/m68k/mm/init.c
arch/m68k/mm/mcfmmu.c
arch/m68k/mm/motorola.c
arch/m68k/mm/sun3mmu.c
arch/microblaze/include/asm/pgtable.h
arch/microblaze/kernel/head.S
arch/microblaze/kernel/microblaze_ksyms.c
arch/nios2/include/asm/pgtable.h
arch/nios2/kernel/head.S
arch/nios2/kernel/nios2_ksyms.c
arch/openrisc/include/asm/pgtable.h
arch/openrisc/kernel/head.S
arch/openrisc/kernel/or32_ksyms.c
arch/openrisc/mm/init.c
arch/parisc/include/asm/pgtable.h
arch/parisc/mm/init.c
arch/powerpc/include/asm/pgtable.h
arch/powerpc/mm/mem.c
arch/riscv/include/asm/pgtable.h
arch/riscv/mm/init.c
arch/sh/include/asm/pgtable.h
arch/sh/include/asm/setup.h
arch/sh/kernel/head_32.S
arch/sh/kernel/sh_ksyms_32.c
arch/sh/mm/init.c
arch/sparc/include/asm/pgtable_32.h
arch/sparc/include/asm/setup.h
arch/sparc/kernel/head_32.S
arch/sparc/mm/init_32.c
arch/sparc/mm/init_64.c
arch/um/include/asm/pgtable.h
arch/um/include/shared/kern_util.h
arch/um/kernel/mem.c
arch/um/kernel/um_arch.c
arch/x86/include/asm/pgtable.h
arch/x86/kernel/head_32.S
arch/x86/kernel/head_64.S
arch/xtensa/include/asm/pgtable.h
arch/xtensa/kernel/head.S
arch/xtensa/kernel/xtensa_ksyms.c
include/linux/pgtable.h
mm/mm_init.c

index e9368c54be452ac7aca8ba4c50275b852df82b18..268ddde3361714af6a9880b554f3043138b95c32 100644 (file)
@@ -126,12 +126,6 @@ struct vm_area_struct;
  */
 #define pgprot_noncached(prot) (prot)
 
-/*
- * ZERO_PAGE is a global shared page that is always zero:  used
- * for zero-mapped memory areas etc..
- */
-#define ZERO_PAGE(vaddr)       (virt_to_page(ZERO_PGE))
-
 /*
  * On certain platforms whose physical address space can overlap KSEG,
  * namely EV6 and above, we must re-twiddle the physaddr to restore the
index bd580e2b62d7c073ef82a9ed1a93755996b67643..0fdaea81b5fa5fac983c2078d0b2f9670c385088 100644 (file)
@@ -21,9 +21,6 @@
 
 #ifndef __ASSEMBLER__
 
-extern char empty_zero_page[PAGE_SIZE];
-#define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
-
 extern pgd_t swapper_pg_dir[] __aligned(PAGE_SIZE);
 
 /* to cope with aliasing VIPT cache */
index a5e92f46e5d1370ff89d05052e438034b4e3c30d..d6b5c27a0098f6bd6310372be2b355c194e96519 100644 (file)
@@ -19,8 +19,6 @@
 #include <asm/arcregs.h>
 
 pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
-char empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE);
-EXPORT_SYMBOL(empty_zero_page);
 
 static const unsigned long low_mem_start = CONFIG_LINUX_RAM_BASE;
 static unsigned long low_mem_sz;
index 6fa9acd6a7f5dcca9f1ef282b019c2c0037e81a5..982795cf45637e9c21f453989b4f366d86b8cb34 100644 (file)
 #include <linux/const.h>
 #include <asm/proc-fns.h>
 
-#ifndef __ASSEMBLY__
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
-#endif
-
 #include <asm-generic/pgtable-nopud.h>
 
 #ifndef CONFIG_MMU
index 518def8314e778546312d7c1d87a0200e7652c19..23b87b5ef7f1b57ca3a90fc4ff14b3714649224b 100644 (file)
 
 extern unsigned long __atags_pointer;
 
-/*
- * empty_zero_page is a special page that is used for
- * zero-initialized data and COW.
- */
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 /*
  * The pmd table for the upper-most set of pages.
  */
index 7e42d8accec6b27102cf540c174f0e1ff8258bb1..040ea43cce32e4cbc6155a67f8cf61c9bb3445b5 100644 (file)
 
 unsigned long vectors_base;
 
-/*
- * empty_zero_page is a special page that is used for
- * zero-initialized data and COW.
- */
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 #ifdef CONFIG_ARM_MPU
 struct mpu_rgn_info mpu_rgn_info;
 #endif
index b3e58735c49bdd1cc86542663727cb8a029482e3..769570e43c1853e70e5f58d9aa554340cac296ac 100644 (file)
@@ -110,7 +110,6 @@ static inline void arch_leave_lazy_mmu_mode(void)
  * ZERO_PAGE is a global shared page that is always zero: used
  * for zero-mapped memory areas etc..
  */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
 #define ZERO_PAGE(vaddr)       phys_to_page(__pa_symbol(empty_zero_page))
 
 #define pte_ERROR(e)   \
index a12ea8776c32977e6f3a284ebf39a9d65fa20e06..ec932f6ccddcac73c590b4b7e5d08d2c5cbff852 100644 (file)
@@ -64,13 +64,6 @@ static bool rodata_is_rw __ro_after_init = true;
  */
 long __section(".mmuoff.data.write") __early_cpu_boot_status;
 
-/*
- * Empty_zero_page is a special page that is used for zero-initialized data
- * and COW.
- */
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 static DEFINE_SPINLOCK(swapper_pgdir_lock);
 static DEFINE_MUTEX(fixmap_lock);
 
index d606afbabce199f07fe7c8b679db30aabe4bd2a3..bafcd5823531a5e66d8801c3b95b9b5baba7c3fc 100644 (file)
@@ -76,9 +76,6 @@
 #define MAX_SWAPFILES_CHECK() \
                BUILD_BUG_ON(MAX_SWAPFILES_SHIFT != 5)
 
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
-
 extern void load_pgd(unsigned long pg_dir);
 extern pte_t invalid_pte_table[PTRS_PER_PTE];
 
index 573da66b25438a33a8f031ddc3bdfbe9aec062c5..fa16015ea1c04d87a9d8fa23a48553a53b14e67c 100644 (file)
@@ -38,9 +38,6 @@ pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned_bss;
 pte_t kernel_pte_tables[PTRS_KERN_TABLE] __page_aligned_bss;
 
 EXPORT_SYMBOL(invalid_pte_table);
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
-                                               __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
 
 void free_initmem(void)
 {
index fbf24d1d1ca6aafc95179cac6af720bf29f10231..27b269e2870d375c686a94243dc718c59006c02b 100644 (file)
@@ -14,9 +14,6 @@
 #include <asm/page.h>
 #include <asm-generic/pgtable-nopmd.h>
 
-/* A handy thing to have if one has the RAM. Declared in head.S */
-extern unsigned long empty_zero_page;
-
 /*
  * The PTE model described here is that of the Hexagon Virtual Machine,
  * which autonomously walks 2-level page tables.  At a lower level, we
@@ -348,9 +345,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
        return (unsigned long)__va(pmd_val(pmd) & PAGE_MASK);
 }
 
-/* ZERO_PAGE - returns the globally shared zero page */
-#define ZERO_PAGE(vaddr) (virt_to_page(&empty_zero_page))
-
 /*
  * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
  * are !pte_none() && !pte_present().
index 0b016308cc79f041579cfcf8929afe1e5b2b6b5f..908ffece913245eaa57160a9cd79585ad476fbc3 100644 (file)
@@ -216,8 +216,3 @@ __head_s_vaddr_target:
 .p2align PAGE_SHIFT
 ENTRY(external_cmdline_buffer)
         .fill _PAGE_SIZE,1,0
-
-.data
-.p2align PAGE_SHIFT
-ENTRY(empty_zero_page)
-        .fill _PAGE_SIZE,1,0
index 36a80e31d1879518d19e86544876bc9310cef8dc..81bc6f81e20095f46b3bce4d4fdf6cc5fbdda06e 100644 (file)
@@ -17,7 +17,6 @@ EXPORT_SYMBOL(raw_copy_to_user);
 EXPORT_SYMBOL(__vmgetie);
 EXPORT_SYMBOL(__vmsetie);
 EXPORT_SYMBOL(__vmyield);
-EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memset);
 
index c33b3bcb733e3adf681054b17c96b2da929a73ab..a244de27a03e7997690cfc8b921990b8502a52b8 100644 (file)
 struct mm_struct;
 struct vm_area_struct;
 
-/*
- * ZERO_PAGE is a global shared page that is always zero; used
- * for zero-mapped memory areas etc..
- */
-
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-
-#define ZERO_PAGE(vaddr)       virt_to_page(empty_zero_page)
-
 #ifdef CONFIG_32BIT
 
 #define VMALLOC_START  (vm_map_base + PCI_IOSIZE + (2 * PAGE_SIZE))
index c331bf69d2ec19ead69f82a6a1fca618355e2d91..00f3822b6e47c66e2946cf55074ce31b457146fe 100644 (file)
@@ -36,9 +36,6 @@
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
 
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 void copy_user_highpage(struct page *to, struct page *from,
        unsigned long vaddr, struct vm_area_struct *vma)
 {
index bba64a9c49acd0de4e4b7a1d63f3e89060f394e2..7501ff030c6335da76e168f8461c69c35358ee10 100644 (file)
@@ -110,15 +110,6 @@ extern unsigned long m68k_vmalloc_end;
 #define VMALLOC_END KMAP_START
 #endif
 
-/* zero page used for uninitialized stuff */
-extern void *empty_zero_page;
-
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-#define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
-
 extern void kernel_set_cachemode(void *addr, unsigned long size, int cmode);
 
 /*
index 1a86c15b9008f03dd551ee212aa6d2b97a5254ea..11751807a3f3b4b5077a75780032bd86b79bdee8 100644 (file)
 
 #define swapper_pg_dir ((pgd_t *) 0)
 
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern void *empty_zero_page;
-#define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
-
 /*
  * All 32bit addresses are effectively valid for vmalloc...
  * Sort of meaningless for non-VM targets.
index 53b71f786c27e7a005082d0dbff7b8e344d280ab..3b88c0dd1616d7c69ed946267882a90907f7c260 100644 (file)
 #include <asm/sections.h>
 #include <asm/tlb.h>
 
-/*
- * ZERO_PAGE is a special page that is used for zero-initialized
- * data and COW.
- */
-void *empty_zero_page;
-EXPORT_SYMBOL(empty_zero_page);
-
 void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
 {
        max_zone_pfns[ZONE_DMA] = PFN_DOWN(memblock_end_of_DRAM());
@@ -71,8 +64,6 @@ void __init paging_init(void)
        unsigned long end_mem = memory_end & PAGE_MASK;
 
        high_memory = (void *) end_mem;
-
-       empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
 }
 
 #endif /* CONFIG_MMU */
index 3418fd8642377ffbaeeb1e35d3e3c7a0ec6e6a13..4924f2ff8ef87a314198d99ae7f7a53e5571bebc 100644 (file)
@@ -41,8 +41,6 @@ void __init paging_init(void)
        unsigned long next_pgtable;
        int i;
 
-       empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
-
        pg_dir = swapper_pg_dir;
        memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir));
 
index 127a3fa69f4c1b17fd7b1e9381b4f861068355db..b30aa69a73a6adee70cd644148e27199f99730e0 100644 (file)
@@ -498,12 +498,6 @@ void __init paging_init(void)
 
        early_memtest(min_addr, max_addr);
 
-       /*
-        * initialize the bad page table and bad page to point
-        * to a couple of allocated pages
-        */
-       empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
-
        /*
         * Set up SFC/DFC registers
         */
index c801677f7df87a2692a3f989d813efee48b3c7a9..f139cc15753a7479f42de48aca15f518d60c4c64 100644 (file)
@@ -43,8 +43,6 @@ void __init paging_init(void)
        unsigned long bootmem_end;
        unsigned long size;
 
-       empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
-
        address = PAGE_OFFSET;
        pg_dir = swapper_pg_dir;
        memset (swapper_pg_dir, 0, sizeof (swapper_pg_dir));
index 4eb76de6be4ac962d3f158aa956030c5cc904e45..ea72291de55317c43e10676a8527f74768bd099b 100644 (file)
@@ -207,16 +207,6 @@ extern pte_t *va_to_pte(unsigned long address);
  * Also, write permissions imply read permissions.
  */
 
-#ifndef __ASSEMBLER__
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[1024];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
-#endif /* __ASSEMBLER__ */
-
 #define pte_none(pte)          ((pte_val(pte) & ~_PTE_NONE_MASK) == 0)
 #define pte_present(pte)       (pte_val(pte) & _PAGE_PRESENT)
 #define pte_clear(mm, addr, ptep) \
index ec2fcb545e646327b19c7c2e7a9b5cf269c4518f..808019c3b7ac2cb27b998a4316e3ebf1d7c6f6db 100644 (file)
 #include <asm/processor.h>
 
 .section .data
-.global empty_zero_page
-.align 12
-empty_zero_page:
-       .space  PAGE_SIZE
 .global swapper_pg_dir
 swapper_pg_dir:
        .space  PAGE_SIZE
index a8553f54152b7623e6febce6bc0ae976d7359e9a..ad7596d7ba07690c1c2f5461f4a5aa4a4e1ba9ac 100644 (file)
@@ -33,8 +33,6 @@ EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
 #endif
 
-EXPORT_SYMBOL(empty_zero_page);
-
 EXPORT_SYMBOL(mbc);
 
 extern void __divsi3(void);
index 844dce55569f34b8a324470d32a9e43ab9b666b3..d389aa9ca57ce0437fb57d78ba0ca45d6de83e90 100644 (file)
@@ -65,13 +65,6 @@ struct mm_struct;
 #define PGDIR_SIZE     (1UL << PGDIR_SHIFT)
 #define PGDIR_MASK     (~(PGDIR_SIZE-1))
 
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr)       (virt_to_page(empty_zero_page))
-
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
 
index 372ce4a33018b7ca1439d9a196ff5019798978d2..613212e1a63acc7b475ec53e18b485789a639565 100644 (file)
 #include <asm/asm-offsets.h>
 #include <asm/asm-macros.h>
 
-/*
- * ZERO_PAGE is a special page that is used for zero-initialized
- * data and COW.
- */
-.data
-.global empty_zero_page
-.align 12
-empty_zero_page:
-       .space  PAGE_SIZE
-
 /*
  * This global variable is used as an extension to the nios'
  * STATUS register to emulate a user/supervisor mode.
index 54f7b23df1bf5f68eb9d009614edb1f6662a0a5d..c40aa39e865878a99b9a71611faf9aef1aad655b 100644 (file)
@@ -20,7 +20,6 @@ EXPORT_SYMBOL(memmove);
 
 /* memory management */
 
-EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(flush_icache_range);
 
 /*
index b218050e2f6ddf79559a2b52e695950e3e322e71..6b89996d0b628ecef5a5a7771a006928844202d2 100644 (file)
@@ -179,10 +179,6 @@ extern void paging_init(void);
        __pgprot(_PAGE_ALL | _PAGE_SRE | _PAGE_SWE \
                 | _PAGE_SHARED | _PAGE_DIRTY | _PAGE_EXEC | _PAGE_CI)
 
-/* zero page used for uninitialized stuff */
-extern unsigned long empty_zero_page[2048];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
 #define pte_none(x)    (!pte_val(x))
 #define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
 #define pte_clear(mm, addr, xp)        do { pte_val(*(xp)) = 0; } while (0)
index bd760066f1cdc45045a430602c1379856cd71beb..45890393947d8c152f6b42b290159454f2473fe0 100644 (file)
@@ -1563,9 +1563,6 @@ _string_nl:
  */
        .section .data,"aw"
        .align  8192
-       .global  empty_zero_page
-empty_zero_page:
-       .space  8192
 
        .global  swapper_pg_dir
 swapper_pg_dir:
index 212e5f85004cc73b1d5144807323448a1f88ee11..84a937a64e2a7834591a291b1e2a44dde141aeca 100644 (file)
@@ -40,7 +40,6 @@ DECLARE_EXPORT(__ashldi3);
 DECLARE_EXPORT(__lshrdi3);
 DECLARE_EXPORT(__ucmpdi2);
 
-EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(__copy_tofrom_user);
 EXPORT_SYMBOL(__clear_user);
 EXPORT_SYMBOL(memset);
index 78fb0734cdbc2340a1626a5491e4a971cd827373..89d8c6df88551128284714018f8b95995763696e 100644 (file)
@@ -188,9 +188,6 @@ void __init mem_init(void)
 {
        BUG_ON(!mem_map);
 
-       /* clear the zero-page */
-       memset((void *)empty_zero_page, 0, PAGE_SIZE);
-
        printk("mem_init_done ...........................................\n");
        mem_init_done = 1;
        return;
index 17afe7a59edfded35cd9c0c26918e7561db4d6ca..f6fb99cb94d9e76c17b6f698983da449405abf42 100644 (file)
@@ -262,17 +262,6 @@ extern pgd_t swapper_pg_dir[]; /* declared in init_task.c */
 
 extern pte_t pg0[];
 
-/* zero page used for uninitialized stuff */
-
-extern unsigned long *empty_zero_page;
-
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
 #define pte_none(x)     (pte_val(x) == 0)
 #define pte_present(x) (pte_val(x) & _PAGE_PRESENT)
 #define pte_user(x)    (pte_val(x) & _PAGE_USER)
index 6a39e031e5ff77cd9a52b5dbc8a818839140c30e..be3380c9bcdae3b88ba9d8034b05c551b2bde052 100644 (file)
@@ -604,9 +604,6 @@ void __init mem_init(void)
 #endif
 }
 
-unsigned long *empty_zero_page __ro_after_init;
-EXPORT_SYMBOL(empty_zero_page);
-
 /*
  * pagetable_init() sets up the page tables
  *
@@ -639,9 +636,6 @@ static void __init pagetable_init(void)
                          initrd_end - initrd_start, PAGE_KERNEL, 0);
        }
 #endif
-
-       empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
-
 }
 
 static void __init gateway_init(void)
index dcd3a88caaf634fef26fa57f5b8852274e0d4cb5..b27d94c06d0e7377071c261109e249c022d98a76 100644 (file)
@@ -76,12 +76,6 @@ static inline const void *pmd_page_vaddr(pmd_t pmd)
 }
 #define pmd_page_vaddr pmd_page_vaddr
 #endif
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
 
 extern pgd_t swapper_pg_dir[];
 
index b7982d0243d487c98b4f92430959eb50245cdcd5..648d0c5602ec8b3f8137e9172518aee3d7fa7d6c 100644 (file)
@@ -38,9 +38,6 @@
 
 unsigned long long memory_limit __initdata;
 
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 pgprot_t __phys_mem_access_prot(unsigned long pfn, unsigned long size,
                                pgprot_t vma_prot)
 {
index 08d1ca04710464811df25cc0984f9790e10d7d84..ab4ce1cc9d9c15d33ac79079bc069e27ef66cd49 100644 (file)
@@ -1284,13 +1284,6 @@ extern u64 satp_mode;
 void paging_init(void);
 void misc_mem_init(void);
 
-/*
- * ZERO_PAGE is a global shared page that is always zero,
- * used for zero-mapped memory areas, etc.
- */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
 /*
  * Use set_p*_safe(), and elide TLB flushing, when confident that *no*
  * TLB flush will be required as a result of the "set". For example, use
index 811e03786c560f128c4d556d7c3e43617370dd19..017bad735d47e5edd6829d510ff10216cd02f9ea 100644 (file)
@@ -69,10 +69,6 @@ unsigned long vmemmap_start_pfn __ro_after_init;
 EXPORT_SYMBOL(vmemmap_start_pfn);
 #endif
 
-unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
-                                                       __page_aligned_bss;
-EXPORT_SYMBOL(empty_zero_page);
-
 extern char _start[];
 void *_dtb_early_va __initdata;
 uintptr_t _dtb_early_pa __initdata;
index 10fa8f2bb8d1f399d9602ceecaf7092de6bad473..d5ce0950a32319aa37008c56718e4f367ed0ca2e 100644 (file)
 #ifndef __ASSEMBLER__
 #include <asm/addrspace.h>
 #include <asm/fixmap.h>
-
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
 #endif /* !__ASSEMBLER__ */
 
 /*
index 84bb23a771f3538b3835480c2704dc6aceae8498..63c9efc063486874b51323b0a6850c92bb81c0b2 100644 (file)
@@ -7,7 +7,8 @@
 /*
  * This is set up by the setup-routine at boot-time
  */
-#define PARAM  ((unsigned char *)empty_zero_page)
+extern unsigned char *boot_params_page;
+#define PARAM boot_params_page
 
 #define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
 #define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
index b603b7968b388f334ca8fdc692fb668c5a60deff..0b91bb85d40a04e13e8e9a190d81d2cb7005660c 100644 (file)
@@ -26,7 +26,7 @@
 #endif
 
        .section        .empty_zero_page, "aw"
-ENTRY(empty_zero_page)
+ENTRY(boot_params_page)
        .long   1               /* MOUNT_ROOT_RDONLY */
        .long   0               /* RAMDISK_FLAGS */
        .long   0x0200          /* ORIG_ROOT_DEV */
@@ -39,7 +39,7 @@ ENTRY(empty_zero_page)
        .long   0x53453f00 + 29 /* "SE?" = 29 bit */
 #endif
 1:
-       .skip   PAGE_SIZE - empty_zero_page - 1b
+       .skip   PAGE_SIZE - boot_params_page - 1b
 
        __HEAD
 
index 5858936cb4311138a94eaefbd4fad69e6ec1fd7c..041191002e2e2355e896a45c2034bf065178f37c 100644 (file)
@@ -20,7 +20,6 @@ EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(csum_partial_copy_generic);
 EXPORT_SYMBOL(copy_page);
 EXPORT_SYMBOL(__clear_user);
-EXPORT_SYMBOL(empty_zero_page);
 #ifdef CONFIG_FLATMEM
 /* need in pfn_valid macro */
 EXPORT_SYMBOL(min_low_pfn);
index 464a3a63e2fa53939d7c5bad0e41b2a1a86bee0a..4e40d5e96be9d82bb3f7cba0c447050ebeb7d942 100644 (file)
@@ -332,7 +332,6 @@ void __init mem_init(void)
        cpu_cache_init();
 
        /* clear the zero-page */
-       memset(empty_zero_page, 0, PAGE_SIZE);
        __flush_wback_region(empty_zero_page, PAGE_SIZE);
 
        vsyscall_init();
index a9f802d1dd64f429c001a199516462dce1c1d952..f89b1250661dff0c7cfd4f6d5774a4bc2fbb0cbe 100644 (file)
@@ -71,14 +71,6 @@ extern unsigned long ptr_in_current_pgd;
 extern unsigned long phys_base;
 extern unsigned long pfn_base;
 
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
 /*
  * In general all page table modifications should use the V8 atomic
  * swap instruction.  This insures the mmu and the cpu are in sync
index 72205684e51eae3b202b26806acc93252b6d189e..21bed551402887f56c0fef894356481a293e3bc0 100644 (file)
@@ -17,8 +17,6 @@ extern char reboot_command[];
  */
 extern unsigned char boot_cpu_id;
 
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
-
 extern int serial_console;
 static inline int con_is_present(void)
 {
index 38345460d5420a295e941d53015d72a8c8d50be1..8c320fa25a670ca7afc9265d6c66fcb108d88c74 100644 (file)
@@ -57,13 +57,6 @@ sun4e_notsup:
 
        .align PAGE_SIZE
 
-/* This was the only reasonable way I could think of to properly align
- * these page-table data structures.
- */
-       .globl empty_zero_page
-empty_zero_page:       .skip PAGE_SIZE
-EXPORT_SYMBOL(empty_zero_page)
-
        .global root_flags
        .global ram_flags
        .global root_dev
index fdc93dd12c3e3e85ca117eb70a25a575c8dad699..e0e66f91ceebcf377669e427682c8cc90a00899d 100644 (file)
@@ -246,10 +246,6 @@ void __init arch_mm_preinit(void)
                prom_halt();
        }
 
-
-       /* Saves us work later. */
-       memset((void *)empty_zero_page, 0, PAGE_SIZE);
-
        i = last_valid_pfn >> ((20 - PAGE_SHIFT) + 5);
        i += 1;
        sparc_valid_addr_bitmap = (unsigned long *)
index f46394c46a764e0a1e88a13651749be9ebfd7713..748790998ff50cf79abcc9a24757f7da85fb155e 100644 (file)
@@ -2492,6 +2492,9 @@ static void __init register_page_bootmem_info(void)
 }
 void __init mem_init(void)
 {
+       phys_addr_t zero_page_pa = kern_base +
+               ((unsigned long)&empty_zero_page[0] - KERNBASE);
+
        /*
         * Must be done after boot memory is put on freelist, because here we
         * might set fields in deferred struct pages that have not yet been
@@ -2504,13 +2507,7 @@ void __init mem_init(void)
         * Set up the zero page, mark it reserved, so that page count
         * is not manipulated when freeing the page from user ptes.
         */
-       mem_map_zero = alloc_pages(GFP_KERNEL|__GFP_ZERO, 0);
-       if (mem_map_zero == NULL) {
-               prom_printf("paging_init: Cannot alloc zero page.\n");
-               prom_halt();
-       }
-       mark_page_reserved(mem_map_zero);
-
+       mem_map_zero = pfn_to_page(PHYS_PFN(zero_page_pa));
 
        if (tlb_type == cheetah || tlb_type == cheetah_plus)
                cheetah_ecache_flush_init();
index 3b42b0f45bf6cdf5807659bd5bd8b31ccdf45884..19e0608fb649799a8a032e86af3920f47bcf1c94 100644 (file)
@@ -34,9 +34,6 @@
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 
-/* zero page used for uninitialized stuff */
-extern unsigned long *empty_zero_page;
-
 /* Just any arbitrary offset to the start of the vmalloc VM area: the
  * current 8MB value just means that there will be a 8MB "hole" after the
  * physical memory until the kernel virtual memory starts.  That means that
@@ -74,12 +71,6 @@ extern unsigned long *empty_zero_page;
  * get..
  */
 
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
-
 #define pte_clear(mm, addr, xp) pte_set_val(*(xp), (phys_t) 0, __pgprot(_PAGE_NEEDSYNC))
 
 #define pmd_none(x)    (!((unsigned long)pmd_val(x) & ~_PAGE_NEEDSYNC))
index 38321188c04c4ce7ce96c4248e5fdf99b1545585..9812efd14ec0ee1d789de5f8241724befe636e3e 100644 (file)
@@ -38,7 +38,6 @@ extern void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs
 extern void uml_pm_wake(void);
 
 extern int start_uml(void);
-extern void paging_init(void);
 
 extern void uml_cleanup(void);
 extern void do_uml_exitcalls(void);
index 89c8c8b94a79673fd71e5f645d27b6260c709847..1eef0e42ef5dba4b3cbc5ec4ddf1189c16c6d3d8 100644 (file)
@@ -44,10 +44,6 @@ __section(".kasan_init") __used
 = kasan_init;
 #endif
 
-/* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
-unsigned long *empty_zero_page = NULL;
-EXPORT_SYMBOL(empty_zero_page);
-
 /*
  * Initialized during boot, and readonly for initializing page tables
  * afterwards
@@ -65,9 +61,6 @@ void __init arch_mm_preinit(void)
        /* Safe to call after jump_label_init(). Enables KASAN. */
        kasan_init_generic();
 
-       /* clear the zero-page */
-       memset(empty_zero_page, 0, PAGE_SIZE);
-
        /* Map in the area just after the brk now that kmalloc is about
         * to be turned on.
         */
@@ -89,15 +82,6 @@ void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
        max_zone_pfns[ZONE_NORMAL] = high_physmem >> PAGE_SHIFT;
 }
 
-void __init paging_init(void)
-{
-       empty_zero_page = (unsigned long *) memblock_alloc_low(PAGE_SIZE,
-                                                              PAGE_SIZE);
-       if (!empty_zero_page)
-               panic("%s: Failed to allocate %lu bytes align=%lx\n",
-                     __func__, PAGE_SIZE, PAGE_SIZE);
-}
-
 /*
  * This can't do anything because nothing in the kernel image can be freed
  * since it's not in kernel physical memory.
index e2b24e1ecfa6493cbfd89ea3fbb57583d99e7017..2141f5f1f5a2057bac5b7e8e3fa93b25911b234c 100644 (file)
@@ -413,7 +413,6 @@ void __init setup_arch(char **cmdline_p)
        uml_dtb_init();
        read_initrd();
 
-       paging_init();
        strscpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
        *cmdline_p = command_line;
        setup_hostinfo(host_info, sizeof host_info);
index 1662c5a8f445f58c62e7364040d13b5958347818..54289f4587a4c062135b6eb635a5a463567ed798 100644 (file)
@@ -47,14 +47,6 @@ void ptdump_walk_user_pgd_level_checkwx(void);
 #define debug_checkwx_user()   do { } while (0)
 #endif
 
-/*
- * ZERO_PAGE is a global shared page that is always zero: used
- * for zero-mapped memory areas etc..
- */
-extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)]
-       __visible;
-#define ZERO_PAGE(vaddr) ((void)(vaddr),virt_to_page(empty_zero_page))
-
 extern spinlock_t pgd_lock;
 extern struct list_head pgd_list;
 
index 80ef5d386b03dcc8e2dc184d72d6482b2b35c04f..5171cb746444ecd4f996345e83f800ee94045b73 100644 (file)
@@ -441,10 +441,6 @@ initial_pg_fixmap:
 swapper_pg_dir:
        .fill 1024,4,0
        .fill PTI_USER_PGD_FILL,4,0
-.globl empty_zero_page
-empty_zero_page:
-       .fill 4096,1,0
-EXPORT_SYMBOL(empty_zero_page)
 
 /*
  * This starts the data section.
index 85d4a5094f6bc4e0697c030aad74cb69e265eccf..7ed5520dd52eb1c16f8a803e724151123adaca1b 100644 (file)
@@ -684,10 +684,3 @@ SYM_PIC_ALIAS(phys_base);
 EXPORT_SYMBOL(phys_base)
 
 #include "../xen/xen-head.S"
-
-       __PAGE_ALIGNED_BSS
-SYM_DATA_START_PAGE_ALIGNED(empty_zero_page)
-       .skip PAGE_SIZE
-SYM_DATA_END(empty_zero_page)
-EXPORT_SYMBOL(empty_zero_page)
-
index 50a136213b2bf2024dea9e91c3eef9644442677f..61f07d981a94d5a402d7d08a2d1bc706286b0652 100644 (file)
 #define pgd_ERROR(e) \
        printk("%s:%d: bad pgd entry %08lx.\n", __FILE__, __LINE__, pgd_val(e))
 
-extern unsigned long empty_zero_page[1024];
-
-#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
-
 #ifdef CONFIG_MMU
 extern pgd_t swapper_pg_dir[PAGE_SIZE/sizeof(pgd_t)];
 extern void paging_init(void);
index 8484294bc623f03c8a427aa290402927a8d5517a..4b0c5c5e685af354546e85d80f0eaf32c05acc68 100644 (file)
@@ -381,6 +381,3 @@ ENTRY(swapper_pg_dir)
        .fill   PAGE_SIZE, 1, 0
 END(swapper_pg_dir)
 #endif
-ENTRY(empty_zero_page)
-       .fill   PAGE_SIZE, 1, 0
-END(empty_zero_page)
index 62d81e76e18e238ec1772de97b783f07033228e6..ced335b4df5fa517cbb433876b12b77dc60aabe7 100644 (file)
@@ -15,8 +15,6 @@
 #include <linux/module.h>
 #include <asm/pgtable.h>
 
-EXPORT_SYMBOL(empty_zero_page);
-
 unsigned int __sync_fetch_and_and_4(volatile void *p, unsigned int v)
 {
        BUG();
index c3a56f6b1ea51b196fa6ee5f73882ba3660f9ae0..2a05c3885f85b21b785a3873692c637fc0a12136 100644 (file)
@@ -1925,6 +1925,9 @@ static inline void pfnmap_setup_cachemode_pfn(unsigned long pfn, pgprot_t *prot)
  * for different ranges in the virtual address space.
  *
  * zero_page_pfn identifies the first (or the only) pfn for these pages.
+ *
+ * For architectures that don't __HAVE_COLOR_ZERO_PAGE the zero page lives in
+ * empty_zero_page in BSS.
  */
 #ifdef __HAVE_COLOR_ZERO_PAGE
 static inline int is_zero_pfn(unsigned long pfn)
@@ -1951,6 +1954,13 @@ static inline unsigned long zero_pfn(unsigned long addr)
 
        return zero_page_pfn;
 }
+
+extern uint8_t empty_zero_page[PAGE_SIZE];
+
+#ifndef ZERO_PAGE
+#define ZERO_PAGE(vaddr) ((void)(vaddr),virt_to_page(empty_zero_page))
+#endif
+
 #endif /* __HAVE_COLOR_ZERO_PAGE */
 
 #ifdef CONFIG_MMU
index ab6578516dd6bce293fe5f0d5609f4554e32f6a2..a0472d496c9173abb2911a24347bd4888cb575e5 100644 (file)
@@ -56,6 +56,11 @@ EXPORT_SYMBOL(high_memory);
 unsigned long zero_page_pfn __ro_after_init;
 EXPORT_SYMBOL(zero_page_pfn);
 
+#ifndef __HAVE_COLOR_ZERO_PAGE
+uint8_t empty_zero_page[PAGE_SIZE] __page_aligned_bss;
+EXPORT_SYMBOL(empty_zero_page);
+#endif
+
 #ifdef CONFIG_DEBUG_MEMORY_INIT
 int __meminitdata mminit_loglevel;