From patchwork Mon Jan 24 12:57:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12722090 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 6B5FFC433F5 for ; Mon, 24 Jan 2022 12:59:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 054026B00BE; Mon, 24 Jan 2022 07:59:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 004396B00BF; Mon, 24 Jan 2022 07:58:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E359F6B00C0; Mon, 24 Jan 2022 07:58:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id D40DE6B00BE for ; Mon, 24 Jan 2022 07:58:59 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9DA818F6FC for ; Mon, 24 Jan 2022 12:58:59 +0000 (UTC) X-FDA: 79065185598.18.E83591A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 21D72C002D for ; Mon, 24 Jan 2022 12:58:59 +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 AF1D7113E; Mon, 24 Jan 2022 04:58:58 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D46AE3F774; Mon, 24 Jan 2022 04:58:55 -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 , Nick Hu Subject: [RFC V1 27/31] nds32/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 24 Jan 2022 18:27:04 +0530 Message-Id: <1643029028-12710-28-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> X-Stat-Signature: re6f7hgw83mn7ghtspjfi46egq5hwmox Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 21D72C002D X-HE-Tag: 1643029139-558652 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 | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 42 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..bfb3929d634a 100644 --- a/arch/nds32/mm/mmap.c +++ b/arch/nds32/mm/mmap.c @@ -71,3 +71,44 @@ 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: + return (PAGE_COPY | _PAGE_CACHE_SHRD); + case VM_READ | VM_WRITE: + 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: + return (PAGE_COPY | _PAGE_E | _PAGE_CACHE_SHRD); + case VM_EXEC | VM_READ | VM_WRITE: + 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: + return (PAGE_RDWR | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_READ | VM_WRITE: + 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: + return (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD); + case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE: + return (PAGE_RDWR | _PAGE_E | _PAGE_CACHE_SHRD); + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot);