Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6001502pxb; Mon, 14 Feb 2022 12:50:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSxDC1eRvTrOAtwFiPnKOtoIi+W5exk43knWM7MmDHNfEtwQy3yaQjKlOaSENiJ4AS6sSJ X-Received: by 2002:a05:6a00:1992:: with SMTP id d18mr462211pfl.85.1644871851951; Mon, 14 Feb 2022 12:50:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644871851; cv=none; d=google.com; s=arc-20160816; b=b3qZvZ36JKfz1KWsMOTQPvPLIwmkW5oMJLGuVvZPvYLVLXYw7xvftSxdsVynoccCk7 G3v5a40CrXJ6F1s0LMVLHUJ5/lKr3OPdTtbXD/KXPnXJzGpsOi1CgT+QPBQ7gARCnf6+ JsnJWFKIuG8Vdx8sw+3b9Ze53QHU4dNhdMyWBqSRhdammA/4voD+JDp4BYiNNc8Jw+ys pjdOzUB7e0ftehf8GvFCe+/2O02ZGM9ieBnwYLM9lb988y7+WlaKE+0MvCGfmA9F7HSe kpKGhCRwhX4Z5MM1jN04aKP7u04UQPwBJe2rfCwrlSwtCYeE1R27qkfl92PIpra59H/Q ZmQQ== 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=bi9pXq8+qi+pIj68QnE5uLnLmUyPwyfiXI5QrZNUkFgVc6kzQsaQOy69q5c0WcWskc j5qhpwJS5mxxW6tph/lnma2INT3UYyP6eTnY18fjXu9Hp1TQW3tXNbf45j9nso/YlIoc M/GxRIZ4gXyLruUJI/JpvwO0ipe06edPZYqNt54uKoUDpF1Yliy8uGBbBWxvt9ztntk2 oMN1ttWhFLUQuoK37bwRZnAsQaeoPHh+5HpeJ9Z6av3+hFGskZqycRdjgFDmIefRnVFO t1iQgHmBxtVsGP9PQlZ+UrNxN/anQAH8FbEus6ZhKYfDa8Oy94kfKM+bsvHKoAXa2k3i aO1g== 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 67si901324pgi.130.2022.02.14.12.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:50:51 -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 4C5011D1782; Mon, 14 Feb 2022 12:16:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239753AbiBNCdn (ORCPT + 99 others); Sun, 13 Feb 2022 21:33:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239762AbiBNCdL (ORCPT ); Sun, 13 Feb 2022 21:33:11 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C2985FF12; Sun, 13 Feb 2022 18:32:19 -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 4B682106F; Sun, 13 Feb 2022 18:32:19 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.47.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0A7DD3F718; Sun, 13 Feb 2022 18:32:16 -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, Dinh Nguyen Subject: [PATCH 25/30] nios2/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Date: Mon, 14 Feb 2022 08:00:48 +0530 Message-Id: <1644805853-21338-26-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: 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