mm: define default value for FIRST_USER_ADDRESS
authorAnshuman Khandual <anshuman.khandual@arm.com>
Thu, 1 Jul 2021 01:53:13 +0000 (18:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 18:06:02 +0000 (11:06 -0700)
Currently most platforms define FIRST_USER_ADDRESS as 0UL duplication the
same code all over.  Instead just define a generic default value (i.e 0UL)
for FIRST_USER_ADDRESS and let the platforms override when required.  This
makes it much cleaner with reduced code.

The default FIRST_USER_ADDRESS here would be skipped in <linux/pgtable.h>
when the given platform overrides its value via <asm/pgtable.h>.

Link: https://lkml.kernel.org/r/1620615725-24623-1-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> [m68k]
Acked-by: Guo Ren <guoren@kernel.org> [csky]
Acked-by: Stafford Horne <shorne@gmail.com> [openrisc]
Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Acked-by: Palmer Dabbelt <palmerdabbelt@google.com> [RISC-V]
Cc: Richard Henderson <rth@twiddle.net>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Brian Cain <bcain@codeaurora.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Ley Foon Tan <ley.foon.tan@intel.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Stafford Horne <shorne@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26 files changed:
arch/alpha/include/asm/pgtable.h
arch/arc/include/asm/pgtable.h
arch/arm64/include/asm/pgtable.h
arch/csky/include/asm/pgtable.h
arch/hexagon/include/asm/pgtable.h
arch/ia64/include/asm/pgtable.h
arch/m68k/include/asm/pgtable_mm.h
arch/microblaze/include/asm/pgtable.h
arch/mips/include/asm/pgtable-32.h
arch/mips/include/asm/pgtable-64.h
arch/nios2/include/asm/pgtable.h
arch/openrisc/include/asm/pgtable.h
arch/parisc/include/asm/pgtable.h
arch/powerpc/include/asm/book3s/pgtable.h
arch/powerpc/include/asm/nohash/32/pgtable.h
arch/powerpc/include/asm/nohash/64/pgtable.h
arch/riscv/include/asm/pgtable.h
arch/s390/include/asm/pgtable.h
arch/sh/include/asm/pgtable.h
arch/sparc/include/asm/pgtable_32.h
arch/sparc/include/asm/pgtable_64.h
arch/um/include/asm/pgtable-2level.h
arch/um/include/asm/pgtable-3level.h
arch/x86/include/asm/pgtable_types.h
arch/xtensa/include/asm/pgtable.h
include/linux/pgtable.h

index e1757b7cfe3df52a120b3420347c2f216a103a21..ff690846465e37b4844c8e4b02167461d9e5e13e 100644 (file)
@@ -46,7 +46,6 @@ struct vm_area_struct;
 #define PTRS_PER_PMD   (1UL << (PAGE_SHIFT-3))
 #define PTRS_PER_PGD   (1UL << (PAGE_SHIFT-3))
 #define USER_PTRS_PER_PGD      (TASK_SIZE / PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 
 /* Number of pointers that fit on a page:  this will go away. */
 #define PTRS_PER_PAGE  (1UL << (PAGE_SHIFT-3))
index 5878846f00cfe5913bac2398f187806cebd782b9..577682e8cc7ff8dd67b8f5be9a7d8659d5c4518b 100644 (file)
  */
 #define        USER_PTRS_PER_PGD       (TASK_SIZE / PGDIR_SIZE)
 
-/*
- * No special requirements for lowest virtual address we permit any user space
- * mapping to be mapped at.
- */
-#define FIRST_USER_ADDRESS      0UL
-
 
 /****************************************************************
  * Bucket load of VM Helpers
index 0b10204e72fcbca2586d0106a610833e9f6b194c..25f5c04b43cea10b31752a3c5fad5b1fd2f16a32 100644 (file)
@@ -26,8 +26,6 @@
 
 #define vmemmap                        ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT))
 
-#define FIRST_USER_ADDRESS     0UL
-
 #ifndef __ASSEMBLY__
 
 #include <asm/cmpxchg.h>
index 0d60367b6bfa7db06c10fe639e6cdd8f75fff48b..151607ed5158738b70db6f54aedccc059bb75322 100644 (file)
@@ -14,7 +14,6 @@
 #define PGDIR_MASK             (~(PGDIR_SIZE-1))
 
 #define USER_PTRS_PER_PGD      (PAGE_OFFSET/PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 
 /*
  * C-SKY is two-level paging structure:
index dbb22b80b8c45a6dfe0486385f33d1978a4c1918..e4979508cddf7786dcb8178ed8409902deb8233e 100644 (file)
@@ -155,9 +155,6 @@ extern unsigned long _dflt_cache_att;
 
 extern pgd_t swapper_pg_dir[PTRS_PER_PGD];  /* located in head.S */
 
-/* Seems to be zero even in architectures where the zero page is firewalled? */
-#define FIRST_USER_ADDRESS 0UL
-
 /*  HUGETLB not working currently  */
 #ifdef CONFIG_HUGETLB_PAGE
 #define pte_mkhuge(pte) __pte((pte_val(pte) & ~0x3) | HVM_HUGEPAGE_SIZE)
index d765fd948faec3c5862613a3892c11bba5122227..3f5dbbd8b9d8ce4bd7baa726ecab804e67d439c3 100644 (file)
 #define PTRS_PER_PGD_SHIFT     PTRS_PER_PTD_SHIFT
 #define PTRS_PER_PGD           (1UL << PTRS_PER_PGD_SHIFT)
 #define USER_PTRS_PER_PGD      (5*PTRS_PER_PGD/8)      /* regions 0-4 are user regions */
-#define FIRST_USER_ADDRESS     0UL
 
 /*
  * All the normal masks have the "page accessed" bits on, as any time
index aca22c2c1ee23f4f0f2c467fd1f921014904ed1a..143ba7de9bda1ce18993e5ddb3626566e6483294 100644 (file)
@@ -72,7 +72,6 @@
 #define PTRS_PER_PGD   128
 #endif
 #define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 
 /* Virtual address region for use by kernel_map() */
 #ifdef CONFIG_SUN3
index 9ae8d2c17dd56f2dc565b20773bdb1f8933c64be..71cd547655d9dcb6b14907b93ad9ba343877884c 100644 (file)
@@ -25,8 +25,6 @@ extern int mem_init_done;
 #include <asm/mmu.h>
 #include <asm/page.h>
 
-#define FIRST_USER_ADDRESS     0UL
-
 extern unsigned long va_to_phys(unsigned long address);
 extern pte_t *va_to_pte(unsigned long address);
 
index 6c0532d7b21191a8c0e4eccc1d2ada2acb71f8ad..95df9c293d8d97fd2bb6d7de4d6a5d6f3ca63c46 100644 (file)
@@ -93,7 +93,6 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
 #endif
 
 #define USER_PTRS_PER_PGD      (0x80000000UL/PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 
 #define VMALLOC_START    MAP_BASE
 
index 1e7d6ce9d8d62f251dda5a114457f5dc2a985048..046465906c825e20a36b8179aad65e488a9e3837 100644 (file)
 #define PTRS_PER_PTE   ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
 
 #define USER_PTRS_PER_PGD       ((TASK_SIZE64 / PGDIR_SIZE)?(TASK_SIZE64 / PGDIR_SIZE):1)
-#define FIRST_USER_ADDRESS     0UL
 
 /*
  * TLB refill handlers also map the vmalloc area into xuseg.  Avoid
index 2600d76c310c4a9aa84f49148b81d2fc0fa8bf39..4a995fa628eef81e386d8530de1fca17d5a98bc7 100644 (file)
@@ -24,8 +24,6 @@
 #include <asm/pgtable-bits.h>
 #include <asm-generic/pgtable-nopmd.h>
 
-#define FIRST_USER_ADDRESS     0UL
-
 #define VMALLOC_START          CONFIG_NIOS2_KERNEL_MMU_REGION_BASE
 #define VMALLOC_END            (CONFIG_NIOS2_KERNEL_REGION_BASE - 1)
 
index 9425bedab4fc84814c831818c4d9403c1d578843..4ac591c9ca33becd5467eee8b6347767929a1124 100644 (file)
@@ -73,7 +73,6 @@ extern void paging_init(void);
  */
 
 #define USER_PTRS_PER_PGD       (TASK_SIZE/PGDIR_SIZE)
-#define FIRST_USER_ADDRESS      0UL
 
 /*
  * Kernels own virtual memory area.
index 39017210dbf06135123ab98ea6aacc710aaac51c..7f33c29764cc18bc9d9818663983323b54977ee4 100644 (file)
@@ -171,8 +171,6 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
  * pgd entries used up by user/kernel:
  */
 
-#define FIRST_USER_ADDRESS     0UL
-
 /* NB: The tlb miss handlers make certain assumptions about the order */
 /*     of the following bits, so be careful (One example, bits 25-31  */
 /*     are moved together in one instruction).                        */
index 0e1263455d737f2016f39af28cc495c456ccde25..ad130e15a126f39a98257860a17e4e34d198d322 100644 (file)
@@ -8,7 +8,6 @@
 #include <asm/book3s/32/pgtable.h>
 #endif
 
-#define FIRST_USER_ADDRESS     0UL
 #ifndef __ASSEMBLY__
 /* Insert a PTE, top-level function is out of line. It uses an inline
  * low level function in the respective pgtable-* files
index 96522f7f0618a0eb9096858f2b63ff2b98bc3046..f06ae00f2a65e9d910eeef363622ae98485ad629 100644 (file)
@@ -54,7 +54,6 @@ extern int icache_44x_need_flush;
 #define PGD_MASKED_BITS                0
 
 #define USER_PTRS_PER_PGD      (TASK_SIZE / PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 
 #define pte_ERROR(e) \
        pr_err("%s:%d: bad pte %llx.\n", __FILE__, __LINE__, \
index 57cd3892bfe05237231e929fb1284612d9d13cbe..53fbfdfac93d04eea63370c5c87d49f0d3c4e0fa 100644 (file)
@@ -12,8 +12,6 @@
 #include <asm/barrier.h>
 #include <asm/asm-const.h>
 
-#define FIRST_USER_ADDRESS     0UL
-
 /*
  * Size of EA range mapped by our pagetables.
  */
index 380cd3a7e5483291943d0f7683d7a380e6dc21ea..62f3fe7368f39bef7e5d4239b20588e4381cf118 100644 (file)
@@ -536,8 +536,6 @@ void setup_bootmem(void);
 void paging_init(void);
 void misc_mem_init(void);
 
-#define FIRST_USER_ADDRESS  0
-
 /*
  * ZERO_PAGE is a global shared page that is always zero,
  * used for zero-mapped memory areas, etc.
index b38f7b7815649cf4f3889d998cb8d3bbed04beb4..7c86bf03fc8f0feffc3f4638855fcf87877f7046 100644 (file)
@@ -65,8 +65,6 @@ extern unsigned long zero_page_mask;
 
 /* TODO: s390 cannot support io_remap_pfn_range... */
 
-#define FIRST_USER_ADDRESS  0UL
-
 #define pte_ERROR(e) \
        printk("%s:%d: bad pte %p.\n", __FILE__, __LINE__, (void *) pte_val(e))
 #define pmd_ERROR(e) \
index 27751e9470df3c2ef1293cd7d02d86cdd2af39fc..d7ddb1ec86a03213ecf3121bea40057b695b5eb9 100644 (file)
@@ -59,8 +59,6 @@ static inline unsigned long long neff_sign_extend(unsigned long val)
 /* Entries per level */
 #define PTRS_PER_PTE   (PAGE_SIZE / (1 << PTE_MAGNITUDE))
 
-#define FIRST_USER_ADDRESS     0UL
-
 #define PHYS_ADDR_MASK29               0x1fffffff
 #define PHYS_ADDR_MASK32               0xffffffff
 
index a5cf79c149fef574d75612db52d24a3c26b71baf..0888bda245f5334913e66b00825289ef39d647f9 100644 (file)
@@ -48,7 +48,6 @@ unsigned long __init bootmem_init(unsigned long *pages_avail);
 #define PTRS_PER_PMD           64
 #define PTRS_PER_PGD           256
 #define USER_PTRS_PER_PGD      PAGE_OFFSET / PGDIR_SIZE
-#define FIRST_USER_ADDRESS     0UL
 #define PTE_SIZE               (PTRS_PER_PTE*4)
 
 #define PAGE_NONE      SRMMU_PAGE_NONE
index 2cd80a0a97953f55d778995dec624ee0e971dfd8..a400e0f2304651213cbd9d2a1bc8b35645f44278 100644 (file)
@@ -95,9 +95,6 @@ bool kern_addr_valid(unsigned long addr);
 #define PTRS_PER_PUD   (1UL << PUD_BITS)
 #define PTRS_PER_PGD   (1UL << PGDIR_BITS)
 
-/* Kernel has a separate 44bit address space. */
-#define FIRST_USER_ADDRESS     0UL
-
 #define pmd_ERROR(e)                                                   \
        pr_err("%s:%d: bad pmd %p(%016lx) seen at (%pS)\n",             \
               __FILE__, __LINE__, &(e), pmd_val(e), __builtin_return_address(0))
index 32106d31e4ab277a1d5fd2c690b8d6e54fc73420..8256ecc5b919865b1bd2e1152fa40536c6feac96 100644 (file)
@@ -23,7 +23,6 @@
 #define PTRS_PER_PTE   1024
 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)
 #define PTRS_PER_PGD   1024
