CVS commit: src/sys/arch/aarch64/aarch64

2020-02-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb 20 07:52:55 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Use orr instead of mov (an alias for orr) to appease clang... *shrug*


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Feb 15 13:51:33 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
avoid nesting /*'s (-Wcomment)


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.56 src/sys/arch/aarch64/aarch64/locore.S:1.57
--- src/sys/arch/aarch64/aarch64/locore.S:1.56	Sat Feb 15 08:16:10 2020
+++ src/sys/arch/aarch64/aarch64/locore.S	Sat Feb 15 13:51:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.56 2020/02/15 08:16:10 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.57 2020/02/15 13:51:33 tnn Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.56 2020/02/15 08:16:10 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.57 2020/02/15 13:51:33 tnn Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -47,9 +47,9 @@ RCSID("$NetBSD: locore.S,v 1.56 2020/02/
 #endif
 #define	MAIR_DEVICE_MEM_SO	MAIR_DEVICE_nGnRnE
 
-/*#define DEBUG_LOCORE			/* debug print */
-/*#define DEBUG_LOCORE_PRINT_LOCK	/* avoid mixing AP's output */
-/*#define DEBUG_MMU			/* dump MMU table */
+/*#define DEBUG_LOCORE			// debug print */
+/*#define DEBUG_LOCORE_PRINT_LOCK	// avoid mixing AP's output */
+/*#define DEBUG_MMU			// dump MMU table */
 
 #define LOCORE_EL2
 



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Feb 15 13:51:33 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
avoid nesting /*'s (-Wcomment)


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 07:02:08 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: vectors.S

Log Message:
Adjust comments


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/vectors.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/vectors.S
diff -u src/sys/arch/aarch64/aarch64/vectors.S:1.10 src/sys/arch/aarch64/aarch64/vectors.S:1.11
--- src/sys/arch/aarch64/aarch64/vectors.S:1.10	Wed Feb 12 01:09:17 2020
+++ src/sys/arch/aarch64/aarch64/vectors.S	Wed Feb 12 07:02:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vectors.S,v 1.10 2020/02/12 01:09:17 riastradh Exp $	*/
+/*	$NetBSD: vectors.S,v 1.11 2020/02/12 07:02:08 skrll Exp $	*/
 
 #include 
 #include "assym.h"
@@ -23,7 +23,8 @@
 	.align 7	/* aligned 0x80 */
 
 	.if \el == 1
