lkml.org 
[lkml]   [2022]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 25/30] nios2/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT
From
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 __PXXX
> macros can be dropped which are no longer needed.
>
> Cc: Dinh Nguyen <dinguyen@kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> Acked-by: Dinh Nguyen <dinguyen@kernel.org>
> ---
> 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);

I'm getting this compile error after applying this patch when build NIOS2:


mm/mmap.c:105:2: error: ‘__P000’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:105:10: error: ‘__P001’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:105:18: error: ‘__P010’ 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: ‘__P011’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:105:34: error: ‘__P100’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:105:42: error: ‘__P101’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:105:50: error: ‘__P110’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:105:58: error: ‘__P111’ undeclared here (not in a function)

105 | __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,

| ^~~~~~

mm/mmap.c:106:2: error: ‘__S000’ undeclared here (not in a function)

106 | __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111

| ^~~~~~

mm/mmap.c:106:10: error: ‘__S001’ undeclared here (not in a function)

106 | __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111



Dinh

\
 
 \ /
  Last update: 2022-02-25 02:35    [W:0.235 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site