Skip to content

Commit

Permalink
arc/mm: enable ARCH_HAS_VM_GET_PAGE_PROT
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Anshuman Khandual <[email protected]>
Cc: Vineet Gupta <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Brian Cain <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Chris Zankel <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Geert Uytterhoeven <[email protected]>
Cc: Guo Ren <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Jeff Dike <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Russell King <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Cc: Stafford Horne <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: WANG Xuerui <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Anshuman Khandual authored and akpm00 committed Jul 18, 2022
1 parent 6d0b922 commit 5d26062
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions arch/arc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ config ARC
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_HAS_VM_GET_PAGE_PROT
select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC
select ARCH_32BIT_OFF_T
select BUILDTIME_TABLE_SORT
Expand Down
18 changes: 0 additions & 18 deletions arch/arc/include/asm/pgtable-bits-arcv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,6 @@
* This is to enable COW mechanism
*/
/* xwr */
#define __P000 PAGE_U_NONE
#define __P001 PAGE_U_R
#define __P010 PAGE_U_R /* Pvt-W => !W */
#define __P011 PAGE_U_R /* Pvt-W => !W */
#define __P100 PAGE_U_X_R /* X => R */
#define __P101 PAGE_U_X_R
#define __P110 PAGE_U_X_R /* Pvt-W => !W and X => R */
#define __P111 PAGE_U_X_R /* Pvt-W => !W */

#define __S000 PAGE_U_NONE
#define __S001 PAGE_U_R
#define __S010 PAGE_U_W_R /* W => R */
#define __S011 PAGE_U_W_R
#define __S100 PAGE_U_X_R /* X => R */
#define __S101 PAGE_U_X_R
#define __S110 PAGE_U_X_W_R /* X => R */
#define __S111 PAGE_U_X_W_R

#ifndef __ASSEMBLY__

#define pte_write(pte) (pte_val(pte) & _PAGE_WRITE)
Expand Down
20 changes: 20 additions & 0 deletions arch/arc/mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,23 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
info.align_offset = pgoff << PAGE_SHIFT;
return vm_unmapped_area(&info);
}

static const pgprot_t protection_map[16] = {
[VM_NONE] = PAGE_U_NONE,
[VM_READ] = PAGE_U_R,
[VM_WRITE] = PAGE_U_R,
[VM_WRITE | VM_READ] = PAGE_U_R,
[VM_EXEC] = PAGE_U_X_R,
[VM_EXEC | VM_READ] = PAGE_U_X_R,
[VM_EXEC | VM_WRITE] = PAGE_U_X_R,
[VM_EXEC | VM_WRITE | VM_READ] = PAGE_U_X_R,
[VM_SHARED] = PAGE_U_NONE,
[VM_SHARED | VM_READ] = PAGE_U_R,
[VM_SHARED | VM_WRITE] = PAGE_U_W_R,
[VM_SHARED | VM_WRITE | VM_READ] = PAGE_U_W_R,
[VM_SHARED | VM_EXEC] = PAGE_U_X_R,
[VM_SHARED | VM_EXEC | VM_READ] = PAGE_U_X_R,
[VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_U_X_W_R,
[VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_U_X_W_R
};
DECLARE_VM_GET_PAGE_PROT

0 comments on commit 5d26062

Please sign in to comment.