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

2022-05-06 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri May  6 06:09:51 UTC 2022

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

Log Message:
Sprinkle isb after modifying system regs of pointer auth.
With options ARMV83_PAC, it now works on native Mac M1.

TODO: Multiple ISBs should be combined in one place.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.25 -r1.26 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/cpuswitch.S
diff -u src/sys/arch/aarch64/aarch64/cpuswitch.S:1.33 src/sys/arch/aarch64/aarch64/cpuswitch.S:1.34
--- src/sys/arch/aarch64/aarch64/cpuswitch.S:1.33	Tue Mar  9 16:44:27 2021
+++ src/sys/arch/aarch64/aarch64/cpuswitch.S	Fri May  6 06:09:50 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.33 2021/03/09 16:44:27 ryo Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.34 2022/05/06 06:09:50 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include "opt_ddb.h"
 #include "opt_kasan.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.33 2021/03/09 16:44:27 ryo Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.34 2022/05/06 06:09:50 ryo Exp $")
 
 	ARMV8_DEFINE_OPTIONS
 
@@ -115,6 +115,7 @@ ENTRY_NP(cpu_switchto)
 	msr	APGAKeyLo_EL1, x5
 	msr	APGAKeyHi_EL1, x6
 1:
+	isb
 #endif
 
 	msr	tpidr_el1, x1		/* switch curlwp to new lwp */