-	sub	sp, sp, #TRAP_FRAMESIZE	/* need to allocate stack on el1 */
+	/* need to allocate stack on el1 */
+	sub	sp, sp, #TRAP_FRAMESIZE
 	.endif
 
 	stp	x0, x1, [sp, #TF_X0]
@@ -47,7 +48,8 @@
 	.if \el == 0
 	mrs	x20, sp_el0
 	.else
-	add	x20, sp, #TRAP_FRAMESIZE	/* sp is already adjusted */
+	/* sp was already adjusted, so adjust x20 back */
+	add	x20, sp, #TRAP_FRAMESIZE
 	.endif
 	mrs	x21, elr_el1
 



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb 12 07:02:08 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: vectors.S

Log Message:
Adjust comments


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/vectors.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:09:17 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: vectors.S

Log Message:
Create a buffer space of 512 bytes before the trapframe.

dtrace fbt needs enough space to emulate an

stp x29, x30, [sp,#-FRAMESIZE]!

instruction in a function prologue.  In the aarch64 instruction
encoding, FRAMESIZE can be as large as 512 bytes, so reserve this
much space when KDTRACE_HOOKS is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/vectors.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/vectors.S
diff -u src/sys/arch/aarch64/aarch64/vectors.S:1.9 src/sys/arch/aarch64/aarch64/vectors.S:1.10
--- src/sys/arch/aarch64/aarch64/vectors.S:1.9	Fri Oct 12 01:28:57 2018
+++ src/sys/arch/aarch64/aarch64/vectors.S	Wed Feb 12 01:09:17 2020
@@ -1,8 +1,20 @@
-/*	$NetBSD: vectors.S,v 1.9 2018/10/12 01:28:57 ryo Exp $	*/
+/*	$NetBSD: vectors.S,v 1.10 2020/02/12 01:09:17 riastradh Exp $	*/
 
 #include 
 #include "assym.h"
 #include "opt_ddb.h"
+#include "opt_dtrace.h"
+
+#ifdef KDTRACE_HOOKS
+/*
+ * dtrace needs to emulate  stp x29,x30,[sp,#-FRAMESIZE]!   where
+ * FRAMESIZE can be as large as 512, so create a 512-byte buffer
+ * between the interrupted code's frame and our struct trapframe.
+ */
+#define	TRAP_FRAMESIZE	(TF_SIZE + 512)
+#else
+#define	TRAP_FRAMESIZE	TF_SIZE
+#endif
 
 	/*
 	 * vector_entry macro must be small enough to fit 0x80 bytes!
@@ -11,7 +23,7 @@
 	.align 7	/* aligned 0x80 */
 
 	.if \el == 1
-	sub	sp, sp, #TF_SIZE	/* need to allocate stack on el1 */
+	sub	sp, sp, #TRAP_FRAMESIZE	/* need to allocate stack on el1 */
 	.endif
 
 	stp	x0, x1, [sp, #TF_X0]
@@ -35,7 +47,7 @@
 	.if \el == 0
 	mrs	x20, sp_el0
 	.else
-	add	x20, sp, #TF_SIZE	/* sp is already adjusted */
+	add	x20, sp, #TRAP_FRAMESIZE	/* sp is already adjusted */
 	.endif
 	mrs	x21, elr_el1
 



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:09:17 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: vectors.S

Log Message:
Create a buffer space of 512 bytes before the trapframe.

dtrace fbt needs enough space to emulate an

stp x29, x30, [sp,#-FRAMESIZE]!

instruction in a function prologue.  In the aarch64 instruction
encoding, FRAMESIZE can be as large as 512 bytes, so reserve this
much space when KDTRACE_HOOKS is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/vectors.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Feb 11 03:12:06 UTC 2020

Removed Files:
src/sys/arch/aarch64/aarch64: cpu_in_cksum.S

Log Message:
Delete aarch64 cpu_in_cksum.S draft.

This isn't actually used in the kernel; it is only used to cause the
in_cksum tests to fail.

If you want to revive it and make it work, you can pull it out of the
attic.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 src/sys/arch/aarch64/aarch64/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Feb 11 03:12:06 UTC 2020

Removed Files:
src/sys/arch/aarch64/aarch64: cpu_in_cksum.S

Log Message:
Delete aarch64 cpu_in_cksum.S draft.

This isn't actually used in the kernel; it is only used to cause the
in_cksum tests to fail.

If you want to revive it and make it work, you can pull it out of the
attic.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 src/sys/arch/aarch64/aarch64/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb  9 08:14:56 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
#if 0 / #endif -> a comment


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.39 src/sys/arch/aarch64/aarch64/cpu.c:1.40
--- src/sys/arch/aarch64/aarch64/cpu.c:1.39	Tue Jan 28 17:47:50 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Feb  9 08:14:55 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.39 2020/01/28 17:47:50 maxv Exp $ */
+/* $NetBSD: cpu.c,v 1.40 2020/02/09 08:14:55 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.39 2020/01/28 17:47:50 maxv Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.40 2020/02/09 08:14:55 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -159,10 +159,8 @@ cpu_attach(device_t dv, cpuid_t id)
 	fpu_attach(ci);
 
 	cpu_identify1(dv, ci);
-#if 0
-	/* already done in locore */
-	aarch64_getcacheinfo(unit);
-#endif
+
+	/* aarch64_getcacheinfo(0) was called by locore.S */
 	aarch64_printcacheinfo(dv);
 	cpu_identify2(dv, ci);
 



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb  9 08:14:56 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
#if 0 / #endif -> a comment


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb  9 08:09:59 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Improve comments


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-02-09 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb  9 08:09:59 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Improve comments


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.54 src/sys/arch/aarch64/aarch64/locore.S:1.55
--- src/sys/arch/aarch64/aarch64/locore.S:1.54	Tue Jan 28 17:33:07 2020
+++ src/sys/arch/aarch64/aarch64/locore.S	Sun Feb  9 08:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.54 2020/01/28 17:33:07 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.55 2020/02/09 08:09:58 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.54 2020/01/28 17:33:07 maxv Exp $")
+RCSID("$NetBSD: locore.S,v 1.55 2020/02/09 08:09:58 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -178,11 +178,13 @@ vstart:
 	msr	tpidr_el1, x0		/* curcpu is cpu_info[0] */
 	DPRINTREG("curcpu   = ", x0);
 
-	/* get cache configuration */
+	/* set topology information */
 	mrs	x0, tpidr_el1		/* curcpu */
 	mrs x1, mpidr_el1
 	mov	x2, #0
 	bl	arm_cpu_topology_set
+
+	/* get cache configuration */
 	mov	x0, xzr
 	bl	aarch64_getcacheinfo
 



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-31 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 31 09:08:57 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: netbsd32_machdep.c

Log Message:
D means E here (aarch32), so don't check it. A-I-F are checked below
already, so drop the whole line.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.9 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.10
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.9	Sun Nov 24 04:08:36 2019
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Fri Jan 31 09:08:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.9 2019/11/24 04:08:36 rin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.10 2020/01/31 09:08:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.9 2019/11/24 04:08:36 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.10 2020/01/31 09:08:57 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -318,8 +318,6 @@ cpu_mcontext32_validate(struct lwp *l, c
 
 	if (__SHIFTOUT(spsr, SPSR_M) != SPSR_M_USR32)
 		return EINVAL;
-	if ((spsr & (SPSR_A64_D|SPSR_A|SPSR_I|SPSR_F)) != 0)
-		return EINVAL;
 
 #ifdef __AARCH64EB__
 	if ((spsr & SPSR_A32_E) == 0)



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-31 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jan 31 09:08:57 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: netbsd32_machdep.c

Log Message:
D means E here (aarch32), so don't check it. A-I-F are checked below
already, so drop the whole line.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 27 16:25:09 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
NVIDIA's breakaway marketing dept have been in touch.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.37 src/sys/arch/aarch64/aarch64/cpu.c:1.38
--- src/sys/arch/aarch64/aarch64/cpu.c:1.37	Mon Jan 27 12:56:44 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c	Mon Jan 27 16:25:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.37 2020/01/27 12:56:44 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.38 2020/01/27 16:25:08 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.37 2020/01/27 12:56:44 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.38 2020/01/27 16:25:08 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -190,7 +190,7 @@ const struct cpuidtab cpuids[] = {
 	{ CPU_ID_CORTEXA76R3 & CPU_PARTMASK, "Cortex-A76", "Cortex", "V8.2-A+" },
 	{ CPU_ID_CORTEXA76AER1 & CPU_PARTMASK, "Cortex-A76AE", "Cortex", "V8.2-A+" },
 	{ CPU_ID_CORTEXA77R0 & CPU_PARTMASK, "Cortex-A77", "Cortex", "V8.2-A+" },
-	{ CPU_ID_NVIDIADENVER2 & CPU_PARTMASK, "Nvidia", "Denver2", "V8-A" },
+	{ CPU_ID_NVIDIADENVER2 & CPU_PARTMASK, "NVIDIA", "Denver2", "V8-A" },
 	{ CPU_ID_EMAG8180 & CPU_PARTMASK, "Ampere eMAG", "Skylark", "V8-A" },
 	{ CPU_ID_NEOVERSEE1R1 & CPU_PARTMASK, "Neoverse E1", "Neoverse", "V8.2-A+" },
 	{ CPU_ID_NEOVERSEN1R3 & CPU_PARTMASK, "Neoverse N1", "Neoverse", "V8.2-A+" },



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 27 16:25:09 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
NVIDIA's breakaway marketing dept have been in touch.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jan 25 18:18:31 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jan 25 18:18:31 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.35 src/sys/arch/aarch64/aarch64/cpu.c:1.36
--- src/sys/arch/aarch64/aarch64/cpu.c:1.35	Mon Jan 20 12:32:04 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sat Jan 25 18:18:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.35 2020/01/20 12:32:04 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.36 2020/01/25 18:18:31 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.35 2020/01/20 12:32:04 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.36 2020/01/25 18:18:31 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -161,7 +161,7 @@ cpu_attach(device_t dv, cpuid_t id)
 	cpu_identify1(dv, ci);
 #if 0
 	/* already done in locore */
-	aarch64_getcacheinfo(unit); 
+	aarch64_getcacheinfo(unit);
 #endif
 	aarch64_printcacheinfo(dv);
 	cpu_identify2(dv, ci);
@@ -229,7 +229,7 @@ cpu_identify(device_t self, struct cpu_i
 	const char *m;
 
 	identify_aarch64_model(ci->ci_id.ac_midr, model, sizeof(model));
-	if (ci->ci_index == 0) { 
+	if (ci->ci_index == 0) {
 		m = cpu_getmodel();
 		if (m == NULL || *m == 0)
 			cpu_setmodel("%s", model);



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 22 17:15:53 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Fixup a comment


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.37 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.38
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.37	Wed Jan  8 05:41:07 2020
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Wed Jan 22 17:15:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.37 2020/01/08 05:41:07 ryo Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.38 2020/01/22 17:15:53 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.37 2020/01/08 05:41:07 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.38 2020/01/22 17:15:53 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -99,7 +99,8 @@ vaddr_t physical_end;
 /* filled in before cleaning bss. keep in .data */
 u_long kern_vtopdiff __attribute__((__section__(".data")));
 
-long kernend_extra;	/* extra physicalmemory allocated from round_page(_end[]) */
+/* extra physical memory allocated from round_page(_end[]) */
+long kernend_extra;
 
 /* dump configuration */
 int	cpu_dump(void);



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 22 17:15:53 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Fixup a comment


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 20 12:32:04 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 20 12:32:04 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.34 src/sys/arch/aarch64/aarch64/cpu.c:1.35
--- src/sys/arch/aarch64/aarch64/cpu.c:1.34	Wed Jan 15 08:34:04 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c	Mon Jan 20 12:32:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.34 2020/01/15 08:34:04 mrg Exp $ */
+/* $NetBSD: cpu.c,v 1.35 2020/01/20 12:32:04 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.34 2020/01/15 08:34:04 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.35 2020/01/20 12:32:04 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -35,13 +35,13 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.34
 #include "opt_multiprocessor.h"
 
 #include 
-#include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jan 19 15:08:43 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: start.S

Log Message:
Style.  NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jan 19 15:08:43 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: start.S

Log Message:
Style.  NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/start.S
diff -u src/sys/arch/aarch64/aarch64/start.S:1.5 src/sys/arch/aarch64/aarch64/start.S:1.6
--- src/sys/arch/aarch64/aarch64/start.S:1.5	Sat Dec 14 17:24:30 2019
+++ src/sys/arch/aarch64/aarch64/start.S	Sun Jan 19 15:08:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: start.S,v 1.5 2019/12/14 17:24:30 skrll Exp $	*/
+/*	$NetBSD: start.S,v 1.6 2020/01/19 15:08:43 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -32,7 +32,7 @@
 
 #include 
 
-RCSID("$NetBSD: start.S,v 1.5 2019/12/14 17:24:30 skrll Exp $")
+RCSID("$NetBSD: start.S,v 1.6 2020/01/19 15:08:43 skrll Exp $")
 
 /* load far effective address (pc relative) */
 .macro	ADDR, reg, addr
@@ -41,9 +41,10 @@ RCSID("$NetBSD: start.S,v 1.5 2019/12/14
 .endm
 
 /*
- * Padding at start of kernel image to make room for 64-byte header (non-ELF booting)
+ * Padding at start of kernel image to make room for 64-byte header
+ * (non-ELF booting)
  */
-.space	64, 0x0
+	.space	64, 0x0
 
 /*
  * Kernel start routine for aarch64 boards.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-13 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jan 13 17:23:07 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: bus_space_asm_generic.S

Log Message:
Fix mis-incrementing pointer size in bus_space_read_region_{4,8}

pointed out by jmcneill@. thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S
diff -u src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S:1.1 src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S:1.2
--- src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S:1.1	Sun Apr  1 04:35:03 2018
+++ src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S	Mon Jan 13 17:23:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_space_asm_generic.S,v 1.1 2018/04/01 04:35:03 ryo Exp $	*/
+/*	$NetBSD: bus_space_asm_generic.S,v 1.2 2020/01/13 17:23:07 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: bus_space_asm_generic.S,v 1.1 2018/04/01 04:35:03 ryo Exp $")
+RCSID("$NetBSD: bus_space_asm_generic.S,v 1.2 2020/01/13 17:23:07 ryo Exp $")
 
 .macro generate_bsfunc funcname, dsbop
 /* uint8_t {funcname}_bs_r_1(x0:tag, x1:addr, x2:offset) */
@@ -334,7 +334,7 @@ ENTRY_NP(\funcname\()_bs_rr_4)
 	ldr	w8, [x1, x2]	/* value = *src */
 	subs	x4, x4, #1	/* count-- */
 	add	x2, x2, x9	/* src += delta */
-	str	w8, [x3], #2	/* *dst++ = value */
+	str	w8, [x3], #4	/* *dst++ = value */
 	b.ne	1b
 	ret
 #ifdef DIAGNOSTIC
@@ -363,7 +363,7 @@ ENTRY_NP(\funcname\()_bs_rr_8)
 	ldr	x8, [x1, x2]	/* value = *src */
 	subs	x4, x4, #1	/* count-- */
 	add	x2, x2, x9	/* src += delta */
-	str	x8, [x3], #2	/* *dst++ = value */
+	str	x8, [x3], #8	/* *dst++ = value */
 	b.ne	1b
 	ret
 #ifdef DIAGNOSTIC
@@ -423,7 +423,7 @@ ENTRY_NP(\funcname\()_bs_rr_4_swap)
 	subs	x4, x4, #1	/* count-- */
 	add	x2, x2, x9	/* src += delta */
 	rev	w8, w8
-	str	w8, [x3], #2	/* *dst++ = value */
+	str	w8, [x3], #4	/* *dst++ = value */
 	b.ne	1b
 	ret
 #ifdef DIAGNOSTIC
@@ -453,7 +453,7 @@ ENTRY_NP(\funcname\()_bs_rr_8_swap)
 	subs	x4, x4, #1	/* count-- */
 	add	x2, x2, x9	/* src += delta */
 	rev	x8, x8
-	str	x8, [x3], #2	/* *dst++ = value */
+	str	x8, [x3], #8	/* *dst++ = value */
 	b.ne	1b
 	ret
 #ifdef DIAGNOSTIC



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-13 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jan 13 17:23:07 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: bus_space_asm_generic.S

Log Message:
Fix mis-incrementing pointer size in bus_space_read_region_{4,8}

pointed out by jmcneill@. thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/bus_space_asm_generic.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Jan  9 01:38:34 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: fault.c pmap.c

Log Message:
fix behaviour mmap()/mprotect() when passed only PROT_EXEC.

when mmap()/mprotect() with only PROT_EXEC, syscall will be successful,
but the page actually hadn't been mapped.
it should be mapped with PROT_READ|PROT_EXEC implicitly. (r-x)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/fault.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/fault.c
diff -u src/sys/arch/aarch64/aarch64/fault.c:1.10 src/sys/arch/aarch64/aarch64/fault.c:1.11
--- src/sys/arch/aarch64/aarch64/fault.c:1.10	Mon Jun 10 05:56:15 2019
+++ src/sys/arch/aarch64/aarch64/fault.c	Thu Jan  9 01:38:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.10 2019/06/10 05:56:15 ryo Exp $	*/
+/*	$NetBSD: fault.c,v 1.11 2020/01/09 01:38:34 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.10 2019/06/10 05:56:15 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.11 2020/01/09 01:38:34 ryo Exp $");
 
 #include "opt_compat_netbsd32.h"
 #include "opt_ddb.h"
@@ -170,7 +170,7 @@ data_abort_handler(struct trapframe *tf,
 	}
 
 	if ((eclass == ESR_EC_INSN_ABT_EL0) || (eclass == ESR_EC_INSN_ABT_EL1))
-		ftype = VM_PROT_READ | VM_PROT_EXECUTE;
+		ftype = VM_PROT_EXECUTE;
 	else if (__SHIFTOUT(esr, ESR_ISS_DATAABORT_CM))
 		ftype = VM_PROT_READ;
 	else

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.60 src/sys/arch/aarch64/aarch64/pmap.c:1.61
--- src/sys/arch/aarch64/aarch64/pmap.c:1.60	Mon Dec 30 16:03:48 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Thu Jan  9 01:38:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.60 2019/12/30 16:03:48 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.61 2020/01/09 01:38:34 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60 2019/12/30 16:03:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.61 2020/01/09 01:38:34 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1232,6 +1232,10 @@ pmap_protect(struct pmap *pm, vaddr_t sv
 	KASSERT_PM_ADDR(pm, sva);
 	KASSERT(!IN_KSEG_ADDR(sva));
 
+	/* PROT_EXEC requires implicit PROT_READ */
+	if (prot & VM_PROT_EXECUTE)
+		prot |= VM_PROT_READ;
+
 	if ((prot & VM_PROT_READ) == VM_PROT_NONE) {
 		PMAP_COUNT(protect_remove_fallback);
 		pmap_remove(pm, sva, eva);
@@ -2139,6 +2143,10 @@ pmap_fault_fixup(struct pmap *pm, vaddr_
 	/* ignore except read/write */
 	accessprot &= (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
 
+	/* PROT_EXEC requires implicit PROT_READ */
+	if (accessprot & VM_PROT_EXECUTE)
+		accessprot |= VM_PROT_READ;
+
 	/* no permission to read/write/execute for this page */
 	if ((pmap_prot & accessprot) != accessprot) {
 		UVMHIST_LOG(pmaphist, "no permission to access", 0, 0, 0, 0);



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Jan  9 01:38:34 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: fault.c pmap.c

Log Message:
fix behaviour mmap()/mprotect() when passed only PROT_EXEC.

when mmap()/mprotect() with only PROT_EXEC, syscall will be successful,
but the page actually hadn't been mapped.
it should be mapped with PROT_READ|PROT_EXEC implicitly. (r-x)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/fault.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-07 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Jan  8 05:41:07 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c locore.S

Log Message:
fix panic when modload.

>panic: kernel diagnostic assertion "!pmap_extract(pmap_kernel(), loopva, 
>NULL)" failed: file "../../../../uvm/uvm_km.c", line 674 
>loopva=0xffc00100'

The space allocated by bootpage_alloc() is only used as a physical page
for pagetable pages, so there is no need to map it with KVA.
And kernend_extra should not have consumed any KVA space.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.36 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.37
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.36	Mon Dec 30 15:54:55 2019
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Wed Jan  8 05:41:07 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.36 2019/12/30 15:54:55 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.37 2020/01/08 05:41:07 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.36 2019/12/30 15:54:55 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.37 2020/01/08 05:41:07 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -99,7 +99,7 @@ vaddr_t physical_end;
 /* filled in before cleaning bss. keep in .data */
 u_long kern_vtopdiff __attribute__((__section__(".data")));
 
-long kernend_extra;	/* extra memory allocated from round_page(_end[]) */
+long kernend_extra;	/* extra physicalmemory allocated from round_page(_end[]) */
 
 /* dump configuration */
 int	cpu_dump(void);
@@ -227,7 +227,7 @@ cpu_kernel_vm_init(uint64_t memory_start
 	pmapboot_protect(L2_TRUNC_BLOCK(kernstart),
 	L2_TRUNC_BLOCK(data_start), VM_PROT_WRITE);
 	pmapboot_protect(L2_ROUND_BLOCK(rodata_start),
-	L2_ROUND_BLOCK(kernend + kernend_extra), VM_PROT_EXECUTE);
+	L2_ROUND_BLOCK(kernend), VM_PROT_EXECUTE);
 
 	aarch64_tlbi_all();
 
@@ -287,7 +287,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	kernstart = trunc_page((vaddr_t)__kernel_text);
 	kernend = round_page((vaddr_t)_end);
 	kernstart_l2 = L2_TRUNC_BLOCK(kernstart);
-	kernend_l2 = L2_ROUND_BLOCK(kernend + kernend_extra);
+	kernend_l2 = L2_ROUND_BLOCK(kernend);
 	kernelvmstart = kernend_l2;
 
 #ifdef MODULAR
@@ -341,14 +341,14 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	"physical_start= 0x%016lx\n"
 	"kernel_start_phys = 0x%016lx\n"
 	"kernel_end_phys   = 0x%016lx\n"
+	"pagetables_start_phys = 0x%016lx\n"
+	"pagetables_end_phys   = 0x%016lx\n"
 	"msgbuf= 0x%016lx\n"
 	"physical_end  = 0x%016lx\n"
 	"VM_MIN_KERNEL_ADDRESS = 0x%016lx\n"
 	"kernel_start_l2   = 0x%016lx\n"
 	"kernel_start  = 0x%016lx\n"
 	"kernel_end= 0x%016lx\n"
-	"pagetables= 0x%016lx\n"
-	"pagetables_end= 0x%016lx\n"
 	"kernel_end_l2 = 0x%016lx\n"
 #ifdef MODULAR
 	"module_start  = 0x%016lx\n"
@@ -362,14 +362,14 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	physical_start,
 	kernstart_phys,
 	kernend_phys,
+	round_page(kernend_phys),
+	round_page(kernend_phys) + kernend_extra,
 	msgbufaddr,
 	physical_end,
 	VM_MIN_KERNEL_ADDRESS,
 	kernstart_l2,
 	kernstart,
 	kernend,
-	round_page(kernend),
-	round_page(kernend) + kernend_extra,
 	kernend_l2,
 #ifdef MODULAR
 	module_start,
@@ -553,7 +553,7 @@ mm_md_kernacc(void *ptr, vm_prot_t prot,
 #define IN_RANGE(addr,sta,end)	(((sta) <= (addr)) && ((addr) < (end)))
 
 	*handled = false;
-	if (IN_RANGE(v, kernstart, kernend + kernend_extra)) {
+	if (IN_RANGE(v, kernstart, kernend)) {
 		*handled = true;
 		if ((v < data_start) && (prot & VM_PROT_WRITE))
 			return EFAULT;

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.49 src/sys/arch/aarch64/aarch64/locore.S:1.50
--- src/sys/arch/aarch64/aarch64/locore.S:1.49	Sat Dec 28 17:19:43 2019
+++ src/sys/arch/aarch64/aarch64/locore.S	Wed Jan  8 05:41:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.49 2019/12/28 17:19:43 jmcneill Exp $	*/
+/*	$NetBSD: locore.S,v 1.50 2020/01/08 05:41:07 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.49 2019/12/28 17:19:43 jmcneill Exp $")
+RCSID("$NetBSD: locore.S,v 1.50 2020/01/08 05:41:07 ryo Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -848,7 +848,6 @@ 

CVS commit: src/sys/arch/aarch64/aarch64

2020-01-07 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Jan  8 05:41:07 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c locore.S

Log Message:
fix panic when modload.

>panic: kernel diagnostic assertion "!pmap_extract(pmap_kernel(), loopva, 
>NULL)" failed: file "../../../../uvm/uvm_km.c", line 674 
>loopva=0xffc00100'

The space allocated by bootpage_alloc() is only used as a physical page
for pagetable pages, so there is no need to map it with KVA.
And kernend_extra should not have consumed any KVA space.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan  6 08:36:09 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
fix new cpu_intr_p


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.23 src/sys/arch/aarch64/aarch64/trap.c:1.24
--- src/sys/arch/aarch64/aarch64/trap.c:1.23	Sun Jan  5 20:17:43 2020
+++ src/sys/arch/aarch64/aarch64/trap.c	Mon Jan  6 08:36:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.23 2020/01/05 20:17:43 ad Exp $ */
+/* $NetBSD: trap.c,v 1.24 2020/01/06 08:36:08 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.23 2020/01/05 20:17:43 ad Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.24 2020/01/06 08:36:08 skrll Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -641,7 +641,7 @@ cpu_intr_p(void)
 	do {
 		ncsw = l->l_ncsw;
 		__insn_barrier();
-		idepth = l->l_cpu->ci_idepth;
+		idepth = l->l_cpu->ci_intr_depth;
 		__insn_barrier();
 	} while (__predict_false(ncsw != l->l_ncsw));
 



CVS commit: src/sys/arch/aarch64/aarch64

2020-01-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan  6 08:36:09 UTC 2020

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
fix new cpu_intr_p


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Dec 30 16:03:48 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Update pmap_map_chunk to allow L[12] block mappings and L3 page mappings


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Dec 30 16:03:48 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Update pmap_map_chunk to allow L[12] block mappings and L3 page mappings


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.59 src/sys/arch/aarch64/aarch64/pmap.c:1.60
--- src/sys/arch/aarch64/aarch64/pmap.c:1.59	Mon Dec 30 15:42:39 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Mon Dec 30 16:03:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.59 2019/12/30 15:42:39 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.60 2019/12/30 16:03:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.59 2019/12/30 15:42:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60 2019/12/30 16:03:48 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -268,6 +268,12 @@ pm_unlock(struct pmap *pm)
 
 static const struct pmap_devmap *pmap_devmap_table;
 
+#define	L1_BLK_MAPPABLE_P(va, pa, size)	\
+va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE)
+
+#define	L2_BLK_MAPPABLE_P(va, pa, size)	\
+va) | (pa)) & L2_OFFSET) == 0 && (size) >= L2_SIZE)
+
 static vsize_t
 pmap_map_chunk(vaddr_t va, paddr_t pa, vsize_t size,
 vm_prot_t prot, u_int flags)
@@ -276,25 +282,40 @@ pmap_map_chunk(vaddr_t va, paddr_t pa, v
 	psize_t blocksize;
 	int rc;
 
-	/* devmap always use L2 mapping */
-	blocksize = L2_SIZE;
+	vsize_t resid = round_page(size);
+	vsize_t mapped = 0;
 
-	attr = _pmap_pte_adjust_prot(L2_BLOCK, prot, VM_PROT_ALL, false);
-	attr = _pmap_pte_adjust_cacheflags(attr, flags);
-	/* user cannot execute, and kernel follows the prot */
-	attr |= (LX_BLKPAG_UXN|LX_BLKPAG_PXN);
-	if (prot & VM_PROT_EXECUTE)
-		attr &= ~LX_BLKPAG_PXN;
+	while (resid > 0) {
+		if (L1_BLK_MAPPABLE_P(va, pa, resid)) {
+			blocksize = L1_SIZE;
+			attr = L1_BLOCK;
+		} else if (L2_BLK_MAPPABLE_P(va, pa, resid)) {
+			blocksize = L2_SIZE;
+			attr = L2_BLOCK;
+		} else {
+			blocksize = L3_SIZE;
+			attr = L3_PAGE;
+		}
+
+		attr = _pmap_pte_adjust_prot(attr, prot, VM_PROT_ALL, false);
+		attr = _pmap_pte_adjust_cacheflags(attr, flags);
 
-	rc = pmapboot_enter(va, pa, size, blocksize, attr,
-	PMAPBOOT_ENTER_NOOVERWRITE, bootpage_alloc, NULL);
-	if (rc != 0)
-		panic("%s: pmapboot_enter failed. %lx is already mapped?\n",
-		__func__, va);
+		rc = pmapboot_enter(va, pa, blocksize, blocksize, attr,
+		PMAPBOOT_ENTER_NOOVERWRITE, bootpage_alloc, NULL);
+		if (rc != 0) {
+			panic("%s: pmapboot_enter failed. %lx is already mapped?\n",
+			__func__, va);
+		}
 
-	aarch64_tlbi_by_va(va);
+		va += blocksize;
+		pa += blocksize;
+		resid -= blocksize;
+		mapped += blocksize;
+
+		aarch64_tlbi_by_va(va);
+	}
 
-	return ((va + size + blocksize - 1) & ~(blocksize - 1)) - va;
+	return mapped;
 }
 
 void



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Dec 30 15:54:55 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Flush the cache and disable TTBR0 translations once we're done with
them in cpu_kernel_vm_init

The Cortex A72s in RPI4 need the cache flush for some reason.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.35 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.36
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.35	Wed Dec 18 21:45:43 2019
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Mon Dec 30 15:54:55 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.35 2019/12/18 21:45:43 riastradh Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.36 2019/12/30 15:54:55 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.35 2019/12/18 21:45:43 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.36 2019/12/30 15:54:55 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -205,6 +205,13 @@ cpu_kernel_vm_init(uint64_t memory_start
 			left -= mapsize;
 		}
 	}
+	aarch64_dcache_wbinv_all();
+
+	/* Disable translation table walks using TTBR0 */
+	uint64_t tcr = reg_tcr_el1_read();
+	reg_tcr_el1_write(tcr | TCR_EPD0);
+	__asm __volatile("isb" ::: "memory");
+
 	aarch64_tlbi_all();
 
 	/*



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Dec 30 15:54:55 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Flush the cache and disable TTBR0 translations once we're done with
them in cpu_kernel_vm_init

The Cortex A72s in RPI4 need the cache flush for some reason.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Dec 30 15:42:40 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Remove unnecessary brackets and unwrap a conditional.  Same code before
and after.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Dec 30 15:42:40 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Remove unnecessary brackets and unwrap a conditional.  Same code before
and after.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.58 src/sys/arch/aarch64/aarch64/pmap.c:1.59
--- src/sys/arch/aarch64/aarch64/pmap.c:1.58	Sat Dec 28 17:19:43 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Mon Dec 30 15:42:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.58 2019/12/28 17:19:43 jmcneill Exp $	*/
+/*	$NetBSD: pmap.c,v 1.59 2019/12/30 15:42:39 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.58 2019/12/28 17:19:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.59 2019/12/30 15:42:39 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -323,8 +323,7 @@ pmap_devmap_bootstrap(vaddr_t l0pt, cons
 		(va < (VM_KERNEL_IO_ADDRESS + VM_KERNEL_IO_SIZE)));
 
 		/* update and check virtual_devmap_addr */
-		if ((virtual_devmap_addr == 0) ||
-		(virtual_devmap_addr > va)) {
+		if (virtual_devmap_addr == 0 || virtual_devmap_addr > va) {
 			virtual_devmap_addr = va;
 		}
 
@@ -423,7 +422,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 #endif
 
 	/* devmap already uses last of va? */
-	if ((virtual_devmap_addr != 0) && (virtual_devmap_addr < vend))
+	if (virtual_devmap_addr != 0 && virtual_devmap_addr < vend)
 		vend = virtual_devmap_addr;
 
 	virtual_avail = vstart;



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Dec 27 21:55:51 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.29 src/sys/arch/aarch64/aarch64/cpu.c:1.30
--- src/sys/arch/aarch64/aarch64/cpu.c:1.29	Fri Dec 27 15:36:02 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Fri Dec 27 21:55:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.29 2019/12/27 15:36:02 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.30 2019/12/27 21:55:51 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.29 2019/12/27 15:36:02 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.30 2019/12/27 21:55:51 mlelstv Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -302,7 +302,8 @@ cpu_identify2(device_t self, struct cpu_
 
 	dfr0 = reg_id_aa64dfr0_el1_read();
 
-	aprint_debug_dev(self, "midr=0x%\n" PRIx32, (uint32_t)ci->ci_id.ac_midr);
+	aprint_debug_dev(self, "midr=0x%" PRIx32 "\n",
+	(uint32_t)ci->ci_id.ac_midr);
 	aprint_normal_dev(self, "revID=0x%" PRIx64, id->ac_revidr);
 
 	/* ID_AA64DFR0_EL1 */



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Dec 27 21:55:51 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec 27 15:36:02 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Add a missing newline


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec 27 15:36:02 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Add a missing newline


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.28 src/sys/arch/aarch64/aarch64/cpu.c:1.29
--- src/sys/arch/aarch64/aarch64/cpu.c:1.28	Sat Dec 21 12:53:54 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Fri Dec 27 15:36:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.28 2019/12/21 12:53:54 ad Exp $ */
+/* $NetBSD: cpu.c,v 1.29 2019/12/27 15:36:02 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.28 2019/12/21 12:53:54 ad Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.29 2019/12/27 15:36:02 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -302,6 +302,7 @@ cpu_identify2(device_t self, struct cpu_
 
 	dfr0 = reg_id_aa64dfr0_el1_read();
 
+	aprint_debug_dev(self, "midr=0x%\n" PRIx32, (uint32_t)ci->ci_id.ac_midr);
 	aprint_normal_dev(self, "revID=0x%" PRIx64, id->ac_revidr);
 
 	/* ID_AA64DFR0_EL1 */



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 26 08:48:53 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.46 src/sys/arch/aarch64/aarch64/locore.S:1.47
--- src/sys/arch/aarch64/aarch64/locore.S:1.46	Sun Dec  8 10:37:19 2019
+++ src/sys/arch/aarch64/aarch64/locore.S	Thu Dec 26 08:48:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.46 2019/12/08 10:37:19 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.47 2019/12/26 08:48:53 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.46 2019/12/08 10:37:19 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.47 2019/12/26 08:48:53 skrll Exp $")
 
 
 /*#define DEBUG_LOCORE			/* debug print */
@@ -119,7 +119,6 @@ ASENTRY_NP(aarch64_start)
 	DPRINTSREG("ID_AA64MMFR0_EL1 = ", id_aa64mmfr0_el1)
 	DPRINTSREG("ID_AA64MMFR1_EL1 = ", id_aa64mmfr1_el1)
 
-
 #ifdef LOCORE_EL2
 	VPRINT("Drop to EL1...")
 # include 
@@ -153,7 +152,6 @@ aarch64_fatal:
 	mov	sp, x28
 	ret
 
-
 /*
  * vstart is in kernel virtual address
  */
@@ -403,7 +401,6 @@ ENTRY_NP(cpu_mpstart)
 	CPU_DPRINTSREG("MIDR_EL1 = ", midr_el1)
 	CPU_DPRINTSREG("MPIDR_EL1= ", mpidr_el1)
 
-
 #ifdef LOCORE_EL2
 	CPU_DPRINT("Drop to EL1...\n")
 	bl	drop_to_el1



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 26 08:48:53 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 19 07:44:56 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
G/C kasan_shadow_map call in pmap_enter

pmap_growkernel calls kasan_shadow_map for KVA


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.55 src/sys/arch/aarch64/aarch64/pmap.c:1.56
--- src/sys/arch/aarch64/aarch64/pmap.c:1.55	Wed Dec 18 11:10:24 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Thu Dec 19 07:44:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.55 2019/12/18 11:10:24 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.56 2019/12/19 07:44:56 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.55 2019/12/18 11:10:24 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.56 2019/12/19 07:44:56 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1681,10 +1681,6 @@ _pmap_enter(struct pmap *pm, vaddr_t va,
 	opte = atomic_swap_64(ptep, 0);
 	need_sync_icache = (prot & VM_PROT_EXECUTE);
 
-	if (!user) {
-		kasan_shadow_map((void *)va, PAGE_SIZE);
-	}
-
 	/* for lock ordering for pg and opg */
 	pgs[0] = pg;
 	pgs[1] = NULL;



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Dec 19 07:44:56 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
G/C kasan_shadow_map call in pmap_enter

pmap_growkernel calls kasan_shadow_map for KVA


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-18 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Dec 18 11:10:24 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
atomic_add_16() is not used in pmap.c anymore. no need decl here.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.54 src/sys/arch/aarch64/aarch64/pmap.c:1.55
--- src/sys/arch/aarch64/aarch64/pmap.c:1.54	Wed Dec 18 11:06:42 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Wed Dec 18 11:10:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.54 2019/12/18 11:06:42 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.55 2019/12/18 11:10:24 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.54 2019/12/18 11:06:42 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.55 2019/12/18 11:10:24 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -195,9 +195,6 @@ struct pv_entry {
 #define L3INDEXMASK	(L3_SIZE * Ln_ENTRIES - 1)
 #define PDPSWEEP_TRIGGER	512
 
-void atomic_add_16(volatile uint16_t *, int16_t);
-uint16_t atomic_add_16_nv(volatile uint16_t *, int16_t);
-
 static pt_entry_t *_pmap_pte_lookup_l3(struct pmap *, vaddr_t);
 static pt_entry_t *_pmap_pte_lookup_bs(struct pmap *, vaddr_t, vsize_t *);
 static pt_entry_t _pmap_pte_adjust_prot(pt_entry_t, vm_prot_t, vm_prot_t, bool);



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-18 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Dec 18 11:10:24 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
atomic_add_16() is not used in pmap.c anymore. no need decl here.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-18 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Dec 18 11:06:43 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
space to tab


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-18 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Dec 18 11:06:43 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
space to tab


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.53 src/sys/arch/aarch64/aarch64/pmap.c:1.54
--- src/sys/arch/aarch64/aarch64/pmap.c:1.53	Sat Dec 14 13:48:09 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Wed Dec 18 11:06:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.53 2019/12/14 13:48:09 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.54 2019/12/18 11:06:42 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.53 2019/12/14 13:48:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.54 2019/12/18 11:06:42 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -699,8 +699,8 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	UVMHIST_LOG(pmaphist, "maxkvaddr=%llx, pmap_maxkvaddr=%llx",
 	maxkvaddr, pmap_maxkvaddr, 0, 0);
 
-kasan_shadow_map((void *)pmap_maxkvaddr,
-  (size_t)(maxkvaddr - pmap_maxkvaddr));
+	kasan_shadow_map((void *)pmap_maxkvaddr,
+	(size_t)(maxkvaddr - pmap_maxkvaddr));
 
 	pmap_maxkvaddr = maxkvaddr;
 



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 17:24:30 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: start.S

Log Message:
revert previous - i was confused about boot files on rpi + aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 17:24:30 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: start.S

Log Message:
revert previous - i was confused about boot files on rpi + aarch64


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/start.S
diff -u src/sys/arch/aarch64/aarch64/start.S:1.4 src/sys/arch/aarch64/aarch64/start.S:1.5
--- src/sys/arch/aarch64/aarch64/start.S:1.4	Sat Dec 14 17:04:02 2019
+++ src/sys/arch/aarch64/aarch64/start.S	Sat Dec 14 17:24:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: start.S,v 1.4 2019/12/14 17:04:02 skrll Exp $	*/
+/*	$NetBSD: start.S,v 1.5 2019/12/14 17:24:30 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -32,7 +32,7 @@
 
 #include 
 
-RCSID("$NetBSD: start.S,v 1.4 2019/12/14 17:04:02 skrll Exp $")
+RCSID("$NetBSD: start.S,v 1.5 2019/12/14 17:24:30 skrll Exp $")
 
 /* load far effective address (pc relative) */
 .macro	ADDR, reg, addr
@@ -40,14 +40,10 @@ RCSID("$NetBSD: start.S,v 1.4 2019/12/14
 	add	\reg, \reg, #:lo12:\addr
 .endm
 
-rpi_start:
-	b	start
-
 /*
  * Padding at start of kernel image to make room for 64-byte header (non-ELF booting)
  */
-
-	.align	6
+.space	64, 0x0
 
 /*
  * Kernel start routine for aarch64 boards.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 17:04:02 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: start.S

Log Message:
Allow RPI firmware boots to work again


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/start.S
diff -u src/sys/arch/aarch64/aarch64/start.S:1.3 src/sys/arch/aarch64/aarch64/start.S:1.4
--- src/sys/arch/aarch64/aarch64/start.S:1.3	Wed Dec  4 11:24:31 2019
+++ src/sys/arch/aarch64/aarch64/start.S	Sat Dec 14 17:04:02 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: start.S,v 1.3 2019/12/04 11:24:31 jmcneill Exp $	*/
+/*	$NetBSD: start.S,v 1.4 2019/12/14 17:04:02 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -32,7 +32,7 @@
 
 #include 
 
-RCSID("$NetBSD: start.S,v 1.3 2019/12/04 11:24:31 jmcneill Exp $")
+RCSID("$NetBSD: start.S,v 1.4 2019/12/14 17:04:02 skrll Exp $")
 
 /* load far effective address (pc relative) */
 .macro	ADDR, reg, addr
@@ -40,10 +40,14 @@ RCSID("$NetBSD: start.S,v 1.3 2019/12/04
 	add	\reg, \reg, #:lo12:\addr
 .endm
 
+rpi_start:
+	b	start
+
 /*
  * Padding at start of kernel image to make room for 64-byte header (non-ELF booting)
  */
-.space	64, 0x0
+
+	.align	6
 
 /*
  * Kernel start routine for aarch64 boards.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 17:04:02 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: start.S

Log Message:
Allow RPI firmware boots to work again


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/start.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 13:48:10 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Fix build... wire_count probably doesn't need atomics


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.52 src/sys/arch/aarch64/aarch64/pmap.c:1.53
--- src/sys/arch/aarch64/aarch64/pmap.c:1.52	Fri Dec 13 08:11:12 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Dec 14 13:48:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.52 2019/12/13 08:11:12 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.53 2019/12/14 13:48:09 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.52 2019/12/13 08:11:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.53 2019/12/14 13:48:09 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -655,7 +655,7 @@ _pmap_sweep_pdp(struct pmap *pm)
 		/* unlink from parent */
 		opte = atomic_swap_64(ptep_in_parent, 0);
 		KASSERT(lxpde_valid(opte));
-		wirecount = atomic_add_16_nv(>wire_count, -1); /* 1 -> 0 */
+		wirecount = atomic_add_32_nv(>wire_count, -1); /* 1 -> 0 */
 		KASSERT(wirecount == 0);
 		pmap_free_pdp(pm, pg);
 		nsweep++;
@@ -670,7 +670,7 @@ _pmap_sweep_pdp(struct pmap *pm)
 		KASSERTMSG(pg->wire_count >= 1,
 		"wire_count=%d", pg->wire_count);
 		/* decrement wire_count of parent */
-		wirecount = atomic_add_16_nv(>wire_count, -1);
+		wirecount = atomic_add_32_nv(>wire_count, -1);
 		KASSERTMSG(pg->wire_count <= (Ln_ENTRIES + 1),
 		"pm=%p[%d], pg=%p, wire_count=%d",
 		pm, pm->pm_asid, pg, pg->wire_count);
@@ -1443,8 +1443,8 @@ _pmap_pdp_addref(struct pmap *pm, paddr_
 		pg = PHYS_TO_VM_PAGE(pdppa);
 	KASSERT(pg != NULL);
 
-	CTASSERT(sizeof(pg->wire_count) == sizeof(uint16_t));
-	atomic_add_16(>wire_count, 1);
+	CTASSERT(sizeof(pg->wire_count) == sizeof(uint32_t));
+	atomic_add_32(>wire_count, 1);
 
 	KASSERTMSG(pg->wire_count <= (Ln_ENTRIES + 1),
 	"pg=%p, wire_count=%d", pg, pg->wire_count);
@@ -1473,7 +1473,7 @@ _pmap_pdp_delref(struct pmap *pm, paddr_
 	pg = PHYS_TO_VM_PAGE(pdppa);
 	KASSERT(pg != NULL);
 
-	wirecount = atomic_add_16_nv(>wire_count, -1);
+	wirecount = atomic_add_32_nv(>wire_count, -1);
 
 	if (!do_free_pdp) {
 		/*
@@ -1501,7 +1501,7 @@ _pmap_pdp_delref(struct pmap *pm, paddr_
 		/* unlink from parent */
 		opte = atomic_swap_64(ptep_in_parent, 0);
 		KASSERT(lxpde_valid(opte));
-		wirecount = atomic_add_16_nv(>wire_count, -1); /* 1 -> 0 */
+		wirecount = atomic_add_32_nv(>wire_count, -1); /* 1 -> 0 */
 		KASSERT(wirecount == 0);
 		pmap_free_pdp(pm, pg);
 		removed = true;
@@ -1516,7 +1516,7 @@ _pmap_pdp_delref(struct pmap *pm, paddr_
 		KASSERTMSG(pg->wire_count >= 1,
 		"wire_count=%d", pg->wire_count);
 		/* decrement wire_count of parent */
-		wirecount = atomic_add_16_nv(>wire_count, -1);
+		wirecount = atomic_add_32_nv(>wire_count, -1);
 		KASSERTMSG(pg->wire_count <= (Ln_ENTRIES + 1),
 		"pm=%p[%d], pg=%p, wire_count=%d",
 		pm, pm->pm_asid, pg, pg->wire_count);



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 14 13:48:10 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Fix build... wire_count probably doesn't need atomics


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec 13 08:11:12 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Fix KASAN support by calling kasan_shadow_map in pmap_growkernel


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.51 src/sys/arch/aarch64/aarch64/pmap.c:1.52
--- src/sys/arch/aarch64/aarch64/pmap.c:1.51	Tue Dec 10 18:08:32 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri Dec 13 08:11:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.51 2019/12/10 18:08:32 ad Exp $	*/
+/*	$NetBSD: pmap.c,v 1.52 2019/12/13 08:11:12 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.51 2019/12/10 18:08:32 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.52 2019/12/13 08:11:12 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -699,6 +699,9 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	UVMHIST_LOG(pmaphist, "maxkvaddr=%llx, pmap_maxkvaddr=%llx",
 	maxkvaddr, pmap_maxkvaddr, 0, 0);
 
+kasan_shadow_map((void *)pmap_maxkvaddr,
+  (size_t)(maxkvaddr - pmap_maxkvaddr));
+
 	pmap_maxkvaddr = maxkvaddr;
 
 	return maxkvaddr;



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Dec 13 08:11:12 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Fix KASAN support by calling kasan_shadow_map in pmap_growkernel


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Tue Dec 10 18:08:33 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
pg->phys_addr -> VM_PAGE_TO_PHYS(pg)


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.50 src/sys/arch/aarch64/aarch64/pmap.c:1.51
--- src/sys/arch/aarch64/aarch64/pmap.c:1.50	Thu Nov 14 17:09:22 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Tue Dec 10 18:08:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.50 2019/11/14 17:09:22 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.51 2019/12/10 18:08:32 ad Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.50 2019/11/14 17:09:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.51 2019/12/10 18:08:32 ad Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1034,7 +1034,7 @@ pg_dump(struct vm_page *pg, void (*pr)(c
 	pr(" pg->loan_count = %u\n", pg->loan_count);
 	pr(" pg->wire_count = %u\n", pg->wire_count);
 	pr(" pg->pqflags= %u\n", pg->pqflags);
-	pr(" pg->phys_addr  = %016lx\n", pg->phys_addr);
+	pr(" pg->phys_addr  = %016lx\n", VM_PAGE_TO_PHYS(pg));
 }
 
 static void



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-10 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Tue Dec 10 18:08:33 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
pg->phys_addr -> VM_PAGE_TO_PHYS(pg)


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Dec  8 10:37:19 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Mark FDT as non-exec and create KVA=VA mapping of same size as identity
mapping, i.e. include BOOTPAGE_ALLOC_MAX


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.45 src/sys/arch/aarch64/aarch64/locore.S:1.46
--- src/sys/arch/aarch64/aarch64/locore.S:1.45	Fri Nov 22 05:21:19 2019
+++ src/sys/arch/aarch64/aarch64/locore.S	Sun Dec  8 10:37:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.45 2019/11/22 05:21:19 mlelstv Exp $	*/
+/*	$NetBSD: locore.S,v 1.46 2019/12/08 10:37:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.45 2019/11/22 05:21:19 mlelstv Exp $")
+RCSID("$NetBSD: locore.S,v 1.46 2019/12/08 10:37:19 skrll Exp $")
 
 
 /*#define DEBUG_LOCORE			/* debug print */
@@ -826,6 +826,7 @@ init_mmutable:
 	adr	x6, bootpage_alloc		/* allocator */
 	mov	x5, xzr/* flags = 0 */
 	mov	x4, #LX_BLKPAG_ATTR_NORMAL_NC|LX_BLKPAG_AP_RW	/* attr */
+	orr	x4, x4, #LX_BLKPAG_UXN|LX_BLKPAG_PXN
 	mov	x3, #L2_SIZE			/* blocksize */
 	mov	x2, #L2_SIZE			/* size */
 	mov	x1, x8/* pa */
@@ -844,6 +845,7 @@ init_mmutable:
 	adr	x1, start			/* pa = start */
 	ADDR	x2, _end
 	sub	x2, x2, x1			/* size = _end - start */
+	add	x2, x2, #BOOTPAGE_ALLOC_MAX	/* for bootpage_alloc() */
 	ldr	x0, =start			/* va */
 	bl	pmapboot_enter
 	cbnz	x0, init_mmutable_error



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Dec  8 10:37:19 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Mark FDT as non-exec and create KVA=VA mapping of same size as identity
mapping, i.e. include BOOTPAGE_ALLOC_MAX


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-04 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Dec  5 05:45:52 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
fix build error by my previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/cpufunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-04 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Dec  5 05:45:52 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
fix build error by my previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/cpufunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.10 src/sys/arch/aarch64/aarch64/cpufunc.c:1.11
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.10	Thu Dec  5 05:17:55 2019
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Thu Dec  5 05:45:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.10 2019/12/05 05:17:55 ryo Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.11 2019/12/05 05:45:52 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.10 2019/12/05 05:17:55 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.11 2019/12/05 05:45:52 ryo Exp $");
 
 #include 
 #include 
@@ -126,7 +126,7 @@ aarch64_getcacheinfo(int unit)
 
 	/* Need static buffer for the boot CPU */
 	if (unit == 0)
-		cinfo = _cacheinfo0;
+		cinfo = aarch64_cacheinfo0;
 	else
 		cinfo = kmem_zalloc(sizeof(struct aarch64_cache_info)
 		* MAX_CACHE_LEVEL, KM_SLEEP);



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-04 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Dec  5 05:17:55 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
MAX_CACHE_LEVEL * struct aarch64_cache_info are required to statically allocate 
for cpu0.

avoid "cpu0: L2 512KB/64B 16-way write-back read-allocate write-allocate PIPT 
*UNK* cache" by r1.8


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/cpufunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-04 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Dec  5 05:17:55 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
MAX_CACHE_LEVEL * struct aarch64_cache_info are required to statically allocate 
for cpu0.

avoid "cpu0: L2 512KB/64B 16-way write-back read-allocate write-allocate PIPT 
*UNK* cache" by r1.8


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/cpufunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.9 src/sys/arch/aarch64/aarch64/cpufunc.c:1.10
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.9	Mon Dec  2 23:22:43 2019
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Thu Dec  5 05:17:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.9 2019/12/02 23:22:43 ad Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.10 2019/12/05 05:17:55 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -29,7 +29,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.9 2019/12/02 23:22:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.10 2019/12/05 05:17:55 ryo Exp $");
 
 #include 
 #include 
@@ -49,7 +49,7 @@ u_int aarch64_cache_prefer_mask;
 /* cache info per cluster. the same cluster has the same cache configuration? */
 #define MAXCPUPACKAGES	MAXCPUS		/* maximum of ci->ci_package_id */
 static struct aarch64_cache_info *aarch64_cacheinfo[MAXCPUPACKAGES];
-static struct aarch64_cache_info aarch64_cacheinfo0;
+static struct aarch64_cache_info aarch64_cacheinfo0[MAX_CACHE_LEVEL];
 
 
 static void



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec  4 13:47:03 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: TODO

Log Message:
remove DTrace from TODO list


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/TODO

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec  4 13:47:03 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: TODO

Log Message:
remove DTrace from TODO list


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/aarch64/TODO

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/TODO
diff -u src/sys/arch/aarch64/aarch64/TODO:1.7 src/sys/arch/aarch64/aarch64/TODO:1.8
--- src/sys/arch/aarch64/aarch64/TODO:1.7	Wed May  8 02:57:11 2019
+++ src/sys/arch/aarch64/aarch64/TODO	Wed Dec  4 13:47:03 2019
@@ -1,8 +1,7 @@
-$NetBSD: TODO,v 1.7 2019/05/08 02:57:11 msaitoh Exp $
+$NetBSD: TODO,v 1.8 2019/12/04 13:47:03 jmcneill Exp $
 
 TODO list for NetBSD/aarch64
   - kernel preemption
   - Implement __HAVE_UCAS_FULL or __HAVE_UCAS_MP (don't use full generic impl)
   - pmap should be work even if PID_MAX >= 65536 (don't depend 16bit ASID)
   - TLB ASID in pmap should be randomized
-  - DTrace



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec  3 22:02:43 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
Add KDTRACE_HOOKS support.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/aarch64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec  3 22:02:43 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
Add KDTRACE_HOOKS support.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/aarch64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.21 src/sys/arch/aarch64/aarch64/trap.c:1.22
--- src/sys/arch/aarch64/aarch64/trap.c:1.21	Sun Nov 24 04:08:36 2019
+++ src/sys/arch/aarch64/aarch64/trap.c	Tue Dec  3 22:02:43 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.21 2019/11/24 04:08:36 rin Exp $ */
+/* $NetBSD: trap.c,v 1.22 2019/12/03 22:02:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,10 +31,11 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.21 2019/11/24 04:08:36 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.22 2019/12/03 22:02:43 jmcneill Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
+#include "opt_dtrace.h"
 
 #include 
 #include 
@@ -73,11 +74,20 @@ __KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.2
 #include 
 #include 
 #endif
+#ifdef KDTRACE_HOOKS
+#include 
+#endif
 
 #ifdef DDB
 int sigill_debug = 0;
 #endif
 
+#ifdef KDTRACE_HOOKS
+dtrace_doubletrap_func_t	dtrace_doubletrap_func = NULL;
+dtrace_trap_func_t		dtrace_trap_func = NULL;
+int (*dtrace_invop_jump_addr)(struct trapframe *);
+#endif
+
 const char * const trap_names[] = {
 	[ESR_EC_UNKNOWN]	= "Unknown Reason (Illegal Instruction)",
 	[ESR_EC_SERROR]		= "SError Interrupt",
@@ -182,16 +192,29 @@ trap_el1h_sync(struct trapframe *tf)
 	else
 		daif_enable(DAIF_D|DAIF_A);
 
+#ifdef KDTRACE_HOOKS
+	if (dtrace_trap_func != NULL && (*dtrace_trap_func)(tf, eclass))
+		return;
+#endif
+
 	switch (eclass) {
 	case ESR_EC_INSN_ABT_EL1:
 	case ESR_EC_DATA_ABT_EL1:
 		data_abort_handler(tf, eclass);
 		break;
 
+	case ESR_EC_BKPT_INSN_A64:
+#ifdef KDTRACE_HOOKS
+		if (__SHIFTOUT(esr, ESR_ISS) == 0x40d &&
+		dtrace_invop_jump_addr != 0) {
+			(*dtrace_invop_jump_addr)(tf);
+			break;
+		}
+		/* FALLTHROUGH */
+#endif
 	case ESR_EC_BRKPNT_EL1:
 	case ESR_EC_SW_STEP_EL1:
 	case ESR_EC_WTCHPNT_EL1:
-	case ESR_EC_BKPT_INSN_A64:
 #ifdef DDB
 		if (eclass == ESR_EC_BRKPNT_EL1)
 			kdb_trap(DB_TRAP_BREAKPOINT, tf);



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  1 20:27:26 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: kobj_machdep.c

Log Message:
Flush insn / data caches after loading modules


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/kobj_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/kobj_machdep.c
diff -u src/sys/arch/aarch64/aarch64/kobj_machdep.c:1.2 src/sys/arch/aarch64/aarch64/kobj_machdep.c:1.3
--- src/sys/arch/aarch64/aarch64/kobj_machdep.c:1.2	Sun Aug 19 20:02:22 2018
+++ src/sys/arch/aarch64/aarch64/kobj_machdep.c	Sun Dec  1 20:27:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kobj_machdep.c,v 1.2 2018/08/19 20:02:22 ryo Exp $	*/
+/*	$NetBSD: kobj_machdep.c,v 1.3 2019/12/01 20:27:26 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,19 +27,21 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.2 2018/08/19 20:02:22 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.3 2019/12/01 20:27:26 jmcneill Exp $");
 
 #define ELFSIZE		ARCH_ELFSIZE
 
 #include "opt_ddb.h"
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -357,8 +359,26 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 	return 0;
 }
 
+static void
+kobj_idcache_wbinv_all(void)
+{
+	cpu_idcache_wbinv_all();
+}
+
 int
 kobj_machdep(kobj_t ko, void *base, size_t size, bool load)
 {
+	uint64_t where;
+
+	if (load) {
+		if (cold) {
+			kobj_idcache_wbinv_all();
+		} else {
+			where = xc_broadcast(0,
+			(xcfunc_t)kobj_idcache_wbinv_all, NULL, NULL);
+			xc_wait(where);
+		}
+	}
+
 	return 0;
 }



CVS commit: src/sys/arch/aarch64/aarch64

2019-12-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  1 20:27:26 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: kobj_machdep.c

Log Message:
Flush insn / data caches after loading modules


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/kobj_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-11-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Nov 24 11:45:00 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: exec_machdep.c

Log Message:
part of PR port-arm/54702

Make sure that md_march32 and ep_machine_arch have same size.

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/exec_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-11-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Nov 24 11:45:00 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: exec_machdep.c

Log Message:
part of PR port-arm/54702

Make sure that md_march32 and ep_machine_arch have same size.

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/exec_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/exec_machdep.c
diff -u src/sys/arch/aarch64/aarch64/exec_machdep.c:1.5 src/sys/arch/aarch64/aarch64/exec_machdep.c:1.6
--- src/sys/arch/aarch64/aarch64/exec_machdep.c:1.5	Sun Nov 24 04:08:36 2019
+++ src/sys/arch/aarch64/aarch64/exec_machdep.c	Sun Nov 24 11:45:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_machdep.c,v 1.5 2019/11/24 04:08:36 rin Exp $ */
+/* $NetBSD: exec_machdep.c,v 1.6 2019/11/24 11:45:00 rin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: exec_machdep.c,v 1.5 2019/11/24 04:08:36 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_machdep.c,v 1.6 2019/11/24 11:45:00 rin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_netbsd32.h"
@@ -86,6 +86,8 @@ aarch64_netbsd_elf32_probe(struct lwp *l
 	/*
 	 * Copy (if any) the machine_arch of the executable to the proc.
 	 */
+	CTASSERT(sizeof(l->l_proc->p_md.md_march32) ==
+	sizeof(epp->ep_machine_arch));
 	if (epp->ep_machine_arch[0] != 0)
 		strlcpy(l->l_proc->p_md.md_march32, epp->ep_machine_arch,
 		sizeof(l->l_proc->p_md.md_march32));



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-28 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Oct 28 18:15:26 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: db_disasm.c

Log Message:
Format string annotation for strdisasm_printf


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/db_disasm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/db_disasm.c
diff -u src/sys/arch/aarch64/aarch64/db_disasm.c:1.6 src/sys/arch/aarch64/aarch64/db_disasm.c:1.7
--- src/sys/arch/aarch64/aarch64/db_disasm.c:1.6	Sun Jan 27 02:08:36 2019
+++ src/sys/arch/aarch64/aarch64/db_disasm.c	Mon Oct 28 18:15:25 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: db_disasm.c,v 1.6 2019/01/27 02:08:36 pgoyette Exp $ */
+/* $NetBSD: db_disasm.c,v 1.7 2019/10/28 18:15:25 joerg Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.6 2019/01/27 02:08:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.7 2019/10/28 18:15:25 joerg Exp $");
 
 #include 
 #include 
@@ -75,7 +75,7 @@ strdisasm_readword(uintptr_t address)
 	return *(uint32_t *)address;
 }
 
-static void
+static void __printflike(1, 2)
 strdisasm_printf(const char *fmt, ...)
 {
 	va_list ap;



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-28 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Oct 28 18:15:26 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: db_disasm.c

Log Message:
Format string annotation for strdisasm_printf


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/aarch64/aarch64/db_disasm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 20 14:03:51 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c locore.S

Log Message:
Use separate cacheline aligned arrays for mbox and hatched as before.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.24 src/sys/arch/aarch64/aarch64/cpu.c:1.25
--- src/sys/arch/aarch64/aarch64/cpu.c:1.24	Sun Oct 20 11:17:41 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Oct 20 14:03:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.24 2019/10/20 11:17:41 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.25 2019/10/20 14:03:51 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.24 2019/10/20 11:17:41 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.25 2019/10/20 14:03:51 jmcneill Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -69,9 +69,8 @@ static void cpu_setup_sysctl(device_t, s
 #ifdef MULTIPROCESSOR
 uint64_t cpu_mpidr[MAXCPUS];
 
-volatile u_int aarch64_cpu_mbox[MAXCPUS] __cacheline_aligned = { 0 };
-#define CPU_MBOX_HATCHED	__BIT(0)
-#define	CPU_MBOX_START		__BIT(1)
+volatile u_int aarch64_cpu_mbox[howmany(MAXCPUS, sizeof(u_int))] __cacheline_aligned = { 0 };
+volatile u_int aarch64_cpu_hatched[howmany(MAXCPUS, sizeof(u_int))] __cacheline_aligned = { 0 };
 u_int arm_cpu_max = 1;
 
 static kmutex_t cpu_hatch_lock;
@@ -500,7 +499,7 @@ cpu_setup_sysctl(device_t dv, struct cpu
 void
 cpu_boot_secondary_processors(void)
 {
-	u_int cpuno;
+	u_int n, bit;
 
 	if ((boothowto & RB_MD1) != 0)
 		return;
@@ -510,22 +509,20 @@ cpu_boot_secondary_processors(void)
 	VPRINTF("%s: starting secondary processors\n", __func__);
 
 	/* send mbox to have secondary processors do cpu_hatch() */
-	for (cpuno = 1; cpuno < ncpu; cpuno++) {
-		if (cpu_hatched_p(cpuno) == false)
-			continue;
-		atomic_or_uint(_cpu_mbox[cpuno], CPU_MBOX_START);
-	}
+	for (n = 0; n < __arraycount(aarch64_cpu_mbox); n++)
+		atomic_or_uint(_cpu_mbox[n], aarch64_cpu_hatched[n]);
 	__asm __volatile ("sev; sev; sev");
 
 	/* wait all cpus have done cpu_hatch() */
-	for (cpuno = 1; cpuno < ncpu; cpuno++) {
-		if (cpu_hatched_p(cpuno) == 0)
-			continue;
-		while (membar_consumer(), aarch64_cpu_mbox[cpuno] & CPU_MBOX_START) {
+	for (n = 0; n < __arraycount(aarch64_cpu_mbox); n++) {
+		while (membar_consumer(), aarch64_cpu_mbox[n] & aarch64_cpu_hatched[n]) {
 			__asm __volatile ("wfe");
 		}
-		/* Add processor to kcpuset */
-		kcpuset_set(kcpuset_attached, cpuno);
+		/* Add processors to kcpuset */
+		for (bit = 0; bit < 32; bit++) {
+			if (aarch64_cpu_hatched[n] & __BIT(bit))
+kcpuset_set(kcpuset_attached, n * 32 + bit);
+		}
 	}
 
 	VPRINTF("%s: secondary processors hatched\n", __func__);
@@ -563,15 +560,18 @@ cpu_hatch(struct cpu_info *ci)
 	 * ci_index are each cpu0=0, cpu1=1, cpu2=undef, cpu3=2.
 	 * therefore we have to use device_unit instead of ci_index for mbox.
 	 */
-	const u_int cpuno = device_unit(ci->ci_dev);
-	atomic_and_uint(_cpu_mbox[cpuno], ~(u_int)CPU_MBOX_START);
+	const u_int off = device_unit(ci->ci_dev) / 32;
+	const u_int bit = device_unit(ci->ci_dev) % 32;
+	atomic_and_uint(_cpu_mbox[off], ~__BIT(bit));
 	__asm __volatile ("sev; sev; sev");
 }
 
 bool
 cpu_hatched_p(u_int cpuindex)
 {
-	aarch64_dcache_inv_range((vaddr_t)_cpu_mbox[cpuindex], 4);
-	return (aarch64_cpu_mbox[cpuindex] & CPU_MBOX_HATCHED) != 0;
+	const u_int off = cpuindex / 32;
+	const u_int bit = cpuindex % 32;
+	membar_consumer();
+	return (aarch64_cpu_hatched[off] & __BIT(bit)) != 0;
 }
 #endif /* MULTIPROCESSOR */

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.43 src/sys/arch/aarch64/aarch64/locore.S:1.44
--- src/sys/arch/aarch64/aarch64/locore.S:1.43	Sun Oct 20 12:25:43 2019
+++ src/sys/arch/aarch64/aarch64/locore.S	Sun Oct 20 14:03:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.43 2019/10/20 12:25:43 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.44 2019/10/20 14:03:51 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.43 2019/10/20 12:25:43 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.44 2019/10/20 14:03:51 jmcneill Exp $")
 
 
 /*#define DEBUG_LOCORE			/* debug print */
@@ -361,19 +361,16 @@ ENTRY_NP(cpu_mpstart)
 	mov	x1, xzr
 1:
 	add	x1, x1, #1
-	cmp	x1, MAXCPUS		/* cpuindex >= MAXCPUS ? */
+	cmp	x1, #MAXCPUS		/* cpuindex >= MAXCPUS ? */
 	bge	toomanycpus
 	ldr	x2, [x0, x1, lsl #3]	/* cpu_mpidr[cpuindex] */
 	cmp	x2, x3			/* == mpidr_el1 & MPIDR_AFF ? */
 	bne	1b
 
 	mov	x27, x1			/* x27 = cpuindex */
-	ADDR	x0, 

CVS commit: src/sys/arch/aarch64/aarch64

2019-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 20 14:03:51 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c locore.S

Log Message:
Use separate cacheline aligned arrays for mbox and hatched as before.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 20 12:25:43 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Avoid overlap between BP and last AP stack. AP stacks are now in order of
increasing address order.

Spotted by and idea from mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 20 12:25:43 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Avoid overlap between BP and last AP stack. AP stacks are now in order of
increasing address order.

Spotted by and idea from mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.42 src/sys/arch/aarch64/aarch64/locore.S:1.43
--- src/sys/arch/aarch64/aarch64/locore.S:1.42	Sat Oct 19 18:04:26 2019
+++ src/sys/arch/aarch64/aarch64/locore.S	Sun Oct 20 12:25:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.42 2019/10/19 18:04:26 jmcneill Exp $	*/
+/*	$NetBSD: locore.S,v 1.43 2019/10/20 12:25:43 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.42 2019/10/19 18:04:26 jmcneill Exp $")
+RCSID("$NetBSD: locore.S,v 1.43 2019/10/20 12:25:43 skrll Exp $")
 
 
 /*#define DEBUG_LOCORE			/* debug print */
@@ -379,9 +379,8 @@ ENTRY_NP(cpu_mpstart)
 	/* set stack pointer for boot */
 	mov	x1, #BOOT_AP_STACKSIZE
 	mul	x1, x1, x27
-	ADDR	x0, bootstk_cpus
-	sub	sp, x0, x1  /* sp = bootstk_cpus-(BOOT_AP_STACKSIZE*cpuindex) */
-
+	ADDR	x0, bootstk
+	add	sp, x0, x1  /* sp = bootstk + (BOOT_AP_STACKSIZE * cpuindex) */
 
 	bl	1f
 1:	CPU_DPRINTREG("PC   = ", lr)
@@ -1038,7 +1037,6 @@ bootstk:
 
 #ifdef MULTIPROCESSOR
 	.space	BOOT_AP_STACKSIZE * (MAXCPUS - 1)
-bootstk_cpus:
 #endif
 
 	.section ".init_pagetable", "aw", %nobits



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 20 11:17:42 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Invalidate dcache before polling AP hatched status


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.23 src/sys/arch/aarch64/aarch64/cpu.c:1.24
--- src/sys/arch/aarch64/aarch64/cpu.c:1.23	Sat Oct 19 18:04:26 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Oct 20 11:17:41 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.23 2019/10/19 18:04:26 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.24 2019/10/20 11:17:41 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.23 2019/10/19 18:04:26 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.24 2019/10/20 11:17:41 jmcneill Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -571,7 +571,7 @@ cpu_hatch(struct cpu_info *ci)
 bool
 cpu_hatched_p(u_int cpuindex)
 {
-	membar_consumer();
+	aarch64_dcache_inv_range((vaddr_t)_cpu_mbox[cpuindex], 4);
 	return (aarch64_cpu_mbox[cpuindex] & CPU_MBOX_HATCHED) != 0;
 }
 #endif /* MULTIPROCESSOR */



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 20 11:17:42 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Invalidate dcache before polling AP hatched status


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 14 22:53:05 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Remove the A72 errata #859971 detection, it causes an illegal instruction on 
AWS A1 (virtualized)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.21 src/sys/arch/aarch64/aarch64/cpu.c:1.22
--- src/sys/arch/aarch64/aarch64/cpu.c:1.21	Sun Sep 15 15:16:30 2019
+++ src/sys/arch/aarch64/aarch64/cpu.c	Mon Oct 14 22:53:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.21 2019/09/15 15:16:30 tnn Exp $ */
+/* $NetBSD: cpu.c,v 1.22 2019/10/14 22:53:05 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.21 2019/09/15 15:16:30 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.22 2019/10/14 22:53:05 jmcneill Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -432,14 +432,6 @@ cpu_identify2(device_t self, struct cpu_
 	}
 
 	aprint_normal("\n");
-
-	if ((id->ac_midr & CPU_PARTMASK) == (CPU_ID_CORTEXA72R0 & CPU_PARTMASK)
-	&& __SHIFTOUT(id->ac_midr, CPU_ID_REVISION_MASK) <= 3) {
-		aprint_normal_dev(self, "A72 errata #859971 present"
-		", workaround %s\n",
-		ISSET(reg_a72_cpuactlr_el1_read(), __BIT(32))
-		? "enabled" : "NOT enabled (U-Boot update needed)");
-	}
 }
 
 /*



CVS commit: src/sys/arch/aarch64/aarch64

2019-10-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 14 22:53:05 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c

Log Message:
Remove the A72 errata #859971 detection, it causes an illegal instruction on 
AWS A1 (virtualized)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/aarch64/aarch64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 29 08:33:20 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 29 08:33:20 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
Typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/aarch64/aarch64/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.40 src/sys/arch/aarch64/aarch64/locore.S:1.41
--- src/sys/arch/aarch64/aarch64/locore.S:1.40	Sun Sep  8 12:17:23 2019
+++ src/sys/arch/aarch64/aarch64/locore.S	Sun Sep 29 08:33:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.40 2019/09/08 12:17:23 jmcneill Exp $	*/
+/*	$NetBSD: locore.S,v 1.41 2019/09/29 08:33:20 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.40 2019/09/08 12:17:23 jmcneill Exp $")
+RCSID("$NetBSD: locore.S,v 1.41 2019/09/29 08:33:20 skrll Exp $")
 
 
 /*#define DEBUG_LOCORE			/* debug print */
@@ -799,7 +799,7 @@ init_mmutable:
 	adr	x0, start			/* va = start */
 	ADDR	x2, _end
 	sub	x2, x2, x0			/* size = _end - start */
-	add	x2, x2, #BOOTPAGE_ALLOC_MAX	/* for boopage_alloc() */
+	add	x2, x2, #BOOTPAGE_ALLOC_MAX	/* for bootpage_alloc() */
 	mov	x1, x0/* pa */
 	bl	pmapboot_enter
 	cbnz	x0, init_mmutable_error



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 28 07:06:50 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
newline after break


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/aarch64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 28 07:06:50 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: trap.c

Log Message:
newline after break


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/aarch64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/trap.c
diff -u src/sys/arch/aarch64/aarch64/trap.c:1.18 src/sys/arch/aarch64/aarch64/trap.c:1.19
--- src/sys/arch/aarch64/aarch64/trap.c:1.18	Wed Aug  7 09:49:40 2019
+++ src/sys/arch/aarch64/aarch64/trap.c	Sat Sep 28 07:06:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.18 2019/08/07 09:49:40 jmcneill Exp $ */
+/* $NetBSD: trap.c,v 1.19 2019/09/28 07:06:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.18 2019/08/07 09:49:40 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.19 2019/09/28 07:06:50 skrll Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -348,10 +348,12 @@ trap_el0_32sync(struct trapframe *tf)
 	case ESR_EC_SVC_A32:
 		(*l->l_proc->p_md.md_syscall)(tf);
 		break;
+
 	case ESR_EC_FP_ACCESS:
 		fpu_load(l);
 		userret(l);
 		break;
+
 	case ESR_EC_FP_TRAP_A32:
 		do_trapsignal(l, SIGFPE, FPE_FLTUND, NULL, esr); /* XXX */
 		userret(l);
@@ -361,6 +363,7 @@ trap_el0_32sync(struct trapframe *tf)
 		do_trapsignal(l, SIGBUS, BUS_ADRALN, (void *)tf->tf_pc, esr);
 		userret(l);
 		break;
+
 	case ESR_EC_SP_ALIGNMENT:
 		do_trapsignal(l, SIGBUS, BUS_ADRALN,
 		(void *)tf->tf_reg[13], esr); /* sp is r13 on AArch32 */



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 28 07:06:32 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 28 07:06:32 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.31 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.32
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.31	Wed Sep 11 08:15:48 2019
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Sat Sep 28 07:06:32 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.31 2019/09/11 08:15:48 ryo Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.32 2019/09/28 07:06:32 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.31 2019/09/11 08:15:48 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.32 2019/09/28 07:06:32 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -225,7 +225,6 @@ cpu_kernel_vm_init(uint64_t memory_start
 
 	aarch64_tlbi_all();
 
-
 	VPRINTF("%s: kernel phys start %lx end %lx+%lx\n", __func__,
 	kernstart_phys, kernend_phys, kernend_extra);
 	fdt_add_reserved_memory_range(kernstart_phys,



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 22 13:57:55 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Disable translation table walks using TTBR0 while changing its value and
when deactivating a pmap. Fixes stability issues on Ampere eMAG CPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 22 13:57:55 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
Disable translation table walks using TTBR0 while changing its value and
when deactivating a pmap. Fixes stability issues on Ampere eMAG CPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.46 src/sys/arch/aarch64/aarch64/pmap.c:1.47
--- src/sys/arch/aarch64/aarch64/pmap.c:1.46	Fri Sep 20 05:35:27 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Sep 22 13:57:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.46 2019/09/20 05:35:27 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.47 2019/09/22 13:57:55 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.46 2019/09/20 05:35:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.47 2019/09/22 13:57:55 jmcneill Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1274,7 +1274,7 @@ void
 pmap_activate(struct lwp *l)
 {
 	struct pmap *pm = l->l_proc->p_vmspace->vm_map.pmap;
-	uint64_t ttbr0;
+	uint64_t ttbr0, tcr;
 
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLED(pmaphist);
@@ -1288,6 +1288,11 @@ pmap_activate(struct lwp *l)
 
 	UVMHIST_LOG(pmaphist, "lwp=%p (pid=%d)", l, l->l_proc->p_pid, 0, 0);
 
+	/* Disable translation table walks using TTBR0 */
+	tcr = reg_tcr_el1_read();
+	reg_tcr_el1_write(tcr | TCR_EPD0);
+	__asm __volatile("isb" ::: "memory");
+
 	/* XXX */
 	CTASSERT(PID_MAX <= 65535);	/* 16bit ASID */
 	if (pm->pm_asid == -1)
@@ -1296,6 +1301,11 @@ pmap_activate(struct lwp *l)
 	ttbr0 = ((uint64_t)pm->pm_asid << 48) | pm->pm_l0table_pa;
 	cpu_set_ttbr0(ttbr0);
 
+	/* Re-enable translation table walks using TTBR0 */
+	tcr = reg_tcr_el1_read();
+	reg_tcr_el1_write(tcr & ~TCR_EPD0);
+	__asm __volatile("isb" ::: "memory");
+
 	pm->pm_activated = true;
 
 	PMAP_COUNT(activate);
@@ -1305,6 +1315,7 @@ void
 pmap_deactivate(struct lwp *l)
 {
 	struct pmap *pm = l->l_proc->p_vmspace->vm_map.pmap;
+	uint64_t tcr;
 
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLED(pmaphist);
@@ -1314,6 +1325,11 @@ pmap_deactivate(struct lwp *l)
 
 	UVMHIST_LOG(pmaphist, "lwp=%p, asid=%d", l, pm->pm_asid, 0, 0);
 
+	/* Disable translation table walks using TTBR0 */
+	tcr = reg_tcr_el1_read();
+	reg_tcr_el1_write(tcr | TCR_EPD0);
+	__asm __volatile("isb" ::: "memory");
+
 	/* XXX */
 	pm->pm_activated = false;
 



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-19 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Sep 20 05:35:27 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
ref/mod bit should be set according to 'flags' argument, not 'prot'.  r1.44 was 
incomplete.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-19 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Sep 20 05:35:27 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c

Log Message:
ref/mod bit should be set according to 'flags' argument, not 'prot'.  r1.44 was 
incomplete.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.45 src/sys/arch/aarch64/aarch64/pmap.c:1.46
--- src/sys/arch/aarch64/aarch64/pmap.c:1.45	Fri Sep 13 18:07:30 2019
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri Sep 20 05:35:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.45 2019/09/13 18:07:30 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.46 2019/09/20 05:35:27 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.45 2019/09/13 18:07:30 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.46 2019/09/20 05:35:27 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1724,6 +1724,8 @@ _pmap_enter(struct pmap *pm, vaddr_t va,
 	 */
 	if (prot & (VM_PROT_WRITE|VM_PROT_EXECUTE))
 		prot |= VM_PROT_READ;
+	if (flags & (VM_PROT_WRITE|VM_PROT_EXECUTE))
+		flags |= VM_PROT_READ;
 
 	mdattr = VM_PROT_READ | VM_PROT_WRITE;
 	if (need_update_pv) {
@@ -1750,7 +1752,7 @@ _pmap_enter(struct pmap *pm, vaddr_t va,
 	if (pg != NULL) {
 		/* update referenced/modified flags */
 		VM_PAGE_TO_MD(pg)->mdpg_flags |=
-		(prot & (VM_PROT_READ | VM_PROT_WRITE));
+		(flags & (VM_PROT_READ | VM_PROT_WRITE));
 		mdattr &= VM_PAGE_TO_MD(pg)->mdpg_flags;
 	}
 



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 15 07:13:37 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpuswitch.S

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/cpuswitch.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 15 07:13:37 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpuswitch.S

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/cpuswitch.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpuswitch.S
diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.11 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.12
--- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.11	Thu Dec 27 09:55:27 2018
+++ src/sys/arch/aarch64/aarch64/cpuswitch.S	Sun Sep 15 07:13:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.11 2018/12/27 09:55:27 mrg Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.12 2019/09/15 07:13:37 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #include "opt_ddb.h"
 #include "opt_kasan.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.11 2018/12/27 09:55:27 mrg Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.12 2019/09/15 07:13:37 skrll Exp $")
 
 /*
  * At IPL_SCHED:
@@ -64,7 +64,7 @@ ENTRY_NP(cpu_switchto)
 	 * Save the current stack pointer and the CPACR and save them in
 	 * old lwp md area.
 	 */
-	mov	x4, sp 
+	mov	x4, sp
 	mrs	x5, cpacr_el1
 	str	x5, [x0, #L_MD_CPACR]
 	ldr	x6, [x0, #L_PCB]	/* x6 = lwp_getpcb(oldlwp) */



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Sep 12 09:05:28 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
Do not attempt to change coherency_unit at runtime. Instead, if the
required coherency unit is greater than COHERENCY_UNIT in a MULTIPROCESSOR
kernel, just panic instead.

This makes non-MULTIPROCESSOR kernels work again.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/cpufunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Sep 12 09:05:28 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc.c

Log Message:
Do not attempt to change coherency_unit at runtime. Instead, if the
required coherency unit is greater than COHERENCY_UNIT in a MULTIPROCESSOR
kernel, just panic instead.

This makes non-MULTIPROCESSOR kernels work again.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/cpufunc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.5 src/sys/arch/aarch64/aarch64/cpufunc.c:1.6
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.5	Fri Dec 21 08:01:01 2018
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Thu Sep 12 09:05:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.5 2018/12/21 08:01:01 ryo Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.6 2019/09/12 09:05:28 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -26,8 +26,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_multiprocessor.h"
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.5 2018/12/21 08:01:01 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.6 2019/09/12 09:05:28 jmcneill Exp $");
 
 #include 
 #include 
@@ -135,9 +137,12 @@ aarch64_getcacheinfo(void)
 		arm_dcache_align = sizeof(int) << arm_dcache_maxline;
 		arm_dcache_align_mask = arm_dcache_align - 1;
 	}
-	/* update coherency_unit (in param.h) */
+
+#ifdef MULTIPROCESSOR
 	if (coherency_unit < arm_dcache_align)
-		coherency_unit = arm_dcache_align;
+		panic("coherency_unit %ld < arm_dcache_align %d; increase COHERENCY_UNIT",
+		coherency_unit, arm_dcache_align);
+#endif
 
 	/*
 	 * CLIDR -  Cache Level ID Register



CVS commit: src/sys/arch/aarch64/aarch64

2019-09-12 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Sep 12 06:12:56 UTC 2019

Modified Files:
src/sys/arch/aarch64/aarch64: cpufunc_asm_armv8.S

Log Message:
even if "no options MULTIPROCESSOR" requires isb after tlbi op. since it should 
be harmless, dsb is also added.
fixed a problem that rockpro64 doesn't boot without MULTIPROCESSOR.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S
diff -u src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.3 src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.4
--- src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S:1.3	Fri Dec 21 08:01:01 2018
+++ src/sys/arch/aarch64/aarch64/cpufunc_asm_armv8.S	Thu Sep 12 06:12:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc_asm_armv8.S,v 1.3 2018/12/21 08:01:01 ryo Exp $	*/
+/*	$NetBSD: cpufunc_asm_armv8.S,v 1.4 2019/09/12 06:12:56 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2014 Robin Randhawa
@@ -243,16 +243,14 @@ ENTRY(aarch64_tlbi_by_asid_va)
 	/* x8 = bit 63[ASID]48, 47[RES0]44, 43[VA(55:12)]0 */
 	lsl	x8, x0, #48
 	bfxil	x8, x1, #12, #44
-#ifdef MULTIPROCESSOR
-	/* need dsb and isb for inner shareable? */
 	dsb	ishst
+#ifdef MULTIPROCESSOR
 	tlbi	vae1is, x8
-	dsb	ish
-	isb
 #else
-	/* no need dsb and isb for single entry */
 	tlbi	vae1, x8
 #endif
+	dsb	ish
+	isb
 	ret
 END(aarch64_tlbi_by_asid_va)
 
@@ -261,15 +259,13 @@ ENTRY(aarch64_tlbi_by_asid_va_ll)
 	/* x8 = bit 63[ASID]48, 47[RES0]44, 43[VA(55:12)]0 */
 	lsl	x8, x0, #48
 	bfxil	x8, x1, #12, #44
-#ifdef MULTIPROCESSOR
-	/* need dsb and isb for inner shareable? */
 	dsb	ishst
+#ifdef MULTIPROCESSOR
 	tlbi	vale1is, x8
-	dsb	ish
-	isb
 #else
-	/* no need dsb and isb for single entry */
 	tlbi	vale1, x8
 #endif
+	dsb	ish
+	isb
 	ret
 END(aarch64_tlbi_by_asid_va_ll)



<    1   2   3   4   5   6   7   8   9   >