Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3519249pxb; Mon, 24 Jan 2022 11:15:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwioBXlpvwTZvcmuR0sj1i0FHrRIS/b/8A3LAoRgyKms763OQ6u4x1SiBuvClZHA1xSfma/ X-Received: by 2002:a17:90a:b798:: with SMTP id m24mr3283605pjr.143.1643051737637; Mon, 24 Jan 2022 11:15:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051737; cv=none; d=google.com; s=arc-20160816; b=L7KrMuZWiyydgTiY5LhUeX2S0aHvAHHB1Algu8W7XFFC5IMy8ZkaE6zidqA4gaBzoM vJgJbgc3VIdYxW3DUcZ7uwHcN2tlYwuAC3otRDOUXq0DIiXhFFpI7Z3QjoGgTfzihZNE dto1azBZgJBnL1GZz4iMHSGOVVXj59ISKZfPcQupIrta4dYVkCYE9d1Z/ewtX8FkvnEq HMAxPkiRefklp+5p3VzafG/RLRRCfIzOt/T/LRC/HDYx+5tQLJzwxIvg1X1GVpHSArrK 3lKm58v/ni6rug+xCqRApbRSjRPSY4Rxpx2VPLNbWF3fy/jyrLCQhTOTRsXcqSzR2xvw k0wA== 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=WoAFLQzvEata377U6t8e1qkenHQDh5VQikKW2EvF0FQ=; b=UE2NtQp0a3ysQpVm0+l9zjxg7l4GOr3aPJBzxfsw+NUbxSX1qqmH5Wa6S69MlZTT5c 0Xsvg65eg5oKXmlPbF6051dpOE7ZH5mnDZLxBn2yReAqlLW1BFD97d0VELUoFSOgOF6/ cY6dBEut3hfGweUeMzuismfy6MdT8if4QIuUP/Kpus76jWluBO/bq4xmWn0N4RTLNd48 t75UrIVs0tLmpow0F5q+DCK2xO6gM+o8vQXCTdPwQ9KMrZ+h0noQ4KybAm3Fnyv/CYBS 0YX4Msk02CdvZKMn4+GHnTUly4flP5YOPsDzx7NGTgWJRVk85kjimkQV7kh7m1yCCtqI 7KgA== 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 o8si14421831pgn.270.2022.01.24.11.15.25; Mon, 24 Jan 2022 11:15:37 -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 S242783AbiAXM60 (ORCPT + 99 others); Mon, 24 Jan 2022 07:58:26 -0500 Received: from foss.arm.com ([217.140.110.172]:33084 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242832AbiAXM6T (ORCPT ); Mon, 24 Jan 2022 07:58:19 -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 4C05D101E; Mon, 24 Jan 2022 04:58:18 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.43.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 666CB3F7F5; Mon, 24 Jan 2022 04:58:14 -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 , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org Subject: [RFC V1 17/31] sh/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 24 Jan 2022 18:26:54 +0530 Message-Id: <1643029028-12710-18-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: 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 | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 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..21b3fae77a4e 100644 --- a/arch/sh/mm/mmap.c +++ b/arch/sh/mm/mmap.c @@ -162,3 +162,46 @@ 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: + return PAGE_COPY; + case VM_READ | VM_WRITE: + return PAGE_COPY; + case VM_EXEC: + return PAGE_EXECREAD; + case VM_EXEC | VM_READ: + return PAGE_EXECREAD; + case VM_EXEC | VM_WRITE: + return PAGE_COPY; + case VM_EXEC | VM_READ | VM_WRITE: + return PAGE_COPY; + case VM_SHARED: + return PAGE_COPY; + case VM_SHARED | VM_READ: + return PAGE_READONLY; + case VM_SHARED | VM_WRITE: + return PAGE_WRITEONLY; + case VM_SHARED | VM_READ | VM_WRITE: + return PAGE_SHARED; + case VM_SHARED | VM_EXEC: + return PAGE_EXECREAD; + case VM_SHARED | VM_EXEC | VM_READ: + return PAGE_EXECREAD; + case VM_SHARED | VM_EXEC | VM_WRITE: + return PAGE_RWX; + case VM_SHARED | VM_EXEC | VM_READ | VM_WRITE: + return PAGE_RWX; + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); +#endif -- 2.25.1