Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3521059pxb; Mon, 24 Jan 2022 11:17:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzREEV/sdL+lGZeZ92g0WmCnvv0VcYJbGOHuguAccO9kNSd/IpaqlB9rB9Mi1cFQrjVqAYu X-Received: by 2002:a63:87c6:: with SMTP id i189mr5482989pge.261.1643051756546; Mon, 24 Jan 2022 11:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051756; cv=none; d=google.com; s=arc-20160816; b=QGVVtLxH9WlC+/CI4mn5MM4BsEmEm3d8HLlgbOdi9IpS8WKtULrUpgtTiq/fXKEAh/ z0qbLCX2wFgy2XnkNwweVEMr+vjB5PY49EJntp07ESTToSMsjjQe3FxBxSIxmglE9sol 8lAcEc10yshfn/5bQxvqiFMnIk10Q29AtwNfQioENRJMtovSJjclHN+qg6MroS+8bz59 JIh0rubOCwLr/wuxLuRMbcGit+9pq1x2vc+4LK1YhzpISLb5tuD9Wso/sGOj2P2R6Hhi kzqrFCbrjKZB8JtaqQ43f6QTdQbpqa6AD9biZl0RQBohGSHGhTOXBPW3L1GN3bN0SLxI mEfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=VmIiUjm1JR4o0Mss66UhI0JnyCUbi9u7HJyFVasTiwQ=; b=cRl5C7D5QL6ZeVESTonmeKF/fhvkALUKXQymngNT4H0S6BJcvtZc8WnBsPm5YVO2Vb Vg5ydc+clqyO6b9pV/fJEoTDu8d5RCGGe8AB6SIqyurhRnYEzVW8aRKLiOM+P4nsBdec 3Yc67+Dxi1pZIDZOW8Kfzg88xlmXTjBSJAIepkTIK7oXahi3haqTbEQ9vY6JSixAQVPe kIZRhEWr7gLfTp0OkKKua8owxPGw4Gr2kdTpvwMFRpKt+wW+gBvkt2+tKFfGSRHPjhLW Nk2+ZeCYA0YdttcsuFWLGj3PzJsCNTDTYqNukX8heMxXHh2pQE2ecpX5zL5r1IDCsq47 JXuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si14057386plz.237.2022.01.24.11.15.41; Mon, 24 Jan 2022 11:15:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242910AbiAXM7O (ORCPT + 99 others); Mon, 24 Jan 2022 07:59:14 -0500 Received: from foss.arm.com ([217.140.110.172]:33250 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242878AbiAXM67 (ORCPT ); Mon, 24 Jan 2022 07:58:59 -0500 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.25.1