Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3624970pxb; Mon, 21 Feb 2022 02:08:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu4CmDeZA0I4YWYoEhkzQtN4YQCLVZ0Oe804qZzoVsNFELeOxnQ9f3l3Qg/XMSXHT90Gbi X-Received: by 2002:a17:90a:7063:b0:1bc:1243:13d7 with SMTP id f90-20020a17090a706300b001bc124313d7mr8402457pjk.221.1645438110703; Mon, 21 Feb 2022 02:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645438110; cv=none; d=google.com; s=arc-20160816; b=PaylA7dJgxiBjL4xxv2kQDw+dawh5GhzmhGgVDzI0tsZzpVQIN9dzi6Tn5UisDQrZ0 Y1uIx4E+kQ55PX9yAvNGfbzGit0p16zqeBohYjudeaKJHSGMj+SevvFHhAznz9DJrHFO D78pd5u6VAFfzwGcJ99km0QtDN2grpJcBZVHWlkJPqP1ZGN9M4XSUKiNXsFjGJHrdVsk 8x7Hm1RX9Iem1T5MPCjkaB/2NFj+AVJ73Io/xHSon5WeuV7A+I3+zAAT647gab4XE9nq yMcOMxtNgQPfrGbUZqWrJTq6CyJOj7Z6vonBagD1MXo1AuxeGwyeGky3pHHx09AT1Snz zvbw== 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=k44GZp2EIAs0kU6TGi5VU2cMRanFEZ6t+MB8mDMfAMc=; b=emjAxNipsMNZSm9FpO/Ovk+wzcDtRiUtrDPh1z2q0rYvHk53LrXbH/xaPvY01cO/XR FthBxEjU/WDd+xxr6ymDrkOJ6RMAT3xGpHemuLesgbBBFYinKqK3EwJxrxT8HkTR70dN eksGDkXHRZDRFAYKtuJ3jQnnN6BR3wU+dYmfdjQGltthVMDSz+HYLeUlGbLGtrzGf2Mp Ds86D+xb430WC5faooLs6b15avBom4bZQj4tDs/vVwUHlB1zfPCl5xnlS6LTHoBhUcdV Bj95BgGlgn3db+RecqrxzD5yjnLN9xtDAbu1xKyLVB28LfXNJi5xuxwUezc/00yZ/qLw rCsA== 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 s9si9336982pfu.100.2022.02.21.02.08.16; Mon, 21 Feb 2022 02:08:30 -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 S1345525AbiBUGmN (ORCPT + 99 others); Mon, 21 Feb 2022 01:42:13 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345495AbiBUGlX (ORCPT ); Mon, 21 Feb 2022 01:41:23 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E6B32A721; Sun, 20 Feb 2022 22:40: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 2556D1509; Sun, 20 Feb 2022 22:40:11 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.49.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8AFA53F70D; Sun, 20 Feb 2022 22:40:08 -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, Dinh Nguyen Subject: [PATCH V2 25/30] nios2/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 21 Feb 2022 12:08:34 +0530 Message-Id: <1645425519-9034-26-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: Dinh Nguyen Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual Acked-by: Dinh Nguyen --- arch/nios2/Kconfig | 1 + arch/nios2/include/asm/pgtable.h | 16 ------------ arch/nios2/mm/init.c | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 33fd06f5fa41..85a58a357a3b 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -6,6 +6,7 @@ config NIOS2 select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_DMA_SET_UNCACHED + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_NO_SWAP select COMMON_CLK select TIMER_OF diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index 4a995fa628ee..2678dad58a63 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -40,24 +40,8 @@ struct mm_struct; */ /* Remove W bit on private pages for COW support */ -#define __P000 MKP(0, 0, 0) -#define __P001 MKP(0, 0, 1) -#define __P010 MKP(0, 0, 0) /* COW */ -#define __P011 MKP(0, 0, 1) /* COW */ -#define __P100 MKP(1, 0, 0) -#define __P101 MKP(1, 0, 1) -#define __P110 MKP(1, 0, 0) /* COW */ -#define __P111 MKP(1, 0, 1) /* COW */ /* Shared pages can have exact HW mapping */ -#define __S000 MKP(0, 0, 0) -#define __S001 MKP(0, 0, 1) -#define __S010 MKP(0, 1, 0) -#define __S011 MKP(0, 1, 1) -#define __S100 MKP(1, 0, 0) -#define __S101 MKP(1, 0, 1) -#define __S110 MKP(1, 1, 0) -#define __S111 MKP(1, 1, 1) /* Used all over the kernel */ #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHED | _PAGE_READ | \ diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index 613fcaa5988a..311b2146a248 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -124,3 +124,48 @@ const char *arch_vma_name(struct vm_area_struct *vma) { return (vma->vm_start == KUSER_BASE) ? "[kuser]" : NULL; } + +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 MKP(0, 0, 0); + case VM_READ: + return MKP(0, 0, 1); + /* COW */ + case VM_WRITE: + return MKP(0, 0, 0); + /* COW */ + case VM_WRITE | VM_READ: + return MKP(0, 0, 1); + case VM_EXEC: + return MKP(1, 0, 0); + case VM_EXEC | VM_READ: + return MKP(1, 0, 1); + /* COW */ + case VM_EXEC | VM_WRITE: + return MKP(1, 0, 0); + /* COW */ + case VM_EXEC | VM_WRITE | VM_READ: + return MKP(1, 0, 1); + case VM_SHARED: + return MKP(0, 0, 0); + case VM_SHARED | VM_READ: + return MKP(0, 0, 1); + case VM_SHARED | VM_WRITE: + return MKP(0, 1, 0); + case VM_SHARED | VM_WRITE | VM_READ: + return MKP(0, 1, 1); + case VM_SHARED | VM_EXEC: + return MKP(1, 0, 0); + case VM_SHARED | VM_EXEC | VM_READ: + return MKP(1, 0, 1); + case VM_SHARED | VM_EXEC | VM_WRITE: + return MKP(1, 1, 0); + case VM_SHARED | VM_EXEC | VM_WRITE | VM_READ: + return MKP(1, 1, 1); + default: + BUILD_BUG(); + } +} +EXPORT_SYMBOL(vm_get_page_prot); -- 2.25.1