From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AEB6C433EF for ; Mon, 24 Jan 2022 12:57:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A55E6B0085; Mon, 24 Jan 2022 07:57:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 908386B0087; Mon, 24 Jan 2022 07:57:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 781746B0088; Mon, 24 Jan 2022 07:57:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id 68ECA6B0085 for ; Mon, 24 Jan 2022 07:57:18 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 099168249980 for ; Mon, 24 Jan 2022 12:57:18 +0000 (UTC) X-FDA: 79065181356.08.BC6A656 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id A176514001C for ; Mon, 24 Jan 2022 12:57:17 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EF7A4D6E; Mon, 24 Jan 2022 04:57:16 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1590B3F774; Mon, 24 Jan 2022 04:57:13 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, hch@infradead.org, akpm@linux-foundation.org, Anshuman Khandual Subject: [RFC V1 02/31] mm/mmap: Clarify protection_map[] indices Date: Mon, 24 Jan 2022 18:26:39 +0530 Message-Id: <1643029028-12710-3-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com> References: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A176514001C X-Stat-Signature: bpihn587mpjyrdm47q6qwtj9gomq4a4a Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-HE-Tag: 1643029037-320576 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- mm/mmap.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1e8fdb0b51ed..254d716220df 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -102,8 +102,22 @@ static void unmap_region(struct mm_struct *mm, * 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_READ|VM_WRITE] = __P011, + [VM_EXEC] = __P100, + [VM_EXEC|VM_READ] = __P101, + [VM_EXEC|VM_WRITE] = __P110, + [VM_EXEC|VM_READ|VM_WRITE] = __P111, + [VM_SHARED] = __S000, + [VM_SHARED|VM_READ] = __S001, + [VM_SHARED|VM_WRITE] = __S010, + [VM_SHARED|VM_READ|VM_WRITE] = __S011, + [VM_SHARED|VM_EXEC] = __S100, + [VM_SHARED|VM_READ|VM_EXEC] = __S101, + [VM_SHARED|VM_WRITE|VM_EXEC] = __S110, + [VM_SHARED|VM_READ|VM_WRITE|VM_EXEC] = __S111 }; #ifndef CONFIG_ARCH_HAS_FILTER_PGPROT -- 2.25.1