@@ -202,6 +203,7 @@ ENTRY_NP(cpu_switchto_softint)
 	ldp	x5, x6, [x0, #L_MD_IA_KERN]
 	msr	APIAKeyLo_EL1, x5
 	msr	APIAKeyHi_EL1, x6
+	isb
 1:
 #endif
 	ENABLE_INTERRUPT
@@ -235,6 +237,7 @@ ENTRY_NP(cpu_switchto_softint)
 	ldp	x5, x6, [x19, #L_MD_IA_KERN]
 	msr	APIAKeyLo_EL1, x5
 	msr	APIAKeyHi_EL1, x6
+	isb
 1:
 #endif
 
@@ -289,12 +292,14 @@ ENTRY_NP(lwp_trampoline)
 	ldr	w4, [x4]
 	cbz	w4, 1f
 	mov	x26, x1
+
 	bl	_C_LABEL(cprng_strong64)
-	str	x0, [x26, #L_MD_IA_KERN]
-	msr	APIAKeyLo_EL1, x0
+	mov	x25, x0
 	bl	_C_LABEL(cprng_strong64)
-	str	x0, [x26, #(L_MD_IA_KERN + 8)]
+	stp	x25, x0, [x26, #L_MD_IA_KERN]
+	msr	APIAKeyLo_EL1, x25
 	msr	APIAKeyHi_EL1, x0
+	isb
 1:
 #endif
 

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.85 src/sys/arch/aarch64/aarch64/locore.S:1.86
--- src/sys/arch/aarch64/aarch64/locore.S:1.85	Mon Jan 31 09:16:09 2022
+++ src/sys/arch/aarch64/aarch64/locore.S	Fri May  6 06:09:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.85 2022/01/31 09:16:09 ryo Exp $	*/
+/*	$NetBSD: locore.S,v 1.86 2022/05/06 06:09:50 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.85 2022/01/31 09:16:09 ryo Exp $")
+RCSID("$NetBSD: locore.S,v 1.86 2022/05/06 06:09:50 ryo Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -196,6 +196,7 @@ vstart:
 	ldr	x1, sctlr_pac
 	orr	x0, x0, x1		/*  enable PAC */
 	msr	sctlr_el1, x0
+	isb
 1:
 
 	adrl	x19, cpu_info_store	/* curcpu (_info_store[0] */
@@ -565,6 +566,7 @@ mp_vstart:
 	ldr	x1, sctlr_pac
 	orr	x0, x0, x1		/*  enable PAC */
 	msr	sctlr_el1, x0
+	isb
 1:
 
 	mov	fp, xzr			/* trace back starts here */

Index: src/sys/arch/aarch64/aarch64/vectors.S
diff -u src/sys/arch/aarch64/aarch64/vectors.S:1.25 src/sys/arch/aarch64/aarch64/vectors.S:1.26
--- src/sys/arch/aarch64/aarch64/vectors.S:1.25	Fri May  6 05:14:38 2022
+++ src/sys/arch/aarch64/aarch64/vectors.S	Fri May  6 06:09:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vectors.S,v 1.25 2022/05/06 05:14:38 ryo Exp $	*/
+/*	$NetBSD: vectors.S,v 1.26 2022/05/06 06:09:50 ryo Exp $	*/
 
 #include 
 #include 
@@ -11,7 +11,7 @@
 #include "opt_dtrace.h"
 #include "opt_gic.h"
 
-RCSID("$NetBSD: vectors.S,v 1.25 2022/05/06 05:14:38 ryo Exp $")
+RCSID("$NetBSD: vectors.S,v 1.26 2022/05/06 06:09:50 ryo Exp $")
 
 	ARMV8_DEFINE_OPTIONS
 
@@ -100,6 +100,7 @@ ENTRY_NBTI(\func)
 	ldp	x5, x6, [x1, #L_MD_IA_KERN]
 	msr	APIAKeyLo_EL1, x5
 	msr	APIAKeyHi_EL1, x6
+	isb
 1:
 #endif
 	.endif
@@ -310,6 +311,7 @@ ENTRY_NP(el0_trap_exit)
 	ldp	x5, x6, [x9, #L_MD_IA_USER]
 	msr	APIAKeyLo_EL1, x5
 	msr	APIAKeyHi_EL1, x6
+	isb
 1:
 #endif
 



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

2022-05-06 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri May  6 06:09:51 UTC 2022

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

Log Message:
Sprinkle isb after modifying system regs of pointer auth.
With options ARMV83_PAC, it now works on native Mac M1.

TODO: Multiple ISBs should be combined in one place.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/aarch64/cpuswitch.S
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.25 -r1.26 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

2022-05-05 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri May  6 05:14:38 UTC 2022

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

Log Message:
md_astpending is uint32_t


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/arch/aarch64/aarch64/vectors.S:1.25
--- src/sys/arch/aarch64/aarch64/vectors.S:1.24	Sat Sep 18 12:25:06 2021
+++ src/sys/arch/aarch64/aarch64/vectors.S	Fri May  6 05:14:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vectors.S,v 1.24 2021/09/18 12:25:06 jmcneill Exp $	*/
+/*	$NetBSD: vectors.S,v 1.25 2022/05/06 05:14:38 ryo Exp $	*/
 
 #include 
 #include 
@@ -11,7 +11,7 @@
 #include "opt_dtrace.h"
 #include "opt_gic.h"
 
-RCSID("$NetBSD: vectors.S,v 1.24 2021/09/18 12:25:06 jmcneill Exp $")
+RCSID("$NetBSD: vectors.S,v 1.25 2022/05/06 05:14:38 ryo Exp $")
 
 	ARMV8_DEFINE_OPTIONS
 
@@ -282,7 +282,7 @@ ENTRY_NP(el0_trap_exit)
 	cbz	w8, 9f
 
 	/* curlwp->l_md.md_astpending = 0; */
-	str	xzr, [x9, #L_MD_ASTPENDING]
+	str	wzr, [x9, #L_MD_ASTPENDING]
 
 	/*  trap_doast(tf); */
 	ENABLE_INTERRUPT



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

2022-05-05 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri May  6 05:14:38 UTC 2022

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

Log Message:
md_astpending is uint32_t


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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

2022-05-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May  3 20:10:20 UTC 2022

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

Log Message:
Style. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/efi_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/efi_machdep.c
diff -u src/sys/arch/aarch64/aarch64/efi_machdep.c:1.12 src/sys/arch/aarch64/aarch64/efi_machdep.c:1.13
--- src/sys/arch/aarch64/aarch64/efi_machdep.c:1.12	Wed Apr 27 23:38:31 2022
+++ src/sys/arch/aarch64/aarch64/efi_machdep.c	Tue May  3 20:10:20 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.13 2022/05/03 20:10:20 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.13 2022/05/03 20:10:20 skrll Exp $");
 
 #include 
 #include 
@@ -106,11 +106,9 @@ arm_efirt_md_map_range(vaddr_t va, paddr
 int
 arm_efirt_md_enter(void)
 {
-	struct lwp *l;
-	int err;
-
 	kpreempt_disable();
-	l = curlwp;
+
+	struct lwp * const l = curlwp;
 
 	/* Save FPU state */
 	arm_efirt_state.fpu_used = fpu_used_p(l) != 0;
@@ -125,7 +123,7 @@ arm_efirt_md_enter(void)
 	 * Install custom fault handler. EFI lock is held across calls so
 	 * shared faultbuf is safe here.
 	 */
-	err = cpu_set_onfault(_efirt_state.faultbuf);
+	int err = cpu_set_onfault(_efirt_state.faultbuf);
 	if (err)
 		return err;
 
@@ -142,7 +140,7 @@ arm_efirt_md_enter(void)
 void
 arm_efirt_md_exit(void)
 {
-	struct lwp *l = curlwp;
+	struct lwp * const l = curlwp;
 
 	if (efi_userva) {
 		pmap_deactivate_efirt();
@@ -151,7 +149,6 @@ arm_efirt_md_exit(void)
 		}
 	}
 
-
 	/* Disable FP access */
 	reg_cpacr_el1_write(CPACR_FPEN_NONE);
 	isb();



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

2022-05-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May  3 20:10:20 UTC 2022

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

Log Message:
Style. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/aarch64/efi_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

2022-05-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May  3 20:09:54 UTC 2022

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

Log Message:
Sprinkle some KASSERT(kpreempt_disabled());


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 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

2022-05-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May  3 20:09:54 UTC 2022

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

Log Message:
Sprinkle some KASSERT(kpreempt_disabled());


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 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.136 src/sys/arch/aarch64/aarch64/pmap.c:1.137
--- src/sys/arch/aarch64/aarch64/pmap.c:1.136	Wed Apr 27 23:38:31 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Tue May  3 20:09:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.137 2022/05/03 20:09:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.137 2022/05/03 20:09:54 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1502,6 +1502,8 @@ pmap_activate_efirt(void)
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLARGS(pmaphist, " (pm=%#jx)", (uintptr_t)pm, 0, 0, 0);
 
+	KASSERT(kpreempt_disabled());
+
 	ci->ci_pmap_asid_cur = pai->pai_asid;
 	UVMHIST_LOG(pmaphist, "setting asid to %#jx", pai->pai_asid,
 	0, 0, 0);
@@ -1527,6 +1529,7 @@ pmap_activate(struct lwp *l)
 	UVMHIST_CALLARGS(pmaphist, "lwp=%p (pid=%d, kernel=%u)", l,
 	l->l_proc->p_pid, pm == pmap_kernel() ? 1 : 0, 0);
 
+	KASSERT(kpreempt_disabled());
 	KASSERT((reg_tcr_el1_read() & TCR_EPD0) != 0);
 
 	if (pm == pmap_kernel())
@@ -1561,6 +1564,8 @@ pmap_deactivate_efirt(void)
 
 	UVMHIST_FUNC(__func__); UVMHIST_CALLED(pmaphist);
 
+	KASSERT(kpreempt_disabled());
+
 	/* Disable translation table walks using TTBR0 */
 	uint64_t tcr = reg_tcr_el1_read();
 	reg_tcr_el1_write(tcr | TCR_EPD0);
@@ -1588,6 +1593,8 @@ pmap_deactivate(struct lwp *l)
 	UVMHIST_CALLARGS(pmaphist, "lwp=%p (pid=%d, (kernel=%u))", l,
 	l->l_proc->p_pid, pm == pmap_kernel() ? 1 : 0, 0);
 
+	KASSERT(kpreempt_disabled());
+
 	/* Disable translation table walks using TTBR0 */
 	tcr = reg_tcr_el1_read();
 	reg_tcr_el1_write(tcr | TCR_EPD0);



CVS commit: src/sys/arch/aarch64

2022-05-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon May  2 10:13:16 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: db_machdep.c
src/sys/arch/aarch64/include: armreg.h

Log Message:
Only print the appropriate PAR fields for PAR.F={0,1}

Group the fields in the header.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/aarch64/aarch64/db_machdep.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/aarch64/include/armreg.h

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

2022-05-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon May  2 10:13:16 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: db_machdep.c
src/sys/arch/aarch64/include: armreg.h

Log Message:
Only print the appropriate PAR fields for PAR.F={0,1}

Group the fields in the header.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/aarch64/aarch64/db_machdep.c
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/aarch64/include/armreg.h

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_machdep.c
diff -u src/sys/arch/aarch64/aarch64/db_machdep.c:1.42 src/sys/arch/aarch64/aarch64/db_machdep.c:1.43
--- src/sys/arch/aarch64/aarch64/db_machdep.c:1.42	Sun Oct 31 16:23:47 2021
+++ src/sys/arch/aarch64/aarch64/db_machdep.c	Mon May  2 10:13:15 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.42 2021/10/31 16:23:47 skrll Exp $ */
+/* $NetBSD: db_machdep.c,v 1.43 2022/05/02 10:13:15 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.42 2021/10/31 16:23:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.43 2022/05/02 10:13:15 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -456,17 +456,29 @@ db_par_print(uint64_t par, vaddr_t va)
 	paddr_t pa = (__SHIFTOUT(par, PAR_PA) << PAR_PA_SHIFT) +
 	(va & __BITS(PAR_PA_SHIFT - 1, 0));
 
-	db_printf("%016"PRIx64": ATTR=0x%02lx, NS=%ld, S=%ld, SHA=%ld, PTW=%ld"
-	", FST=%ld, F=%ld, PA=%016"PRIxPADDR"\n",
-	par,
-	__SHIFTOUT(par, PAR_ATTR),
-	__SHIFTOUT(par, PAR_NS),
-	__SHIFTOUT(par, PAR_S),
-	__SHIFTOUT(par, PAR_SHA),
-	__SHIFTOUT(par, PAR_PTW),
-	__SHIFTOUT(par, PAR_FST),
-	__SHIFTOUT(par, PAR_F),
-	pa);
+	if (__SHIFTOUT(par, PAR_F) == 0) {
+		db_printf("%016" PRIx64
+		": ATTR=0x%02" __PRIxBITS
+		", NS=%" __PRIuBITS
+		", SH=%" __PRIuBITS
+		", PA=%016" PRIxPADDR
+		" (no fault)\n",
+		par,
+		__SHIFTOUT(par, PAR_ATTR),
+		__SHIFTOUT(par, PAR_NS),
+		__SHIFTOUT(par, PAR_SH),
+		pa);
+	} else {
+		db_printf("%016" PRIx64
+		", S=%" __PRIuBITS
+		", PTW=%" __PRIuBITS
+		", FST=%" __PRIuBITS
+		" (fault)\n",
+		par,
+		__SHIFTOUT(par, PAR_S),
+		__SHIFTOUT(par, PAR_PTW),
+		__SHIFTOUT(par, PAR_FST));
+	}
 }
 
 void

Index: src/sys/arch/aarch64/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.60 src/sys/arch/aarch64/include/armreg.h:1.61
--- src/sys/arch/aarch64/include/armreg.h:1.60	Wed Jan  5 19:53:32 2022
+++ src/sys/arch/aarch64/include/armreg.h	Mon May  2 10:13:15 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.60 2022/01/05 19:53:32 ryo Exp $ */
+/* $NetBSD: armreg.h,v 1.61 2022/05/02 10:13:15 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -788,11 +788,12 @@ AARCH64REG_WRITE_INLINE(par_el1)
 #define	PAR_PA			__BITS(51,12)	// F=0 physical address
 #define	PAR_PA_SHIFT		12
 #define	PAR_NS			__BIT(9)	// F=0 non-secure
+#define	PAR_SH			__BITS(8,7)	// F=0 shareability attribute
+#define	 PAR_SH_NONE		 0
+#define	 PAR_SH_OUTER		 2
+#define	 PAR_SH_INNER		 3
+
 #define	PAR_S			__BIT(9)	// F=1 failure stage
-#define	PAR_SHA			__BITS(8,7)	// F=0 shareability attribute
-#define	 PAR_SHA_NONE		 0
-#define	 PAR_SHA_OUTER		 2
-#define	 PAR_SHA_INNER		 3
 #define	PAR_PTW			__BIT(8)	// F=1 partial table walk
 #define	PAR_FST			__BITS(6,1)	// F=1 fault status code
 #define	PAR_F			__BIT(0)	// translation failed



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

2022-04-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Apr 30 07:07:01 UTC 2022

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

Log Message:
whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/fault.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.22 src/sys/arch/aarch64/aarch64/fault.c:1.23
--- src/sys/arch/aarch64/aarch64/fault.c:1.22	Mon Jan 31 09:16:09 2022
+++ src/sys/arch/aarch64/aarch64/fault.c	Sat Apr 30 07:07:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: fault.c,v 1.22 2022/01/31 09:16:09 ryo Exp $	*/
+/*	$NetBSD: fault.c,v 1.23 2022/04/30 07:07:01 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.22 2022/01/31 09:16:09 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.23 2022/04/30 07:07:01 skrll Exp $");
 
 #include "opt_compat_netbsd32.h"
 #include "opt_cpuoptions.h"
@@ -224,7 +224,6 @@ data_abort_handler(struct trapframe *tf,
 		return;
 	}
 
-
  do_fault:
 	/* faultbail path? */
 	if (curcpu()->ci_intr_depth == 0) {



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

2022-04-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Apr 30 07:07:01 UTC 2022

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

Log Message:
whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/fault.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

2022-04-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Apr 27 23:38:31 UTC 2022

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

Log Message:
since pmap_activate_efirt() rewrites TTBR0, it is necessary to pmap_activate() 
again after pmap_deactivate_efirt() to restore the original TTBR0.

- Fix to do pmap_{de,}activate() before/after pmap_{,de}activate_efirt().
- moved kpreempt_{disable,enable}() to the caller since everything between
  arm_efirt_md_enter() and arm_efirt_md_exit() should be kpreempt disabled.

ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/efi_machdep.c
cvs rdiff -u -r1.135 -r1.136 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/efi_machdep.c
diff -u src/sys/arch/aarch64/aarch64/efi_machdep.c:1.11 src/sys/arch/aarch64/aarch64/efi_machdep.c:1.12
--- src/sys/arch/aarch64/aarch64/efi_machdep.c:1.11	Sat Apr  2 11:16:06 2022
+++ src/sys/arch/aarch64/aarch64/efi_machdep.c	Wed Apr 27 23:38:31 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.11 2022/04/02 11:16:06 skrll Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.11 2022/04/02 11:16:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $");
 
 #include 
 #include 
@@ -106,9 +106,12 @@ arm_efirt_md_map_range(vaddr_t va, paddr
 int
 arm_efirt_md_enter(void)
 {
-	struct lwp *l = curlwp;
+	struct lwp *l;
 	int err;
 
+	kpreempt_disable();
+	l = curlwp;
+
 	/* Save FPU state */
 	arm_efirt_state.fpu_used = fpu_used_p(l) != 0;
 	if (arm_efirt_state.fpu_used)
@@ -126,8 +129,12 @@ arm_efirt_md_enter(void)
 	if (err)
 		return err;
 
-	if (efi_userva)
+	if (efi_userva) {
+		if ((l->l_flag & LW_SYSTEM) == 0) {
+			pmap_deactivate(l);
+		}
 		pmap_activate_efirt();
+	}
 
 	return 0;
 }
@@ -137,8 +144,13 @@ arm_efirt_md_exit(void)
 {
 	struct lwp *l = curlwp;
 
-	if (efi_userva)
+	if (efi_userva) {
 		pmap_deactivate_efirt();
+		if ((l->l_flag & LW_SYSTEM) == 0) {
+			pmap_activate(l);
+		}
+	}
+
 
 	/* Disable FP access */
 	reg_cpacr_el1_write(CPACR_FPEN_NONE);
@@ -150,4 +162,6 @@ arm_efirt_md_exit(void)
 
 	/* Remove custom fault handler */
 	cpu_unset_onfault();
+
+	kpreempt_enable();
 }

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.135 src/sys/arch/aarch64/aarch64/pmap.c:1.136
--- src/sys/arch/aarch64/aarch64/pmap.c:1.135	Sun Apr 17 15:20:36 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Wed Apr 27 23:38:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1495,8 +1495,6 @@ pmap_protect(struct pmap *pm, vaddr_t sv
 void
 pmap_activate_efirt(void)
 {
-	kpreempt_disable();
-
 	struct cpu_info *ci = curcpu();
 	struct pmap *pm = _pmap;
 	struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci));
@@ -1577,8 +1575,6 @@ pmap_deactivate_efirt(void)
 	pm->pm_activated = false;
 
 	PMAP_COUNT(deactivate);
-
-	kpreempt_enable();
 }
 #endif
 



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

2022-04-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Apr 27 23:38:31 UTC 2022

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

Log Message:
since pmap_activate_efirt() rewrites TTBR0, it is necessary to pmap_activate() 
again after pmap_deactivate_efirt() to restore the original TTBR0.

- Fix to do pmap_{de,}activate() before/after pmap_{,de}activate_efirt().
- moved kpreempt_{disable,enable}() to the caller since everything between
  arm_efirt_md_enter() and arm_efirt_md_exit() should be kpreempt disabled.

ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/efi_machdep.c
cvs rdiff -u -r1.135 -r1.136 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

2022-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 17 15:20:36 UTC 2022

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

Log Message:
Add the missing kpreempt_enable to pmap_deactivate_efirt


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 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.134 src/sys/arch/aarch64/aarch64/pmap.c:1.135
--- src/sys/arch/aarch64/aarch64/pmap.c:1.134	Sun Apr 10 10:01:15 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Apr 17 15:20:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.134 2022/04/10 10:01:15 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.134 2022/04/10 10:01:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1577,6 +1577,8 @@ pmap_deactivate_efirt(void)
 	pm->pm_activated = false;
 
 	PMAP_COUNT(deactivate);
+
+	kpreempt_enable();
 }
 #endif
 



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

2022-04-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 17 15:20:36 UTC 2022

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

Log Message:
Add the missing kpreempt_enable to pmap_deactivate_efirt


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 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

2022-04-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 10 10:01:15 UTC 2022

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

Log Message:
No need to flush icache for EFI RT mappings as bootaa64.efi flushed
the full icache for us.  (Also this avoids traps)


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 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

2022-04-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 10 10:01:15 UTC 2022

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

Log Message:
No need to flush icache for EFI RT mappings as bootaa64.efi flushed
the full icache for us.  (Also this avoids traps)


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 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.133 src/sys/arch/aarch64/aarch64/pmap.c:1.134
--- src/sys/arch/aarch64/aarch64/pmap.c:1.133	Sat Apr  9 23:38:31 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Apr 10 10:01:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.133 2022/04/09 23:38:31 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.134 2022/04/10 10:01:15 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.133 2022/04/09 23:38:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.134 2022/04/10 10:01:15 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1992,7 +1992,7 @@ _pmap_enter(struct pmap *pm, vaddr_t va,
 	idx = l3pte_index(va);
 	ptep = [idx];	/* as PTE */
 	opte = *ptep;
-	need_sync_icache = (prot & VM_PROT_EXECUTE);
+	need_sync_icache = (prot & VM_PROT_EXECUTE) && !efirt_p;
 
 	/* for lock ordering for old page and new page */
 	pps[0] = pp;



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

2022-03-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 19 09:53:19 UTC 2022

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

Log Message:
Slight code re-organisation. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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.130 src/sys/arch/aarch64/aarch64/pmap.c:1.131
--- src/sys/arch/aarch64/aarch64/pmap.c:1.130	Sat Mar 12 15:32:30 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Mar 19 09:53:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.130 2022/03/12 15:32:30 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.131 2022/03/19 09:53:18 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.130 2022/03/12 15:32:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.131 2022/03/19 09:53:18 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -276,7 +276,7 @@ phys_to_pp(paddr_t pa)
 #endif /* __HAVE_PMAP_PV_TRACK */
 }
 
-#define IN_RANGE(va,sta,end)	(((sta) <= (va)) && ((va) < (end)))
+#define IN_RANGE(va, sta, end)	(((sta) <= (va)) && ((va) < (end)))
 
 #define IN_DIRECTMAP_ADDR(va)	\
 	IN_RANGE((va), AARCH64_DIRECTMAP_START, AARCH64_DIRECTMAP_END)
@@ -288,31 +288,34 @@ phys_to_pp(paddr_t pa)
 #endif
 
 #ifdef DIAGNOSTIC
-#define KASSERT_PM_ADDR(pm,va)		\
-	do {\
-		int space = aarch64_addressspace(va);			\
-		if ((pm) == pmap_kernel()) {\
-			KASSERTMSG(space == AARCH64_ADDRSPACE_UPPER,	\
-			"%s: kernel pm %p: va=%016lx"		\
-			" is out of upper address space",		\
-			__func__, (pm), (va));			\
-			KASSERTMSG(IN_RANGE((va), VM_MIN_KERNEL_ADDRESS, \
-			VM_MAX_KERNEL_ADDRESS),			\
-			"%s: kernel pm %p: va=%016lx"		\
-			" is not kernel address",			\
-			__func__, (pm), (va));			\
-		} else {		\
-			KASSERTMSG(space == AARCH64_ADDRSPACE_LOWER,	\
-			"%s: user pm %p: va=%016lx"			\
-			" is out of lower address space",		\
-			__func__, (pm), (va));			\
-			KASSERTMSG(IN_RANGE((va),			\
-			VM_MIN_ADDRESS, VM_MAX_ADDRESS),		\
-			"%s: user pm %p: va=%016lx"			\
-			" is not user address",			\
-			__func__, (pm), (va));			\
-		}			\
-	} while (0 /* CONSTCOND */)
+
+#define KERNEL_ADDR_P(va)		\
+IN_RANGE((va), VM_MIN_KERNEL_ADDRESS, VM_MAX_KERNEL_ADDRESS)
+
+#define KASSERT_PM_ADDR(pm, va)		\
+do {\
+	int space = aarch64_addressspace(va);\
+	if ((pm) == pmap_kernel()) {	\
+		KASSERTMSG(space == AARCH64_ADDRSPACE_UPPER,		\
+		"%s: kernel pm %p: va=%016lx"			\
+		" is out of upper address space",			\
+		__func__, (pm), (va));\
+		KASSERTMSG(KERNEL_ADDR_P(va),\
+		"%s: kernel pm %p: va=%016lx"			\
+		" is not kernel address",\
+		__func__, (pm), (va));\
+	} else {			\
+		KASSERTMSG(space == AARCH64_ADDRSPACE_LOWER,		\
+		"%s: user pm %p: va=%016lx"\
+		" is out of lower address space",			\
+		__func__, (pm), (va));\
+		KASSERTMSG(IN_RANGE((va),\
+		VM_MIN_ADDRESS, VM_MAX_ADDRESS),			\
+		"%s: user pm %p: va=%016lx"\
+		" is not user address",\
+		__func__, (pm), (va));\
+	}\
+} while (0 /* CONSTCOND */)
 #else /* DIAGNOSTIC */
 #define KASSERT_PM_ADDR(pm,va)
 #endif /* DIAGNOSTIC */



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

2022-03-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 19 09:53:19 UTC 2022

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

Log Message:
Slight code re-organisation. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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

2022-03-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar  5 16:53:24 UTC 2022

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

Log Message:
Slight comment improvement.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 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.128 src/sys/arch/aarch64/aarch64/pmap.c:1.129
--- src/sys/arch/aarch64/aarch64/pmap.c:1.128	Wed Feb 16 22:00:55 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Mar  5 16:53:24 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.128 2022/02/16 22:00:55 andvar Exp $	*/
+/*	$NetBSD: pmap.c,v 1.129 2022/03/05 16:53:24 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.128 2022/02/16 22:00:55 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.129 2022/03/05 16:53:24 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1598,7 +1598,7 @@ _pmap_pdp_addref(struct pmap *pm, paddr_
 {
 	struct vm_page *pg;
 
-	/* kernel L0-L3 page will be never freed */
+	/* kernel L0-L3 pages will never be freed */
 	if (pm == pmap_kernel())
 		return;
 
@@ -1632,7 +1632,7 @@ _pmap_pdp_delref(struct pmap *pm, paddr_
 	bool removed;
 	uint16_t wirecount;
 
-	/* kernel L0-L3 page will be never freed */
+	/* kernel L0-L3 pages will never be freed */
 	if (pm == pmap_kernel())
 		return false;
 



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

2022-03-05 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar  5 16:53:24 UTC 2022

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

Log Message:
Slight comment improvement.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 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

2022-01-31 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jan 31 08:43:05 UTC 2022

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

Log Message:
Skip unnecessary PTE operations and TLB invalidation.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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.125 src/sys/arch/aarch64/aarch64/pmap.c:1.126
--- src/sys/arch/aarch64/aarch64/pmap.c:1.125	Sun Jan 16 10:50:02 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Mon Jan 31 08:43:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.125 2022/01/16 10:50:02 rillig Exp $	*/
+/*	$NetBSD: pmap.c,v 1.126 2022/01/31 08:43:05 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.125 2022/01/16 10:50:02 rillig Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.126 2022/01/31 08:43:05 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -2515,6 +2515,8 @@ pmap_clear_modify(struct vm_page *pg)
  tryagain:
 		if (!l3pte_valid(pte))
 			continue;
+		if ((pte & LX_BLKPAG_AP) == LX_BLKPAG_AP_RO)
+			continue;
 
 		/* clear write permission */
 		pte &= ~LX_BLKPAG_AP;
@@ -2576,6 +2578,8 @@ pmap_clear_reference(struct vm_page *pg)
  tryagain:
 		if (!l3pte_valid(pte))
 			continue;
+		if ((pte & LX_BLKPAG_AF) == 0)
+			continue;
 
 		/* clear access permission */
 		pte &= ~LX_BLKPAG_AF;



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

2022-01-31 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Jan 31 08:43:05 UTC 2022

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

Log Message:
Skip unnecessary PTE operations and TLB invalidation.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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

2022-01-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 16 10:50:02 UTC 2022

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

Log Message:
aarch64/pmap: remove stray semicolon

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 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.124 src/sys/arch/aarch64/aarch64/pmap.c:1.125
--- src/sys/arch/aarch64/aarch64/pmap.c:1.124	Sat Jan 15 07:39:04 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Jan 16 10:50:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.124 2022/01/15 07:39:04 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.125 2022/01/16 10:50:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.124 2022/01/15 07:39:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.125 2022/01/16 10:50:02 rillig Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -77,7 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.1
 #endif
 
 struct kern_history_ent pmaphistbuf[UVMHIST_PMAPHIST_SIZE];
-UVMHIST_DEFINE(pmaphist) = UVMHIST_INITIALIZER(pmaphist, pmaphistbuf);;
+UVMHIST_DEFINE(pmaphist) = UVMHIST_INITIALIZER(pmaphist, pmaphistbuf);
 
 static void
 pmap_hist_init(void)



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

2022-01-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 16 10:50:02 UTC 2022

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

Log Message:
aarch64/pmap: remove stray semicolon

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 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

2022-01-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jan 15 07:39:04 UTC 2022

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

Log Message:
The translations that need invalidation are always last level so remove
the (dubious) logic around tracking the level.  The "any level" TLB
invalidation maintenance operation are used, but this may change after
further testing.

before
==
1661.0u 420.2s 2:53.82 1197.3% 231+29k 10+33918io 102pf+0w
1646.8u 425.2s 2:52.96 1198.0% 232+29k 1+33937io 49pf+0w
1647.9u 425.7s 2:52.58 1201.6% 232+29k 0+33940io 32pf+0w

After
=
1602.5u 420.8s 2:49.09 1196.6% 238+30k 24+33893io 54pf+0w
1600.7u 421.3s 2:51.53 1178.8% 238+30k 1+33914io 33pf+0w
1597.5u 424.3s 2:50.46 1186.1% 238+30k 0+33915io 17pf+0w

LGTM from ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 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.123 src/sys/arch/aarch64/aarch64/pmap.c:1.124
--- src/sys/arch/aarch64/aarch64/pmap.c:1.123	Fri Jan 14 07:21:53 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Jan 15 07:39:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.123 2022/01/14 07:21:53 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.124 2022/01/15 07:39:04 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.123 2022/01/14 07:21:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.124 2022/01/15 07:39:04 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -160,21 +160,13 @@ PMAP_COUNTER(unwire_failure, "pmap_unwir
 
 /*
  * invalidate TLB entry for ASID and VA.
- * `ll' invalidates only the Last Level (usually L3) of TLB entry
  */
-#define AARCH64_TLBI_BY_ASID_VA(asid, va, ll)\
-	do {\
-		if ((ll)) {		\
-			if ((asid) == 0)\
-aarch64_tlbi_by_va_ll((va));		\
-			else		\
-aarch64_tlbi_by_asid_va_ll((asid), (va)); \
-		} else {		\
-			if ((asid) == 0)\
-aarch64_tlbi_by_va((va));		\
-			else		\
-aarch64_tlbi_by_asid_va((asid), (va));	\
-		}			\
+#define AARCH64_TLBI_BY_ASID_VA(asid, va)			\
+	do {			\
+		if ((asid) == 0)\
+			aarch64_tlbi_by_va((va));		\
+		else		\
+			aarch64_tlbi_by_asid_va((asid), (va));	\
 	} while (0/*CONSTCOND*/)
 
 /*
@@ -182,10 +174,10 @@ PMAP_COUNTER(unwire_failure, "pmap_unwir
  * change the pte to be accessible temporarily before cpu_icache_sync_range().
  * this macro modifies PTE (*ptep). need to update PTE after this.
  */
-#define PTE_ICACHE_SYNC_PAGE(pte, ptep, asid, va, ll)			\
+#define PTE_ICACHE_SYNC_PAGE(pte, ptep, asid, va)			\
 	do {\
 		atomic_swap_64((ptep), (pte) | LX_BLKPAG_AF);		\
-		AARCH64_TLBI_BY_ASID_VA((asid), (va), (ll));		\
+		AARCH64_TLBI_BY_ASID_VA((asid), (va));			\
 		cpu_icache_sync_range((va), PAGE_SIZE);			\
 	} while (0/*CONSTCOND*/)
 
@@ -202,7 +194,7 @@ static void _pmap_remove(struct pmap *, 
 struct pv_entry **);
 static int _pmap_enter(struct pmap *, vaddr_t, paddr_t, vm_prot_t, u_int, bool);
 static int _pmap_get_pdp(struct pmap *, vaddr_t, bool, int, paddr_t *,
-struct vm_page **, bool *);
+struct vm_page **);
 
 static struct pmap kernel_pmap __cacheline_aligned;
 
@@ -753,7 +745,6 @@ pmap_growkernel(vaddr_t maxkvaddr)
 {
 	struct pmap *pm = pmap_kernel();
 	struct vm_page *pg;
-	bool l3only = true;
 	int error;
 	vaddr_t va;
 	paddr_t pa;
@@ -764,7 +755,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 
 	mutex_enter(>pm_lock);
 	for (va = pmap_maxkvaddr & L2_FRAME; va <= maxkvaddr; va += L2_SIZE) {
-		error = _pmap_get_pdp(pm, va, false, 0, , , );
+		error = _pmap_get_pdp(pm, va, false, 0, , );
 		if (error != 0) {
 			panic("%s: cannot allocate L3 table error=%d",
 			__func__, error);
@@ -986,10 +977,10 @@ pmap_icache_sync_range(pmap_t pm, vaddr_
 			cpu_tlb_info(ci));
 
 			atomic_swap_64(ptep, pte | LX_BLKPAG_AF);
-			AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, va, true);
+			AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, va);
 			cpu_icache_sync_range(va, len);
 			atomic_swap_64(ptep, pte);
-			AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, va, true);
+			AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, va);
 		}
 	}
 
@@ -1311,8 +1302,7 @@ _pmap_protect_pv(struct pmap_page *pp, s
 	struct pmap * const pm = pv->pv_pmap;
 	struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci));
 
-	AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, trunc_page(pv->pv_va),
-	true);
+	AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, trunc_page(pv->pv_va));
 }
 
 void
@@ -1415,17 +1405,17 @@ pmap_protect(struct pmap *pm, vaddr_t sv
 
 			if (!l3pte_readable(pte)) {
 PTE_ICACHE_SYNC_PAGE(pte, ptep, pai->pai_asid,
-va, true);
+va);
 atomic_swap_64(ptep, pte);
-AARCH64_TLBI_BY_ASID_VA(pai->pai_asid, va, true);
+

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

2022-01-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jan 15 07:39:04 UTC 2022

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

Log Message:
The translations that need invalidation are always last level so remove
the (dubious) logic around tracking the level.  The "any level" TLB
invalidation maintenance operation are used, but this may change after
further testing.

before
==
1661.0u 420.2s 2:53.82 1197.3% 231+29k 10+33918io 102pf+0w
1646.8u 425.2s 2:52.96 1198.0% 232+29k 1+33937io 49pf+0w
1647.9u 425.7s 2:52.58 1201.6% 232+29k 0+33940io 32pf+0w

After
=
1602.5u 420.8s 2:49.09 1196.6% 238+30k 24+33893io 54pf+0w
1600.7u 421.3s 2:51.53 1178.8% 238+30k 1+33914io 33pf+0w
1597.5u 424.3s 2:50.46 1186.1% 238+30k 0+33915io 17pf+0w

LGTM from ryo@


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 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

2022-01-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 14 07:21:53 UTC 2022

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

Log Message:
Restore the previous pmap_remove_all behaviour as the new method meant
the n1sdp couldn't complete a build.

No noticeable change in kernel build performance.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/aarch64/include/pmap.h

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.122 src/sys/arch/aarch64/aarch64/pmap.c:1.123
--- src/sys/arch/aarch64/aarch64/pmap.c:1.122	Tue Jan  4 05:55:45 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri Jan 14 07:21:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.122 2022/01/04 05:55:45 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.123 2022/01/14 07:21:53 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.122 2022/01/04 05:55:45 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.123 2022/01/14 07:21:53 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1511,7 +1511,6 @@ pmap_create(void)
 
 	kcpuset_create(>pm_active, true);
 	kcpuset_create(>pm_onproc, true);
-	pm->pm_remove_all = false;
 
 	pm->pm_l0table_pa = pmap_alloc_pdp(pm, NULL, 0, true);
 	KASSERT(pm->pm_l0table_pa != POOL_PADDR_INVALID);
@@ -1531,9 +1530,8 @@ pmap_destroy(struct pmap *pm)
 	unsigned int refcnt;
 
 	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLARGS(pmaphist,
-	"pm=%p, pm_l0table=%016lx, pm_remove_all=%jd, refcnt=%jd",
-	pm, pm->pm_l0table, pm->pm_remove_all, pm->pm_refcnt);
+	UVMHIST_CALLARGS(pmaphist, "pm=%p, pm_l0table=%016lx, refcnt=%jd",
+	pm, pm->pm_l0table, pm->pm_refcnt, 0);
 
 	if (pm == NULL)
 		return;
@@ -1541,16 +1539,12 @@ pmap_destroy(struct pmap *pm)
 	if (pm == pmap_kernel())
 		panic("cannot destroy kernel pmap");
 
-	if (pm->pm_remove_all) {
-		pmap_tlb_asid_release_all(pm);
-		pm->pm_remove_all = false;
-	}
-
 	refcnt = atomic_dec_uint_nv(>pm_refcnt);
 	if (refcnt > 0)
 		return;
 
 	KASSERT(LIST_EMPTY(>pm_pvlist));
+	pmap_tlb_asid_release_all(pm);
 
 	_pmap_free_pdp_all(pm, true);
 	mutex_destroy(>pm_lock);
@@ -2054,41 +2048,6 @@ pmap_enter(struct pmap *pm, vaddr_t va, 
 }
 
 
-
-void
-pmap_update(pmap_t pm)
-{
-
-	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLARGS(maphist, "pm=%#jx remove_all %jd", (uintptr_t)pm,
-	pm->pm_remove_all, 0, 0);
-
-	kpreempt_disable();
-	/*
-	 * If pmap_remove_all was called, we deactivated ourselves and released
-	 * our ASID.  Now we have to reactivate ourselves.
-	 */
-	if (__predict_false(pm->pm_remove_all)) {
-		pm->pm_remove_all = false;
-
-		KASSERT(pm != pmap_kernel());
-
-		/* this calls tlb_set_asid which calls cpu_set_ttbr0 */
-		pmap_tlb_asid_acquire(pm, curlwp);
-
-		/* Enable translation table walks using TTBR0 */
-		uint64_t tcr = reg_tcr_el1_read();
-		reg_tcr_el1_write(tcr & ~TCR_EPD0);
-		isb();
-
-		pm->pm_activated = true;
-	}
-
-	kpreempt_enable();
-
-	UVMHIST_LOG(maphist, "  <-- done", 0, 0, 0, 0);
-}
-
 bool
 pmap_remove_all(struct pmap *pm)
 {
@@ -2102,23 +2061,6 @@ pmap_remove_all(struct pmap *pm)
 
 	KASSERT(pm != pmap_kernel());
 
-	struct cpu_info * const ci = curcpu();
-	// This should be the last CPU with this pmap onproc
-	KASSERT(!kcpuset_isotherset(pm->pm_onproc, cpu_index(ci)));
-	if (kcpuset_isset(pm->pm_onproc, cpu_index(ci))) {
-		/* Disable translation table walks using TTBR0 */
-		uint64_t tcr = reg_tcr_el1_read();
-		reg_tcr_el1_write(tcr | TCR_EPD0);
-		isb();
-
-		pmap_tlb_asid_deactivate(pm);
-	}
-
-	KASSERT(kcpuset_iszero(pm->pm_onproc));
-
-	pmap_tlb_asid_release_all(pm);
-	pm->pm_remove_all = true;
-
 	UVMHIST_LOG(pmaphist, "pm=%p, asid=%d", pm,
 	PMAP_PAI(pm, cpu_tlb_info(ci))->pai_asid, 0, 0);
 
@@ -2155,6 +2097,8 @@ pmap_remove_all(struct pmap *pm)
 	/* clear L0 page table page */
 	pmap_zero_page(pm->pm_l0table_pa);
 
+	aarch64_tlbi_by_asid(PMAP_PAI(pm, cpu_tlb_info(ci))->pai_asid);
+
 	/* free L1-L3 page table pages, but not L0 */
 	_pmap_free_pdp_all(pm, false);
 

Index: src/sys/arch/aarch64/include/pmap.h
diff -u src/sys/arch/aarch64/include/pmap.h:1.49 src/sys/arch/aarch64/include/pmap.h:1.50
--- src/sys/arch/aarch64/include/pmap.h:1.49	Sun Oct 10 07:15:25 2021
+++ src/sys/arch/aarch64/include/pmap.h	Fri Jan 14 07:21:53 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.49 2021/10/10 07:15:25 skrll Exp $ */
+/* $NetBSD: pmap.h,v 1.50 2022/01/14 07:21:53 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -125,7 +125,6 @@ struct pmap {
 
 	struct pmap_asid_info pm_pai[PMAP_TLB_MAX];
 	bool pm_activated;
-	bool pm_remove_all;
 };
 
 static inline paddr_t
@@ -384,6 +383,7 @@ aarch64_mmap_flags(paddr_t mdpgno)
 

CVS commit: src/sys/arch/aarch64

2022-01-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jan 14 07:21:53 UTC 2022

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

Log Message:
Restore the previous pmap_remove_all behaviour as the new method meant
the n1sdp couldn't complete a build.

No noticeable change in kernel build performance.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/aarch64/include/pmap.h

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

2022-01-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jan  4 05:55:45 UTC 2022

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 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.121 src/sys/arch/aarch64/aarch64/pmap.c:1.122
--- src/sys/arch/aarch64/aarch64/pmap.c:1.121	Fri Dec 10 20:36:02 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Tue Jan  4 05:55:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.121 2021/12/10 20:36:02 andvar Exp $	*/
+/*	$NetBSD: pmap.c,v 1.122 2022/01/04 05:55:45 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.121 2021/12/10 20:36:02 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.122 2022/01/04 05:55:45 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -2011,7 +2011,7 @@ _pmap_enter(struct pmap *pm, vaddr_t va,
 		if (!l3pte_readable(pte)) {
 			PTE_ICACHE_SYNC_PAGE(pte, ptep, asid, va, l3only);
 			atomic_swap_64(ptep, pte);
-			AARCH64_TLBI_BY_ASID_VA(asid, va ,true);
+			AARCH64_TLBI_BY_ASID_VA(asid, va, true);
 		} else {
 			atomic_swap_64(ptep, pte);
 			AARCH64_TLBI_BY_ASID_VA(asid, va, l3only);



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

2022-01-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jan  4 05:55:45 UTC 2022

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 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

2021-11-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 27 14:11:04 UTC 2021

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

Log Message:
aarch64: Fix stack traces from jump-to-null.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/aarch64/aarch64/db_trace.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_trace.c
diff -u src/sys/arch/aarch64/aarch64/db_trace.c:1.13 src/sys/arch/aarch64/aarch64/db_trace.c:1.14
--- src/sys/arch/aarch64/aarch64/db_trace.c:1.13	Fri Dec 11 18:03:33 2020
+++ src/sys/arch/aarch64/aarch64/db_trace.c	Sat Nov 27 14:11:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_trace.c,v 1.13 2020/12/11 18:03:33 skrll Exp $ */
+/* $NetBSD: db_trace.c,v 1.14 2021/11/27 14:11:04 riastradh Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.13 2020/12/11 18:03:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.14 2021/11/27 14:11:04 riastradh Exp $");
 
 #include 
 #include 
@@ -302,8 +302,21 @@ db_stack_trace_print(db_expr_t addr, boo
 			lastfp = (uint64_t)tf;
 			lastlr = lr;
 			lr = fp = 0;
-			db_read_bytes((db_addr_t)>tf_pc, sizeof(lr), (char *));
-			db_read_bytes((db_addr_t)>tf_reg[29], sizeof(fp), (char *));
+			db_read_bytes((db_addr_t)>tf_pc, sizeof(lr),
+			(char *));
+			if (lr == 0) {
+/*
+ * The exception may have been from a
+ * jump to null, so the null pc we
+ * would return to is useless.  Try
+ * x[30] instead -- that will be the
+ * return address for the jump.
+ */
+db_read_bytes((db_addr_t)>tf_reg[30],
+sizeof(lr), (char *));
+			}
+			db_read_bytes((db_addr_t)>tf_reg[29], sizeof(fp),
+			(char *));
 			lr = aarch64_strip_pac(lr);
 
 			/*



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

2021-11-27 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Nov 27 14:11:04 UTC 2021

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

Log Message:
aarch64: Fix stack traces from jump-to-null.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/aarch64/aarch64/db_trace.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

2021-11-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 14 15:12:01 UTC 2021

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c \
src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.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.22 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.23
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep.c:1.22	Sat Nov  6 20:42:56 2021
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep.c	Sun Nov 14 15:12:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.22 2021/11/06 20:42:56 thorpej Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.23 2021/11/14 15:12:01 skrll Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.22 2021/11/06 20:42:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.23 2021/11/14 15:12:01 skrll Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -632,16 +632,16 @@ netbsd32_vm_default_addr(struct proc *p,
 		return VM_DEFAULT_ADDRESS32_BOTTOMUP(base, sz);
 }
 
-void  
+void
 netbsd32_machdep_md_init(void)
-{ 
- 
+{
+
 	/* nothing to do */
 }
- 
+
 void
 netbsd32_machdep_md_fini(void)
 {
- 
+
 	/* nothing to do */
 }

Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c:1.2 src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c:1.3
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c:1.2	Sun Jan 27 02:08:36 2019
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c	Sun Nov 14 15:12:01 2021
@@ -29,22 +29,22 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_13.c,v 1.2 2019/01/27 02:08:36 pgoyette Exp $");
+__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_13.c,v 1.3 2021/11/14 15:12:01 skrll Exp $");
 
 #if defined (_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
-void  
+void
 netbsd32_machdep_md_13_init(void)
-{ 
- 
+{
+
 	/* nothing to do */
 }
- 
+
 void
 netbsd32_machdep_md_13_fini(void)
 {
- 
+
 	/* nothing to do */
 }
Index: src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c
diff -u src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c:1.2 src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c:1.3
--- src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c:1.2	Sun Jan 27 02:08:36 2019
+++ src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.c	Sun Nov 14 15:12:01 2021
@@ -29,22 +29,22 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_16.c,v 1.2 2019/01/27 02:08:36 pgoyette Exp $");
+__KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep_16.c,v 1.3 2021/11/14 15:12:01 skrll Exp $");
 
 #if defined (_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
-void  
+void
 netbsd32_machdep_md_16_init(void)
-{ 
- 
+{
+
 	/* nothing to do */
 }
- 
+
 void
 netbsd32_machdep_md_16_fini(void)
 {
- 
+
 	/* nothing to do */
 }



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

2021-11-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 14 15:12:01 UTC 2021

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/aarch64/aarch64/netbsd32_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/aarch64/aarch64/netbsd32_machdep_13.c \
src/sys/arch/aarch64/aarch64/netbsd32_machdep_16.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/include

2021-11-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov  5 15:18:18 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: signal.h

Log Message:
Normally, to support COMPAT_NETBSD32 we need to define
__HAVE_STRUCT_SIGCONTEXT in order to support the old
"sigcontext" style of handlers for 32-bit binaries.
However, we only support 32-bit EABI binaries on AArch64,
and by happy accident (due to a libc bug introduced in
2006), 32-bit NetBSD EABI binaries never used "sigcontext"
style handlers.  So, we don't need to carry any of this
baggage forward.

This addresses the AArch64 case of PR kern/56487.


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

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/include/signal.h
diff -u src/sys/arch/aarch64/include/signal.h:1.3 src/sys/arch/aarch64/include/signal.h:1.4
--- src/sys/arch/aarch64/include/signal.h:1.3	Wed Oct 27 04:45:42 2021
+++ src/sys/arch/aarch64/include/signal.h	Fri Nov  5 15:18:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: signal.h,v 1.3 2021/10/27 04:45:42 thorpej Exp $ */
+/* $NetBSD: signal.h,v 1.4 2021/11/05 15:18:18 thorpej Exp $ */
 
 #ifndef _AARCH64_SIGNAL_H_
 #define	_AARCH64_SIGNAL_H_
@@ -6,8 +6,16 @@
 #include 
 
 #ifdef _KERNEL
-/* This is needed to support COMPAT_NETBSD32. */ 
-#define	__HAVE_STRUCT_SIGCONTEXT
+/*
+ * Normally, to support COMPAT_NETBSD32 we need to define
+ * __HAVE_STRUCT_SIGCONTEXT in order to support the old
+ * "sigcontext" style of handlers for 32-bit binaries.
+ * However, we only support 32-bit EABI binaries on AArch64,
+ * and by happy accident (due to a libc bug introduced in
+ * 2006), 32-bit NetBSD EABI binaries never used "sigcontext"
+ * style handlers.  So, we don't need to carry any of this
+ * baggage forward.
+ */
 #endif /* _KERNEL */
 
 #endif /* ! _AARCH64_SIGNAL_H_ */



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

2021-11-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Nov  5 15:18:18 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: signal.h

Log Message:
Normally, to support COMPAT_NETBSD32 we need to define
__HAVE_STRUCT_SIGCONTEXT in order to support the old
"sigcontext" style of handlers for 32-bit binaries.
However, we only support 32-bit EABI binaries on AArch64,
and by happy accident (due to a libc bug introduced in
2006), 32-bit NetBSD EABI binaries never used "sigcontext"
style handlers.  So, we don't need to carry any of this
baggage forward.

This addresses the AArch64 case of PR kern/56487.


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

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/include

2021-11-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Nov  1 08:53:40 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Fix a last minute rebase/merge botch so that the cpu_hatch commit actually
works.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/aarch64/include/cpu.h

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/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.43 src/sys/arch/aarch64/include/cpu.h:1.44
--- src/sys/arch/aarch64/include/cpu.h:1.43	Sun Oct 31 16:23:47 2021
+++ src/sys/arch/aarch64/include/cpu.h	Mon Nov  1 08:53:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.43 2021/10/31 16:23:47 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.44 2021/11/01 08:53:40 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -168,7 +168,7 @@ struct cpu_info {
 	struct aarch64_sysctl_cpu_id ci_id;
 
 	/* cache information and function pointers */
-	struct aarch64_cache_info *ci_cacheinfo;
+	struct aarch64_cache_info ci_cacheinfo[MAX_CACHE_LEVEL];
 	struct aarch64_cpufuncs ci_cpufuncs;
 
 #if defined(GPROF) && defined(MULTIPROCESSOR)



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

2021-11-01 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Nov  1 08:53:40 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Fix a last minute rebase/merge botch so that the cpu_hatch commit actually
works.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/aarch64/include/cpu.h

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/include

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 22:06:32 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: db_machdep.h

Log Message:
Fix crash(8) build


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/include/db_machdep.h

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/include/db_machdep.h
diff -u src/sys/arch/aarch64/include/db_machdep.h:1.15 src/sys/arch/aarch64/include/db_machdep.h:1.16
--- src/sys/arch/aarch64/include/db_machdep.h:1.15	Sun Oct 31 16:23:47 2021
+++ src/sys/arch/aarch64/include/db_machdep.h	Sun Oct 31 22:06:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.15 2021/10/31 16:23:47 skrll Exp $ */
+/* $NetBSD: db_machdep.h,v 1.16 2021/10/31 22:06:32 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -221,12 +221,6 @@ db_addr_t db_branch_taken(db_expr_t, db_
 void db_pteinfo(vaddr_t, void (*)(const char *, ...) __printflike(1, 2));
 void db_pte_print(pt_entry_t, int, void (*)(const char *, ...) __printflike(1, 2));
 void db_ttbrdump(bool, vaddr_t, void (*pr)(const char *, ...) __printflike(1, 2));
-#endif
-
-void dump_trapframe(struct trapframe *, void (*)(const char *, ...) __printflike(1, 2));
-
-void dump_switchframe(struct trapframe *, void (*)(const char *, ...) __printflike(1, 2));
-const char *strdisasm(vaddr_t, uint64_t);
 void db_machdep_cpu_init(void);
 void db_machdep_init(struct cpu_info * const);
 
@@ -237,6 +231,12 @@ void aarch64_watchpoint_set(int, vaddr_t
 #define WATCHPOINT_ACCESS_STORE		0x02
 #define WATCHPOINT_ACCESS_LOADSTORE	0x03
 #define WATCHPOINT_ACCESS_MASK		0x03
+#endif
+
+void dump_trapframe(struct trapframe *, void (*)(const char *, ...) __printflike(1, 2));
+
+void dump_switchframe(struct trapframe *, void (*)(const char *, ...) __printflike(1, 2));
+const char *strdisasm(vaddr_t, uint64_t);
 
 #define DB_ELF_SYMBOLS
 



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 22:06:32 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: db_machdep.h

Log Message:
Fix crash(8) build


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/include/db_machdep.h

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/include

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 08:21:25 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Annotate some cpu_info members


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/aarch64/include/cpu.h

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/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.41 src/sys/arch/aarch64/include/cpu.h:1.42
--- src/sys/arch/aarch64/include/cpu.h:1.41	Tue Oct 26 06:02:00 2021
+++ src/sys/arch/aarch64/include/cpu.h	Sun Oct 31 08:21:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.41 2021/10/26 06:02:00 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.42 2021/10/31 08:21:24 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -134,8 +134,10 @@ struct cpu_info {
 	/* ACPI */
 	uint32_t ci_acpiid;	/* ACPI Processor Unique ID */
 
+	/* sysctl(9) exposed system registers */
 	struct aarch64_sysctl_cpu_id ci_id;
 
+	/* cache information and function pointers */
 	struct aarch64_cache_info *ci_cacheinfo;
 	struct aarch64_cpufuncs ci_cpufuncs;
 



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 08:21:25 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Annotate some cpu_info members


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/aarch64/include/cpu.h

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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 07:56:55 UTC 2021

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

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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.30 src/sys/arch/aarch64/aarch64/cpufunc.c:1.31
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.30	Sat Oct 23 06:48:31 2021
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Sun Oct 31 07:56:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.30 2021/10/23 06:48:31 skrll Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.31 2021/10/31 07:56:55 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -30,7 +30,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.30 2021/10/23 06:48:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.31 2021/10/31 07:56:55 skrll Exp $");
 
 #include 
 #include 
@@ -313,11 +313,10 @@ prt_cache(device_t self, struct aarch64_
 void
 aarch64_printcacheinfo(device_t dev)
 {
-	struct aarch64_cache_info *cinfo;
+	struct cpu_info * const ci = curcpu();
+	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	cinfo = curcpu()->ci_cacheinfo;
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++)
 		if (prt_cache(dev, cinfo, level) < 0)
 			break;
@@ -382,11 +381,10 @@ ln_dcache_inv_all(int level, struct aarc
 void
 aarch64_dcache_wbinv_all(void)
 {
-	struct aarch64_cache_info *cinfo;
+	struct cpu_info * const ci = curcpu();
+	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	cinfo = curcpu()->ci_cacheinfo;
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++) {
 		if (cinfo[level].cacheable == CACHE_CACHEABLE_NONE)
 			break;
@@ -400,11 +398,10 @@ aarch64_dcache_wbinv_all(void)
 void
 aarch64_dcache_inv_all(void)
 {
-	struct aarch64_cache_info *cinfo;
+	struct cpu_info * const ci = curcpu();
+	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	cinfo = curcpu()->ci_cacheinfo;
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++) {
 		if (cinfo[level].cacheable == CACHE_CACHEABLE_NONE)
 			break;
@@ -418,11 +415,10 @@ aarch64_dcache_inv_all(void)
 void
 aarch64_dcache_wb_all(void)
 {
-	struct aarch64_cache_info *cinfo;
+	struct cpu_info * const ci = curcpu();
+	struct aarch64_cache_info * const cinfo = ci->ci_cacheinfo;
 	int level;
 
-	cinfo = curcpu()->ci_cacheinfo;
-
 	for (level = 0; level < MAX_CACHE_LEVEL; level++) {
 		if (cinfo[level].cacheable == CACHE_CACHEABLE_NONE)
 			break;



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

2021-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 31 07:56:55 UTC 2021

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

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 18:49:47 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf

Log Message:
Add CI_SPLX_SAVEDIPL and CI_HWPL


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

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/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.35 src/sys/arch/aarch64/aarch64/genassym.cf:1.36
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.35	Thu Sep 30 21:19:16 2021
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Sat Oct 30 18:49:47 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.35 2021/09/30 21:19:16 skrll Exp $
+# $NetBSD: genassym.cf,v 1.36 2021/10/30 18:49:47 jmcneill Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -298,6 +298,8 @@ define	CI_SOFTINTS		offsetof(struct cpu_
 define	CI_IDLELWP		offsetof(struct cpu_info, ci_data.cpu_idlelwp)
 define	CI_CC_NINTR		offsetof(struct cpu_info, ci_data.cpu_nintr)
 define	CI_SPLX_RESTART		offsetof(struct cpu_info, ci_splx_restart)
+define	CI_SPLX_SAVEDIPL	offsetof(struct cpu_info, ci_splx_savedipl)
+define	CI_HWPL			offsetof(struct cpu_info, ci_hwpl)
 
 define	V_RESCHED_KPREEMPT	ilog2(RESCHED_KPREEMPT)
 



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

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 18:49:47 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf

Log Message:
Add CI_SPLX_SAVEDIPL and CI_HWPL


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

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

2021-10-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 30 10:47:03 UTC 2021

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

Log Message:
G/C MD_CPU_HATCH. It's old evbarm (<= armv7)


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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.65 src/sys/arch/aarch64/aarch64/cpu.c:1.66
--- src/sys/arch/aarch64/aarch64/cpu.c:1.65	Sat Oct 30 09:42:27 2021
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sat Oct 30 10:47:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.65 2021/10/30 09:42:27 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.66 2021/10/30 10:47:03 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.65 2021/10/30 09:42:27 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.66 2021/10/30 10:47:03 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -703,9 +703,6 @@ cpu_hatch(struct cpu_info *ci)
 #ifdef FDT
 	arm_fdt_cpu_hatch(ci);
 #endif
-#ifdef MD_CPU_HATCH
-	MD_CPU_HATCH(ci);	/* for non-fdt arch? */
-#endif
 
 	/*
 	 * clear my bit of arm_cpu_mbox to tell cpu_boot_secondary_processors().



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

2021-10-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 30 10:47:03 UTC 2021

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

Log Message:
G/C MD_CPU_HATCH. It's old evbarm (<= armv7)


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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

2021-10-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 30 09:42:27 UTC 2021

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

Log Message:
style. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 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.64 src/sys/arch/aarch64/aarch64/cpu.c:1.65
--- src/sys/arch/aarch64/aarch64/cpu.c:1.64	Sun Oct 17 07:26:20 2021
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sat Oct 30 09:42:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.64 2021/10/17 07:26:20 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.65 2021/10/30 09:42:27 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.64 2021/10/17 07:26:20 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.65 2021/10/30 09:42:27 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -148,7 +148,7 @@ cpu_attach(device_t dv, cpuid_t id)
 	ci->ci_kfpu_spl = -1;
 
 	arm_cpu_do_topology(ci);
-	cpu_identify(ci->ci_dev, ci);
+	cpu_identify(dv, ci);
 
 #ifdef MULTIPROCESSOR
 	if (unit != 0) {



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

2021-10-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 30 09:42:27 UTC 2021

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

Log Message:
style. NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 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

2021-10-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 30 09:42:01 UTC 2021

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

Log Message:
Remove an item


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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

2021-10-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 30 09:42:01 UTC 2021

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

Log Message:
Remove an item


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/arch/aarch64/aarch64/TODO:1.10
--- src/sys/arch/aarch64/aarch64/TODO:1.9	Mon Aug  3 06:29:59 2020
+++ src/sys/arch/aarch64/aarch64/TODO	Sat Oct 30 09:42:01 2021
@@ -1,6 +1,5 @@
-$NetBSD: TODO,v 1.9 2020/08/03 06:29:59 ryo Exp $
+$NetBSD: TODO,v 1.10 2021/10/30 09:42:01 skrll Exp $
 
 TODO list for NetBSD/aarch64
   - kernel preemption
-  - pmap should be work even if PID_MAX >= 65536 (don't depend 16bit ASID)
   - TLB ASID in pmap should be randomized



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

2021-10-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct 29 07:55:04 UTC 2021

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

Log Message:
Fix length of memset in tlb_record_asids


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/aarch64_tlb.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_tlb.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_tlb.c:1.1 src/sys/arch/aarch64/aarch64/aarch64_tlb.c:1.2
--- src/sys/arch/aarch64/aarch64/aarch64_tlb.c:1.1	Sun Oct 10 07:15:25 2021
+++ src/sys/arch/aarch64/aarch64/aarch64_tlb.c	Fri Oct 29 07:55:04 2021
@@ -31,7 +31,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_tlb.c,v 1.1 2021/10/10 07:15:25 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_tlb.c,v 1.2 2021/10/29 07:55:04 skrll Exp $");
 
 #include 
 #include 
@@ -104,7 +104,7 @@ tlb_record_asids(u_long *mapp, tlb_asid_
 	KASSERT(asid_max == pmap_md_tlb_asid_max());
 
 #if DIAGNOSTIC
-	memset(mapp, 0xff, (asid_max + 1) / (NBBY * sizeof(u_long)));
+	memset(mapp, 0xff, (asid_max + 1) / NBBY);
 	mapp[0] ^= __BITS(0, KERNEL_PID);
 #endif
 	return asid_max;



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

2021-10-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct 29 07:55:04 UTC 2021

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

Log Message:
Fix length of memset in tlb_record_asids


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/aarch64_tlb.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/include

2021-10-26 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Tue Oct 26 16:58:46 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
fix build with COPTS=-O0


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

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/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.58 src/sys/arch/aarch64/include/armreg.h:1.59
--- src/sys/arch/aarch64/include/armreg.h:1.58	Sat Oct 23 05:31:53 2021
+++ src/sys/arch/aarch64/include/armreg.h	Tue Oct 26 16:58:46 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.58 2021/10/23 05:31:53 skrll Exp $ */
+/* $NetBSD: armreg.h,v 1.59 2021/10/26 16:58:46 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -74,8 +74,8 @@ reg_##regname##_write(uint64_t __val)			
 	AARCH64REG_WRITE_INLINE3(regname, regdesc, )
 
 #define AARCH64REG_WRITEIMM_INLINE2(regname, regdesc)		\
-static __inline void		\
-reg_##regname##_write(uint64_t __val)\
+static __inline void __always_inline\
+reg_##regname##_write(const uint64_t __val)			\
 {\
 	__asm __volatile(	\
 	"msr " #regdesc ", %0" :: "n"(__val) : "memory"	\



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

2021-10-26 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Tue Oct 26 16:58:46 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
fix build with COPTS=-O0


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

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/include

2021-10-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Oct 26 06:02:00 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Add a comment and adjust whitespace to match style in this file


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

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/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.40 src/sys/arch/aarch64/include/cpu.h:1.41
--- src/sys/arch/aarch64/include/cpu.h:1.40	Sun Oct 10 07:15:25 2021
+++ src/sys/arch/aarch64/include/cpu.h	Tue Oct 26 06:02:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.40 2021/10/10 07:15:25 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.41 2021/10/26 06:02:00 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -113,7 +113,8 @@ struct cpu_info {
 
 	int ci_kfpu_spl;
 
-	tlb_asid_t	ci_pmap_asid_cur;
+	/* ASID of current pmap */
+	tlb_asid_t ci_pmap_asid_cur;
 
 	/* event counters */
 	struct evcnt ci_vfp_use;



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

2021-10-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Oct 26 06:02:00 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h

Log Message:
Add a comment and adjust whitespace to match style in this file


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

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

2021-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 06:49:46 UTC 2021

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

Log Message:
Fix non-UVMHIST build


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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

2021-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 06:49:46 UTC 2021

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

Log Message:
Fix non-UVMHIST build


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 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.118 src/sys/arch/aarch64/aarch64/pmap.c:1.119
--- src/sys/arch/aarch64/aarch64/pmap.c:1.118	Sat Oct 16 06:34:30 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Oct 23 06:49:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.118 2021/10/16 06:34:30 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.119 2021/10/23 06:49:46 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.118 2021/10/16 06:34:30 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.119 2021/10/23 06:49:46 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1455,10 +1455,8 @@ pmap_activate(struct lwp *l)
 	/* this calls tlb_set_asid which calls cpu_set_ttbr0 */
 	pmap_tlb_asid_acquire(pm, l);
 
-	struct pmap_asid_info * const pai __debugused = PMAP_PAI(pm,
-	cpu_tlb_info(ci));
-
-	UVMHIST_LOG(pmaphist, "lwp=%p, asid=%d", l, pai->pai_asid, 0, 0);
+	UVMHIST_LOG(pmaphist, "lwp=%p, asid=%d", l,
+	PMAP_PAI(pm, cpu_tlb_info(ci))->pai_asid, 0, 0);
 
 	/* Re-enable translation table walks using TTBR0 */
 	tcr = reg_tcr_el1_read();
@@ -1485,10 +1483,8 @@ pmap_deactivate(struct lwp *l)
 	reg_tcr_el1_write(tcr | TCR_EPD0);
 	isb();
 
-	struct pmap_asid_info * const pai __debugused = PMAP_PAI(pm,
-	cpu_tlb_info(ci));
-
-	UVMHIST_LOG(pmaphist, "lwp=%p, asid=%d", l, pai->pai_asid, 0, 0);
+	UVMHIST_LOG(pmaphist, "lwp=%p, asid=%d", l,
+	PMAP_PAI(pm, cpu_tlb_info(ci))->pai_asid, 0, 0);
 
 	pmap_tlb_asid_deactivate(pm);
 
@@ -2123,9 +2119,8 @@ pmap_remove_all(struct pmap *pm)
 	pmap_tlb_asid_release_all(pm);
 	pm->pm_remove_all = true;
 
-	struct pmap_asid_info * const pai __debugused = PMAP_PAI(pm,
-	cpu_tlb_info(ci));
-	UVMHIST_LOG(pmaphist, "pm=%p, asid=%d", pm, pai->pai_asid, 0, 0);
+	UVMHIST_LOG(pmaphist, "pm=%p, asid=%d", pm,
+	PMAP_PAI(pm, cpu_tlb_info(ci))->pai_asid, 0, 0);
 
 	pm_lock(pm);
 



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

2021-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 06:48:31 UTC 2021

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

Log Message:
Shrink a panic message to avoid a long line


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/sys/arch/aarch64/aarch64/cpufunc.c:1.30
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.29	Sat Oct 23 05:42:49 2021
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Sat Oct 23 06:48:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.29 2021/10/23 05:42:49 skrll Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.30 2021/10/23 06:48:31 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -30,7 +30,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.29 2021/10/23 05:42:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.30 2021/10/23 06:48:31 skrll Exp $");
 
 #include 
 #include 
@@ -159,7 +159,7 @@ aarch64_getcacheinfo(int unit)
 
 #ifdef MULTIPROCESSOR
 	if (coherency_unit < arm_dcache_align)
-		panic("coherency_unit %ld < arm_dcache_align %d; increase COHERENCY_UNIT",
+		panic("coherency_unit %ld < %d; increase COHERENCY_UNIT",
 		coherency_unit, arm_dcache_align);
 #endif
 



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

2021-10-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 06:48:31 UTC 2021

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

Log Message:
Shrink a panic message to avoid a long line


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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

2021-10-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 05:42:49 UTC 2021

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

Log Message:
Remove unnecessary brackets in a conditional


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.28 src/sys/arch/aarch64/aarch64/cpufunc.c:1.29
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.28	Thu Sep 23 06:34:00 2021
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Sat Oct 23 05:42:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.28 2021/09/23 06:34:00 skrll Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.29 2021/10/23 05:42:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -30,7 +30,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.28 2021/09/23 06:34:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.29 2021/10/23 05:42:49 skrll Exp $");
 
 #include 
 #include 
@@ -215,10 +215,10 @@ aarch64_getcacheinfo(int unit)
 	}
 
 	/* calculate L1 icache virtual index size */
-	if (((cinfo[0].icache.cache_type == CACHE_TYPE_VIVT) ||
-	 (cinfo[0].icache.cache_type == CACHE_TYPE_VIPT)) &&
-	((cinfo[0].cacheable == CACHE_CACHEABLE_ICACHE) ||
-	 (cinfo[0].cacheable == CACHE_CACHEABLE_IDCACHE))) {
+	if ((cinfo[0].icache.cache_type == CACHE_TYPE_VIVT ||
+	 cinfo[0].icache.cache_type == CACHE_TYPE_VIPT) &&
+	(cinfo[0].cacheable == CACHE_CACHEABLE_ICACHE ||
+	 cinfo[0].cacheable == CACHE_CACHEABLE_IDCACHE)) {
 
 		vindexsize =
 		cinfo[0].icache.cache_size /



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

2021-10-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 05:42:49 UTC 2021

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

Log Message:
Remove unnecessary brackets in a conditional


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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/include

2021-10-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 05:32:40 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/include/cpufunc.h

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/include/cpufunc.h
diff -u src/sys/arch/aarch64/include/cpufunc.h:1.20 src/sys/arch/aarch64/include/cpufunc.h:1.21
--- src/sys/arch/aarch64/include/cpufunc.h:1.20	Thu May 27 06:11:20 2021
+++ src/sys/arch/aarch64/include/cpufunc.h	Sat Oct 23 05:32:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.20 2021/05/27 06:11:20 ryo Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.21 2021/10/23 05:32:40 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -108,7 +108,6 @@ void aarch64_tlbi_by_asid_va_ll(int, vad
 #define cpu_idnum()			aarch64_cpuid()
 
 /* cache op */
-
 #define cpu_dcache_wbinv_all()		aarch64_dcache_wbinv_all()
 #define cpu_dcache_inv_all()		aarch64_dcache_inv_all()
 #define cpu_dcache_wb_all()		aarch64_dcache_wb_all()



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

2021-10-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 05:32:40 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpufunc.h

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/aarch64/include/cpufunc.h

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/include

2021-10-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 05:31:53 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
Typo in comment


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

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/include/armreg.h
diff -u src/sys/arch/aarch64/include/armreg.h:1.57 src/sys/arch/aarch64/include/armreg.h:1.58
--- src/sys/arch/aarch64/include/armreg.h:1.57	Sat Jun 19 13:40:00 2021
+++ src/sys/arch/aarch64/include/armreg.h	Sat Oct 23 05:31:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: armreg.h,v 1.57 2021/06/19 13:40:00 jmcneill Exp $ */
+/* $NetBSD: armreg.h,v 1.58 2021/10/23 05:31:53 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -1636,7 +1636,7 @@ struct aarch64_sysctl_cpu_id {
 	uint32_t ac_mvfr2;	/* Media and VFP Feature Register 2 */
 	uint32_t ac_pad;
 
-	uint64_t ac_clidr;	/* Cacle Level ID Register */
+	uint64_t ac_clidr;	/* Cache Level ID Register */
 	uint64_t ac_ctr;	/* Cache Type Register */
 };
 



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

2021-10-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 23 05:31:53 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: armreg.h

Log Message:
Typo in comment


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

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

2021-10-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 21 06:06:16 UTC 2021

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

Log Message:
fix gimplish


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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.80 src/sys/arch/aarch64/aarch64/locore.S:1.81
--- src/sys/arch/aarch64/aarch64/locore.S:1.80	Thu Sep 30 21:19:16 2021
+++ src/sys/arch/aarch64/aarch64/locore.S	Thu Oct 21 06:06:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.80 2021/09/30 21:19:16 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.81 2021/10/21 06:06:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.80 2021/09/30 21:19:16 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.81 2021/10/21 06:06:16 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -480,7 +480,7 @@ mp_vstart:
 	ldr	x0, [x0]
 	add	sp, sp, x0
 
-	/* stop using TTBR0 - CPU_DPRINT{,REG,SREG} no longer after this */
+	/* disable TTBR0 - CPU_DPRINT{,REG,SREG} no longer work after this */
 	mrs	x0, tcr_el1
 	orr	x0, x0, #TCR_EPD0
 	msr	tcr_el1, x0



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

2021-10-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 21 06:06:16 UTC 2021

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

Log Message:
fix gimplish


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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

2021-10-17 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Oct 17 22:44:35 UTC 2021

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

Log Message:
When booted with "boot netbsd -1" (disable multiprocessor boot),
"ddb>continue" didn't work when ddb was started by breakpoint trap.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/aarch64/aarch64/db_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/db_machdep.c
diff -u src/sys/arch/aarch64/aarch64/db_machdep.c:1.40 src/sys/arch/aarch64/aarch64/db_machdep.c:1.41
--- src/sys/arch/aarch64/aarch64/db_machdep.c:1.40	Fri Apr 30 20:07:22 2021
+++ src/sys/arch/aarch64/aarch64/db_machdep.c	Sun Oct 17 22:44:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.40 2021/04/30 20:07:22 skrll Exp $ */
+/* $NetBSD: db_machdep.c,v 1.41 2021/10/17 22:44:34 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.40 2021/04/30 20:07:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.41 2021/10/17 22:44:34 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"
@@ -1145,25 +1145,26 @@ kdb_trap(int type, struct trapframe *tf)
 	}
 
 #ifdef MULTIPROCESSOR
-	/*
-	 * Try to take ownership of DDB.
-	 * If we do, tell all other CPUs to enter DDB too.
-	 */
-	if ((ncpu > 1) &&
-	(atomic_cas_ptr(_onproc, NULL, ci) == NULL)) {
-		intr_ipi_send(NULL, IPI_DDB);
-		db_trigger = ci;
-	} else {
+	if (ncpu > 1) {
 		/*
-		 * If multiple CPUs catch kdb_trap() that is not IPI_DDB derived
-		 * at the same time, only the CPU that was able to get db_onproc
-		 * first will execute db_trap.
-		 * The CPU that could not get db_onproc will be set to type = -1
-		 * once, and kdb_trap will be called again with the correct type
-		 * after kdb_trap returns.
+		 * Try to take ownership of DDB.
+		 * If we do, tell all other CPUs to enter DDB too.
 		 */
-		type = -1;
-		restore_hw_watchpoints = true;
+		if (atomic_cas_ptr(_onproc, NULL, ci) == NULL) {
+			intr_ipi_send(NULL, IPI_DDB);
+			db_trigger = ci;
+		} else {
+			/*
+			 * If multiple CPUs catch kdb_trap() that is not IPI_DDB
+			 * derived at the same time, only the CPU that was able
+			 * to get db_onproc first will execute db_trap.
+			 * The CPU that could not get db_onproc will be set to
+			 * type = -1 once, and kdb_trap will be called again
+			 * with the correct type after kdb_trap returns.
+			 */
+			type = -1;
+			restore_hw_watchpoints = true;
+		}
 	}
 	db_readytoswitch[ci->ci_index] = tf;
 #endif



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

2021-10-17 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Oct 17 22:44:35 UTC 2021

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

Log Message:
When booted with "boot netbsd -1" (disable multiprocessor boot),
"ddb>continue" didn't work when ddb was started by breakpoint trap.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/aarch64/aarch64/db_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

2021-10-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 17 07:26:20 UTC 2021

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

Log Message:
Remove some newlines


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 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.63 src/sys/arch/aarch64/aarch64/cpu.c:1.64
--- src/sys/arch/aarch64/aarch64/cpu.c:1.63	Sun Oct 10 07:41:21 2021
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Oct 17 07:26:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.63 2021/10/10 07:41:21 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.64 2021/10/17 07:26:20 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.63 2021/10/10 07:41:21 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.64 2021/10/17 07:26:20 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -364,8 +364,6 @@ cpu_identify2(device_t self, struct cpu_
 	}
 	aprint_verbose("\n");
 
-
-
 	aprint_verbose_dev(self, "auxID=0x%" PRIx64, ci->ci_id.ac_aa64isar0);
 
 	/* PFR0 */



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

2021-10-17 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 17 07:26:20 UTC 2021

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

Log Message:
Remove some newlines


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 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

2021-10-16 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Oct 16 06:34:30 UTC 2021

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

Log Message:
fix non-MULTIPROCESSOR build


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 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.117 src/sys/arch/aarch64/aarch64/pmap.c:1.118
--- src/sys/arch/aarch64/aarch64/pmap.c:1.117	Sun Oct 10 07:15:25 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sat Oct 16 06:34:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.117 2021/10/10 07:15:25 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.118 2021/10/16 06:34:30 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2021/10/10 07:15:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.118 2021/10/16 06:34:30 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -498,11 +498,13 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	CTASSERT(sizeof(kpm->pm_stats.resident_count) == sizeof(long));
 }
 
+#ifdef MULTIPROCESSOR
 void
 pmap_md_tlb_info_attach(struct pmap_tlb_info *ti, struct cpu_info *ci)
 {
 	/* nothing */
 }
+#endif /* MULTIPROCESSOR */
 
 static inline void
 _pmap_adj_wired_count(struct pmap *pm, int adj)



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

2021-10-16 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sat Oct 16 06:34:30 UTC 2021

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

Log Message:
fix non-MULTIPROCESSOR build


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:59:45 UTC 2021

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/idle_machdep.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/idle_machdep.S
diff -u src/sys/arch/aarch64/aarch64/idle_machdep.S:1.10 src/sys/arch/aarch64/aarch64/idle_machdep.S:1.11
--- src/sys/arch/aarch64/aarch64/idle_machdep.S:1.10	Mon Aug 30 22:28:50 2021
+++ src/sys/arch/aarch64/aarch64/idle_machdep.S	Sun Oct 10 08:59:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: idle_machdep.S,v 1.10 2021/08/30 22:28:50 jmcneill Exp $ */
+/* $NetBSD: idle_machdep.S,v 1.11 2021/10/10 08:59:45 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: idle_machdep.S,v 1.10 2021/08/30 22:28:50 jmcneill Exp $");
+RCSID("$NetBSD: idle_machdep.S,v 1.11 2021/10/10 08:59:45 skrll Exp $");
 
 #ifdef ARM_INTR_IMPL
 #include ARM_INTR_IMPL
@@ -55,7 +55,7 @@ ENTRY(cpu_idle)
 	/*
 	 * hardware interrupt -> trap handler -> interrupt handler
 	 */
-	dsb sy
+	dsb	sy
 	wfi
 
 #else /* LAZY_CPUIDLE */
@@ -94,7 +94,7 @@ ENTRY(cpu_idle)
 	 */
 	str	w2, [x28, #CI_INTR_DEPTH]	/* ci->ci_intr_depth = 1 */
 
-	dsb sy
+	dsb	sy
 	wfi
 	bl	ARM_IRQ_HANDLER			/* irqhandler(trapframe) */
 1:



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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 08:59:45 UTC 2021

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/idle_machdep.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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:41:21 UTC 2021

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

Log Message:
Need to call pmap_tlb_info_attach for each CPU.  Missed in previous
commit.
CVS --


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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.62 src/sys/arch/aarch64/aarch64/cpu.c:1.63
--- src/sys/arch/aarch64/aarch64/cpu.c:1.62	Mon Oct  4 09:39:18 2021
+++ src/sys/arch/aarch64/aarch64/cpu.c	Sun Oct 10 07:41:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.62 2021/10/04 09:39:18 skrll Exp $ */
+/* $NetBSD: cpu.c,v 1.63 2021/10/10 07:41:21 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.62 2021/10/04 09:39:18 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.63 2021/10/10 07:41:21 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -153,6 +153,7 @@ cpu_attach(device_t dv, cpuid_t id)
 #ifdef MULTIPROCESSOR
 	if (unit != 0) {
 		mi_cpu_attach(ci);
+		pmap_tlb_info_attach(_tlb0_info, ci);
 		return;
 	}
 #endif /* MULTIPROCESSOR */



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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:41:21 UTC 2021

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

Log Message:
Need to call pmap_tlb_info_attach for each CPU.  Missed in previous
commit.
CVS --


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 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

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:15:25 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/aarch64/include: cpu.h pmap.h pte.h types.h
Added Files:
src/sys/arch/aarch64/aarch64: aarch64_tlb.c

Log Message:
Use sys/uvm/pmap/pmap_tlb.c on Aarch64 in the same way that some Arm, MIPS,
and some PPC kernels do.  This removes the limitation of 256 processes on
CPUs with 8bit ASID field, e.g. Apple M1.

Additionally the following changes have been made

- removed a couple of unnecessary aarch64_tlbi_all calls
- removed any invalidation after freeing page tables due to
  _pmap_sweep_pdp. This was never necessary afaict.
- all kernel mappings are marked global and userland mapping not-global.

Performance testing hasn't show a significant difference.  The data here
is from building a kernel on an lx2k system with nvme.

before
1489.6u 400.4s 2:40.65 1176.5% 228+224k 0+32289io 57pf+0w
1482.6u 403.2s 2:38.49 1189.9% 228+222k 0+32274io 46pf+0w
1485.4u 402.2s 2:37.27 1200.2% 228+222k 0+32275io 12pf+0w

after
1493.9u 404.6s 2:37.50 1205.4% 227+221k 0+32265io 48pf+0w
1485.0u 408.0s 2:38.54 1194.0% 227+222k 0+32272io 36pf+0w
1484.3u 407.0s 2:35.88 1213.3% 228+224k 0+32268io 14pf+0w

>>> stats.ttest_ind([160.65,158.49,157.27], [157.5,158.54,155.88])
Ttest_indResult(statistic=1.1923622711296888, pvalue=0.2990182944606766)
>>>


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/aarch64/aarch64/aarch64_tlb.c
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/aarch64/include/pmap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/include/pte.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/include/types.h

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.116 src/sys/arch/aarch64/aarch64/pmap.c:1.117
--- src/sys/arch/aarch64/aarch64/pmap.c:1.116	Thu Sep 30 21:19:16 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Oct 10 07:15:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.116 2021/09/30 21:19:16 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.117 2021/10/10 07:15:25 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.116 2021/09/30 21:19:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2021/10/10 07:15:25 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.1
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -181,10 +182,10 @@ PMAP_COUNTER(unwire_failure, "pmap_unwir
  * change the pte to accessible temporarly before cpu_icache_sync_range().
  * this macro modifies PTE (*ptep). need to update PTE after this.
  */
-#define PTE_ICACHE_SYNC_PAGE(pte, ptep, pm, va, ll)			\
+#define PTE_ICACHE_SYNC_PAGE(pte, ptep, asid, va, ll)			\
 	do {\
 		atomic_swap_64((ptep), (pte) | LX_BLKPAG_AF);		\
-		AARCH64_TLBI_BY_ASID_VA((pm)->pm_asid, (va), (ll));	\
+		AARCH64_TLBI_BY_ASID_VA((asid), (va), (ll));		\
 		cpu_icache_sync_range((va), PAGE_SIZE);			\
 	} while (0/*CONSTCOND*/)
 
@@ -336,7 +337,6 @@ pmap_map_chunk(vaddr_t va, paddr_t pa, v
 	attr = _pmap_pte_adjust_prot(0, prot, VM_PROT_ALL, false);
 	attr = _pmap_pte_adjust_cacheflags(attr, flags);
 	pmapboot_enter_range(va, pa, resid, attr, printf);
-	aarch64_tlbi_all();
 
 	return resid;
 }
@@ -472,18 +472,23 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	virtual_end = vend;
 	pmap_maxkvaddr = vstart;
 
-	aarch64_tlbi_all();
-
 	l0pa = reg_ttbr1_el1_read();
 	l0 = (void *)AARCH64_PA_TO_KVA(l0pa);
 
+	pmap_tlb_info_init(_tlb0_info);
+
 	memset(_pmap, 0, sizeof(kernel_pmap));
+
 	kpm = pmap_kernel();
-	kpm->pm_asid = 0;
+	struct pmap_asid_info * const pai = PMAP_PAI(kpm, cpu_tlb_info(ci));
+
+	pai->pai_asid = KERNEL_PID;
 	kpm->pm_refcnt = 1;
 	kpm->pm_idlepdp = 0;
 	kpm->pm_l0table = l0;
 	kpm->pm_l0table_pa = l0pa;
+	kpm->pm_onproc = kcpuset_running;
+	kpm->pm_active = kcpuset_running;
 	kpm->pm_activated = true;
 	LIST_INIT(>pm_vmlist);
 	LIST_INIT(>pm_pvlist);	/* not used for kernel pmap */
@@ -493,6 +498,12 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	CTASSERT(sizeof(kpm->pm_stats.resident_count) == sizeof(long));
 }
 
+void
+pmap_md_tlb_info_attach(struct pmap_tlb_info *ti, struct cpu_info *ci)
+{
+	/* nothing */
+}
+
 static inline void
 _pmap_adj_wired_count(struct pmap *pm, int adj)
 {
@@ -556,9 +567,7 @@ pmap_init(void)
 	32, 0, PR_LARGECACHE, "pvpl", NULL, IPL_NONE, _pmap_pv_ctor,
 	NULL, NULL);
 
-	int nmaxproc = cpu_maxproc();
-	if (maxproc > nmaxproc)
-		maxproc = nmaxproc;
+	

CVS commit: src/sys/arch/aarch64

2021-10-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Oct 10 07:15:25 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: pmap.c
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/aarch64/include: cpu.h pmap.h pte.h types.h
Added Files:
src/sys/arch/aarch64/aarch64: aarch64_tlb.c

Log Message:
Use sys/uvm/pmap/pmap_tlb.c on Aarch64 in the same way that some Arm, MIPS,
and some PPC kernels do.  This removes the limitation of 256 processes on
CPUs with 8bit ASID field, e.g. Apple M1.

Additionally the following changes have been made

- removed a couple of unnecessary aarch64_tlbi_all calls
- removed any invalidation after freeing page tables due to
  _pmap_sweep_pdp. This was never necessary afaict.
- all kernel mappings are marked global and userland mapping not-global.

Performance testing hasn't show a significant difference.  The data here
is from building a kernel on an lx2k system with nvme.

before
1489.6u 400.4s 2:40.65 1176.5% 228+224k 0+32289io 57pf+0w
1482.6u 403.2s 2:38.49 1189.9% 228+222k 0+32274io 46pf+0w
1485.4u 402.2s 2:37.27 1200.2% 228+222k 0+32275io 12pf+0w

after
1493.9u 404.6s 2:37.50 1205.4% 227+221k 0+32265io 48pf+0w
1485.0u 408.0s 2:38.54 1194.0% 227+222k 0+32272io 36pf+0w
1484.3u 407.0s 2:35.88 1213.3% 228+224k 0+32268io 14pf+0w

>>> stats.ttest_ind([160.65,158.49,157.27], [157.5,158.54,155.88])
Ttest_indResult(statistic=1.1923622711296888, pvalue=0.2990182944606766)
>>>


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/aarch64/aarch64/aarch64_tlb.c
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/aarch64/include/pmap.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/aarch64/include/pte.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/include/types.h

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

2021-10-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Oct  8 21:41:29 UTC 2021

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

Log Message:
Use BOOT_FLAG() to recognize standard boot options.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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.61 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.62
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.61	Thu Jun  3 07:02:59 2021
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Fri Oct  8 21:41:29 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.61 2021/06/03 07:02:59 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.62 2021/10/08 21:41:29 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.61 2021/06/03 07:02:59 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.62 2021/10/08 21:41:29 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -42,6 +42,7 @@ __KERNEL_RCSID(1, "$NetBSD: aarch64_mach
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -537,24 +538,26 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
 void
 parse_mi_bootargs(char *args)
 {
-	int val;
+	const char *p = args;
 
-	if (get_bootconf_option(args, "-1", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= RB_MD1;
-	if (get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= RB_SINGLE;
-	if (get_bootconf_option(args, "-d", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= RB_KDB;
-	if (get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= RB_ASKNAME;
-	if (get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= AB_QUIET;
-	if (get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= AB_VERBOSE;
-	if (get_bootconf_option(args, "-x", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= AB_DEBUG;
-	if (get_bootconf_option(args, "-z", BOOTOPT_TYPE_BOOLEAN, ) && val)
-		boothowto |= AB_SILENT;
+	while (*p != '\0') {
+		while (isspace(*p))
+			p++;
+
+		/* parse single dash (`-') options */
+		if (*p == '-') {
+			p++;
+			while (!isspace(*p) && *p != '\0') {
+BOOT_FLAG(*p, boothowto);
+p++;
+			}
+			continue;
+		}
+
+		/* skip normal argument */
+		while (!isspace(*p) && *p != '\0')
+			p++;
+	}
 }
 
 void



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

2021-10-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Oct  8 21:41:29 UTC 2021

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

Log Message:
Use BOOT_FLAG() to recognize standard boot options.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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

2021-10-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct  4 09:39:18 UTC 2021

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

Log Message:
Add a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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.61 src/sys/arch/aarch64/aarch64/cpu.c:1.62
--- src/sys/arch/aarch64/aarch64/cpu.c:1.61	Mon Aug 30 22:57:33 2021
+++ src/sys/arch/aarch64/aarch64/cpu.c	Mon Oct  4 09:39:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.61 2021/08/30 22:57:33 jmcneill Exp $ */
+/* $NetBSD: cpu.c,v 1.62 2021/10/04 09:39:18 skrll Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.61 2021/08/30 22:57:33 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.62 2021/10/04 09:39:18 skrll Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -681,6 +681,7 @@ void
 cpu_hatch(struct cpu_info *ci)
 {
 	KASSERT(curcpu() == ci);
+	KASSERT((reg_tcr_el1_read() & TCR_EPD0) != 0);
 
 	mutex_enter(_hatch_lock);
 



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

2021-10-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Oct  4 09:39:18 UTC 2021

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

Log Message:
Add a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 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

2021-09-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 30 21:19:16 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf locore.S pmap.c

Log Message:
Ensure TCR_EPD0 is set on entry to pmap_activate and ensure it is set as
early as possible for APs.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.115 -r1.116 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/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.34 src/sys/arch/aarch64/aarch64/genassym.cf:1.35
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.34	Sat Sep 18 12:25:06 2021
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Thu Sep 30 21:19:16 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.34 2021/09/18 12:25:06 jmcneill Exp $
+# $NetBSD: genassym.cf,v 1.35 2021/09/30 21:19:16 skrll Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -137,6 +137,7 @@ define	TCR_IRGN0_NC		TCR_IRGN0_NC
 define	TCR_IRGN0_WB_WA		TCR_IRGN0_WB_WA
 define	TCR_IRGN0_WT		TCR_IRGN0_WT
 define	TCR_IRGN0_WB		TCR_IRGN0_WB
+define	TCR_EPD0		TCR_EPD0
 define	TCR_T0SZ		TCR_T0SZ
 
 define	EFAULT			EFAULT

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.79 src/sys/arch/aarch64/aarch64/locore.S:1.80
--- src/sys/arch/aarch64/aarch64/locore.S:1.79	Mon Aug 30 22:24:39 2021
+++ src/sys/arch/aarch64/aarch64/locore.S	Thu Sep 30 21:19:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.79 2021/08/30 22:24:39 jmcneill Exp $	*/
+/*	$NetBSD: locore.S,v 1.80 2021/09/30 21:19:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.79 2021/08/30 22:24:39 jmcneill Exp $")
+RCSID("$NetBSD: locore.S,v 1.80 2021/09/30 21:19:16 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -468,7 +468,27 @@ ENTRY_NP(cpu_mpstart)
 
 mp_vstart:
 	hint	0x24		/* bti j */
+
 	CPU_DPRINTREG("PC   = ", x20)
+	CPU_DPRINTREG("SP   = ", sp)
+
+	CPU_DPRINTSREG("TTBR0= ", ttbr0_el1)
+	CPU_DPRINTSREG("TTBR1= ", ttbr1_el1)
+
+	/* Set SP to VA */
+	adrl	x0, kern_vtopdiff
+	ldr	x0, [x0]
+	add	sp, sp, x0
+
+	/* stop using TTBR0 - CPU_DPRINT{,REG,SREG} no longer after this */
+	mrs	x0, tcr_el1
+	orr	x0, x0, #TCR_EPD0
+	msr	tcr_el1, x0
+	isb
+
+	tlbi	vmalle1is
+	dsb	ish
+	isb
 
 	/* set exception vector */
 	adrl	x0, _C_LABEL(el1_vectors)

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.115 src/sys/arch/aarch64/aarch64/pmap.c:1.116
--- src/sys/arch/aarch64/aarch64/pmap.c:1.115	Sun Sep 26 09:58:13 2021
+++ src/sys/arch/aarch64/aarch64/pmap.c	Thu Sep 30 21:19:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.115 2021/09/26 09:58:13 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.116 2021/09/30 21:19:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.115 2021/09/26 09:58:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.116 2021/09/30 21:19:16 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1426,6 +1426,8 @@ pmap_activate(struct lwp *l)
 	UVMHIST_CALLARGS(pmaphist, "lwp=%p asid=%d (pid=%d)", l, pm->pm_asid,
 	l->l_proc->p_pid, 0);
 
+	KASSERT((reg_tcr_el1_read() & TCR_EPD0) != 0);
+
 	if (pm == pmap_kernel())
 		return;
 	if (l != curlwp)



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

2021-09-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 30 21:19:16 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: genassym.cf locore.S pmap.c

Log Message:
Ensure TCR_EPD0 is set on entry to pmap_activate and ensure it is set as
early as possible for APs.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.115 -r1.116 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/include

2021-09-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 30 18:33:28 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: types.h

Log Message:
Make tlb_asid_t unsigned int as pmap_tlb.c expects tlb_asid_t to be able to
hold ASID_MAX + 1.


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

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/include/types.h
diff -u src/sys/arch/aarch64/include/types.h:1.18 src/sys/arch/aarch64/include/types.h:1.19
--- src/sys/arch/aarch64/include/types.h:1.18	Wed Mar 24 05:00:24 2021
+++ src/sys/arch/aarch64/include/types.h	Thu Sep 30 18:33:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.18 2021/03/24 05:00:24 simonb Exp $ */
+/* $NetBSD: types.h,v 1.19 2021/09/30 18:33:28 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@ typedef __uint32_t register32_t;
 #define PRIxREGISTER	PRIx64
 #define PRIxREGISTER32	PRIx32
 
-typedef unsigned short	tlb_asid_t;
+typedef unsigned int	tlb_asid_t;
 
 #if defined(_KERNEL)
 #define LBL_X19	0



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

2021-09-30 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 30 18:33:28 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: types.h

Log Message:
Make tlb_asid_t unsigned int as pmap_tlb.c expects tlb_asid_t to be able to
hold ASID_MAX + 1.


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

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

2021-09-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Sep 27 17:51:15 UTC 2021

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

Log Message:
remove unused code.
The syscall for 32bit uses aarch32_syscall.c, so there is no need to make 
syscall.c support it.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/syscall.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/syscall.c
diff -u src/sys/arch/aarch64/aarch64/syscall.c:1.10 src/sys/arch/aarch64/aarch64/syscall.c:1.11
--- src/sys/arch/aarch64/aarch64/syscall.c:1.10	Mon Sep 27 17:40:39 2021
+++ src/sys/arch/aarch64/aarch64/syscall.c	Mon Sep 27 17:51:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.10 2021/09/27 17:40:39 ryo Exp $	*/
+/*	$NetBSD: syscall.c,v 1.11 2021/09/27 17:51:15 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -49,9 +49,6 @@
 #define	NARGREG		8		/* 8 args are in registers */
 #endif
 #define	MOREARGS(sp)	((const void *)(uintptr_t)(sp)) /* more args go here */
-#ifndef REGISTER_T
-#define REGISTER_T	register_t
-#endif
 
 #ifndef EMULNAME
 #include 
@@ -61,7 +58,7 @@
 #define EMULNAME(x)	(x)
 #define EMULNAMEU(x)	(x)
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.10 2021/09/27 17:40:39 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.11 2021/09/27 17:51:15 ryo Exp $");
 
 void
 cpu_spawn_return(struct lwp *l)
@@ -143,52 +140,10 @@ EMULNAME(syscall)(struct trapframe *tf)
 	if (__predict_false(callp->sy_narg > nargs)) {
 		const size_t diff = callp->sy_narg - nargs;
 		memcpy(args, params, nargs * sizeof(params[0]));
-		if (sizeof(params[0]) == sizeof(REGISTER_T)) {
-			error = copyin(MOREARGS(tf->tf_sp), [nargs],
-			diff * sizeof(register_t));
-			if (error)
-goto bad;
-		} else {
-			/*
-			 * If the register_t used by the process isn't the
-			 * as the one used by the kernel, we can't directly
-			 * copy the arguments off the stack into args.  We
-			 * need to buffer them in a REGISTER_T array and
-			 * then move them individually into args.
-			 */
-			REGISTER_T args32[10];
-			error = copyin(MOREARGS(tf->tf_sp), args32,
-			diff * sizeof(REGISTER_T));
-			if (error)
-goto bad;
-			for (size_t i = 0; i < diff; i++) {
-args[nargs + i] = args32[i];
-			}
-		}
-		params = args;
-	}
-
-#ifdef __AARCH64EB__
-#define SYCALL_ARG_64(a, b)	(((register_t) (a) << 32) | (uint32_t)(b))
-#else
-#define SYCALL_ARG_64(a, b)	(((register_t) (b) << 32) | (uint32_t)(a))
-#endif
-
-	/*
-	 * If the syscall used a different (smaller) register size,
-	 * reconstruct the 64-bit arguments from two 32-bit registers.
-	 */
-	if (__predict_false(sizeof(register_t) != sizeof(REGISTER_T)
-			&& SYCALL_NARGS64(callp) > 0)) {
-		for (size_t i = 0, j = 0; i < callp->sy_narg; i++, j++) {
-			if (SYCALL_ARG_64_P(callp, i)) {
-register_t *inp = [j];
-args[i] = SYCALL_ARG_64(inp[0], inp[1]);
-j++;
-			} else if (i != j) {
-args[i] = params[j];
-			}
-		}
+		error = copyin(MOREARGS(tf->tf_sp), [nargs],
+		diff * sizeof(register_t));
+		if (error)
+			goto bad;
 		params = args;
 	}
 
@@ -197,21 +152,10 @@ EMULNAME(syscall)(struct trapframe *tf)
 	error = sy_invoke(callp, l, params, rval, code);
 
 	if (__predict_true(error == 0)) {
-		if (__predict_false(sizeof(register_t) != sizeof(REGISTER_T)
-&& SYCALL_RET_64_P(callp))) {
-#ifdef __AARCH64EB__
-			tf->tf_reg[0] = (uint32_t) (rval[0] >> 32);
-			tf->tf_reg[1] = (uint32_t) (rval[0] >>  0);
-#else
-			tf->tf_reg[0] = (uint32_t) (rval[0] >>  0);
-			tf->tf_reg[1] = (uint32_t) (rval[0] >> 32);
-#endif
-		} else {
-			tf->tf_reg[0] = rval[0];
+		tf->tf_reg[0] = rval[0];
 #ifndef SYSCALL_NO_RVAL1
-			tf->tf_reg[1] = rval[1];
+		tf->tf_reg[1] = rval[1];
 #endif
-		}
 		tf->tf_spsr &= ~NZCV_C;
 	} else {
 		switch (error) {



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

2021-09-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Sep 27 17:51:15 UTC 2021

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

Log Message:
remove unused code.
The syscall for 32bit uses aarch32_syscall.c, so there is no need to make 
syscall.c support it.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/aarch64/syscall.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

2021-09-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Sep 27 17:40:39 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: linux_syscall.c syscall.c

Log Message:
linux syscall should not break x1 register


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/linux_syscall.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/syscall.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/linux_syscall.c
diff -u src/sys/arch/aarch64/aarch64/linux_syscall.c:1.1 src/sys/arch/aarch64/aarch64/linux_syscall.c:1.2
--- src/sys/arch/aarch64/aarch64/linux_syscall.c:1.1	Thu Sep 23 06:56:26 2021
+++ src/sys/arch/aarch64/aarch64/linux_syscall.c	Mon Sep 27 17:40:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_syscall.c,v 1.1 2021/09/23 06:56:26 ryo Exp $	*/
+/*	$NetBSD: linux_syscall.c,v 1.2 2021/09/27 17:40:39 ryo Exp $	*/
 
 /*
  * Copyright (c) 2021 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.1 2021/09/23 06:56:26 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.2 2021/09/27 17:40:39 ryo Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_linux.h"
@@ -54,5 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_syscal
 /* used when __HAVE_MINIMAL_EMUL is not defined */
 #define SYSCALL_EMUL_ERRNO(x)	native_to_linux_errno[x]
 
+/* don't update x1 register with rval[1] */
+#define SYSCALL_NO_RVAL1
 
 #include "syscall.c"

Index: src/sys/arch/aarch64/aarch64/syscall.c
diff -u src/sys/arch/aarch64/aarch64/syscall.c:1.9 src/sys/arch/aarch64/aarch64/syscall.c:1.10
--- src/sys/arch/aarch64/aarch64/syscall.c:1.9	Mon Sep 27 17:37:59 2021
+++ src/sys/arch/aarch64/aarch64/syscall.c	Mon Sep 27 17:40:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.9 2021/09/27 17:37:59 ryo Exp $	*/
+/*	$NetBSD: syscall.c,v 1.10 2021/09/27 17:40:39 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
 #define EMULNAME(x)	(x)
 #define EMULNAMEU(x)	(x)
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.9 2021/09/27 17:37:59 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.10 2021/09/27 17:40:39 ryo Exp $");
 
 void
 cpu_spawn_return(struct lwp *l)
@@ -208,7 +208,9 @@ EMULNAME(syscall)(struct trapframe *tf)
 #endif
 		} else {
 			tf->tf_reg[0] = rval[0];
+#ifndef SYSCALL_NO_RVAL1
 			tf->tf_reg[1] = rval[1];
+#endif
 		}
 		tf->tf_spsr &= ~NZCV_C;
 	} else {



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

2021-09-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Sep 27 17:40:39 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: linux_syscall.c syscall.c

Log Message:
linux syscall should not break x1 register


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/aarch64/linux_syscall.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/aarch64/aarch64/syscall.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

2021-09-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Sep 27 17:37:59 UTC 2021

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

Log Message:
In order to prevent uninitialized values from being reflected in the registers 
after syscall, rval[] must be initialized.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/aarch64/syscall.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

2021-09-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Mon Sep 27 17:37:59 UTC 2021

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

Log Message:
In order to prevent uninitialized values from being reflected in the registers 
after syscall, rval[] must be initialized.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/aarch64/syscall.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/syscall.c
diff -u src/sys/arch/aarch64/aarch64/syscall.c:1.8 src/sys/arch/aarch64/aarch64/syscall.c:1.9
--- src/sys/arch/aarch64/aarch64/syscall.c:1.8	Thu Sep 23 15:19:03 2021
+++ src/sys/arch/aarch64/aarch64/syscall.c	Mon Sep 27 17:37:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.8 2021/09/23 15:19:03 ryo Exp $	*/
+/*	$NetBSD: syscall.c,v 1.9 2021/09/27 17:37:59 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
 #define EMULNAME(x)	(x)
 #define EMULNAMEU(x)	(x)
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.8 2021/09/23 15:19:03 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.9 2021/09/27 17:37:59 ryo Exp $");
 
 void
 cpu_spawn_return(struct lwp *l)
@@ -192,6 +192,8 @@ EMULNAME(syscall)(struct trapframe *tf)
 		params = args;
 	}
 
+	rval[0] = 0;
+	rval[1] = tf->tf_reg[1];
 	error = sy_invoke(callp, l, params, rval, code);
 
 	if (__predict_true(error == 0)) {



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

2021-09-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 26 20:15:04 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: lock.h

Log Message:
Use the yield instruction as SPINLOCK_BACKOFF_HOOK for aarch64.


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

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/include/lock.h
diff -u src/sys/arch/aarch64/include/lock.h:1.3 src/sys/arch/aarch64/include/lock.h:1.4
--- src/sys/arch/aarch64/include/lock.h:1.3	Fri Jun 26 18:27:52 2015
+++ src/sys/arch/aarch64/include/lock.h	Sun Sep 26 20:15:04 2021
@@ -1,6 +1,12 @@
-/* $NetBSD: lock.h,v 1.3 2015/06/26 18:27:52 matt Exp $ */
+/* $NetBSD: lock.h,v 1.4 2021/09/26 20:15:04 jmcneill Exp $ */
 
 #ifdef __aarch64__
+# ifdef _HARDKERNEL
+#  ifdef SPINLOCK_BACKOFF_HOOK
+#   undef SPINLOCK_BACKOFF_HOOK
+#  endif
+#  define SPINLOCK_BACKOFF_HOOK		asm volatile("yield" ::: "memory")
+# endif
 # include 
 #elif defined(__arm__)
 # include 



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

2021-09-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 26 20:15:04 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: lock.h

Log Message:
Use the yield instruction as SPINLOCK_BACKOFF_HOOK for aarch64.


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

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



  1   2   3   >