]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nios2/mm: enable ARCH_HAS_VM_GET_PAGE_PROT
authorAnshuman Khandual <anshuman.khandual@arm.com>
Mon, 11 Jul 2022 07:05:49 +0000 (12:35 +0530)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 00:14:39 +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-16-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
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: Geert Uytterhoeven <geert@linux-m68k.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 Bogendoerfer <tsbogend@alpha.franken.de>
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/nios2/Kconfig
arch/nios2/include/asm/pgtable.h
arch/nios2/mm/init.c

index 4167f1eb4cd83321333c4c5eea81dfce5646a995..e0459dffd218929729cbe968373170a949706914 100644 (file)
@@ -6,6 +6,7 @@ config NIOS2
        select ARCH_HAS_SYNC_DMA_FOR_CPU
        select ARCH_HAS_SYNC_DMA_FOR_DEVICE
        select ARCH_HAS_DMA_SET_UNCACHED
+       select ARCH_HAS_VM_GET_PAGE_PROT
        select ARCH_NO_SWAP
        select COMMON_CLK
        select TIMER_OF
index 262d0609268cd737a97ae931b2a6fe0cc8d41daf..470516d4555e16621ba48f1f6872e8bd30a0b247 100644 (file)
@@ -40,24 +40,8 @@ struct mm_struct;
  */
 
 /* Remove W bit on private pages for COW support */
-#define __P000 MKP(0, 0, 0)
-#define __P001 MKP(0, 0, 1)
-#define __P010 MKP(0, 0, 0)    /* COW */
-#define __P011 MKP(0, 0, 1)    /* COW */
-#define __P100 MKP(1, 0, 0)
-#define __P101 MKP(1, 0, 1)
-#define __P110 MKP(1, 0, 0)    /* COW */
-#define __P111 MKP(1, 0, 1)    /* COW */
 
 /* Shared pages can have exact HW mapping */
-#define __S000 MKP(0, 0, 0)
-#define __S001 MKP(0, 0, 1)
-#define __S010 MKP(0, 1, 0)
-#define __S011 MKP(0, 1, 1)
-#define __S100 MKP(1, 0, 0)
-#define __S101 MKP(1, 0, 1)
-#define __S110 MKP(1, 1, 0)
-#define __S111 MKP(1, 1, 1)
 
 /* Used all over the kernel */
 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHED | _PAGE_READ | \
index 613fcaa5988a9a8d0c63b5feda553ac77e6136bc..ae24687d12ada8500facaba6ce91041b01323f74 100644 (file)
@@ -124,3 +124,23 @@ const char *arch_vma_name(struct vm_area_struct *vma)
 {
        return (vma->vm_start == KUSER_BASE) ? "[kuser]" : NULL;
 }
+
+static const pgprot_t protection_map[16] = {
+       [VM_NONE]                                       = MKP(0, 0, 0),
+       [VM_READ]                                       = MKP(0, 0, 1),
+       [VM_WRITE]                                      = MKP(0, 0, 0),
+       [VM_WRITE | VM_READ]                            = MKP(0, 0, 1),
+       [VM_EXEC]                                       = MKP(1, 0, 0),
+       [VM_EXEC | VM_READ]                             = MKP(1, 0, 1),
+       [VM_EXEC | VM_WRITE]                            = MKP(1, 0, 0),
+       [VM_EXEC | VM_WRITE | VM_READ]                  = MKP(1, 0, 1),
+       [VM_SHARED]                                     = MKP(0, 0, 0),
+       [VM_SHARED | VM_READ]                           = MKP(0, 0, 1),
+       [VM_SHARED | VM_WRITE]                          = MKP(0, 1, 0),
+       [VM_SHARED | VM_WRITE | VM_READ]                = MKP(0, 1, 1),
+       [VM_SHARED | VM_EXEC]                           = MKP(1, 0, 0),
+       [VM_SHARED | VM_EXEC | VM_READ]                 = MKP(1, 0, 1),
+       [VM_SHARED | VM_EXEC | VM_WRITE]                = MKP(1, 1, 0),
+       [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ]      = MKP(1, 1, 1)
+};
+DECLARE_VM_GET_PAGE_PROT