The patch titled Subject: mm/mmap: clarify protection_map[] indices has been added to the -mm tree. Its filename is mm-mmap-clarify-protection_map-indices.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-mmap-clarify-protection_map-indices.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-mmap-clarify-protection_map-indices.patch 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 and is updated there every 3-4 working days ------------------------------------------------------ From: Anshuman Khandual <anshuman.khandual@xxxxxxx> Subject: mm/mmap: clarify protection_map[] indices protection_map[] maps vm_flags access combinations into page protection value as defined by the platform via __PXXX and __SXXX macros. The array indices in protection_map[], represents vm_flags access combinations but it's not very intuitive to derive. This makes it clear and explicit. Link: https://lkml.kernel.org/r/1645425519-9034-3-git-send-email-anshuman.khandual@xxxxxxx Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mmap.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/mm/mmap.c~mm-mmap-clarify-protection_map-indices +++ a/mm/mmap.c @@ -102,8 +102,22 @@ static void unmap_region(struct mm_struc * x: (yes) yes */ pgprot_t protection_map[16] __ro_after_init = { - __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, - __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111 + [VM_NONE] = __P000, + [VM_READ] = __P001, + [VM_WRITE] = __P010, + [VM_WRITE | VM_READ] = __P011, + [VM_EXEC] = __P100, + [VM_EXEC | VM_READ] = __P101, + [VM_EXEC | VM_WRITE] = __P110, + [VM_EXEC | VM_WRITE | VM_READ] = __P111, + [VM_SHARED] = __S000, + [VM_SHARED | VM_READ] = __S001, + [VM_SHARED | VM_WRITE] = __S010, + [VM_SHARED | VM_WRITE | VM_READ] = __S011, + [VM_SHARED | VM_EXEC] = __S100, + [VM_SHARED | VM_EXEC | VM_READ] = __S101, + [VM_SHARED | VM_EXEC | VM_WRITE] = __S110, + [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = __S111 }; #ifndef CONFIG_ARCH_HAS_FILTER_PGPROT _ Patches currently in -mm which might be from anshuman.khandual@xxxxxxx are mm-generalize-arch_has_filter_pgprot.patch mm-merge-pte_mkhuge-call-into-arch_make_huge_pte.patch mm-debug_vm_pgtable-drop-protection_map-usage.patch mm-mmap-clarify-protection_map-indices.patch mm-mmap-add-new-config-arch_has_vm_get_page_prot.patch powerpc-mm-enable-arch_has_vm_get_page_prot.patch arm64-mm-enable-arch_has_vm_get_page_prot.patch sparc-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 arm-mm-enable-arch_has_vm_get_page_prot.patch mm-mmap-drop-protection_map.patch mm-mmap-drop-arch_filter_pgprot.patch mm-mmap-drop-arch_vm_get_page_pgprot.patch s390-mm-enable-arch_has_vm_get_page_prot.patch riscv-mm-enable-arch_has_vm_get_page_prot.patch alpha-mm-enable-arch_has_vm_get_page_prot.patch sh-mm-enable-arch_has_vm_get_page_prot.patch arc-mm-enable-arch_has_vm_get_page_prot.patch csky-mm-enable-arch_has_vm_get_page_prot.patch extensa-mm-enable-arch_has_vm_get_page_prot.patch parisc-mm-enable-arch_has_vm_get_page_prot.patch openrisc-mm-enable-arch_has_vm_get_page_prot.patch um-mm-enable-arch_has_vm_get_page_prot.patch microblaze-mm-enable-arch_has_vm_get_page_prot.patch nios2-mm-enable-arch_has_vm_get_page_prot.patch hexagon-mm-enable-arch_has_vm_get_page_prot.patch nds32-mm-enable-arch_has_vm_get_page_prot.patch ia64-mm-enable-arch_has_vm_get_page_prot.patch mm-mmap-drop-generic-vm_get_page_prot.patch mm-mmap-drop-arch_has_vm_get_page_prot.patch mm-hugetlb-generalize-arch_want_general_hugetlb.patch mm-migration-add-trace-events-for-thp-migrations.patch mm-migration-add-trace-events-for-base-page-and-hugetlb-migrations.patch