mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
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>
169 lines
4.6 KiB
C
169 lines
4.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _M68K_PGTABLE_H
|
|
#define _M68K_PGTABLE_H
|
|
|
|
|
|
#if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE)
|
|
#include <asm-generic/pgtable-nopmd.h>
|
|
#else
|
|
#include <asm-generic/pgtable-nopud.h>
|
|
#endif
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#ifndef __ASSEMBLER__
|
|
#include <asm/processor.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/threads.h>
|
|
|
|
/*
|
|
* This file contains the functions and defines necessary to modify and use
|
|
* the m68k page table tree.
|
|
*/
|
|
|
|
#include <asm/virtconvert.h>
|
|
|
|
/* Certain architectures need to do special things when pte's
|
|
* within a page table are directly modified. Thus, the following
|
|
* hook is made available.
|
|
*/
|
|
#define set_pte(pteptr, pteval) \
|
|
do{ \
|
|
*(pteptr) = (pteval); \
|
|
} while(0)
|
|
|
|
/* PMD_SHIFT determines the size of the area a second-level page table can map */
|
|
#if CONFIG_PGTABLE_LEVELS == 3
|
|
#define PMD_SHIFT 18
|
|
#endif
|
|
#define PMD_SIZE (1UL << PMD_SHIFT)
|
|
#define PMD_MASK (~(PMD_SIZE-1))
|
|
|
|
/* PGDIR_SHIFT determines what a third-level page table entry can map */
|
|
#ifdef CONFIG_SUN3
|
|
#define PGDIR_SHIFT 17
|
|
#elif defined(CONFIG_COLDFIRE)
|
|
#define PGDIR_SHIFT 22
|
|
#else
|
|
#define PGDIR_SHIFT 25
|
|
#endif
|
|
#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
|
|
#define PGDIR_MASK (~(PGDIR_SIZE-1))
|
|
|
|
/*
|
|
* entries per page directory level: the m68k is configured as three-level,
|
|
* so we do have PMD level physically.
|
|
*/
|
|
#ifdef CONFIG_SUN3
|
|
#define PTRS_PER_PTE 16
|
|
#define __PAGETABLE_PMD_FOLDED 1
|
|
#define PTRS_PER_PMD 1
|
|
#define PTRS_PER_PGD 2048
|
|
#elif defined(CONFIG_COLDFIRE)
|
|
#define PTRS_PER_PTE 512
|
|
#define __PAGETABLE_PMD_FOLDED 1
|
|
#define PTRS_PER_PMD 1
|
|
#define PTRS_PER_PGD 1024
|
|
#else
|
|
#define PTRS_PER_PTE 64
|
|
#define PTRS_PER_PMD 128
|
|
#define PTRS_PER_PGD 128
|
|
#endif
|
|
#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
|
|
|
|
/* Virtual address region for use by kernel_map() */
|
|
#ifdef CONFIG_SUN3
|
|
#define KMAP_START 0x0dc00000
|
|
#define KMAP_END 0x0e000000
|
|
#elif defined(CONFIG_COLDFIRE)
|
|
#define KMAP_START 0xe0000000
|
|
#define KMAP_END 0xf0000000
|
|
#elif defined(CONFIG_VIRT)
|
|
#define KMAP_START 0xdf000000
|
|
#define KMAP_END 0xff000000
|
|
#else
|
|
#define KMAP_START 0xd0000000
|
|
#define KMAP_END 0xf0000000
|
|
#endif
|
|
|
|
#ifdef CONFIG_SUN3
|
|
extern unsigned long m68k_vmalloc_end;
|
|
#define VMALLOC_START 0x0f800000
|
|
#define VMALLOC_END m68k_vmalloc_end
|
|
#elif defined(CONFIG_COLDFIRE)
|
|
#define VMALLOC_START 0xd0000000
|
|
#define VMALLOC_END 0xe0000000
|
|
#elif defined(CONFIG_VIRT)
|
|
#define VMALLOC_OFFSET PAGE_SIZE
|
|
#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
|
|
#define VMALLOC_END KMAP_START
|
|
#else
|
|
/* 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
|
|
* any out-of-bounds memory accesses will hopefully be caught.
|
|
* The vmalloc() routines leaves a hole of 4kB between each vmalloced
|
|
* area for the same reason. ;)
|
|
*/
|
|
#define VMALLOC_OFFSET (8*1024*1024)
|
|
#define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
|
|
#define VMALLOC_END KMAP_START
|
|
#endif
|
|
|
|
extern void kernel_set_cachemode(void *addr, unsigned long size, int cmode);
|
|
|
|
/*
|
|
* The m68k doesn't have any external MMU info: the kernel page
|
|
* tables contain all the necessary information. The Sun3 does, but
|
|
* they are updated on demand.
|
|
*/
|
|
static inline void update_mmu_cache_range(struct vm_fault *vmf,
|
|
struct vm_area_struct *vma, unsigned long address,
|
|
pte_t *ptep, unsigned int nr)
|
|
{
|
|
}
|
|
|
|
#define update_mmu_cache(vma, addr, ptep) \
|
|
update_mmu_cache_range(NULL, vma, addr, ptep, 1)
|
|
|
|
#endif /* !__ASSEMBLER__ */
|
|
|
|
/* MMU-specific headers */
|
|
|
|
#ifdef CONFIG_SUN3
|
|
#include <asm/sun3_pgtable.h>
|
|
#elif defined(CONFIG_COLDFIRE)
|
|
#include <asm/mcf_pgtable.h>
|
|
#else
|
|
#include <asm/motorola_pgtable.h>
|
|
#endif
|
|
|
|
#ifndef __ASSEMBLER__
|
|
/*
|
|
* Macro to mark a page protection value as "uncacheable".
|
|
*/
|
|
#ifdef CONFIG_COLDFIRE
|
|
# define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | CF_PAGE_NOCACHE))
|
|
#else
|
|
#ifdef SUN3_PAGE_NOCACHE
|
|
# define __SUN3_PAGE_NOCACHE SUN3_PAGE_NOCACHE
|
|
#else
|
|
# define __SUN3_PAGE_NOCACHE 0
|
|
#endif
|
|
#define pgprot_noncached(prot) \
|
|
(MMU_IS_SUN3 \
|
|
? (__pgprot(pgprot_val(prot) | __SUN3_PAGE_NOCACHE)) \
|
|
: ((MMU_IS_851 || MMU_IS_030) \
|
|
? (__pgprot(pgprot_val(prot) | _PAGE_NOCACHE030)) \
|
|
: (MMU_IS_040 || MMU_IS_060) \
|
|
? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \
|
|
: (prot)))
|
|
|
|
pgprot_t pgprot_dmacoherent(pgprot_t prot);
|
|
#define pgprot_dmacoherent(prot) pgprot_dmacoherent(prot)
|
|
|
|
#endif /* CONFIG_COLDFIRE */
|
|
#endif /* !__ASSEMBLER__ */
|
|
|
|
#endif /* _M68K_PGTABLE_H */
|