Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3518311pxb; Mon, 24 Jan 2022 11:14:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsgNCatrkG/3JcL5GrEaMJ1Yr4vnZSvcjxrJO0TY59nvGeDpoi9kJ2m5nB+fwU2Y9SL9CO X-Received: by 2002:a17:902:c94e:b0:14b:6728:4d9f with SMTP id i14-20020a170902c94e00b0014b67284d9fmr2318611pla.84.1643051661854; Mon, 24 Jan 2022 11:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051661; cv=none; d=google.com; s=arc-20160816; b=0OJx3E7MdB7n1vug/2C8dhc9wKfh3CBce7EXJpnwnJ3T6YFkRSTV+tIMMK3bzeODBZ vnN48jUoc1BcwqQqf/bYDzj/GR8rC3Fhtm2cukJL9HIVa42NeLK3Hun8rRW/5Kp4TfPZ 1zIDwtwAJXlT1ygGz31wnVleGVPpecRoDxNJfk9ejqD04UdicpQCgsaRNnnBPEcWs5/M EGtoHfv7KBlXUAJRj1S497Q01WnG3qpewNu577x+aoV4zsKwCBzWJYCiJcbw9Zrl9sVC E4WFzLFO+Ipc8K1FNFRJ7pAkyYjCH1YS1AINxfopEnZ+gdqZdGszQ6bWHAAj4RW3X/0o XSpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Ls87Pp3QJEG5cNNa7qT1DbjwaE0TWJ8LFZi3xSPy4dI=; b=W2ODgAIeFMtnHuTWDx4lwOmPz8GYbqLzfsVGykPofdfBBD3qXCA/vE9w7gNbpr+pbH GnqeWNsu4a/jf3exJEtF5kRwjBMtEDhR965AI0FDN96sCZ9ad+hffgYy1o1u8pRl9ZJu ytLN9aZICZ+Y4F2vLlTdw7gIYEWrOpfBCD9vA6Fp+4Bcm+nl+NLpLeuxCKHb6P1W0ho3 yQziYvx0+Ehg/lA2Qg2hOfGz4gWYGugXwsgFOTkWHvMzj0l9MxS3cgdKzzVP2fKR5gFm xgkFouGUo0q9xjGufJVQCsWIYA888BbuCC9h+3Z07VxnxWD91W+JcviieLES4EDRZQZC yGYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si7272952pgv.433.2022.01.24.11.14.09; Mon, 24 Jan 2022 11:14:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242715AbiAXM50 (ORCPT + 99 others); Mon, 24 Jan 2022 07:57:26 -0500 Received: from foss.arm.com ([217.140.110.172]:32844 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242629AbiAXM5R (ORCPT ); Mon, 24 Jan 2022 07:57:17 -0500 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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