Commit 6d0b9225 authored by Anshuman Khandual's avatar Anshuman Khandual Committed by Andrew Morton
Browse files

m68k/mm: enable ARCH_HAS_VM_GET_PAGE_PROT

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: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarGeert 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: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 499c1dd9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+0 −59
Original line number Diff line number Diff line
@@ -86,65 +86,6 @@
				 | 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)

+0 −29
Original line number Diff line number Diff line
@@ -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))

/*
+0 −23
Original line number Diff line number Diff line
@@ -66,29 +66,6 @@
				 | 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)
+55 −0
Original line number Diff line number Diff line
@@ -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
Loading