Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5960892pxb; Mon, 14 Feb 2022 11:45:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+yb/teD+Irn0n4ljQJ+NtB0lKPU2QzmrKMu1OWPzFw9COz4+ygj/ot6pS7p76/trElfu+ X-Received: by 2002:a17:902:f645:: with SMTP id m5mr333059plg.56.1644867945222; Mon, 14 Feb 2022 11:45:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644867945; cv=none; d=google.com; s=arc-20160816; b=WOpWZJnuc8f3hwgDP98QFyDyE9m22sVn8WCS9WH44r5/42W9ibew5uX7WUQf9SevVV 4KSSRPZZA8oZqY6Ca5Tsn9T+pQZqIYufrC47v05OYZPhIRBs6QmjLx76DZmuBgWZtF/O AjdxHYMEOaAOJ+tw+vCSzij9EUstTIOdde9vS73OdvU0lLwemwk9D8NC8NgXcCAf3lRO laNa8cbfF6nlkk1S+R/Q3zOlDxbzwYjgTSOtoCSgFI1Pdz8eRMMleHmGR/d2+zOc/oey nd0xtbNbMzAG53Oam7OjfF/a29lPFFjgZ/9MbFe5MvHleiZ4EU5jE1ONzXEHY4GkIrXa 0Byw== 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=ZHQYW4tMmetqKZH48DQ/FvDh/epmLZsFdB3nSoqRKmo=; b=mM4hXqj0jLhlSCd5D/wA7MGUxaCXog+suQYPDdowGdToppm4F5RA5jQmdQxoMyPMw2 MXjCuyL5Lif99/i/jlJBO09u+lnYEHvsfsiPtUj08AATjAIbfDPv1Kk4VHHtMqvx/d1n tCTv8K9xwntHDys8/W7fBlfT1n9b2FLIKXhgqsl69LFCs9EUX50ix3XljRO3NKb85KqA Hvq1jBi3n6QDxE3lKkCfDyB63FN2pPGkCQdjjd9YnuFWupeL3SlbympnL4V5skjo54dk vMf4yWQ1LnJ19mjJSqM5oii3PTLkl2/aUz8g335OCpobDGXBHnBDUDSMQ59i7DoeIRcq H4Zg== 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: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z1si32772937pfe.46.2022.02.14.11.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 11:45:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A55F1119F09; Mon, 14 Feb 2022 11:30:38 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237463AbiBNCdO (ORCPT + 99 others); Sun, 13 Feb 2022 21:33:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239511AbiBNCcy (ORCPT ); Sun, 13 Feb 2022 21:32:54 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0102456214; Sun, 13 Feb 2022 18:32:11 -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 BA990106F; Sun, 13 Feb 2022 18:32:10 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.47.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3B7383F718; Sun, 13 Feb 2022 18:32:07 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Anshuman Khandual , Christoph Hellwig , Andrew Morton , linux-arch@vger.kernel.org, Jonas Bonn , openrisc@lists.librecores.org Subject: [PATCH 22/30] openrisc/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 14 Feb 2022 08:00:45 +0530 Message-Id: <1644805853-21338-23-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1644805853-21338-1-git-send-email-anshuman.khandual@arm.com> References: <1644805853-21338-1-git-send-email-anshuman.khandual@arm.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Jonas Bonn Cc: openrisc@lists.librecores.org Cc: linux-kernel@vger.kernel.org Acked-by: Stafford Horne Signed-off-by: Anshuman Khandual --- arch/openrisc/Kconfig | 1 + arch/openrisc/include/asm/pgtable.h | 18 ------------- arch/openrisc/mm/init.c | 41 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index f724b3f1aeed..842a61426816 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -10,6 +10,7 @@ config OPENRISC select ARCH_HAS_DMA_SET_UNCACHED select ARCH_HAS_DMA_CLEAR_UNCACHED select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_VM_GET_PAGE_PROT select COMMON_CLK select OF select OF_EARLY_FLATTREE diff --git a/arch/openrisc/include/asm/pgtable.h b/arch/openrisc/include/asm/pgtable.h index cdd657f80bfa..fe686c4b7065 100644 --- a/arch/openrisc/include/asm/pgtable.h +++ b/arch/openrisc/include/asm/pgtable.h @@ -176,24 +176,6 @@ extern void paging_init(void); __pgprot(_PAGE_ALL | _PAGE_SRE | _PAGE_SWE \ | _PAGE_SHARED | _PAGE_DIRTY | _PAGE_EXEC | _PAGE_CI) -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY_X -#define __P010 PAGE_COPY -#define __P011 PAGE_COPY_X -#define __P100 PAGE_READONLY -#define __P101 PAGE_READONLY_X -#define __P110 PAGE_COPY -#define __P111 PAGE_COPY_X - -#define __S000 PAGE_NONE -#define __S001 PAGE_READONLY_X -#define __S010 PAGE_SHARED -#define __S011 PAGE_SHARED_X -#define __S100 PAGE_READONLY -#define __S101 PAGE_READONLY_X -#define __S110 PAGE_SHARED -#define __S111 PAGE_SHARED_X - /* zero page used for uninitialized stuff */ extern unsigned long empty_zero_page[2048]; #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c index 97305bde1b16..0d06e3ebef5d 100644 --- a/arch/openrisc/mm/init.c +++ b/arch/openrisc/mm/init.c @@ -210,3 +210,44 @@ void __init mem_init(void) mem_init_done = 1; return; } + +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_X; + case VM_WRITE: + return PAGE_COPY; + case VM_WRITE | VM_READ: + return PAGE_COPY_X; + case VM_EXEC: + return PAGE_READONLY; + case VM_EXEC | VM_READ: + return PAGE_READONLY_X; + case VM_EXEC | VM_WRITE: + return PAGE_COPY; + case VM_EXEC | VM_WRITE | VM_READ: + return PAGE_COPY_X; + case VM_SHARED: + return PAGE_NONE; + case VM_SHARED | VM_READ: + return PAGE_READONLY_X; + case VM_SHARED | VM_WRITE: + return PAGE_SHARED; + case VM_SHARED | VM_WRITE | VM_READ: + return PAGE_SHARED_X; + case VM_SHARED | VM_EXEC: + return PAGE_READONLY; + case VM_SHARED | VM_EXEC | VM_READ: + return PAGE_READONLY_X; + case VM_SHARED | VM_EXEC | VM_WRITE: + return PAGE_SHARED; + case VM_SHARED | VM_EXEC | VM_WRITE | VM_READ: + return PAGE_SHARED_X; + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1