[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1643029028-12710-32-git-send-email-anshuman.khandual@arm.com>
Date: Mon, 24 Jan 2022 18:27:08 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org, hch@...radead.org,
akpm@...ux-foundation.org,
Anshuman Khandual <anshuman.khandual@....com>
Subject: [RFC V1 31/31] mm/mmap: Define macros for vm_flags access permission combinations
These macros will be useful in cleaning up the all those switch statements
in vm_get_page_prot() across all platforms.
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
---
include/linux/mm.h | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6c0844b99b3e..b3691eeec500 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2828,6 +2828,45 @@ static inline bool range_in_vma(struct vm_area_struct *vma,
return (vma && vma->vm_start <= start && end <= vma->vm_end);
}
+/*
+ * Access permission related vm_flags combination is used to map into
+ * platform defined page protection flags. This enumeration helps in
+ * abstracting out possible indices after vm_flags is probed for all
+ * access permission i.e (VM_SHARED | VM_EXEC | VM_READ | VM_WRITE).
+ *
+ * VM_EXEC ---------------------|
+ * |
+ * VM_WRITE ---------------| |
+ * | |
+ * VM_READ -----------| | |
+ * | | |
+ * VM_SHARED ----| | | |
+ * | | | |
+ * v v v v
+ * VMFLAGS_IDX_(S|X)(R|X)(W|X)(E|X)
+ *
+ * X - Indicates that the access flag is absent
+ */
+enum vmflags_idx {
+ VMFLAGS_IDX_XXXX, /* (VM_NONE) */
+ VMFLAGS_IDX_XRXX, /* (VM_READ) */
+ VMFLAGS_IDX_XXWX, /* (VM_WRITE) */
+ VMFLAGS_IDX_XRWX, /* (VM_READ | VM_WRITE) */
+ VMFLAGS_IDX_XXXE, /* (VM_EXEC) */
+ VMFLAGS_IDX_XRXE, /* (VM_EXEC | VM_READ) */
+ VMFLAGS_IDX_XXWE, /* (VM_EXEC | VM_WRITE) */
+ VMFLAGS_IDX_XRWE, /* (VM_EXEC | VM_READ | VM_WRITE) */
+ VMFLAGS_IDX_SXXX, /* (VM_SHARED | VM_NONE) */
+ VMFLAGS_IDX_SRXX, /* (VM_SHARED | VM_READ) */
+ VMFLAGS_IDX_SXWX, /* (VM_SHARED | VM_WRITE) */
+ VMFLAGS_IDX_SRWX, /* (VM_SHARED | VM_READ | VM_WRITE) */
+ VMFLAGS_IDX_SXXE, /* (VM_SHARED | VM_EXEC) */
+ VMFLAGS_IDX_SRXE, /* (VM_SHARED | VM_EXEC | VM_READ) */
+ VMFLAGS_IDX_SXWE, /* (VM_SHARED | VM_EXEC | VM_WRITE) */
+ VMFLAGS_IDX_SRWE, /* (VM_SHARED | VM_EXEC | VM_READ | VM_WRITE) */
+ VMFLAGS_IDX_MAX
+};
+
#ifdef CONFIG_MMU
pgprot_t vm_get_page_prot(unsigned long vm_flags);
void vma_set_page_prot(struct vm_area_struct *vma);
--
2.25.1
Powered by blists - more mailing lists