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 5E055C433EF for ; Thu, 27 Jan 2022 12:40:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D09696B0071; Thu, 27 Jan 2022 07:40:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C928A6B0072; Thu, 27 Jan 2022 07:40:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5BCB6B0073; Thu, 27 Jan 2022 07:40:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id A62E26B0071 for ; Thu, 27 Jan 2022 07:40:10 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 637378E3E6 for ; Thu, 27 Jan 2022 12:40:10 +0000 (UTC) X-FDA: 79076024580.11.198D3AF Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf31.hostedemail.com (Postfix) with ESMTP id 1111520029 for ; Thu, 27 Jan 2022 12:40:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2FCC3B82213; Thu, 27 Jan 2022 12:40:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0858EC340E4; Thu, 27 Jan 2022 12:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643287206; bh=JnlBSQS1AFrenlZcFKIvZzSqaAGifybnUZXObr1eoag=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i/v/gSJJHYSymievjsJE2D9V15USSFVUI1g2oB3UR1s4BPya1TcsGj7M4TdbrG3xv ztjXQHi3pp8UBwrUZ8obIw0pM8fLI6sx99gHlhSF8jq8AwOKZ53La9gk20/WPxKiiG IcbjS+SYB/2tekd19VNeX55R2V4hsxNw2ANt8VuorrTtfXJ1DJHRh3L0wffyPuenxY TdbY651ULXJ+kvXGbwb/vuEFuiNsuq6ZbPg4d5zSfykjBTP1LPifQqMygm8es8nGm1 AHqDuJqYU1npqy3VT3HZXloMaKr3WgFqb1JYUc08m7GAW5TVhH5SqmW+HBmApGHVr0 twLvNlaYwDx3g== Date: Thu, 27 Jan 2022 14:39:59 +0200 From: Mike Rapoport To: Anshuman Khandual Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@infradead.org, akpm@linux-foundation.org Subject: Re: [RFC V1 02/31] mm/mmap: Clarify protection_map[] indices Message-ID: References: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com> <1643029028-12710-3-git-send-email-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1643029028-12710-3-git-send-email-anshuman.khandual@arm.com> X-Rspamd-Queue-Id: 1111520029 X-Rspam-User: nil Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="i/v/gSJJ"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf31.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Stat-Signature: 6fmcsqb7nccns755dpporqzr4cgcsm7q X-Rspamd-Server: rspam08 X-HE-Tag: 1643287208-817163 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: On Mon, Jan 24, 2022 at 06:26:39PM +0530, Anshuman Khandual wrote: > 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. The protection_map is going to be removed in one of the next patches, why bother with this patch at all? > 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 > > -- Sincerely yours, Mike.