Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3606805pxb; Mon, 21 Feb 2022 01:39:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMe4oAndtww3U1Nf+qBWkqeTJkuBz/RFVonCndYErqRWWLVF3ySn1/rn2ioZQNsrzYS/Vw X-Received: by 2002:a05:6402:2806:b0:412:9e3c:9820 with SMTP id h6-20020a056402280600b004129e3c9820mr20122091ede.320.1645436353475; Mon, 21 Feb 2022 01:39:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645436353; cv=none; d=google.com; s=arc-20160816; b=wFVGQVPQcl7+nBBYvIkk8zDyyuH8rXQDoS7mQxgYRtDzrPVCCgzoFBPvRrX63cjFc9 4qjfH0wXQkxeG5RXo3D4FAPahm8IF8oCLkri51oXV1g9CSyFgf9esq3lQ0Y7tQpWWzRN XRkqNZTt7bjVC/CMYRlv36xusLtTARAydGXskT1bldieCUXcYUPxWE9F2bdcAcmJEu/R oSO0sOZzJD7lyx7EHckziqwtRJMlb1MVJJekRiJQNvsNKjcEFO/bBjNB1YU0Ia3gqoZm WlMG//FhaKLshS5/8Rpz0PBkRNr1hKM8MTlRgVx8dTE3BMa9geQNLt/ww/810MEv0j8h anYQ== 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=QJ/tpS4LMItkXi68wpV4O0dNRHfMwzh616T7qt0wtec=; b=trJMB2WesFKIN7hLL+G3m9cueXj+6oN7Bw+9SJ5ZKJvJykNHUU/wH8mOHmBr7GOuSX vV3VFqLBRuPbHC32PzhUqzOY/e5q0QgLVr45QM2Igq9TdNopWitkD6QLNls8F+Az0nl3 OYD1V/mS8amvehLbV/0y+retOecAeGJE1bLz5eO2bkhkEts6sXEaZt9L7NH5CatuqvvQ I3xnGw3hQfezTRZu4gcJ6TsR4GHFeXWJr9LHI61g8n3yO0sQi2ygEHteEIktnPCk2v7I ZJ1VtGBvIlryQgL4xI2mZALIrcTybKaqJ9as/XHaCj5uTNzB2k7aCy99Swm8GJ1I9A/2 5Oag== 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 b8si5987496ejp.906.2022.02.21.01.38.50; Mon, 21 Feb 2022 01:39:13 -0800 (PST) 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 S1345366AbiBUGlx (ORCPT + 99 others); Mon, 21 Feb 2022 01:41:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345403AbiBUGlT (ORCPT ); Mon, 21 Feb 2022 01:41:19 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1D3394476E; Sun, 20 Feb 2022 22:39:58 -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 DFE271509; Sun, 20 Feb 2022 22:39:57 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.49.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3A4493F70D; Sun, 20 Feb 2022 22:39:54 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Anshuman Khandual , Christoph Hellwig , linux-arch@vger.kernel.org, "James E.J. Bottomley" , linux-parisc@vger.kernel.org Subject: [PATCH V2 21/30] parisc/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 21 Feb 2022 12:08:30 +0530 Message-Id: <1645425519-9034-22-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1645425519-9034-1-git-send-email-anshuman.khandual@arm.com> References: <1645425519-9034-1-git-send-email-anshuman.khandual@arm.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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: "James E.J. Bottomley" Cc: linux-parisc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/parisc/Kconfig | 1 + arch/parisc/include/asm/pgtable.h | 20 ---------------- arch/parisc/mm/init.c | 40 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 43c1c880def6..de512f120b50 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -10,6 +10,7 @@ config PARISC select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_NO_SG_CHAIN select ARCH_SUPPORTS_HUGETLBFS if PA20 select ARCH_SUPPORTS_MEMORY_FAILURE diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h index 3e7cf882639f..80d99b2b5913 100644 --- a/arch/parisc/include/asm/pgtable.h +++ b/arch/parisc/include/asm/pgtable.h @@ -269,26 +269,6 @@ extern void __update_cache(pte_t pte); * pages. */ - /*xwr*/ -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY -#define __P010 __P000 /* copy on write */ -#define __P011 __P001 /* copy on write */ -#define __P100 PAGE_EXECREAD -#define __P101 PAGE_EXECREAD -#define __P110 __P100 /* copy on write */ -#define __P111 __P101 /* copy on write */ - -#define __S000 PAGE_NONE -#define __S001 PAGE_READONLY -#define __S010 PAGE_WRITEONLY -#define __S011 PAGE_SHARED -#define __S100 PAGE_EXECREAD -#define __S101 PAGE_EXECREAD -#define __S110 PAGE_RWX -#define __S111 PAGE_RWX - - extern pgd_t swapper_pg_dir[]; /* declared in init_task.c */ /* initial page tables for 0-8MB for kernel */ diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 1dc2e88e7b04..f9e841f874a8 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -865,3 +865,43 @@ void flush_tlb_all(void) spin_unlock(&sid_lock); } #endif + +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; + case VM_READ: + return PAGE_READONLY; + /* copy on write */ + case VM_WRITE: + return PAGE_NONE; + /* copy on write */ + case VM_WRITE | VM_READ: + return PAGE_READONLY; + case VM_EXEC: + case VM_EXEC | VM_READ: + /* copy on write */ + case VM_EXEC | VM_WRITE: + /* copy on write */ + case VM_EXEC | VM_WRITE | VM_READ: + return PAGE_EXECREAD; + case VM_SHARED: + return PAGE_NONE; + case VM_SHARED | VM_READ: + return PAGE_READONLY; + case VM_SHARED | VM_WRITE: + return PAGE_WRITEONLY; + case VM_SHARED | VM_WRITE | VM_READ: + return PAGE_SHARED; + case VM_SHARED | VM_EXEC: + case VM_SHARED | VM_EXEC | VM_READ: + return PAGE_EXECREAD; + case VM_SHARED | VM_EXEC | VM_WRITE: + case VM_SHARED | VM_EXEC | VM_WRITE | VM_READ: + return PAGE_RWX; + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1