]> git.baikalelectronics.ru Git - kernel.git/commitdiff
m68k/mm: enable ARCH_HAS_VM_GET_PAGE_PROT
authorAnshuman Khandual <anshuman.khandual@arm.com>
Mon, 11 Jul 2022 07:05:55 +0000 (12:35 +0530)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 00:14:40 +0000 (17:14 -0700)
This enables ARCH_HAS_VM_GET_PAGE_PROT on the platform and exports
standard vm_get_page_prot() implementation via DECLARE_VM_GET_PAGE_PROT,
which looks up a private and static protection_map[] array.  Subsequently
all __SXXX and __PXXX macros can be dropped which are no longer needed.

Link: https://lkml.kernel.org/r/20220711070600.2378316-22-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Brian Cain <bcain@quicinc.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Will Deacon <will@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/m68k/Kconfig
arch/m68k/include/asm/mcf_pgtable.h
arch/m68k/include/asm/motorola_pgtable.h
arch/m68k/include/asm/sun3_pgtable.h
arch/m68k/mm/mcfmmu.c
arch/m68k/mm/motorola.c
arch/m68k/mm/sun3mmu.c

index 936cce42ae9aa7541277c843e6d1fffc08856f07..49aa0cf13e96acfea7609e46175cd4792e6adba7 100644 (file)
@@ -7,6 +7,7 @@ config M68K
        select ARCH_HAS_CURRENT_STACK_POINTER
        select ARCH_HAS_DMA_PREP_COHERENT if HAS_DMA && MMU && !COLDFIRE
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA
+       select ARCH_HAS_VM_GET_PAGE_PROT
        select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
        select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
        select ARCH_NO_PREEMPT if !COLDFIRE
index 94f38d76e2780986fe874281affcdc288b95a680..b619b22823f840b374ed85b4b3aa10edc44a65ef 100644 (file)
                                 | CF_PAGE_READABLE \
                                 | CF_PAGE_DIRTY)
 
-/*
- * Page protections for initialising protection_map. See mm/mmap.c
- * for use. In general, the bit positions are xwr, and P-items are
- * private, the S-items are shared.
- */
-#define __P000         PAGE_NONE
-#define __P001         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_READABLE)
-#define __P010         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_WRITABLE)
-#define __P011         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_READABLE \
-                                | CF_PAGE_WRITABLE)
-#define __P100         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_EXEC)
-#define __P101         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_READABLE \
-                                | CF_PAGE_EXEC)
-#define __P110         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_WRITABLE \
-                                | CF_PAGE_EXEC)
-#define __P111         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_READABLE \
-                                | CF_PAGE_WRITABLE \
-                                | CF_PAGE_EXEC)
-
-#define __S000         PAGE_NONE
-#define __S001         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_READABLE)
-#define __S010         PAGE_SHARED
-#define __S011         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_SHARED \
-                                | CF_PAGE_READABLE)
-#define __S100         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_EXEC)
-#define __S101         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_READABLE \
-                                | CF_PAGE_EXEC)
-#define __S110         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_SHARED \
-                                | CF_PAGE_EXEC)
-#define __S111         __pgprot(CF_PAGE_VALID \
-                                | CF_PAGE_ACCESSED \
-                                | CF_PAGE_SHARED \
-                                | CF_PAGE_READABLE \
-                                | CF_PAGE_EXEC)
-
 #define PTE_MASK       PAGE_MASK
 #define CF_PAGE_CHG_MASK (PTE_MASK | CF_PAGE_ACCESSED | CF_PAGE_DIRTY)
 
index 7c9b56e2a7509d90c4ae498c1831cbb9d0eb6c88..7ac3d64c6b33e9d01a0159b8ea8c938b3130a033 100644 (file)
@@ -76,35 +76,6 @@ extern unsigned long mm_cachebits;
 #define PAGE_READONLY  __pgprot(_PAGE_PRESENT | _PAGE_RONLY | _PAGE_ACCESSED | mm_cachebits)
 #define PAGE_KERNEL    __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | mm_cachebits)
 
