Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6003453pxb; Mon, 14 Feb 2022 12:54:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqjF8QwDFbZcScQenwYQ11I0NL6aiNGRNr5HvPNOv0rYegRScDNOowPQDv4xcqWm29ziJh X-Received: by 2002:a17:90b:4b88:b0:1b8:ca46:472 with SMTP id lr8-20020a17090b4b8800b001b8ca460472mr613237pjb.0.1644872059969; Mon, 14 Feb 2022 12:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644872059; cv=none; d=google.com; s=arc-20160816; b=ETaonBIfxC/oy5KyNCMsb8dO2IEuBLtD8FHRvymYvTXVp9FXKIIJfMWoTlASAFiTGe T9fNpcrm2T8bEyN5BLN4H/LU+sA1FFVTKU6xWokzKiy6NcawNG6klVVvB6AyaprQapf9 92O6o4nMRBwrZVf/u7LS3awBDbhZwbuq2orS9Bgs7bRkxXf1goeqF+cin9k6XaK+bxkR M0ypJlT6/tmDdjJxkGEJQ5p6m1+rQ5jHgu6s//b0zEn+AmxrRyVKY868kYUyd56m/yij SA8JANjR/OL0UwjAwLTj0z+5JrmBJh7hS94DDdzeZPRqwVCmc8cGDftp2VIT0pO+fLZE u0RA== 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=9tdSlJkQ5TM5FKuWDP0+NkH+OuCyuMwTrlwdf9WuNag=; b=aDgSp4kMEpbr3YiJSDjcYStVR6hfie0N9Mgky+/EIQX2HwI9PGQTljxFuN4rKrVZk9 gRnaUgDaMpTkm0+Prs+ix92nfFwXGPTcg8izrWT3V7J87hfT6yGnnM5P1QbZ8DQcGG0D CBWK1Y1UdaNTH4K4+4OJZbmYh1BGORAF6NB4Xf/NVcRkS76kyzVkLNfrQT12XvYa9DcL SsxZEfibWgxHqajxUSXZBbmiEmLkzezHuuq92J/wfmSiFPd/CLq01JOxXWlMvRZHvVa0 PcuVcUe50Chq5M0SLde2R8LvclbVk/f6ptAYjzaiQjd2bozx4f5LGT3ydjhy0GzM/Ovv DXsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id i63si642559pge.554.2022.02.14.12.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:54:19 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 D1C8B12D092; Mon, 14 Feb 2022 12:18:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239805AbiBNCdw (ORCPT + 99 others); Sun, 13 Feb 2022 21:33:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239513AbiBNCdW (ORCPT ); Sun, 13 Feb 2022 21:33:22 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F7B560043; Sun, 13 Feb 2022 18:32:22 -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 4E8221396; Sun, 13 Feb 2022 18:32:22 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.47.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C3A053F718; Sun, 13 Feb 2022 18:32:19 -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, Brian Cain , linux-hexagon@vger.kernel.org Subject: [PATCH 26/30] hexagon/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 14 Feb 2022 08:00:49 +0530 Message-Id: <1644805853-21338-27-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: Brian Cain Cc: linux-hexagon@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/pgtable.h | 24 ----------- arch/hexagon/mm/init.c | 67 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 24 deletions(-) diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 15dd8f38b698..cdc5df32a1e3 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -6,6 +6,7 @@ config HEXAGON def_bool y select ARCH_32BIT_OFF_T select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_NO_PREEMPT select DMA_GLOBAL_POOL # Other pending projects/to-do items. diff --git a/arch/hexagon/include/asm/pgtable.h b/arch/hexagon/include/asm/pgtable.h index 18cd6ea9ab23..5eceddfe013d 100644 --- a/arch/hexagon/include/asm/pgtable.h +++ b/arch/hexagon/include/asm/pgtable.h @@ -127,31 +127,7 @@ extern unsigned long _dflt_cache_att; #define CACHEDEF (CACHE_DEFAULT << 6) /* Private (copy-on-write) page protections. */ -#define __P000 __pgprot(_PAGE_PRESENT | _PAGE_USER | CACHEDEF) -#define __P001 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | CACHEDEF) -#define __P010 __P000 /* Write-only copy-on-write */ -#define __P011 __P001 /* Read/Write copy-on-write */ -#define __P100 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_EXECUTE | CACHEDEF) -#define __P101 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_EXECUTE | \ - _PAGE_READ | CACHEDEF) -#define __P110 __P100 /* Write/execute copy-on-write */ -#define __P111 __P101 /* Read/Write/Execute, copy-on-write */ - /* Shared page protections. */ -#define __S000 __P000 -#define __S001 __P001 -#define __S010 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_WRITE | CACHEDEF) -#define __S011 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | \ - _PAGE_WRITE | CACHEDEF) -#define __S100 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_EXECUTE | CACHEDEF) -#define __S101 __P101 -#define __S110 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ - _PAGE_EXECUTE | _PAGE_WRITE | CACHEDEF) -#define __S111 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | \ - _PAGE_EXECUTE | _PAGE_WRITE | CACHEDEF) extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* located in head.S */ diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c index f01e91e10d95..b53595fc4103 100644 --- a/arch/hexagon/mm/init.c +++ b/arch/hexagon/mm/init.c @@ -236,3 +236,70 @@ void __init setup_arch_memory(void) * which is called by start_kernel() later on in the process */ } + +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 __pgprot(_PAGE_PRESENT | _PAGE_USER | + CACHEDEF); + case VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_READ | CACHEDEF); + /* Write-only copy-on-write */ + case VM_WRITE: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + CACHEDEF); + /* Read/Write copy-on-write */ + case VM_WRITE | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_READ | CACHEDEF); + case VM_EXEC: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | CACHEDEF); + case VM_EXEC | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | _PAGE_READ | + CACHEDEF); + /* Write/execute copy-on-write */ + case VM_EXEC | VM_WRITE: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | CACHEDEF); + /* Read/Write/Execute, copy-on-write */ + case VM_EXEC | VM_WRITE | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | _PAGE_READ | + CACHEDEF); + case VM_SHARED: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + CACHEDEF); + case VM_SHARED | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_READ | CACHEDEF); + case VM_SHARED | VM_WRITE: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_WRITE | CACHEDEF); + case VM_SHARED | VM_WRITE | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_READ | _PAGE_WRITE | + CACHEDEF); + case VM_SHARED | VM_EXEC: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | CACHEDEF); + case VM_SHARED | VM_EXEC | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | _PAGE_READ | + CACHEDEF); + case VM_SHARED | VM_EXEC | VM_WRITE: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_EXECUTE | _PAGE_WRITE | + CACHEDEF); + case VM_SHARED | VM_EXEC | VM_WRITE | VM_READ: + return __pgprot(_PAGE_PRESENT | _PAGE_USER | + _PAGE_READ | _PAGE_EXECUTE | + _PAGE_WRITE | CACHEDEF); + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1