Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1556900pxb; Tue, 8 Feb 2022 22:11:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi9cnVdM+6/Wi0gpu/ntwPGSl8DSJN5ZlyC+xFlR3JMnLoulOZXkVdzazrhtKuzBCDUoex X-Received: by 2002:a17:903:2406:: with SMTP id e6mr946424plo.98.1644387074709; Tue, 08 Feb 2022 22:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644387074; cv=none; d=google.com; s=arc-20160816; b=TvXt05j+egL6umP/KoJnrlgu9rBbMZ37/LT2xEjD3zHhqFtQEHD0EkKPnfiGeJ0m94 ctv0eD435FpbP8v26E/PGyEF8PGkuXPFiU1uWi0zlJeLhcU6v1E/4FieS6c+hRcW3Lhe ZDSsMFtYFTZQ1VQUpdqoWey8Xhctu3d8aeNFum4t0Hsrwdbe9rBLPn6gn+GDRfY6h5j+ 5DSxouTj5hmaZP7iadnbpH8d9tNzsc7orpp93uCpf1VlLQ1r5T8GrjoDuP4bhzX4bNUr KpWqQmrhMqNrcBIVAkAQmQ6d4RV9PN4TThUPBNs92XMy86NA9Qc6DyQnIK+MkoFYLUVb YPlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=nG9U1uq39SGzkhhCT8gSrfJH1gaF7SIswNpv0BfeB10=; b=BKsWwLONlyeaW/4jpmgpGHMnB5MPJTqSuGBdsrv9b/inKm/QWiHPzqysvdFsWV76t9 RFPnnu/gEVixxBUMOZdIb+fbEi/fd1QDavqK8uxRZkFEGwucMk/sqw1am2wbbcRss4ib WX0xkRvzsIkfSod/4wkQxbZCSUt7VSTcNvQik1Iqg9qKBWzDCwPM5Uwdd7tgLrUxYush Yvmprw1GkPObyTx1hZA6MpdbHuUMWjfcNapZ1Wfi9cfDbhRVBK6FK1/J0EmqzIrsmEug 5dpHBAIPhcSAr1kKqHplGpNdcq/mCQN7lbvbNm1LxX2Tz535ZW5pfH9znN6ZxIg0NE6P n0yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g19si15030391pfv.121.2022.02.08.22.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:11:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2A0EDF8E3EA; Tue, 8 Feb 2022 21:55:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345743AbiBIEMQ (ORCPT + 99 others); Tue, 8 Feb 2022 23:12:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346302AbiBIDXv (ORCPT ); Tue, 8 Feb 2022 22:23:51 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4568FC061576 for ; Tue, 8 Feb 2022 19:23:50 -0800 (PST) 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 B0CC2ED1; Tue, 8 Feb 2022 19:23:49 -0800 (PST) Received: from [10.163.46.128] (unknown [10.163.46.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 512343F73B; Tue, 8 Feb 2022 19:23:46 -0800 (PST) Subject: Re: [RFC V1 02/31] mm/mmap: Clarify protection_map[] indices To: Firo Yang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hch@infradead.org, akpm@linux-foundation.org References: <1643029028-12710-1-git-send-email-anshuman.khandual@arm.com> <1643029028-12710-3-git-send-email-anshuman.khandual@arm.com> <20220205091048.g3fk4eaw7p7itgil@gmail.com> From: Anshuman Khandual Message-ID: <83958cb9-cca7-1e48-f0c8-0d101dbeebc8@arm.com> Date: Wed, 9 Feb 2022 08:53:44 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20220205091048.g3fk4eaw7p7itgil@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/5/22 2:40 PM, Firo Yang wrote: > The 01/24/2022 18:26, 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. >> >> 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 > > Just a little bit picky:) > Would you mind rearranging vm_flags access commbination in the order as > the access bits appear in __SXXX or __PXXX? For example, change the following: > > [VM_SHARED|VM_READ|VM_WRITE|VM_EXEC] = __S111 > to > [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = __S111 > > I think it's would be more clear for looking. So the vm_flags combination set here (and like in the platforms) should be like the following .. [VM_NONE] [VM_READ] [VM_WRITE] [VM_WRITE | VM_READ] [VM_EXEC] [VM_EXEC|VM_READ] [VM_EXEC|VM_WRITE] [VM_EXEC|VM_WRITE | VM_READ] [VM_SHARED] [VM_SHARED|VM_READ] [VM_SHARED|VM_WRITE] [VM_SHARED|VM_WRITE | VM_READ] [VM_SHARED|VM_EXEC] [VM_SHARED|VM_EXEC | VM_READ] [VM_SHARED|VM_EXEC | VM_WRITE] [VM_SHARED|VM_EXEC | VM_WRITE | VM_READ] Implying the relative position for these flags among each other. [VM_SHARED] [VM_EXEC] [VM_WRITE] [VM_WRITE] This makes sense, will change the series accordingly. - Anshuman