From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F8AEC433F5 for ; Fri, 25 Feb 2022 01:31:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D3E08D0005; Thu, 24 Feb 2022 20:31:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1826A8D0001; Thu, 24 Feb 2022 20:31:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04AEB8D0005; Thu, 24 Feb 2022 20:31:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id EC5468D0001 for ; Thu, 24 Feb 2022 20:31:51 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B646095C95 for ; Fri, 25 Feb 2022 01:31:51 +0000 (UTC) X-FDA: 79179575622.27.C1C76EE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id EB8951C000E for ; Fri, 25 Feb 2022 01:31:50 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F407060F45; Fri, 25 Feb 2022 01:31:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B22C5C340F0; Fri, 25 Feb 2022 01:31:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645752709; bh=3AAPf7WkSDBU47MasXkUqlVc+MASq7jzM/CbTcX6ooM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ScwlZhwtdWXtWq7plCxg8/+Li9LCokWs9aZi1UQlDC4f/GB4PFGju2PlGN6lxf4YI O+Ui8gRPpUYSrxfFp4jchgbYurTXPBpu3zA1Wqy1v/vqzAl9qQeAqOfbuhbl4fidMn adMhIwzHGoRR7ozritc4CpwIF5n2N9vvYZXeOc+Gna2PaC28t/++nlIdWpU1afUw4B XFFvqRx33AeRFOvnCBBrNEzHOBTE3j6fRyUfyG/yWOZ5xuE1GKM4M+ol6CA0NC7xCo 1I3zMoAUjtYSP7rdRF7E+OG1Df3YI89/GkNBLpzWPJ6uonF8FR4VkN+FLzViysg1B/ Cp1jGHPdOgmxA== Message-ID: <50ac6dc2-7c71-2a8b-aa00-78926351b252@kernel.org> Date: Thu, 24 Feb 2022 19:31:47 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 25/30] nios2/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT Content-Language: en-US To: Anshuman Khandual , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Andrew Morton , linux-arch@vger.kernel.org References: <1644805853-21338-1-git-send-email-anshuman.khandual@arm.com> <1644805853-21338-26-git-send-email-anshuman.khandual@arm.com> From: Dinh Nguyen In-Reply-To: <1644805853-21338-26-git-send-email-anshuman.khandual@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EB8951C000E X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ScwlZhwt; spf=pass (imf20.hostedemail.com: domain of dinguyen@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dinguyen@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: h89hmrcstxhdhjdfezkhqtm16kthysbw X-HE-Tag: 1645752710-161420 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Anshuman, On 2/13/22 20:30, Anshuman Khandual wrote: > This defines and exports a platform specific custom vm_get_page_prot() = via > subscribing ARCH_HAS_VM_GET_PAGE_PROT. Subsequently all __SXXX and __PX= XX > macros can be dropped which are no longer needed. >=20 > 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(-) >=20 > 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; > */ > =20 > /* 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 */ > =20 > /* 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) > =20 > /* Used all over the kernel */ > #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHED | _PAGE_REA= D | \ > 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 *v= ma) > { > return (vma->vm_start =3D=3D 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); I'm getting this compile error after applying this patch when build NIOS2= : mm/mmap.c:105:2: error: =E2=80=98__P000=E2=80=99 undeclared here (not in = a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:105:10: error: =E2=80=98__P001=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:105:18: error: =E2=80=98__P010=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ AR fs/devpts/built-in.a mm/mmap.c:105:26: error: =E2=80=98__P011=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:105:34: error: =E2=80=98__P100=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:105:42: error: =E2=80=98__P101=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:105:50: error: =E2=80=98__P110=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:105:58: error: =E2=80=98__P111=E2=80=99 undeclared here (not in= a function) 105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, | ^~~~~~ mm/mmap.c:106:2: error: =E2=80=98__S000=E2=80=99 undeclared here (not in = a function) 106 | __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111 | ^~~~~~ mm/mmap.c:106:10: error: =E2=80=98__S001=E2=80=99 undeclared here (not in= a function) 106 | __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111 Dinh