[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220603101411.488970-6-anshuman.khandual@arm.com>
Date: Fri, 3 Jun 2022 15:44:10 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: linux-mm@...ck.org
Cc: Anshuman Khandual <anshuman.khandual@....com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Michael Ellerman <mpe@...erman.id.au>,
Paul Mackerras <paulus@...ba.org>,
"David S. Miller" <davem@...emloft.net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Dinh Nguyen <dinguyen@...nel.org>,
Jonas Bonn <jonas@...thpole.se>,
Andrew Morton <akpm@...ux-foundation.org>, x86@...nel.org,
openrisc@...ts.librecores.org, linux-csky@...r.kernel.org,
linux-mips@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linuxppc-dev@...ts.ozlabs.org, sparclinux@...r.kernel.org,
linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 5/6] nios2/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT
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@...nel.org>
Cc: linux-kernel@...r.kernel.org
Acked-by: Dinh Nguyen <dinguyen@...nel.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
---
arch/nios2/Kconfig | 1 +
arch/nios2/include/asm/pgtable.h | 24 ----------------
arch/nios2/mm/init.c | 47 ++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index 4167f1eb4cd8..e0459dffd218 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 262d0609268c..3c9f83c22733 100644
--- a/arch/nios2/include/asm/pgtable.h
+++ b/arch/nios2/include/asm/pgtable.h
@@ -34,30 +34,6 @@ struct mm_struct;
((x) ? _PAGE_EXEC : 0) | \
((r) ? _PAGE_READ : 0) | \
((w) ? _PAGE_WRITE : 0))
-/*
- * These are the macros that generic kernel code needs
- * (to populate protection_map[])
- */
-
-/* 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..e867f5d85580 100644
--- a/arch/nios2/mm/init.c
+++ b/arch/nios2/mm/init.c
@@ -124,3 +124,50 @@ 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)) {
+ /* Remove W bit on private pages for COW support */
+ 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);
+ /* Shared pages can have exact HW mapping */
+ 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
Powered by blists - more mailing lists