-/* Alternate definitions that are compile time constants, for
-   initializing protection_map.  The cachebits are fixed later.  */
-#define PAGE_NONE_C    __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
-#define PAGE_SHARED_C  __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
-#define PAGE_COPY_C    __pgprot(_PAGE_PRESENT | _PAGE_RONLY | _PAGE_ACCESSED)
-#define PAGE_READONLY_C        __pgprot(_PAGE_PRESENT | _PAGE_RONLY | _PAGE_ACCESSED)
-
-/*
- * The m68k can't do page protection for execute, and considers that the same are read.
- * Also, write permissions imply read permissions. This is the closest we can get..
- */
-#define __P000 PAGE_NONE_C
-#define __P001 PAGE_READONLY_C
-#define __P010 PAGE_COPY_C
-#define __P011 PAGE_COPY_C
-#define __P100 PAGE_READONLY_C
-#define __P101 PAGE_READONLY_C
-#define __P110 PAGE_COPY_C
-#define __P111 PAGE_COPY_C
-
-#define __S000 PAGE_NONE_C
-#define __S001 PAGE_READONLY_C
-#define __S010 PAGE_SHARED_C
-#define __S011 PAGE_SHARED_C
-#define __S100 PAGE_READONLY_C
-#define __S101 PAGE_READONLY_C
-#define __S110 PAGE_SHARED_C
-#define __S111 PAGE_SHARED_C
-
 #define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd))
 
 /*
index 5e4e753f0d246d2a8bb8157bdd0712d343accfd3..90d57e537eb1455ca31d6082db3f39e1053a6c94 100644 (file)
                                 | SUN3_PAGE_SYSTEM \
                                 | SUN3_PAGE_NOCACHE)
 
-/*
- * Page protections for initialising protection_map. The sun3 has only two
- * protection settings, valid (implying read and execute) and writeable. These
- * are as close as we can get...
- */
-#define __P000 PAGE_NONE
-#define __P001 PAGE_READONLY
-#define __P010 PAGE_COPY
-#define __P011 PAGE_COPY
-#define __P100 PAGE_READONLY
-#define __P101 PAGE_READONLY
-#define __P110 PAGE_COPY
-#define __P111 PAGE_COPY
-
-#define __S000 PAGE_NONE
-#define __S001 PAGE_READONLY
-#define __S010 PAGE_SHARED
-#define __S011 PAGE_SHARED
-#define __S100 PAGE_READONLY
-#define __S101 PAGE_READONLY
-#define __S110 PAGE_SHARED
-#define __S111 PAGE_SHARED
-
 /* Use these fake page-protections on PMDs. */
 #define SUN3_PMD_VALID (0x00000001)
 #define SUN3_PMD_MASK  (0x0000003F)
index 6f1f251252944b15bceaeb033ad3a323a822bf52..70aa0979e02710a8d1db820b84f05dcffc93a9f6 100644 (file)
@@ -234,3 +234,58 @@ void steal_context(void)
        destroy_context(mm);
 }
 
+static const pgprot_t protection_map[16] = {
+       [VM_NONE]                                       = PAGE_NONE,
+       [VM_READ]                                       = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE),
+       [VM_WRITE]                                      = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_WRITABLE),
+       [VM_WRITE | VM_READ]                            = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE |
+                                                                  CF_PAGE_WRITABLE),
+       [VM_EXEC]                                       = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_EXEC),
+       [VM_EXEC | VM_READ]                             = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE |
+                                                                  CF_PAGE_EXEC),
+       [VM_EXEC | VM_WRITE]                            = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_WRITABLE |
+                                                                  CF_PAGE_EXEC),
+       [VM_EXEC | VM_WRITE | VM_READ]                  =  __pgprot(CF_PAGE_VALID |
+                                                                   CF_PAGE_ACCESSED |
+                                                                   CF_PAGE_READABLE |
+                                                                   CF_PAGE_WRITABLE |
+                                                                   CF_PAGE_EXEC),
+       [VM_SHARED]                                     = PAGE_NONE,
+       [VM_SHARED | VM_READ]                           = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE),
+       [VM_SHARED | VM_WRITE]                          = PAGE_SHARED,
+       [VM_SHARED | VM_WRITE | VM_READ]                = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE |
+                                                                  CF_PAGE_SHARED),
+       [VM_SHARED | VM_EXEC]                           = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_EXEC),
+       [VM_SHARED | VM_EXEC | VM_READ]                 = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE |
+                                                                  CF_PAGE_EXEC),
+       [VM_SHARED | VM_EXEC | VM_WRITE]                = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_SHARED |
+                                                                  CF_PAGE_EXEC),
+       [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ]      = __pgprot(CF_PAGE_VALID |
+                                                                  CF_PAGE_ACCESSED |
+                                                                  CF_PAGE_READABLE |
+                                                                  CF_PAGE_SHARED |
+                                                                  CF_PAGE_EXEC)
+};
+DECLARE_VM_GET_PAGE_PROT
index df7f797c908a2c28fc8456ce4570c7a54da822a3..2a375637e0077852ed86abf7b9310bc872f345b4 100644 (file)
@@ -382,6 +382,35 @@ static void __init map_node(int node)
 #endif
 }
 
