Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp40509iog; Thu, 23 Jun 2022 21:50:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhfRkeqMPy0etJr1H2gokGlSr7mFN49o2DHV6H/IocCM+QY4i07Do2PdurXbmuweLZVwkA X-Received: by 2002:a17:90a:b797:b0:1ea:c49d:1070 with SMTP id m23-20020a17090ab79700b001eac49d1070mr1718534pjr.175.1656046200172; Thu, 23 Jun 2022 21:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656046200; cv=none; d=google.com; s=arc-20160816; b=Ruirah1l29CGvKGeKIqffVIZU3oDhwibi2zRqHW9AJsIrAjP/+kQeeWgFmGd2iT3Xc ejPGkCoCbfL+hcVA14MZv4Z3Ai7lORvRveC2XpS09EZ3U7TkREBR7eHqH/A259k3wuxC aO/pKKwn4Hg3CdAUWoUec63H0ThL7vyE2AOKbX13b3MPbDS9TE3CQQomdo0qx7GwliFR eB3ohFOkv7u0STio6zdlKRnaQLt1iUvBfWxCtF5JzHbgY2T9o1hisfyKiz2HsrJnvK5Z 9g9BlI5xuE50WhOIGkPGibllvTBjfxZQUiGqROGz0y8jGHnjDRAsmfUza9BXTfmHSE7B Rvgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pjQOiA3wM6fmRDHVYkACn/fw9zCElox8m5yPdWh9Nxg=; b=mqS739LFopMSJ2wZXnsVggXg9Y+oCAPLhcQayyCmQz6EP8POVA33shMjxa1ypPIcHi QNnzct/oTRQeVaYo0Gx7Oy0nYZPZk7E0qUuO1DUaojqW7lM8JJw0Wdb0hZ/LMw6FgKpr uI1ACCNS+92omMy+rcw/pC/rx9g6ciI2P9YWJUcjy8eByYxJNZSyNPBf1LKB5Nt3ym7K fz+WHCnWdbnpfdHopHMoTEv5hLQO6A0kcO4cu2HeZmGvszt3+i7DwqY4ERHZnNlMkdYL 5psmtiF5QG+koTrMcUWRB/WmrE27dBcbpc8cVE9KJe0usuh2n5e/GsC0YDCOUj07nmQl qAMw== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a170902e55200b0016754f4f654si2072572plf.529.2022.06.23.21.49.48; Thu, 23 Jun 2022 21:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230411AbiFXEsx (ORCPT + 99 others); Fri, 24 Jun 2022 00:48:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231812AbiFXErm (ORCPT ); Fri, 24 Jun 2022 00:47:42 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F39BA6B8DE; Thu, 23 Jun 2022 21:46:55 -0700 (PDT) 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 4B8F7175A; Thu, 23 Jun 2022 21:46:55 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.41.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AF58B3F66F; Thu, 23 Jun 2022 21:46:47 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: hch@infradead.org, christophe.leroy@csgroup.eu, Anshuman Khandual , Andrew Morton , linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, x86@kernel.org, openrisc@lists.librecores.org, linux-xtensa@linux-xtensa.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-parisc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-um@lists.infradead.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Gupta Subject: [PATCH V4 22/26] arc/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Fri, 24 Jun 2022 10:13:35 +0530 Message-Id: <20220624044339.1533882-23-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624044339.1533882-1-anshuman.khandual@arm.com> References: <20220624044339.1533882-1-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,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 This enables ARCH_HAS_VM_GET_PAGE_PROT on the platform and exports standard vm_get_page_prot() implementation via DECLARE_VM_GET_PAGE_PROT, which looks up a private and static protection_map[] array. Subsequently all __SXXX and __PXXX macros can be dropped which are no longer needed. Cc: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arc/Kconfig | 1 + arch/arc/include/asm/pgtable-bits-arcv2.h | 18 ------------------ arch/arc/mm/mmap.c | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 9e3653253ef2..8be56a5d8a9b 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -13,6 +13,7 @@ config ARC select ARCH_HAS_SETUP_DMA_OPS select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_SUPPORTS_ATOMIC_RMW if ARC_HAS_LLSC select ARCH_32BIT_OFF_T select BUILDTIME_TABLE_SORT diff --git a/arch/arc/include/asm/pgtable-bits-arcv2.h b/arch/arc/include/asm/pgtable-bits-arcv2.h index 183d23bc1e00..b23be557403e 100644 --- a/arch/arc/include/asm/pgtable-bits-arcv2.h +++ b/arch/arc/include/asm/pgtable-bits-arcv2.h @@ -72,24 +72,6 @@ * This is to enable COW mechanism */ /* xwr */ -#define __P000 PAGE_U_NONE -#define __P001 PAGE_U_R -#define __P010 PAGE_U_R /* Pvt-W => !W */ -#define __P011 PAGE_U_R /* Pvt-W => !W */ -#define __P100 PAGE_U_X_R /* X => R */ -#define __P101 PAGE_U_X_R -#define __P110 PAGE_U_X_R /* Pvt-W => !W and X => R */ -#define __P111 PAGE_U_X_R /* Pvt-W => !W */ - -#define __S000 PAGE_U_NONE -#define __S001 PAGE_U_R -#define __S010 PAGE_U_W_R /* W => R */ -#define __S011 PAGE_U_W_R -#define __S100 PAGE_U_X_R /* X => R */ -#define __S101 PAGE_U_X_R -#define __S110 PAGE_U_X_W_R /* X => R */ -#define __S111 PAGE_U_X_W_R - #ifndef __ASSEMBLY__ #define pte_write(pte) (pte_val(pte) & _PAGE_WRITE) diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c index 722d26b94307..7dd50b66f266 100644 --- a/arch/arc/mm/mmap.c +++ b/arch/arc/mm/mmap.c @@ -74,3 +74,23 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.align_offset = pgoff << PAGE_SHIFT; return vm_unmapped_area(&info); } + +static pgprot_t protection_map[16] __ro_after_init = { + [VM_NONE] = PAGE_U_NONE, + [VM_READ] = PAGE_U_R, + [VM_WRITE] = PAGE_U_R, + [VM_WRITE | VM_READ] = PAGE_U_R, + [VM_EXEC] = PAGE_U_X_R, + [VM_EXEC | VM_READ] = PAGE_U_X_R, + [VM_EXEC | VM_WRITE] = PAGE_U_X_R, + [VM_EXEC | VM_WRITE | VM_READ] = PAGE_U_X_R, + [VM_SHARED] = PAGE_U_NONE, + [VM_SHARED | VM_READ] = PAGE_U_R, + [VM_SHARED | VM_WRITE] = PAGE_U_W_R, + [VM_SHARED | VM_WRITE | VM_READ] = PAGE_U_W_R, + [VM_SHARED | VM_EXEC] = PAGE_U_X_R, + [VM_SHARED | VM_EXEC | VM_READ] = PAGE_U_X_R, + [VM_SHARED | VM_EXEC | VM_WRITE] = PAGE_U_X_W_R, + [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = PAGE_U_X_W_R +}; +DECLARE_VM_GET_PAGE_PROT -- 2.25.1