-#define FIRST_USER_ADDRESS     0UL
 
 #define pte_ERROR(e) \
         printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), \
index 7e6a4180db9d31c18534b9047a3977228591b70c..9289a86643a9d2ca0d3d07bb9c9b3acb708593ae 100644 (file)
@@ -41,7 +41,6 @@
 #endif
 
 #define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 
 #define pte_ERROR(e) \
         printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \
index f24d7ef8fffae6f87e7c3b0bd36f81dc3f9781c9..40497a9020c6eb7f42eadc498cdd3b70325e219a 100644 (file)
@@ -7,8 +7,6 @@
 
 #include <asm/page_types.h>
 
-#define FIRST_USER_ADDRESS     0UL
-
 #define _PAGE_BIT_PRESENT      0       /* is present */
 #define _PAGE_BIT_RW           1       /* writeable */
 #define _PAGE_BIT_USER         2       /* userspace addressable */
index d7fc45c920c2b41ca165244cd1b4ea65a8806710..bd5aeb795567512da4463325cc3a093e1e735a51 100644 (file)
@@ -59,7 +59,6 @@
 #define PTRS_PER_PGD           1024
 #define PGD_ORDER              0
 #define USER_PTRS_PER_PGD      (TASK_SIZE/PGDIR_SIZE)
-#define FIRST_USER_ADDRESS     0UL
 #define FIRST_USER_PGD_NR      (FIRST_USER_ADDRESS >> PGDIR_SHIFT)
 
 #ifdef CONFIG_MMU
index 2b0d02291178e0501d60e8c18a335990309d9658..69700e3e615fc49a70a25eab6c1e401d3e0deb15 100644 (file)
 #define USER_PGTABLES_CEILING  0UL
 #endif
 
+/*
+ * This defines the first usable user address. Platforms
+ * can override its value with custom FIRST_USER_ADDRESS
+ * defined in their respective <asm/pgtable.h>.
+ */
+#ifndef FIRST_USER_ADDRESS
+#define FIRST_USER_ADDRESS     0UL
+#endif
+
 /*
  * A page table page can be thought of an array like this: pXd_t[PTRS_PER_PxD]
  *