Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/aarch64 - define PMAP_{MAP, UNMAP}_POOLPAGE for perf...
details: https://anonhg.NetBSD.org/src/rev/3759a741e0e0
branches: trunk
changeset: 433945:3759a741e0e0
user: ryo <ryo%NetBSD.org@localhost>
date: Sat Oct 13 08:32:36 2018 +0000
description:
- define PMAP_{MAP,UNMAP}_POOLPAGE for performance
- define __HAVE_MM_MD_KERNACC and add mm_md_kernacc()
diffstat:
sys/arch/aarch64/aarch64/aarch64_machdep.c | 43 ++++++++++++++++++++++++++++-
sys/arch/aarch64/include/pmap.h | 6 +++-
sys/arch/aarch64/include/types.h | 3 +-
3 files changed, 48 insertions(+), 4 deletions(-)
diffs (101 lines):
diff -r a09e4c7d05f9 -r 3759a741e0e0 sys/arch/aarch64/aarch64/aarch64_machdep.c
--- a/sys/arch/aarch64/aarch64/aarch64_machdep.c Sat Oct 13 05:53:50 2018 +0000
+++ b/sys/arch/aarch64/aarch64/aarch64_machdep.c Sat Oct 13 08:32:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.13 2018/10/12 21:44:20 jmcneill Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.14 2018/10/13 08:32:36 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.13 2018/10/12 21:44:20 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.14 2018/10/13 08:32:36 ryo Exp $");
#include "opt_arm_debug.h"
#include "opt_ddb.h"
@@ -528,6 +528,45 @@
KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
}
+#ifdef __HAVE_MM_MD_KERNACC
+int
+mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled)
+{
+ extern char __kernel_text[];
+ extern char _end[];
+ extern char __data_start[];
+ extern char __rodata_start[];
+
+ vaddr_t kernstart = trunc_page((vaddr_t)__kernel_text);
+ vaddr_t kernend = round_page((vaddr_t)_end);
+ paddr_t kernstart_phys = KERN_VTOPHYS(kernstart);
+ vaddr_t data_start = (vaddr_t)__data_start;
+ vaddr_t rodata_start = (vaddr_t)__rodata_start;
+ vsize_t rosize = kernend - rodata_start;
+
+ const vaddr_t v = (vaddr_t)ptr;
+
+#define IN_RANGE(addr,sta,end) (((sta) <= (addr)) && ((addr) < (end)))
+
+ *handled = false;
+ if (IN_RANGE(v, kernstart, kernend + kernend_extra)) {
+ *handled = true;
+ if ((v < data_start) && (prot & VM_PROT_WRITE))
+ return EFAULT;
+ } else if (IN_RANGE(v, AARCH64_KSEG_START, AARCH64_KSEG_END)) {
+ paddr_t pa = AARCH64_KVA_TO_PA(v);
+ if (IN_RANGE(pa, physical_start, physical_end)) {
+ *handled = true;
+ if (IN_RANGE(pa, kernstart_phys,
+ kernstart_phys + rosize) &&
+ (prot & VM_PROT_WRITE))
+ return EFAULT;
+ }
+ }
+ return 0;
+}
+#endif
+
void
cpu_startup(void)
{
diff -r a09e4c7d05f9 -r 3759a741e0e0 sys/arch/aarch64/include/pmap.h
--- a/sys/arch/aarch64/include/pmap.h Sat Oct 13 05:53:50 2018 +0000
+++ b/sys/arch/aarch64/include/pmap.h Sat Oct 13 08:32:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.14 2018/10/12 01:28:58 ryo Exp $ */
+/* $NetBSD: pmap.h,v 1.15 2018/10/13 08:32:36 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -47,6 +47,10 @@
#define __HAVE_VM_PAGE_MD
+#define PMAP_MAP_POOLPAGE(pa) AARCH64_PA_TO_KVA(pa)
+#define PMAP_UNMAP_POOLPAGE(va) AARCH64_KVA_TO_PA(va)
+
+
struct pmap {
kmutex_t pm_lock;
struct pool *pm_pvpool;
diff -r a09e4c7d05f9 -r 3759a741e0e0 sys/arch/aarch64/include/types.h
--- a/sys/arch/aarch64/include/types.h Sat Oct 13 05:53:50 2018 +0000
+++ b/sys/arch/aarch64/include/types.h Sat Oct 13 08:32:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.11 2018/07/17 11:55:55 joerg Exp $ */
+/* $NetBSD: types.h,v 1.12 2018/10/13 08:32:36 ryo Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -94,6 +94,7 @@
#define __HAVE_FAST_SOFTINTS
#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
+#define __HAVE_MM_MD_KERNACC
#define __HAVE_CPU_COUNTER
#define __HAVE_SYSCALL_INTERN
#define __HAVE_NEW_STYLE_BUS_H
Home |
Main Index |
Thread Index |
Old Index