+/*
+ * Alternate definitions that are compile time constants, for
+ * initializing protection_map.  The cachebits are fixed later.
+ */
+#define PAGE_NONE_C    __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
+#define PAGE_SHARED_C  __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
+#define PAGE_COPY_C    __pgprot(_PAGE_PRESENT | _PAGE_RONLY | _PAGE_ACCESSED)
+#define PAGE_READONLY_C        __pgprot(_PAGE_PRESENT | _PAGE_RONLY | _PAGE_ACCESSED)
+
+static pgprot_t protection_map[16] __ro_after_init = {
+       [VM_NONE]                                       = PAGE_NONE_C,
+       [VM_READ]                                       = PAGE_READONLY_C,
+       [VM_WRITE]                                      = PAGE_COPY_C,
+       [VM_WRITE | VM_READ]                            = PAGE_COPY_C,
+       [VM_EXEC]                                       = PAGE_READONLY_C,
+       [VM_EXEC | VM_READ]                             = PAGE_READONLY_C,
+       [VM_EXEC | VM_WRITE]                            = PAGE_COPY_C,
+       [VM_EXEC | VM_WRITE | VM_READ]                  = PAGE_COPY_C,
+       [VM_SHARED]                                     = PAGE_NONE_C,
+       [VM_SHARED | VM_READ]                           = PAGE_READONLY_C,
+       [VM_SHARED | VM_WRITE]                          = PAGE_SHARED_C,
+       [VM_SHARED | VM_WRITE | VM_READ]                = PAGE_SHARED_C,
+       [VM_SHARED | VM_EXEC]                           = PAGE_READONLY_C,
+       [VM_SHARED | VM_EXEC | VM_READ]                 = PAGE_READONLY_C,
+       [VM_SHARED | VM_EXEC | VM_WRITE]                = PAGE_SHARED_C,
+       [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ]      = PAGE_SHARED_C
+};
+DECLARE_VM_GET_PAGE_PROT
+
 /*
  * paging_init() continues the virtual memory environment setup which
  * was begun by the code in arch/head.S.
index dad494224497286336232f6d9fb3fbc29edb6bcf..b619d0d4319cc2595c032b7f8604ec1d6c33f800 100644 (file)
@@ -95,3 +95,23 @@ void __init paging_init(void)
 
 
 }
+
+static const pgprot_t protection_map[16] = {
+       [VM_NONE]                                       = PAGE_NONE,
+       [VM_READ]                                       = PAGE_READONLY,
+       [VM_WRITE]                                      = PAGE_COPY,
+       [VM_WRITE | VM_READ]                            = PAGE_COPY,
+       [VM_EXEC]                                       = PAGE_READONLY,
+       [VM_EXEC | VM_READ]                             = PAGE_READONLY,
+       [VM_EXEC | VM_WRITE]                            = PAGE_COPY,
+       [VM_EXEC | VM_WRITE | VM_READ]                  = PAGE_COPY,
+       [VM_SHARED]                                     = PAGE_NONE,
+       [VM_SHARED | VM_READ]                           = PAGE_READONLY,
+       [VM_SHARED | VM_WRITE]                          = PAGE_SHARED,
+       [VM_SHARED | VM_WRITE | VM_READ]                = PAGE_SHARED,
+       [VM_SHARED | VM_EXEC]                           = PAGE_READONLY,
+       [VM_SHARED | VM_EXEC | VM_READ]                 = PAGE_READONLY,
+       [VM_SHARED | VM_EXEC | VM_WRITE]                = PAGE_SHARED,
+       [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ]      = PAGE_SHARED
+};
+DECLARE_VM_GET_PAGE_PROT