Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3615213pxb; Mon, 21 Feb 2022 01:53:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnMFiFgJZhVIcu77nZt4JDW+qP5V2Ar9yeMl4C/Xx1PUmeAHmZbDTGKpjhcCwseBRbOF70 X-Received: by 2002:a17:902:d510:b0:14a:f815:a00a with SMTP id b16-20020a170902d51000b0014af815a00amr18193036plg.168.1645437231681; Mon, 21 Feb 2022 01:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645437231; cv=none; d=google.com; s=arc-20160816; b=cbePxEZKGU6jIwZrCz9NeJKorRYla/2gZGZ8bS05wAcoOyz28W/Kc9QXZrYswXOO5G VylhQj5QL+U2Mb38rXnMpsM9Rip88d01fssn0AdVAVmbY6PA27J+oMXwraM7u/d+fILa 9MWVEGpESiDRZkzYBH0fTx+QlmsB5F9g5jUg2LQQeE+RpT50VPp4Fgeicexb+Wxs9cSY R1bRPEe5v2IBUNaEywaCVPiPOJTmAbQTDdjnW0ihFHG8qVsISWHqJxQZwFTAA6CAWxH2 yxDBBvWf3IvKaVAXkh5vXSU3CJxokjyORLNZ9sqBPk3q7IOswepi8sjOUha7xbMJWk72 VBpQ== 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=S8fctlKevm1WwJ33YmktVLUYR36C8Ub/jes+qmUu4GM=; b=TvdUhVwlKklxssd9p1eWjXu5uNBYGl46bxTwN5p7xGZ3CJbFt4C4QH4JWx2EF/ji3e /fhzXnWaHRksizfGGbuHRDsTc3h7cvl9MTj4AA6ItihLIeNjaRplhjfH5sHU+tXoUtj7 wciMa6XsTbIc1C0bQ3LtO9AlP9wiTcLAdyCIBJW8bzbxvLj9OXtOJLlbvuKcAqlvlTEf rK2Ha2Zve7ItlgUNNuUpmiKnMoL8Tc0+DPYrbfN02HSbhSk1G3rcUGsH3pViVj+mfykY 71nJ7AyTNDKTnUbSc/OJ+hKXlVrLElvdHH6IPYgTpD27PU4npszgUxDXZqt+lwLoWhs+ 3F6w== 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 t21si634146pgv.267.2022.02.21.01.53.38; Mon, 21 Feb 2022 01:53:51 -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 S245456AbiBUGnL (ORCPT + 99 others); Mon, 21 Feb 2022 01:43:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345411AbiBUGkf (ORCPT ); Mon, 21 Feb 2022 01:40:35 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C2C7427FB; Sun, 20 Feb 2022 22:39:44 -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 1B5161476; Sun, 20 Feb 2022 22:39:44 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.49.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E13593F70D; Sun, 20 Feb 2022 22:39:40 -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, Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [PATCH V2 17/30] sh/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 21 Feb 2022 12:08:26 +0530 Message-Id: <1645425519-9034-18-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: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/sh/Kconfig | 1 + arch/sh/include/asm/pgtable.h | 17 ---------------- arch/sh/mm/mmap.c | 38 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 2474a04ceac4..f3fcd1c5e002 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -11,6 +11,7 @@ config SUPERH select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_HIBERNATION_POSSIBLE if MMU select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_WANT_IPC_PARSE_VERSION diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h index d7ddb1ec86a0..6fb9ec54cf9b 100644 --- a/arch/sh/include/asm/pgtable.h +++ b/arch/sh/include/asm/pgtable.h @@ -89,23 +89,6 @@ static inline unsigned long phys_addr_mask(void) * completely separate permission bits for user and kernel space. */ /*xwr*/ -#define __P000 PAGE_NONE -#define __P001 PAGE_READONLY -#define __P010 PAGE_COPY -#define __P011 PAGE_COPY -#define __P100 PAGE_EXECREAD -#define __P101 PAGE_EXECREAD -#define __P110 PAGE_COPY -#define __P111 PAGE_COPY - -#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 typedef pte_t *pte_addr_t; diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c index 6a1a1297baae..cad14af6c8e6 100644 --- a/arch/sh/mm/mmap.c +++ b/arch/sh/mm/mmap.c @@ -162,3 +162,41 @@ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { return 1; } + +#ifdef CONFIG_MMU +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; + case VM_WRITE: + case VM_WRITE | VM_READ: + return PAGE_COPY; + case VM_EXEC: + case VM_EXEC | VM_READ: + return PAGE_EXECREAD; + case VM_EXEC | VM_WRITE: + case VM_EXEC | VM_WRITE | VM_READ: + return PAGE_COPY; + 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); +#endif -- 2.25.1