From patchwork Mon Feb 28 10:47:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12762808 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 1519BC433EF for ; Mon, 28 Feb 2022 10:52:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A45E28D0012; Mon, 28 Feb 2022 05:52:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F5238D0001; Mon, 28 Feb 2022 05:52:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90AD68D0012; Mon, 28 Feb 2022 05:52:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 82E7A8D0001 for ; Mon, 28 Feb 2022 05:52:36 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4AE31181B3643 for ; Mon, 28 Feb 2022 10:52:36 +0000 (UTC) X-FDA: 79191875112.29.8127CD9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id B9DFC16000A for ; Mon, 28 Feb 2022 10:52:35 +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 43542106F; Mon, 28 Feb 2022 02:52:35 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.47.185]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 28EEB3F73D; Mon, 28 Feb 2022 02:52:26 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, geert@linux-m68k.org, Anshuman Khandual , Christoph Hellwig , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linux-mips@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-s390@vger.kernel.org, linux-riscv@lists.infradead.org, linux-alpha@vger.kernel.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-csky@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-parisc@vger.kernel.org, openrisc@lists.librecores.org, linux-um@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-arch@vger.kernel.org, Nick Hu Subject: [PATCH V3 27/30] nds32/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 28 Feb 2022 16:17:50 +0530 Message-Id: <1646045273-9343-28-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1646045273-9343-1-git-send-email-anshuman.khandual@arm.com> References: <1646045273-9343-1-git-send-email-anshuman.khandual@arm.com> X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: o7sze73dppndnp5yctdpkqfgde7ebhwh Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com X-Rspamd-Queue-Id: B9DFC16000A X-HE-Tag: 1646045555-105637 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: This defines and exports a platform specific custom vm_get_page_prot() via subscribing ARCH_HAS_VM_GET_PAGE_PROT. Subsequently all __SXXX and __PXXX macros can be dropped which are no longer needed. Cc: Nick Hu Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/nds32/Kconfig | 1 + arch/nds32/include/asm/pgtable.h | 17 --------------- arch/nds32/mm/mmap.c | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig index 4d1421b18734..576e05479925 100644 --- a/arch/nds32/Kconfig +++ b/arch/nds32/Kconfig @@ -10,6 +10,7 @@ config NDS32 select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_WANT_FRAME_POINTERS if FTRACE select CLKSRC_MMIO select CLONE_BACKWARDS diff --git a/arch/nds32/include/asm/pgtable.h b/arch/nds32/include/asm/pgtable.h index 419f984eef70..79f64ed734cb 100644 --- a/arch/nds32/include/asm/pgtable.h +++ b/arch/nds32/include/asm/pgtable.h @@ -152,23 +152,6 @@ extern void __pgd_error(const char *file, int line, unsigned long val); #endif /* __ASSEMBLY__ */ /* xwr */ -#define __P000 (PAGE_NONE | _PAGE_CACHE_SHRD) -#define __P001 (PAGE_READ | _PAGE_CACHE_SHRD) -#define __P010 (PAGE_COPY | _PAGE_CACHE_SHRD) -#define __P011 (PAGE_COPY | _PAGE_CACHE_SHRD) -#define __P100 (PAGE_EXEC | _PAGE_CACHE_SHRD) -#define __P101 (PAGE_READ | _PAGE_E | _PAGE_CACHE_SHRD) -#define __P110 (PAGE_COPY | _PAGE_E | _PAGE_CACHE_SHRD) -#define __P111 (PAGE_COPY | _PAGE_E | _PAGE_CACHE_SHRD) - -#define __S000 (PAGE_NONE | _PAGE_CACHE_SHRD) -#define __S001 (PAGE_READ | _PAGE_CACHE_SHRD) -#define __S010 (PAGE_RDWR | _PAGE_CACHE_SHRD) -#define __S011 (PAGE_RDWR | _PAGE_CACHE_SHRD) -#define __S100 (PAGE_EXEC | _PAGE_CACHE_SHRD) -#define __S101 (PAGE_READ | _PAGE_E | _PAGE_CACHE_SHRD) -#define __S110 (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD) -#define __S111 (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD) #ifndef __ASSEMBLY__ /* diff --git a/arch/nds32/mm/mmap.c b/arch/nds32/mm/mmap.c index 1bdf5e7d1b43..0399b928948d 100644 --- a/arch/nds32/mm/mmap.c +++ b/arch/nds32/mm/mmap.c @@ -71,3 +71,40 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.align_offset = pgoff << PAGE_SHIFT; return vm_unmapped_area(&info); } + +pgprot_t vm_get_page_prot(unsigned long vm_flags) +{ + switch (vm_flags & (VM_READ | VM_WRITE | VM_EXEC | VM_SHARED)) { + case VM_NONE: + return (PAGE_NONE | _PAGE_CACHE_SHRD); + case VM_READ: + return (PAGE_READ | _PAGE_CACHE_SHRD); + case VM_WRITE: + case VM_WRITE | VM_READ: + return (PAGE_COPY | _PAGE_CACHE_SHRD); + case VM_EXEC: + return (PAGE_EXEC | _PAGE_CACHE_SHRD); + case VM_EXEC | VM_READ: + return (PAGE_READ | _PAGE_E | _PAGE_CACHE_SHRD); + case VM_EXEC | VM_WRITE: + case VM_EXEC | VM_WRITE | VM_READ: + return (PAGE_COPY | _PAGE_E | _PAGE_CACHE_SHRD); + case VM_SHARED: + return (PAGE_NONE | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_READ: + return (PAGE_READ | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_WRITE: + case VM_SHARED | VM_WRITE | VM_READ: + return (PAGE_RDWR | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_EXEC: + return (PAGE_EXEC | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_EXEC | VM_READ: + return (PAGE_READ | _PAGE_E | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_EXEC | VM_WRITE: + case VM_SHARED | VM_EXEC | VM_WRITE | VM_READ: + return (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD); + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot);