The patch titled Subject: arm64/mm: move protection_map[] inside the platform has been added to the -mm mm-unstable branch. Its filename is arm64-mm-move-protection_map-inside-the-platform.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/arm64-mm-move-protection_map-inside-the-platform.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Anshuman Khandual <anshuman.khandual@xxxxxxx> Subject: arm64/mm: move protection_map[] inside the platform Date: Thu, 30 Jun 2022 10:46:09 +0530 This moves protection_map[] inside the platform and makes it a static. Link: https://lkml.kernel.org/r/20220630051630.1718927-6-anshuman.khandual@xxxxxxx Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/arm64/include/asm/pgtable-prot.h | 18 ------------------ arch/arm64/mm/mmap.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) --- a/arch/arm64/include/asm/pgtable-prot.h~arm64-mm-move-protection_map-inside-the-platform +++ a/arch/arm64/include/asm/pgtable-prot.h @@ -89,24 +89,6 @@ extern bool arm64_use_ng_mappings; #define PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_RDONLY | PTE_NG | PTE_PXN) #define PAGE_EXECONLY __pgprot(_PAGE_DEFAULT | PTE_RDONLY | PTE_NG | PTE_PXN) -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY -#define __P010 PAGE_READONLY -#define __P011 PAGE_READONLY -#define __P100 PAGE_READONLY_EXEC /* PAGE_EXECONLY if Enhanced PAN */ -#define __P101 PAGE_READONLY_EXEC -#define __P110 PAGE_READONLY_EXEC -#define __P111 PAGE_READONLY_EXEC - -#define __S000 PAGE_NONE -#define __S001 PAGE_READONLY -#define __S010 PAGE_SHARED -#define __S011 PAGE_SHARED -#define __S100 PAGE_READONLY_EXEC /* PAGE_EXECONLY if Enhanced PAN */ -#define __S101 PAGE_READONLY_EXEC -#define __S110 PAGE_SHARED_EXEC -#define __S111 PAGE_SHARED_EXEC - #endif /* __ASSEMBLY__ */ #endif /* __ASM_PGTABLE_PROT_H */ --- a/arch/arm64/mm/mmap.c~arm64-mm-move-protection_map-inside-the-platform +++ a/arch/arm64/mm/mmap.c @@ -13,6 +13,27 @@ #include <asm/cpufeature.h> #include <asm/page.h> +static pgprot_t protection_map[16] __ro_after_init = { + [VM_NONE] = PAGE_NONE, + [VM_READ] = PAGE_READONLY, + [VM_WRITE] = PAGE_READONLY, + [VM_WRITE | VM_READ] = PAGE_READONLY, + /* PAGE_EXECONLY if Enhanced PAN */ + [VM_EXEC] = PAGE_READONLY_EXEC, + [VM_EXEC | VM_READ] = PAGE_READONLY_EXEC, + [VM_EXEC | VM_WRITE] = PAGE_READONLY_EXEC, + [VM_EXEC | VM_WRITE | VM_READ] = PAGE_READONLY_EXEC, + [VM_SHARED] = PAGE_NONE, + [VM_SHARED | VM_READ] = PAGE_READONLY, + [VM_SHARED | VM_WRITE] = PAGE_SHARED, + [VM_SHARED | VM_WRITE | VM_READ] = PAGE_SHARED, + /* PAGE_EXECONLY if Enhanced PAN */ + [VM_SHARED | VM_EXEC] = PAGE_READONLY_EXEC, + [VM_SHARED | VM_EXEC | VM_READ] = PAGE_READONLY_EXEC, + [VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_SHARED_EXEC, + [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_SHARED_EXEC +}; + /* * You really shouldn't be using read() or write() on /dev/mem. This might go * away in the future. _ Patches currently in -mm which might be from anshuman.khandual@xxxxxxx are mm-mmap-build-protect-protection_map-with-__p000.patch mm-mmap-define-declare_vm_get_page_prot.patch powerpc-mm-move-protection_map-inside-the-platform.patch sparc-mm-move-protection_map-inside-the-platform.patch arm64-mm-move-protection_map-inside-the-platform.patch x86-mm-move-protection_map-inside-the-platform.patch mm-mmap-build-protect-protection_map-with-arch_has_vm_get_page_prot.patch microblaze-mm-enable-arch_has_vm_get_page_prot.patch loongarch-mm-enable-arch_has_vm_get_page_prot.patch openrisc-mm-enable-arch_has_vm_get_page_prot.patch xtensa-mm-enable-arch_has_vm_get_page_prot.patch hexagon-mm-enable-arch_has_vm_get_page_prot.patch parisc-mm-enable-arch_has_vm_get_page_prot.patch alpha-mm-enable-arch_has_vm_get_page_prot.patch nios2-mm-enable-arch_has_vm_get_page_prot.patch riscv-mm-enable-arch_has_vm_get_page_prot.patch csky-mm-enable-arch_has_vm_get_page_prot.patch s390-mm-enable-arch_has_vm_get_page_prot.patch ia64-mm-enable-arch_has_vm_get_page_prot.patch mips-mm-enable-arch_has_vm_get_page_prot.patch m68k-mm-enable-arch_has_vm_get_page_prot.patch arc-mm-enable-arch_has_vm_get_page_prot.patch arm-mm-enable-arch_has_vm_get_page_prot.patch um-mm-enable-arch_has_vm_get_page_prot.patch sh-mm-enable-arch_has_vm_get_page_prot.patch mm-mmap-drop-arch_has_vm_get_page_prot.patch