CVS commit: src/sys/arch/sparc/sparc

2023-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 14:56:37 UTC 2023

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
sparc: Add missing barriers in cpu_switchto.

PR kern/57240

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/sys/arch/sparc/sparc/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/sparc/sparc

2023-02-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Feb 23 14:56:37 UTC 2023

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
sparc: Add missing barriers in cpu_switchto.

PR kern/57240

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.283 src/sys/arch/sparc/sparc/locore.s:1.284
--- src/sys/arch/sparc/sparc/locore.s:1.283	Sun May 15 02:14:15 2022
+++ src/sys/arch/sparc/sparc/locore.s	Thu Feb 23 14:56:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.283 2022/05/15 02:14:15 mrg Exp $	*/
+/*	$NetBSD: locore.s,v 1.284 2023/02/23 14:56:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -4889,7 +4889,30 @@ Lwb1:	SAVE; SAVE; SAVE; SAVE; SAVE; SAVE
 	/* set new cpcb, and curlwp */
 	sethi	%hi(curlwp), %l7
 	st	%g5, [%l6 + %lo(cpcb)]		! cpcb = newpcb;
+
+	/*
+	 * Issue barriers to coordinate mutex_exit on this CPU with
+	 * mutex_vector_enter on another CPU.
+	 *
+	 * 1. Any prior mutex_exit by oldlwp must be visible to other
+	 *CPUs before we set ci_curlwp := newlwp on this one,
+	 *requiring a store-before-store barrier.
+	 *
+	 * 2. ci_curlwp := newlwp must be visible on all other CPUs
+	 *before any subsequent mutex_exit by newlwp can even test
+	 *whether there might be waiters, requiring a
+	 *store-before-load barrier.
+	 *
+	 * See kern_mutex.c for details -- this is necessary for
+	 * adaptive mutexes to detect whether the lwp is on the CPU in
+	 * order to safely block without requiring atomic r/m/w in
+	 * mutex_exit.
+	 */
+	/* stbar -- store-before-store, not needed on TSO */
 	st  %g3, [%l7 + %lo(curlwp)]! curlwp = l;
+#ifdef MULTIPROCESSOR
+	ldstub	[%sp - 4], %g0	/* makeshift store-before-load barrier */
+#endif
 
 	/* compute new wim */
 	ld	[%g5 + PCB_WIM], %o0



CVS commit: src/sys/arch/sparc/sparc

2022-09-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Sep 30 14:32:45 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Make this compile for SUN4-only kernels
(move namebuf inside the SUN4C/SUN4M/SUN4D ifdef to match where it's used).


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.270 src/sys/arch/sparc/sparc/autoconf.c:1.271
--- src/sys/arch/sparc/sparc/autoconf.c:1.270	Sat Jan 22 11:49:16 2022
+++ src/sys/arch/sparc/sparc/autoconf.c	Fri Sep 30 14:32:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.270 2022/01/22 11:49:16 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.271 2022/09/30 14:32:45 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.270 2022/01/22 11:49:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.271 2022/09/30 14:32:45 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1119,8 +1119,8 @@ mainbus_attach(device_t parent, device_t
 	};
 
 	struct mainbus_attach_args ma;
-	char namebuf[32];
 #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
+	char namebuf[32];
 	const char *sp = NULL;
 	int node0, node;
 	const struct boot_special *openboot_special, *ssp;



CVS commit: src/sys/arch/sparc/sparc

2022-09-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Sep 30 14:32:45 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Make this compile for SUN4-only kernels
(move namebuf inside the SUN4C/SUN4M/SUN4D ifdef to match where it's used).


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc

2022-05-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun May 15 02:14:15 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
remove unused Lpanic_savefpstate.


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.282 src/sys/arch/sparc/sparc/locore.s:1.283
--- src/sys/arch/sparc/sparc/locore.s:1.282	Sat Apr 16 18:15:21 2022
+++ src/sys/arch/sparc/sparc/locore.s	Sun May 15 02:14:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.282 2022/04/16 18:15:21 andvar Exp $	*/
+/*	$NetBSD: locore.s,v 1.283 2022/05/15 02:14:15 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -5621,10 +5621,6 @@ Lkcerr:
  *
  * The IPI version just deals with updating event counters first.
  */
-Lpanic_savefpstate:
-	.asciz	"cpu%d: NULL fpstate"
-	_ALIGN
-
 ENTRY(ipi_savefpstate)
 	sethi	%hi(CPUINFO_VA+CPUINFO_SAVEFPSTATE), %o5
 	ldd	[%o5 + %lo(CPUINFO_VA+CPUINFO_SAVEFPSTATE)], %o2



CVS commit: src/sys/arch/sparc/sparc

2022-05-14 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun May 15 02:14:15 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
remove unused Lpanic_savefpstate.


To generate a diff of this commit:
cvs rdiff -u -r1.282 -r1.283 src/sys/arch/sparc/sparc/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/sparc/sparc

2022-04-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 20 23:32:17 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: clkctrl.c

Log Message:
the register is only one byte, act like it


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/sparc/clkctrl.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/sparc/sparc/clkctrl.c
diff -u src/sys/arch/sparc/sparc/clkctrl.c:1.6 src/sys/arch/sparc/sparc/clkctrl.c:1.7
--- src/sys/arch/sparc/sparc/clkctrl.c:1.6	Mon Dec 30 22:13:47 2019
+++ src/sys/arch/sparc/sparc/clkctrl.c	Wed Apr 20 23:32:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: clkctrl.c,v 1.6 2019/12/30 22:13:47 ad Exp $	*/
+/*	$NetBSD: clkctrl.c,v 1.7 2022/04/20 23:32:17 macallan Exp $	*/
 
 /*
  * Copyright (c) 2005 Michael Lorenz
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clkctrl.c,v 1.6 2019/12/30 22:13:47 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clkctrl.c,v 1.7 2022/04/20 23:32:17 macallan Exp $");
 
 #include 
 #include 
@@ -72,7 +72,7 @@ clkctrl_attach(device_t parent, device_t
 	}
 	if (sbus_bus_map(sa->sa_bustag,
 			 sa->sa_slot, sa->sa_offset,
-			 sizeof(long),
+			 1,
 			 BUS_SPACE_MAP_LINEAR, ) != 0) {
 		aprint_error("unable to map register\n");
 		return;



CVS commit: src/sys/arch/sparc/sparc

2022-04-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 20 23:32:17 UTC 2022

Modified Files:
src/sys/arch/sparc/sparc: clkctrl.c

Log Message:
the register is only one byte, act like it


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/sparc/clkctrl.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/sparc/sparc

2021-09-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Sep 17 16:16:18 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: promlib.c

Log Message:
Don't include  in the _STANDALONE case.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/sparc/sparc/promlib.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/sparc/sparc/promlib.c
diff -u src/sys/arch/sparc/sparc/promlib.c:1.49 src/sys/arch/sparc/sparc/promlib.c:1.50
--- src/sys/arch/sparc/sparc/promlib.c:1.49	Wed Sep 15 17:33:08 2021
+++ src/sys/arch/sparc/sparc/promlib.c	Fri Sep 17 16:16:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: promlib.c,v 1.49 2021/09/15 17:33:08 thorpej Exp $ */
+/*	$NetBSD: promlib.c,v 1.50 2021/09/17 16:16:18 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.49 2021/09/15 17:33:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.50 2021/09/17 16:16:18 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_sparc_arch.h"
@@ -45,12 +45,11 @@ __KERNEL_RCSID(0, "$NetBSD: promlib.c,v 
 #include 
 #include 
 
-#include 
-
 #ifdef _STANDALONE
 #include 
 #define malloc(s,t,f)	alloc(s)
 #else
+#include 
 #include 
 #include 
 #endif /* _STANDALONE */



CVS commit: src/sys/arch/sparc/sparc

2021-09-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Sep 17 16:16:18 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: promlib.c

Log Message:
Don't include  in the _STANDALONE case.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/sparc/sparc/promlib.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/sparc/sparc

2021-08-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Aug  7 19:23:03 UTC 2021

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

Log Message:
sp_tlb_flush - consistent whitespace in inline asm.


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.373 src/sys/arch/sparc/sparc/pmap.c:1.374
--- src/sys/arch/sparc/sparc/pmap.c:1.373	Sun Jan 24 07:36:54 2021
+++ src/sys/arch/sparc/sparc/pmap.c	Sat Aug  7 19:23:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.373 2021/01/24 07:36:54 mrg Exp $ */
+/*	$NetBSD: pmap.c,v 1.374 2021/08/07 19:23:03 uwe Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.373 2021/01/24 07:36:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.374 2021/08/07 19:23:03 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -663,13 +663,13 @@ sp_tlb_flush(int va, int ctx, int lvl)
 	opsr = getpsr();	/* KDASSERT(opsr & PSR_ET); */
 	__asm volatile ("wr %0, %1, %%psr"
 			:: "r"(opsr), "n"(PSR_ET) : "memory");
-	__asm volatile ("nop; nop;nop");
+	__asm volatile ("nop; nop; nop");
 
 	octx = getcontext4m();	/* save context */
 
 	/* Do the TLB flush in "ctx" */
 	setcontext4m(ctx);
-	__asm volatile("sta %%g0, [%0]%1" :: "r"(va), "n"(ASI_SRMMUFP));
+	__asm volatile ("sta %%g0, [%0]%1" :: "r"(va), "n"(ASI_SRMMUFP));
 
 	setcontext4m(octx);	/* restore context */
 	setpsr(opsr);		/* turn traps on again */



CVS commit: src/sys/arch/sparc/sparc

2021-08-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Aug  7 19:23:03 UTC 2021

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

Log Message:
sp_tlb_flush - consistent whitespace in inline asm.


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/arch/sparc/sparc/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/sparc/sparc

2021-07-31 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Jul 31 16:54:37 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
s/propective/prospective


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc

2021-07-31 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Jul 31 16:54:37 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
s/propective/prospective


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.267 src/sys/arch/sparc/sparc/autoconf.c:1.268
--- src/sys/arch/sparc/sparc/autoconf.c:1.267	Sat Jul 31 10:07:22 2021
+++ src/sys/arch/sparc/sparc/autoconf.c	Sat Jul 31 16:54:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $ */
+/*	$NetBSD: autoconf.c,v 1.268 2021/07/31 16:54:37 andvar Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.268 2021/07/31 16:54:37 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -2009,7 +2009,7 @@ bootinfo_relocate(void *newloc)
 		(size_t)cp < (size_t)bootinfo + BOOTINFO_SIZE);
 
 	/*
-	 * Check propective gains.
+	 * Check prospective gains.
 	 */
 	if ((int)bootinfo - (int)newloc < bi_size)
 		/* Don't bother */



CVS commit: src/sys/arch/sparc/sparc

2021-07-31 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Jul 31 10:07:23 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
fix typos in comments


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.266 src/sys/arch/sparc/sparc/autoconf.c:1.267
--- src/sys/arch/sparc/sparc/autoconf.c:1.266	Mon May 10 23:53:44 2021
+++ src/sys/arch/sparc/sparc/autoconf.c	Sat Jul 31 10:07:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.266 2021/05/10 23:53:44 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.266 2021/05/10 23:53:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1114,7 +1114,7 @@ mainbus_attach(device_t parent, device_t
 		const char *const dev;
 #define BS_EARLY	1	/* attach device early */
 #define	BS_IGNORE	2	/* ignore root device */
-#define	BS_OPTIONAL	4	/* device not alwas present */
+#define	BS_OPTIONAL	4	/* device not always present */
 		unsigned int flags;
 	};
 



CVS commit: src/sys/arch/sparc/sparc

2021-07-31 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Jul 31 10:07:23 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
fix typos in comments


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc

2021-05-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 29 02:58:38 UTC 2021

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

Log Message:
report to the scheduler if we have different speed cpus.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/arch/sparc/sparc/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/sparc/sparc

2021-05-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat May 29 02:58:38 UTC 2021

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

Log Message:
report to the scheduler if we have different speed cpus.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/arch/sparc/sparc/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/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.259 src/sys/arch/sparc/sparc/cpu.c:1.260
--- src/sys/arch/sparc/sparc/cpu.c:1.259	Sun Jan 24 07:36:54 2021
+++ src/sys/arch/sparc/sparc/cpu.c	Sat May 29 02:58:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.259 2021/01/24 07:36:54 mrg Exp $ */
+/*	$NetBSD: cpu.c,v 1.260 2021/05/29 02:58:37 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.259 2021/01/24 07:36:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.260 2021/05/29 02:58:37 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -520,6 +520,19 @@ cpu_attach(struct cpu_softc *sc, int nod
 	 */
 	if (bootmid == 0)
 		bootmid = mid;
+
+	/*
+	 * Set speeds now we've attached all CPUs.
+	 */
+	if (sparc_ncpus > 1 && sparc_ncpus == cpu_attach_count) {
+		CPU_INFO_ITERATOR n;
+		unsigned best_hz = 0;
+
+		for (CPU_INFO_FOREACH(n, cpi))
+			best_hz = MAX(cpi->hz, best_hz);
+		for (CPU_INFO_FOREACH(n, cpi))
+			cpu_topology_setspeed(cpi, cpi->hz < best_hz);
+	}
 }
 
 /*



CVS commit: src/sys/arch/sparc/sparc

2021-04-25 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Apr 25 21:59:38 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
fix a comment to match the code.


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.279 src/sys/arch/sparc/sparc/locore.s:1.280
--- src/sys/arch/sparc/sparc/locore.s:1.279	Sun Jan 24 07:36:54 2021
+++ src/sys/arch/sparc/sparc/locore.s	Sun Apr 25 21:59:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.279 2021/01/24 07:36:54 mrg Exp $	*/
+/*	$NetBSD: locore.s,v 1.280 2021/04/25 21:59:38 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -2662,7 +2662,7 @@ sparc_interrupt4m_bogus:
 	bnz,a	1f			!	splhigh();
 	 or	%l0, 0xf00, %l0		! } else
 
-	call	_C_LABEL(bogusintr)	!	strayintr()
+	call	_C_LABEL(bogusintr)	!	bogusintr()
 	 add	%sp, CCFSZ, %o0
 	/* all done: restore registers and go return */
 1:



CVS commit: src/sys/arch/sparc/sparc

2021-04-25 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Apr 25 21:59:38 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
fix a comment to match the code.


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/sys/arch/sparc/sparc/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/sparc/sparc

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 16:10:08 UTC 2021

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

Log Message:
The location arg of db_disasm() is a db_addr_t, not a vaddr_t.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sparc/sparc/db_disasm.c

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



CVS commit: src/sys/arch/sparc/sparc

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 16:10:08 UTC 2021

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

Log Message:
The location arg of db_disasm() is a db_addr_t, not a vaddr_t.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sparc/sparc/db_disasm.c

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

Modified files:

Index: src/sys/arch/sparc/sparc/db_disasm.c
diff -u src/sys/arch/sparc/sparc/db_disasm.c:1.22 src/sys/arch/sparc/sparc/db_disasm.c:1.23
--- src/sys/arch/sparc/sparc/db_disasm.c:1.22	Wed Jan 11 12:14:32 2017
+++ src/sys/arch/sparc/sparc/db_disasm.c	Tue Apr  6 16:10:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.22 2017/01/11 12:14:32 joerg Exp $ */
+/*	$NetBSD: db_disasm.c,v 1.23 2021/04/06 16:10:08 simonb Exp $ */
 
 /*
  * Copyright (c) 1994 David S. Miller, da...@nadzieja.rutgers.edu
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.22 2017/01/11 12:14:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.23 2021/04/06 16:10:08 simonb Exp $");
 
 #include 
 #include 
@@ -876,7 +876,7 @@ struct sparc_insn sparc_i[] = {
 };
 
 db_addr_t
-db_disasm(vaddr_t loc, bool altfmt)
+db_disasm(db_addr_t loc, bool altfmt)
 {
 	struct sparc_insn*	i_ptr = (struct sparc_insn *)_i;
 



CVS commit: src/sys/arch/sparc/sparc

2021-02-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 27 18:10:46 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: openfirm.c

Log Message:
sun4v: add 32/64 bit workaround for the OF_read() call, similar to the one 
introduced in revision 1.21


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sparc/sparc/openfirm.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/sparc/sparc/openfirm.c
diff -u src/sys/arch/sparc/sparc/openfirm.c:1.23 src/sys/arch/sparc/sparc/openfirm.c:1.24
--- src/sys/arch/sparc/sparc/openfirm.c:1.23	Sun Mar 26 12:38:24 2017
+++ src/sys/arch/sparc/sparc/openfirm.c	Sat Feb 27 18:10:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $	*/
+/*	$NetBSD: openfirm.c,v 1.24 2021/02/27 18:10:46 palle Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.24 2021/02/27 18:10:46 palle Exp $");
 
 #include 
 #include 
@@ -503,6 +503,15 @@ OF_read(int handle, void *addr, int len)
 	} args;
 	int l, act = 0;
 
+#ifdef SUN4V
+#if __arch64__
+	void *oaddr = addr;
+	__cpu_simple_lock(_lock);
+	if (len > OFBOUNCE_MAXSIZE) 
+		panic("OF_read(len = %d) exceedes bounce buffer\n", len);
+	addr = ofbounce;
+#endif	
+#endif
 	args.name = ADR2CELL("read");
 	args.nargs = 3;
 	args.nreturns = 1;
@@ -511,18 +520,31 @@ OF_read(int handle, void *addr, int len)
 	for (; len > 0; len -= l) {
 		l = MIN(NBPG, len);
 		args.len = l;
-		if (openfirmware() == -1)
-			return -1;
+		if (openfirmware() == -1) {
+			act = -1;
+			goto OF_read_exit;
+		}
 		if (args.actual > 0) {
 			act += args.actual;
 		}
 		if (args.actual < l) {
 			if (act)
-return act;
-			else
-return args.actual;
+goto OF_read_exit;
+			else {
+act = args.actual;	
+goto OF_read_exit;
+			}
 		}
 	}
+OF_read_exit:
+#ifdef SUN4V
+#if __arch64__
+	if (act > 0) {
+		memcpy(oaddr, addr, act);	
+	}
+	__cpu_simple_unlock(_lock);
+#endif
+#endif
 	return act;
 }
 



CVS commit: src/sys/arch/sparc/sparc

2021-02-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 27 18:10:46 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: openfirm.c

Log Message:
sun4v: add 32/64 bit workaround for the OF_read() call, similar to the one 
introduced in revision 1.21


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

2021-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 17 01:54:37 UTC 2021

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

Log Message:
convert most uses of pmapdebug to use the new DPRINTF() macro.

add PMAP_INITLOUD debug option, that shows how pmap_bootstrap()
eats up the space provided by /boot as spare space.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.371 src/sys/arch/sparc/sparc/pmap.c:1.372
--- src/sys/arch/sparc/sparc/pmap.c:1.371	Wed Jan 13 16:42:17 2021
+++ src/sys/arch/sparc/sparc/pmap.c	Sun Jan 17 01:54:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $ */
+/*	$NetBSD: pmap.c,v 1.372 2021/01/17 01:54:37 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.372 2021/01/17 01:54:37 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -155,6 +155,7 @@ EVCNT_ATTACH_STATIC(mmu_pagein_evcnt);
 #define	PDB_CHANGEPROT	0x0008
 #define	PDB_ENTER	0x0010
 #define	PDB_FOLLOW	0x0020
+#define	PDB_INITLOUD	0x0040
 
 #define	PDB_MMU_ALLOC	0x0100
 #define	PDB_MMU_STEAL	0x0200
@@ -166,6 +167,12 @@ EVCNT_ATTACH_STATIC(mmu_pagein_evcnt);
 #define	PDB_SWITCHMAP	0x8000
 #define	PDB_SANITYCHK	0x1
 int	pmapdebug = 0;
+#define DPRINTF(level, fmt, ...) do { \
+	if (pmapdebug & (level)) \
+		printf("%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); \
+} while (0)
+#else
+#define DPRINTF(level, fmt, ...) /* nothing */
 #endif
 
 /*
@@ -1619,8 +1626,8 @@ me_alloc(struct mmuentry *mh, struct pma
 #ifdef DEBUG
 		if (me->me_pmap != NULL)
 			panic("me_alloc: freelist entry has pmap");
-		if (pmapdebug & PDB_MMU_ALLOC)
-			printf("me_alloc: got pmeg %d\n", me->me_cookie);
+		DPRINTF(PDB_MMU_ALLOC,
+		"me_alloc: got pmeg %d", me->me_cookie);
 #endif
 		mmuq_insert_tail(mh, me);
 
@@ -1651,11 +1658,8 @@ me_alloc(struct mmuentry *mh, struct pma
 
 	me = mmuq_first(_lru);
 	pm = me->me_pmap;
-#ifdef DEBUG
-	if (pmapdebug & (PDB_MMU_ALLOC | PDB_MMU_STEAL))
-		printf("me_alloc: stealing pmeg 0x%x from pmap %p\n",
-		me->me_cookie, pm);
-#endif
+	DPRINTF(PDB_MMU_ALLOC | PDB_MMU_STEAL,
+	"me_alloc: stealing pmeg 0x%x from pmap %p", me->me_cookie, pm);
 
 	mmu_stolenpmegs_evcnt.ev_count++;
 
@@ -1801,9 +1805,8 @@ me_free(struct pmap *pm, u_int pmeg)
 
 #ifdef DEBUG
 	rp = >pm_regmap[me->me_vreg];
-	if (pmapdebug & PDB_MMU_ALLOC)
-		printf("me_free: freeing pmeg %d from pmap %p\n",
-		me->me_cookie, pm);
+	DPRINTF(PDB_MMU_ALLOC,
+	   "me_free: freeing pmeg %d from pmap %p", me->me_cookie, pm);
 	if (me->me_cookie != pmeg)
 		panic("me_free: wrong mmuentry");
 	if (pm != me->me_pmap)
@@ -1869,8 +1872,8 @@ region_alloc(struct mmuentry *mh, struct
 #ifdef DEBUG
 		if (me->me_pmap != NULL)
 			panic("region_alloc: freelist entry has pmap");
-		if (pmapdebug & PDB_MMUREG_ALLOC)
-			printf("region_alloc: got smeg 0x%x\n", me->me_cookie);
+		DPRINTF(PDB_MMUREG_ALLOC,
+		"region_alloc: got smeg 0x%x", me->me_cookie);
 #endif
 		mmuq_insert_tail(mh, me);
 
@@ -1895,11 +1898,10 @@ region_alloc(struct mmuentry *mh, struct
 		panic("region_alloc: LRU entry has no pmap");
 	if (pm == pmap_kernel())
 		panic("region_alloc: stealing from kernel");
-#ifdef DEBUG
-	if (pmapdebug & (PDB_MMUREG_ALLOC | PDB_MMUREG_STEAL))
-		printf("region_alloc: stealing smeg 0x%x from pmap %p\n",
-		me->me_cookie, pm);
-#endif
+	DPRINTF(PDB_MMUREG_ALLOC | PDB_MMUREG_STEAL,
+	"region_alloc: stealing smeg 0x%x from pmap %p",
+	me->me_cookie, pm);
+
 	/*
 	 * Remove from LRU list, and insert at end of new list
 	 * (probably the LRU list again, but so what?).
@@ -1946,10 +1948,9 @@ region_free(struct pmap *pm, u_int smeg)
 {
 	struct mmuentry *me = [smeg];
 
+	DPRINTF(PDB_MMUREG_ALLOC,
+	"region_free: freeing smeg 0x%x from pmap %p", me->me_cookie, pm);
 #ifdef DEBUG
-	if (pmapdebug & PDB_MMUREG_ALLOC)
-		printf("region_free: freeing smeg 0x%x from pmap %p\n",
-		me->me_cookie, pm);
 	if (me->me_cookie != smeg)
 		panic("region_free: wrong mmuentry");
 	if (pm != me->me_pmap)
@@ -2145,9 +2146,10 @@ ctx_alloc(struct pmap *pm)
 #ifdef DEBUG
 	if (pm->pm_ctx)
 		panic("ctx_alloc pm_ctx");
-	if (pmapdebug & PDB_CTX_ALLOC)
-		printf("ctx_alloc[%d](%p)\n", cpu_number(), pm);
 #endif
+	DPRINTF(PDB_CTX_ALLOC,
+	"ctx_alloc[%d](%p)", cpu_number(), pm);
+
 	if (CPU_HAS_SUNMMU) {
 		gap_start = pm->pm_gap_start;
 		gap_end = pm->pm_gap_end;
@@ -2169,10 +2171,11 @@ ctx_alloc(struct pmap *pm)
 #ifdef DEBUG
 		if (c->c_pmap == NULL)
 			panic("ctx_alloc cu_pmap");
-		if (pmapdebug & (PDB_CTX_ALLOC | PDB_CTX_STEAL))
-			printf("ctx_alloc[%d]: steal context %d from %p\n",
-			  

CVS commit: src/sys/arch/sparc/sparc

2021-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 17 01:54:37 UTC 2021

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

Log Message:
convert most uses of pmapdebug to use the new DPRINTF() macro.

add PMAP_INITLOUD debug option, that shows how pmap_bootstrap()
eats up the space provided by /boot as spare space.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/arch/sparc/sparc/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/sparc/sparc

2021-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 17 01:04:58 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
note that find_cpus() also sets cpu_arch.


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.262 src/sys/arch/sparc/sparc/autoconf.c:1.263
--- src/sys/arch/sparc/sparc/autoconf.c:1.262	Sun Jan 17 01:02:28 2021
+++ src/sys/arch/sparc/sparc/autoconf.c	Sun Jan 17 01:04:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.262 2021/01/17 01:02:28 mrg Exp $ */
+/*	$NetBSD: autoconf.c,v 1.263 2021/01/17 01:04:58 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.262 2021/01/17 01:02:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.263 2021/01/17 01:04:58 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -198,6 +198,8 @@ set_machine_model(bool late)
 /*
  * Get the number of CPUs in the system and the CPUs' SPARC architecture
  * version. We need this information early in the boot process.
+ *
+ * This also sets cpu_arch to 8 on sun4m and sun4d.
  */
 static int
 find_cpus(void)



CVS commit: src/sys/arch/sparc/sparc

2021-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 17 01:04:58 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
note that find_cpus() also sets cpu_arch.


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc

2021-01-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Jan 13 16:42:17 UTC 2021

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

Log Message:
in pmap_writetext(), restore the context also when we return early.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.370 src/sys/arch/sparc/sparc/pmap.c:1.371
--- src/sys/arch/sparc/sparc/pmap.c:1.370	Mon Jan 11 06:12:43 2021
+++ src/sys/arch/sparc/sparc/pmap.c	Wed Jan 13 16:42:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $ */
+/*	$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2021/01/13 16:42:17 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -7868,8 +7868,7 @@ pmap_writetext(unsigned char *dst, int c
 	if (CPU_HAS_SRMMU) {
 		pte0 = getpte4m(va);
 		if ((pte0 & SRMMU_TETYPE) != SRMMU_TEPTE) {
-			splx(s);
-			return;
+			goto out;
 		}
 		pte = pte0 | PPROT_WRITE;
 		setpte4m(va, pte);
@@ -7882,8 +7881,7 @@ pmap_writetext(unsigned char *dst, int c
 	if (CPU_ISSUN4C || CPU_ISSUN4) {
 		pte0 = getpte4(va);
 		if ((pte0 & PG_V) == 0) {
-			splx(s);
-			return;
+			goto out;
 		}
 		pte = pte0 | PG_W;
 		setpte4(va, pte);
@@ -7892,6 +7890,8 @@ pmap_writetext(unsigned char *dst, int c
 	}
 #endif
 	cache_flush(dst, 1);
+
+out:
 	setcontext(ctx);
 	splx(s);
 }



CVS commit: src/sys/arch/sparc/sparc

2021-01-13 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Jan 13 16:42:17 UTC 2021

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

Log Message:
in pmap_writetext(), restore the context also when we return early.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 src/sys/arch/sparc/sparc/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/sparc/sparc

2021-01-10 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jan 11 06:12:43 UTC 2021

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

Log Message:
in pgt_page_alloc(), wait and retry the page allocation if PR_WAITOK.
fixes PR 55895.


To generate a diff of this commit:
cvs rdiff -u -r1.369 -r1.370 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.369 src/sys/arch/sparc/sparc/pmap.c:1.370
--- src/sys/arch/sparc/sparc/pmap.c:1.369	Wed Dec  9 11:35:44 2020
+++ src/sys/arch/sparc/sparc/pmap.c	Mon Jan 11 06:12:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $ */
+/*	$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.370 2021/01/11 06:12:43 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -907,13 +907,20 @@ pgt_page_alloc(struct pool *pp, int flag
 	paddr_t pa;
 
 	/* Allocate a page of physical memory */
-	if ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL)
-		return (NULL);
+	while ((pg = uvm_pagealloc(NULL, 0, NULL, 0)) == NULL &&
+	   (flags & PR_WAITOK) != 0) {
+		uvm_wait("pgtpg");
+	}
+	if (pg == NULL) {
+		KASSERT((flags & PR_WAITOK) == 0);
+		return NULL;
+	}
 
 	/* Allocate virtual memory */
 	va = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY |
 		((flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT | UVM_KMF_TRYLOCK));
 	if (va == 0) {
+		KASSERT((flags & PR_WAITOK) == 0);
 		uvm_pagefree(pg);
 		return (NULL);
 	}



CVS commit: src/sys/arch/sparc/sparc

2021-01-10 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jan 11 06:12:43 UTC 2021

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

Log Message:
in pgt_page_alloc(), wait and retry the page allocation if PR_WAITOK.
fixes PR 55895.


To generate a diff of this commit:
cvs rdiff -u -r1.369 -r1.370 src/sys/arch/sparc/sparc/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/sparc/sparc

2020-12-09 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  9 11:35:44 UTC 2020

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

Log Message:
Add "memory" constraint on wrpsr, lost in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.368 -r1.369 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.368 src/sys/arch/sparc/sparc/pmap.c:1.369
--- src/sys/arch/sparc/sparc/pmap.c:1.368	Wed Dec  9 04:02:20 2020
+++ src/sys/arch/sparc/sparc/pmap.c	Wed Dec  9 11:35:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.368 2020/12/09 04:02:20 uwe Exp $ */
+/*	$NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.368 2020/12/09 04:02:20 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.369 2020/12/09 11:35:44 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -653,7 +653,8 @@ sp_tlb_flush(int va, int ctx, int lvl)
 	 * XXX: Add to asm.h?  We can use this in cache.c too.
 	 */
 	opsr = getpsr();	/* KDASSERT(opsr & PSR_ET); */
-	__asm volatile ("wr %0, %1, %%psr" :: "r"(opsr), "n"(PSR_ET));
+	__asm volatile ("wr %0, %1, %%psr"
+			:: "r"(opsr), "n"(PSR_ET) : "memory");
 	__asm volatile ("nop; nop;nop");
 
 	octx = getcontext4m();	/* save context */



CVS commit: src/sys/arch/sparc/sparc

2020-12-09 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  9 11:35:44 UTC 2020

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

Log Message:
Add "memory" constraint on wrpsr, lost in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.368 -r1.369 src/sys/arch/sparc/sparc/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/sparc/sparc

2020-12-08 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  9 04:02:20 UTC 2020

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

Log Message:
sp_tlb_flush() - fix inline asm miscompiled by newer gcc versions.

As one national park director once said: "my problems start when the
dumber of my visitors meet the smarter of my bears".

Old inline asm used specific hardcoded registers "assuming that gcc
doesn't do anything funny with these".  Unfortunately now it does,
especially when this function is inlined.  We ended up restoring a
wrong context.  The result was mysterious infinite memory faults.

Rewrite in safer inline asm, so that gcc is not confused.

Many thanks to chs@ for his patience.


To generate a diff of this commit:
cvs rdiff -u -r1.367 -r1.368 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.367 src/sys/arch/sparc/sparc/pmap.c:1.368
--- src/sys/arch/sparc/sparc/pmap.c:1.367	Sat Mar 14 14:05:43 2020
+++ src/sys/arch/sparc/sparc/pmap.c	Wed Dec  9 04:02:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.367 2020/03/14 14:05:43 ad Exp $ */
+/*	$NetBSD: pmap.c,v 1.368 2020/12/09 04:02:20 uwe Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.367 2020/03/14 14:05:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.368 2020/12/09 04:02:20 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -631,42 +631,39 @@ void 		(*pmap_rmu_p)(struct pmap *, vadd
 /*
  * SP versions of the tlb flush operations.
  *
- * Turn off traps to prevent register window overflows
- * from writing user windows to the wrong stack.
+ * Turn off traps to prevent register window overflows from writing
+ * user windows to the wrong stack.  Cf. tlb_flush_page_real() 
  */
 static void
 sp_tlb_flush(int va, int ctx, int lvl)
 {
-	/*
-	 * XXX convert %o3 (oldpsr), %o4 (SRMMU_CXR) and %o5 (old context)
-	 * into generically named registers.  right now we're assuming that
-	 * gcc doesn't do anything funny with these registers.
-	 */
-
-	/* Traps off */
-	__asm("rd	%psr, %o3");
-	__asm("wr	%%o3, %0, %%psr" :: "n" (PSR_ET));
+	int opsr, octx;
 
-	/* Save context */
-	__asm("mov	%0, %%o4" :: "n"(SRMMU_CXR));
-	__asm("lda	[%%o4]%0, %%o5" :: "n"(ASI_SRMMU));
-
-	/* Set new context and flush type bits */
 	va &= ~0xfff;
-	__asm("sta	%1, [%%o4]%0" :: "n"(ASI_SRMMU), "r"(ctx));
 	va |= lvl;
 
-	/* Do the TLB flush */
-	__asm("sta	%%g0, [%1]%0" :: "n"(ASI_SRMMUFP), "r"(va));
+	/*
+	 * Turn off traps.
+	 *
+	 * Like setpsr((opsr = getpsr()) & ~PSR_ET); but we can shave
+	 * off one instruction b/c we never disable traps recursively,
+	 * so we can use the xor done by wrpsr itself to clear the
+	 * bit.
+	 *
+	 * XXX: Add to asm.h?  We can use this in cache.c too.
+	 */
+	opsr = getpsr();	/* KDASSERT(opsr & PSR_ET); */
+	__asm volatile ("wr %0, %1, %%psr" :: "r"(opsr), "n"(PSR_ET));
+	__asm volatile ("nop; nop;nop");
+
+	octx = getcontext4m();	/* save context */
 
-	/* Restore context */
-	__asm("sta	%%o5, [%%o4]%0" :: "n"(ASI_SRMMU));
+	/* Do the TLB flush in "ctx" */
+	setcontext4m(ctx);
+	__asm volatile("sta %%g0, [%0]%1" :: "r"(va), "n"(ASI_SRMMUFP));
 
-	/* and turn traps on again */
-	__asm("wr	%o3, 0, %psr");
-	__asm("nop");
-	__asm("nop");
-	__asm("nop");
+	setcontext4m(octx);	/* restore context */
+	setpsr(opsr);		/* turn traps on again */
 }
 
 static inline void



CVS commit: src/sys/arch/sparc/sparc

2020-12-08 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec  9 04:02:20 UTC 2020

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

Log Message:
sp_tlb_flush() - fix inline asm miscompiled by newer gcc versions.

As one national park director once said: "my problems start when the
dumber of my visitors meet the smarter of my bears".

Old inline asm used specific hardcoded registers "assuming that gcc
doesn't do anything funny with these".  Unfortunately now it does,
especially when this function is inlined.  We ended up restoring a
wrong context.  The result was mysterious infinite memory faults.

Rewrite in safer inline asm, so that gcc is not confused.

Many thanks to chs@ for his patience.


To generate a diff of this commit:
cvs rdiff -u -r1.367 -r1.368 src/sys/arch/sparc/sparc/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/sparc/sparc

2020-12-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Dec  5 08:04:51 UTC 2020

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

Log Message:
for boot -1, don't attach more than the boot CPU most others


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/sys/arch/sparc/sparc/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/sparc/sparc

2020-12-05 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Dec  5 08:04:51 UTC 2020

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

Log Message:
for boot -1, don't attach more than the boot CPU most others


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/sys/arch/sparc/sparc/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/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.256 src/sys/arch/sparc/sparc/cpu.c:1.257
--- src/sys/arch/sparc/sparc/cpu.c:1.256	Sat Jun 13 20:01:27 2020
+++ src/sys/arch/sparc/sparc/cpu.c	Sat Dec  5 08:04:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.256 2020/06/13 20:01:27 ad Exp $ */
+/*	$NetBSD: cpu.c,v 1.257 2020/12/05 08:04:51 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.256 2020/06/13 20:01:27 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.257 2020/12/05 08:04:51 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.25
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -486,6 +487,11 @@ cpu_attach(struct cpu_softc *sc, int nod
 
 #if defined(MULTIPROCESSOR)
 	if (cpu_attach_count > 1) {
+		if ((boothowto & RB_MD1) != 0) {
+			aprint_naive("\n");
+			aprint_normal(": multiprocessor boot disabled\n");
+			return;
+		}
 		cpu_attach_non_boot(sc, cpi, node);
 		cpu_init_evcnt(cpi);
 		cpu_setup_sysctl(sc);



CVS commit: src/sys/arch/sparc/sparc

2020-08-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 14 13:45:44 UTC 2020

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

Log Message:
PR port-sparc/55573: remove kernel message about disabled coprocessor
instructions - it is triggered by userland trying to detect availability
of sparcv9 VIS instructions.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/arch/sparc/sparc/trap.c

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

Modified files:

Index: src/sys/arch/sparc/sparc/trap.c
diff -u src/sys/arch/sparc/sparc/trap.c:1.198 src/sys/arch/sparc/sparc/trap.c:1.199
--- src/sys/arch/sparc/sparc/trap.c:1.198	Sat Apr  6 03:06:27 2019
+++ src/sys/arch/sparc/sparc/trap.c	Fri Aug 14 13:45:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.198 2019/04/06 03:06:27 thorpej Exp $ */
+/*	$NetBSD: trap.c,v 1.199 2020/08/14 13:45:44 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.198 2019/04/06 03:06:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.199 2020/08/14 13:45:44 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_sunos.h"
@@ -606,7 +606,6 @@ trap(unsigned type, int psr, int pc, str
 		break;
 
 	case T_CPDISABLED:
-		uprintf("coprocessor instruction\n");	/* XXX */
 		sig = SIGILL;
 		KSI_INIT_TRAP();
 		ksi.ksi_trap = type;



CVS commit: src/sys/arch/sparc/sparc

2020-08-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 14 13:45:44 UTC 2020

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

Log Message:
PR port-sparc/55573: remove kernel message about disabled coprocessor
instructions - it is triggered by userland trying to detect availability
of sparcv9 VIS instructions.


To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/sys/arch/sparc/sparc/trap.c

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



CVS commit: src/sys/arch/sparc/sparc

2020-08-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 14 10:34:22 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Adapt to new proplib api


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.260 src/sys/arch/sparc/sparc/autoconf.c:1.261
--- src/sys/arch/sparc/sparc/autoconf.c:1.260	Mon Jun  8 02:27:08 2020
+++ src/sys/arch/sparc/sparc/autoconf.c	Fri Aug 14 10:34:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.260 2020/06/08 02:27:08 mrg Exp $ */
+/*	$NetBSD: autoconf.c,v 1.261 2020/08/14 10:34:22 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.260 2020/06/08 02:27:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.261 2020/08/14 10:34:22 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1636,7 +1636,7 @@ set_network_props(device_t dev, void *au
 
 	prom_getether(ofnode, eaddr);
 	dict = device_properties(dev);
-	blob = prop_data_create_data(eaddr, ETHER_ADDR_LEN);
+	blob = prop_data_create_copy(eaddr, ETHER_ADDR_LEN);
 	prop_dictionary_set(dict, "mac-address", blob);
 	prop_object_release(blob);
 }



CVS commit: src/sys/arch/sparc/sparc

2020-08-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 14 10:34:22 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Adapt to new proplib api


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc

2020-06-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jun  8 02:27:08 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
make find_cpus() static.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc

2020-06-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jun  8 02:27:08 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
make find_cpus() static.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.259 src/sys/arch/sparc/sparc/autoconf.c:1.260
--- src/sys/arch/sparc/sparc/autoconf.c:1.259	Sun Oct  4 08:15:46 2015
+++ src/sys/arch/sparc/sparc/autoconf.c	Mon Jun  8 02:27:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.259 2015/10/04 08:15:46 joerg Exp $ */
+/*	$NetBSD: autoconf.c,v 1.260 2020/06/08 02:27:08 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.259 2015/10/04 08:15:46 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.260 2020/06/08 02:27:08 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -144,7 +144,7 @@ static	void bootpath_build(void);
 static	void bootpath_fake(struct bootpath *, const char *);
 static	void bootpath_print(struct bootpath *);
 static	struct bootpath	*bootpath_store(int, struct bootpath *);
-int	find_cpus(void);
+static	int find_cpus(void);
 char	machine_model[100];
 
 #ifdef DEBUG
@@ -172,7 +172,7 @@ matchbyname(device_t parent, cfdata_t cf
  * Get the number of CPUs in the system and the CPUs' SPARC architecture
  * version. We need this information early in the boot process.
  */
-int
+static int
 find_cpus(void)
 {
 	int n;



CVS commit: src/sys/arch/sparc/sparc

2020-05-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 11 18:38:27 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: process_machdep.c

Log Message:
Reject setting unaligned Program Counter

Patch taken from OpenBSD.

Tested in qemu.

Fixes PR port-sparc/54734 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/sparc/process_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/sparc/sparc/process_machdep.c
diff -u src/sys/arch/sparc/sparc/process_machdep.c:1.19 src/sys/arch/sparc/sparc/process_machdep.c:1.20
--- src/sys/arch/sparc/sparc/process_machdep.c:1.19	Fri Dec 30 17:54:43 2016
+++ src/sys/arch/sparc/sparc/process_machdep.c	Mon May 11 18:38:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $ */
+/*	$NetBSD: process_machdep.c,v 1.20 2020/05/11 18:38:26 kamil Exp $ */
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.19 2016/12/30 17:54:43 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.20 2020/05/11 18:38:26 kamil Exp $");
 
 #include 
 #include 
@@ -122,6 +122,9 @@ process_write_regs(struct lwp *l, const 
 {
 	int	psr = l->l_md.md_tf->tf_psr & ~PSR_ICC;
 
+	if (((regs->r_pc | regs->r_npc) & 0x03) != 0)
+		return EINVAL;
+
 	memcpy(l->l_md.md_tf, regs, sizeof(*regs));
 	l->l_md.md_tf->tf_psr = psr | (regs->r_psr & PSR_ICC);
 	return 0;
@@ -140,6 +143,9 @@ int
 process_set_pc(struct lwp *l, void *addr)
 {
 
+	if (((u_int)addr & 0x03) != 0)
+		return EINVAL;
+
 	l->l_md.md_tf->tf_pc = (u_int)addr;
 	l->l_md.md_tf->tf_npc = (u_int)addr + 4;
 	return 0;



CVS commit: src/sys/arch/sparc/sparc

2020-05-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 11 18:38:27 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: process_machdep.c

Log Message:
Reject setting unaligned Program Counter

Patch taken from OpenBSD.

Tested in qemu.

Fixes PR port-sparc/54734 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/sparc/process_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/sparc/sparc

2020-03-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Mar 22 21:21:07 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
cpu_intr_p(): use cpuinfo (always the same VA) for preemption safety.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/sparc/sparc/intr.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/sparc/sparc

2020-03-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Mar 22 21:21:07 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
cpu_intr_p(): use cpuinfo (always the same VA) for preemption safety.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/arch/sparc/sparc/intr.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/sparc/sparc/intr.c
diff -u src/sys/arch/sparc/sparc/intr.c:1.124 src/sys/arch/sparc/sparc/intr.c:1.125
--- src/sys/arch/sparc/sparc/intr.c:1.124	Sat Mar 14 13:34:43 2020
+++ src/sys/arch/sparc/sparc/intr.c	Sun Mar 22 21:21:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.124 2020/03/14 13:34:43 ad Exp $ */
+/*	$NetBSD: intr.c,v 1.125 2020/03/22 21:21:07 ad Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.124 2020/03/14 13:34:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.125 2020/03/22 21:21:07 ad Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
@@ -889,17 +889,10 @@ intr_biglock_wrapper(void *vp)
 bool
 cpu_intr_p(void)
 {
-	uint64_t ncsw;
-	int idepth;
-	lwp_t *l;
-
-	l = curlwp;
-	do {
-		ncsw = l->l_ncsw;
-		__insn_barrier();
-		idepth = curcpu()->ci_idepth;
-		__insn_barrier();
-	} while (__predict_false(ncsw != l->l_ncsw));
 
-	return idepth != 0;
+	/* 
+	 * cpuinfo is the same VA on every CPU.  Even if preempted it will
+	 * give the correct answer.
+	 */
+	return cpuinfo.ci_idepth != 0;
 }



Re: CVS commit: src/sys/arch/sparc/sparc

2020-03-15 Thread Andrew Doran
On Sun, Mar 15, 2020 at 11:38:03AM +1100, matthew green wrote:
> "Andrew Doran" writes:
> > Module Name:src
> > Committed By:   ad
> > Date:   Sat Mar 14 13:34:44 UTC 2020
> > 
> > Modified Files:
> > src/sys/arch/sparc/sparc: intr.c
> > 
> > Log Message:
> > sparc cpu_intr_p(): try to work around l_cpu not being set early on by
> > using curcpu().
> 
> ah, good idea.  this will involve one fewer deref, curcpu()
> is mapped at a fixed address, so it might even be faster now
> than it used to be.

Oh, hm..  Given that it's a fixed address is there a way the compiler can
screw this up in the face of a kernel preemption (theoretical right now for
sparc*)?  I don't think so..  None of the fanciness is required then.

bool
cpu_intr_p(void)
{

return curcpu()->ci_idepth != 0;
}

Andrew


re: CVS commit: src/sys/arch/sparc/sparc

2020-03-14 Thread matthew green
"Andrew Doran" writes:
> Module Name:  src
> Committed By: ad
> Date: Sat Mar 14 13:34:44 UTC 2020
> 
> Modified Files:
>   src/sys/arch/sparc/sparc: intr.c
> 
> Log Message:
> sparc cpu_intr_p(): try to work around l_cpu not being set early on by
> using curcpu().

ah, good idea.  this will involve one fewer deref, curcpu()
is mapped at a fixed address, so it might even be faster now
than it used to be.


.mrg.


CVS commit: src/sys/arch/sparc/sparc

2020-03-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Mar 14 13:34:44 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
sparc cpu_intr_p(): try to work around l_cpu not being set early on by
using curcpu().


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc/sparc/intr.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/sparc/sparc/intr.c
diff -u src/sys/arch/sparc/sparc/intr.c:1.123 src/sys/arch/sparc/sparc/intr.c:1.124
--- src/sys/arch/sparc/sparc/intr.c:1.123	Tue Dec  3 15:20:59 2019
+++ src/sys/arch/sparc/sparc/intr.c	Sat Mar 14 13:34:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.123 2019/12/03 15:20:59 riastradh Exp $ */
+/*	$NetBSD: intr.c,v 1.124 2020/03/14 13:34:43 ad Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.123 2019/12/03 15:20:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.124 2020/03/14 13:34:43 ad Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
@@ -897,7 +897,7 @@ cpu_intr_p(void)
 	do {
 		ncsw = l->l_ncsw;
 		__insn_barrier();
-		idepth = l->l_cpu->ci_idepth;
+		idepth = curcpu()->ci_idepth;
 		__insn_barrier();
 	} while (__predict_false(ncsw != l->l_ncsw));
 



CVS commit: src/sys/arch/sparc/sparc

2020-03-14 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Mar 14 13:34:44 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
sparc cpu_intr_p(): try to work around l_cpu not being set early on by
using curcpu().


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc/sparc/intr.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/sparc/sparc

2020-01-12 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Jan 12 19:13:55 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
Fix some more places in this file it's assumed cpu_info is smaller than 1kB.


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.276 src/sys/arch/sparc/sparc/locore.s:1.277
--- src/sys/arch/sparc/sparc/locore.s:1.276	Wed Jan  8 20:59:19 2020
+++ src/sys/arch/sparc/sparc/locore.s	Sun Jan 12 19:13:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.276 2020/01/08 20:59:19 skrll Exp $	*/
+/*	$NetBSD: locore.s,v 1.277 2020/01/12 19:13:55 ad Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -2770,14 +2770,16 @@ lev14_softint:
 	addx	%l4, %g0, %l4
 	std	%l4, [%l7 + CPUINFO_LEV14]
 
-	ld	[%l6 + CPUINFO_XMSG_TRAP], %l7
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_TRAP), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_TRAP)], %l7
 #ifdef DIAGNOSTIC
 	tst	%l7
 	bz	sparc_interrupt4m_bogus
 	 nop
 #endif
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG0), %l6
 	jmp	%l7
-	 ld	[%l6 + CPUINFO_XMSG_ARG0], %l3	! prefetch 1st arg
+	 ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG0)], %l3	! prefetch 1st arg
 
 /*
  * Fast flush handlers. xcalled from other CPUs throught soft interrupt 14
@@ -2789,9 +2791,11 @@ lev14_softint:
  */
 _ENTRY(_C_LABEL(ft_tlb_flush))
 	!	<%l3 already fetched for us>	! va
-	ld	[%l6 + CPUINFO_XMSG_ARG2], %l5	! level
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG2), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG2)], %l5	! level
 	andn	%l3, 0xfff, %l3			! %l3 = (va&~0xfff | lvl);
-	ld	[%l6 + CPUINFO_XMSG_ARG1], %l4	! context
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG1), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG1)], %l4	! context
 	or	%l3, %l5, %l3
 
 	mov	SRMMU_CXR, %l7			!
@@ -2805,7 +2809,8 @@ ft_rett:
 	! enter here with %l5 = ctx to restore, %l6 = CPUINFO_VA, %l7 = ctx reg
 	mov	1, %l4!
 	sta	%l5, [%l7]ASI_SRMMU		! restore context
-	st	%l4, [%l6 + CPUINFO_XMSG_CMPLT]	! completed = 1
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_CMPLT), %l6
+	st	%l4, [%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_CMPLT)]	! completed = 1
 
 	mov	%l0, %psr			! return from trap
 	 nop
@@ -2813,21 +2818,24 @@ ft_rett:
 
 _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_page))
 	!	<%l3 already fetched for us>	! va
-	ld	[%l6 + CPUINFO_XMSG_ARG1], %l4	! context
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG1), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG1)], %l4	! context
 
 	mov	SRMMU_CXR, %l7			!
 	lda	[%l7]ASI_SRMMU, %l5		! %l5 = old context
 	sta	%l4, [%l7]ASI_SRMMU		! set new context
 
 	set	4096, %l4			! N = page size
-	ld	[%l6 + CPUINFO_CACHE_LINESZ], %l7
+	sethi	%hi(CPUINFO_VA+CPUINFO_CACHE_LINESZ), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_CACHE_LINESZ)], %l7
 1:
 	sta	%g0, [%l3]ASI_IDCACHELFP	!  flush cache line
 	subcc	%l4, %l7, %l4			!  p += linesz;
 	bgu	1b! while ((N -= linesz) > 0)
 	 add	%l3, %l7, %l3
 
-	ld	[%l6 + CPUINFO_XMSG_ARG0], %l3	! reload va
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG0), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG0)], %l3	! reload va
 	!or	%l3, ASI_SRMMUFP_L3(=0), %l3	! va |= ASI_SRMMUFP_L3
 	sta	%g0, [%l3]ASI_SRMMUFP		! flush TLB
 
@@ -2836,8 +2844,10 @@ _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_pa
 
 _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_segment))
 	!	<%l3 already fetched for us>	! vr
-	ld	[%l6 + CPUINFO_XMSG_ARG1], %l5	! vs
-	ld	[%l6 + CPUINFO_XMSG_ARG2], %l4	! context
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG1), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG1)], %l5	! vs
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG2), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG2)], %l4	! context
 
 	sll	%l3, 24, %l3			! va = VSTOVA(vr,vs)
 	sll	%l5, 18, %l5
@@ -2847,8 +2857,10 @@ _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_se
 	lda	[%l7]ASI_SRMMU, %l5		! %l5 = old context
 	sta	%l4, [%l7]ASI_SRMMU		! set new context
 
-	ld	[%l6 + CPUINFO_CACHE_NLINES], %l4
-	ld	[%l6 + CPUINFO_CACHE_LINESZ], %l7
+	sethi	%hi(CPUINFO_VA+CPUINFO_CACHE_NLINES), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_CACHE_NLINES)], %l4
+	sethi	%hi(CPUINFO_VA+CPUINFO_CACHE_LINESZ), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_CACHE_LINESZ)], %l7
 1:
 	sta	%g0, [%l3]ASI_IDCACHELFS	!  flush cache line
 	deccc	%l4!  p += linesz;
@@ -2860,7 +2872,8 @@ _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_se
 
 _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_region))
 	!	<%l3 already fetched for us>	! vr
-	ld	[%l6 + CPUINFO_XMSG_ARG1], %l4	! context
+	sethi	%hi(CPUINFO_VA+CPUINFO_XMSG_ARG1), %l6
+	ld	[%l6 + %lo(CPUINFO_VA+CPUINFO_XMSG_ARG1)], %l4	! context
 
 	sll	%l3, 24, %l3			! va = VRTOVA(vr)
 
@@ -2868,8 +2881,10 @@ _ENTRY(_C_LABEL(ft_srmmu_vcache_flush_re
 	lda	[%l7]ASI_SRMMU, %l5		! %l5 = old context
 	sta	%l4, [%l7]ASI_SRMMU		! set new context
 
-	ld	[%l6 + CPUINFO_CACHE_NLINES], %l4
-	ld	[%l6 + 

CVS commit: src/sys/arch/sparc/sparc

2020-01-12 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Jan 12 19:13:55 UTC 2020

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
Fix some more places in this file it's assumed cpu_info is smaller than 1kB.


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/sys/arch/sparc/sparc/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/sparc/sparc

2019-06-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jun  7 00:18:26 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
remove code to directly check for NULL savefpstate() calls.
it has not triggered for years now, and if it comes back,
you still get a normal kernel fault.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/sys/arch/sparc/sparc/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/sparc/sparc

2019-06-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jun  7 00:18:26 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
remove code to directly check for NULL savefpstate() calls.
it has not triggered for years now, and if it comes back,
you still get a normal kernel fault.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.273 src/sys/arch/sparc/sparc/locore.s:1.274
--- src/sys/arch/sparc/sparc/locore.s:1.273	Sat Apr  6 03:06:27 2019
+++ src/sys/arch/sparc/sparc/locore.s	Fri Jun  7 00:18:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.273 2019/04/06 03:06:27 thorpej Exp $	*/
+/*	$NetBSD: locore.s,v 1.274 2019/06/07 00:18:26 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -5649,8 +5649,6 @@ ENTRY(ipi_savefpstate)
 
 ENTRY(savefpstate)
 	cmp	%o0, 0
-	bz	Lfp_null_fpstate
-	 nop
 	rd	%psr, %o1		! enable FP before we begin
 	set	PSR_EF, %o2
 	or	%o1, %o2, %o1
@@ -5692,22 +5690,6 @@ Lfp_finish:
 	retl
 	 std	%f30, [%o0 + FS_REGS + (4*30)]
 
-/* Handle NULL fpstate argument for savefpstate */
-Lfp_null_fpstate:
-#ifdef DIAGNOSTIC
-	ld	[%o5 + CPUINFO_CPUNO], %o1
-	sethi	%hi(Lpanic_savefpstate), %o0
-	call	_C_LABEL(panic)
-	 or	%o0, %lo(Lpanic_savefpstate), %o0
-#else
-	sethi	%hi(CPUINFO_VA), %o5
-	ldd	[%o5 + CPUINFO_SAVEFPSTATE_NULL], %o2
-	inccc   %o3
-	addx%o2, 0, %o2
-	retl
-	 std	%o2, [%o5 + CPUINFO_SAVEFPSTATE_NULL]
-#endif
-
 /*
  * Store the (now known nonempty) FP queue.
  * We have to reread the fsr each time in order to get the new QNE bit.



CVS commit: src/sys/arch/sparc/sparc

2019-04-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Apr  6 16:22:01 UTC 2019

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

Log Message:
Fix building crash(8) on sparc after ufetch / ustore changes.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sparc/sparc/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/sparc/sparc/db_trace.c
diff -u src/sys/arch/sparc/sparc/db_trace.c:1.36 src/sys/arch/sparc/sparc/db_trace.c:1.37
--- src/sys/arch/sparc/sparc/db_trace.c:1.36	Sat Apr  6 03:06:27 2019
+++ src/sys/arch/sparc/sparc/db_trace.c	Sat Apr  6 16:22:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.36 2019/04/06 03:06:27 thorpej Exp $ */
+/*	$NetBSD: db_trace.c,v 1.37 2019/04/06 16:22:01 thorpej Exp $ */
 
 /*
  * Mach Operating System
@@ -27,11 +27,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.36 2019/04/06 03:06:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.37 2019/04/06 16:22:01 thorpej Exp $");
 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -51,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v
 #define ONINTSTACK(fr)	(0)
 #endif
 
+#ifdef _KERNEL
 static db_addr_t
 db_fetch_word(const void *uaddr)
 {
@@ -60,6 +62,7 @@ db_fetch_word(const void *uaddr)
 		val = (u_int)-1;
 	return val;
 }
+#endif /* _KERNEL */
 
 void
 db_stack_trace_print(db_expr_t addr, bool have_addr,



CVS commit: src/sys/arch/sparc/sparc

2019-04-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Apr  6 16:22:01 UTC 2019

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

Log Message:
Fix building crash(8) on sparc after ufetch / ustore changes.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sparc/sparc/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/sparc/sparc

2019-03-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  2 14:21:19 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: pci_fixup.c

Log Message:
Catch up with MI pci changes.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/sparc/pci_fixup.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/sparc/sparc/pci_fixup.c
diff -u src/sys/arch/sparc/sparc/pci_fixup.c:1.2 src/sys/arch/sparc/sparc/pci_fixup.c:1.3
--- src/sys/arch/sparc/sparc/pci_fixup.c:1.2	Fri Mar  1 04:25:59 2019
+++ src/sys/arch/sparc/sparc/pci_fixup.c	Sat Mar  2 09:21:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_fixup.c,v 1.2 2019/03/01 09:25:59 msaitoh Exp $	*/
+/*	$NetBSD: pci_fixup.c,v 1.3 2019/03/02 14:21:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -323,8 +323,8 @@ mspcic_pci_fixup(int depth, pcitag_t sta
 
 	/* Secondary bus = startbus, subordinate bus = 0xff */
 	pci_conf_write(NULL, starttag, PCI_BRIDGE_BUS_REG,
-	((startbus & 0xff) << PCI_BRIDGE_BUS_SECONDARY_SHIFT) |
-	(0xff << PCI_BRIDGE_BUS_SUBORDINATE_SHIFT));
+	__SHIFTIN(startbus & 0xff,  PCI_BRIDGE_BUS_SECONDARY) |
+	__SHIFTIN(0xff, PCI_BRIDGE_BUS_SUBORDINATE));
 
 	/*
 	 * Fix up bus numbering, bus addresses, device addresses,
@@ -441,8 +441,8 @@ mspcic_pci_fixup(int depth, pcitag_t sta
 
 	/* Secondary bus = startbus, subordinate bus = maxbus */
 	pci_conf_write(NULL, starttag, PCI_BRIDGE_BUS_REG,
-	((startbus & 0xff) << PCI_BRIDGE_BUS_SECONDARY_SHIFT) |
-	((*maxbus & 0xff) << PCI_BRIDGE_BUS_SUBORDINATE_SHIFT));
+	__SHIFTIN(startbus & 0xff,  PCI_BRIDGE_BUS_SECONDARY) |
+	__SHIFTIN(*maxbus & 0xff, PCI_BRIDGE_BUS_SUBORDINATE));
 
 	/* 16-bit I/O range */
 	val = ((startio & 0xf000) >> 8) | ((*(io) - 1) & 0xf000);



CVS commit: src/sys/arch/sparc/sparc

2019-03-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  2 14:21:19 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: pci_fixup.c

Log Message:
Catch up with MI pci changes.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/sparc/pci_fixup.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/sparc/sparc

2019-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Mar  1 02:33:55 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
since SX can trigger NMIs dump the status and error registers along with
the rest if sx is present.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/sparc/sparc/intr.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/sparc/sparc/intr.c
diff -u src/sys/arch/sparc/sparc/intr.c:1.120 src/sys/arch/sparc/sparc/intr.c:1.121
--- src/sys/arch/sparc/sparc/intr.c:1.120	Mon Feb  4 09:57:39 2019
+++ src/sys/arch/sparc/sparc/intr.c	Fri Mar  1 02:33:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.120 2019/02/04 09:57:39 mrg Exp $ */
+/*	$NetBSD: intr.c,v 1.121 2019/03/01 02:33:55 macallan Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,10 +41,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.120 2019/02/04 09:57:39 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.121 2019/03/01 02:33:55 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
+#include "sx.h"
 
 #include 
 #include 
@@ -70,6 +71,11 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.1
 #include 
 #endif
 
+#if NSX > 0
+#include 
+#include 
+#endif
+
 #if defined(MULTIPROCESSOR)
 static int intr_biglock_wrapper(void *);
 
@@ -255,7 +261,10 @@ nmi_hard(void)
 	si = *((uint32_t *)ICR_SI_PEND);
 	snprintb(bits, sizeof(bits), SINTR_BITS, si);
 	printf("cpu%d: NMI: system interrupts: %s\n", cpu_number(), bits);
-		
+
+#if NSX > 0
+	sx_dump();
+#endif
 
 	if ((si & SINTR_M) != 0) {
 		/* ECC memory error */



CVS commit: src/sys/arch/sparc/sparc

2019-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Mar  1 02:33:55 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
since SX can trigger NMIs dump the status and error registers along with
the rest if sx is present.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/sparc/sparc/intr.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/sparc/sparc

2019-02-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 09:57:39 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
print the cpu number for the mutex not held xcallintr debug message.
add a comment about why this case fires.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/sparc/sparc/intr.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/sparc/sparc/intr.c
diff -u src/sys/arch/sparc/sparc/intr.c:1.119 src/sys/arch/sparc/sparc/intr.c:1.120
--- src/sys/arch/sparc/sparc/intr.c:1.119	Sat Dec  2 00:48:05 2017
+++ src/sys/arch/sparc/sparc/intr.c	Mon Feb  4 09:57:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.119 2017/12/02 00:48:05 macallan Exp $ */
+/*	$NetBSD: intr.c,v 1.120 2019/02/04 09:57:39 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.119 2017/12/02 00:48:05 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.120 2019/02/04 09:57:39 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
@@ -366,10 +366,14 @@ xcallintr(void *v)
 	if (v != xcallintr)
 		cpuinfo.ci_sintrcnt[13].ev_count++;
 
+	/*
+	 * This happens when the remote CPU is slow at responding and the
+	 * caller gave up, and has given up the mutex.
+	 */
 	if (mutex_owned(_mutex) == 0) {
 		cpuinfo.ci_xpmsg_mutex_not_held.ev_count++;
 #ifdef DEBUG
-		printf("%s: mutex not held\n", __func__);
+		printf("%s: cpu%d mutex not held\n", __func__, cpu_number());
 #endif
 		cpuinfo.msg.complete = 1;
 		kpreempt_enable();



CVS commit: src/sys/arch/sparc/sparc

2019-02-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 09:57:39 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: intr.c

Log Message:
print the cpu number for the mutex not held xcallintr debug message.
add a comment about why this case fires.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/sparc/sparc/intr.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/sparc/sparc

2019-02-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 03:32:27 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: machdep.c

Log Message:
- rework mm_md_readwrite() to avoid fallthrough warnings entirely


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/sys/arch/sparc/sparc/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/sparc/sparc/machdep.c
diff -u src/sys/arch/sparc/sparc/machdep.c:1.328 src/sys/arch/sparc/sparc/machdep.c:1.329
--- src/sys/arch/sparc/sparc/machdep.c:1.328	Sat Dec 10 10:41:07 2016
+++ src/sys/arch/sparc/sparc/machdep.c	Mon Feb  4 03:32:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.328 2016/12/10 10:41:07 mrg Exp $ */
+/*	$NetBSD: machdep.c,v 1.329 2019/02/04 03:32:27 mrg Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.328 2016/12/10 10:41:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.329 2019/02/04 03:32:27 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_sunos.h"
@@ -3143,10 +3143,7 @@ mm_md_readwrite(dev_t dev, struct uio *u
 	case DEV_EEPROM:
 		if (cputyp == CPU_SUN4)
 			return eeprom_uio(uio);
-		else
 #endif
-		return ENXIO;
-	default:
-		return ENXIO;
 	}
+	return ENXIO;
 }



CVS commit: src/sys/arch/sparc/sparc

2019-02-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  4 03:32:27 UTC 2019

Modified Files:
src/sys/arch/sparc/sparc: machdep.c

Log Message:
- rework mm_md_readwrite() to avoid fallthrough warnings entirely


To generate a diff of this commit:
cvs rdiff -u -r1.328 -r1.329 src/sys/arch/sparc/sparc/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/sparc/sparc

2019-01-13 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 13 22:11:11 UTC 2019

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

Log Message:
switch sparc pmap lock to the scheme sparc64 uses:

- local IPL_NONE mutex for general pmap locking operations, not
  kernel lock.
- for pmap_activate()/pmap_deactivate(), switch to using the
  existing ctx_lock, and push handling of it into ctx_alloc() the
  ctx_free() callers.

fixes easy to trigger deadlocks on systems with >2 cpus.  without
this patch i usually hang during boot.  with it, i was able to
push the machine hard for over 12 hours.

XXX: pullup-8, and maybe -7.


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.366 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.365 src/sys/arch/sparc/sparc/pmap.c:1.366
--- src/sys/arch/sparc/sparc/pmap.c:1.365	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sparc/sparc/pmap.c	Sun Jan 13 22:11:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.365 2018/09/03 16:29:27 riastradh Exp $ */
+/*	$NetBSD: pmap.c,v 1.366 2019/01/13 22:11:11 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.365 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.366 2019/01/13 22:11:11 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -176,8 +176,8 @@ paddr_t	vm_first_phys = (paddr_t)-1;
 paddr_t	vm_last_phys = 0;
 psize_t vm_num_phys;
 
-#define	PMAP_LOCK()	KERNEL_LOCK(1, NULL)
-#define	PMAP_UNLOCK()	KERNEL_UNLOCK_ONE(NULL)
+#define	PMAP_LOCK()	mutex_enter(_lock)
+#define	PMAP_UNLOCK()	mutex_exit(_lock)
 
 /*
  * Flags in pvlist.pv_flags.  Note that PV_MOD must be 1 and PV_REF must be 2
@@ -347,6 +347,7 @@ mmuq_insert_tail(struct mmuentry *head, 
 int	seginval;		/* [4/4c] the invalid segment number */
 int	reginval;		/* [4/3mmu] the invalid region number */
 
+static kmutex_t pmap_lock;
 static kmutex_t demap_lock;
 static bool	lock_available = false;	/* demap_lock has been initialized */
 
@@ -372,15 +373,15 @@ union ctxinfo {
 	struct	pmap *c_pmap;		/* pmap (if busy) */
 };
 
-static kmutex_t	ctx_lock;		/* lock for below */
+static kmutex_t	ctx_lock;		/* lock for below, and {,de}activate */
 union	ctxinfo *ctxinfo;		/* allocated at in pmap_bootstrap */
 union	ctxinfo *ctx_freelist;		/* context free list */
 int	ctx_kick;			/* allocation rover when none free */
 int	ctx_kickdir;			/* ctx_kick roves both directions */
 int	ncontext;			/* sizeof ctx_freelist */
 
-void	ctx_alloc(struct pmap *);
-void	ctx_free(struct pmap *);
+static void	ctx_alloc(struct pmap *);
+static void	ctx_free(struct pmap *);
 
 /*void *	vdumppages;	-* 32KB worth of reserved dump pages */
 
@@ -2121,7 +2122,7 @@ mmu_pagein(struct pmap *pm, vaddr_t va, 
  * This routine is only ever called from locore.s just after it has
  * saved away the previous process, so there are no active user windows.
  */
-void
+static void
 ctx_alloc(struct pmap *pm)
 {
 	union ctxinfo *c;
@@ -2133,6 +2134,8 @@ ctx_alloc(struct pmap *pm)
 	struct cpu_info *cpi;
 #endif
 
+	KASSERT(mutex_owned(_lock));
+
 /*XXX-GCC!*/gap_start=gap_end=0;
 #ifdef DEBUG
 	if (pm->pm_ctx)
@@ -2145,7 +2148,6 @@ ctx_alloc(struct pmap *pm)
 		gap_end = pm->pm_gap_end;
 	}
 
-	mutex_spin_enter(_lock);
 	if ((c = ctx_freelist) != NULL) {
 		ctx_freelist = c->c_nextfree;
 		cnum = c - ctxinfo;
@@ -2288,13 +2290,12 @@ ctx_alloc(struct pmap *pm)
 		setcontext4m(cnum);
 #endif /* SUN4M || SUN4D */
 	}
-	mutex_spin_exit(_lock);
 }
 
 /*
  * Give away a context.
  */
-void
+static void
 ctx_free(struct pmap *pm)
 {
 	union ctxinfo *c;
@@ -2303,6 +2304,8 @@ ctx_free(struct pmap *pm)
 	struct cpu_info *cpi;
 #endif
 
+	KASSERT(mutex_owned(_lock));
+
 	c = pm->pm_ctx;
 	ctx = pm->pm_ctxnum;
 	pm->pm_ctx = NULL;
@@ -2316,8 +2319,6 @@ ctx_free(struct pmap *pm)
 	}
 #endif /* SUN4 || SUN4C */
 
-	mutex_spin_enter(_lock);
-
 #if defined(SUN4M) || defined(SUN4D)
 	if (CPU_HAS_SRMMU) {
 		CPU_INFO_ITERATOR i;
@@ -2334,7 +2335,6 @@ ctx_free(struct pmap *pm)
 
 	c->c_nextfree = ctx_freelist;
 	ctx_freelist = c;
-	mutex_spin_exit(_lock);
 }
 
 
@@ -3070,6 +3070,7 @@ pmap_bootstrap(int nctx, int nregion, in
 	}
 
 	pmap_page_upload();
+	mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(_lock, MUTEX_DEFAULT, IPL_VM);
 	mutex_init(_lock, MUTEX_DEFAULT, IPL_SCHED);
 	lock_available = true;
@@ -4392,7 +4393,9 @@ pmap_pmap_pool_dtor(void *arg, void *obj
 #endif
 
 	if ((c = pm->pm_ctx) != NULL) {
+		mutex_spin_enter(_lock);
 		ctx_free(pm);
+		mutex_spin_exit(_lock);
 	}
 
 #if defined(SUN4M) || defined(SUN4D)
@@ -4662,7 +4665,7 @@ pmap_remove(struct pmap *pm, vaddr_t va,
 	}
 
 	ctx = getcontext();
-	s = splvm();		/* XXX conservative */
+	s = splvm();
 	PMAP_LOCK();
 	for (; va < endva; va = nva) {
 		/* do one virtual 

CVS commit: src/sys/arch/sparc/sparc

2019-01-13 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 13 22:11:11 UTC 2019

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

Log Message:
switch sparc pmap lock to the scheme sparc64 uses:

- local IPL_NONE mutex for general pmap locking operations, not
  kernel lock.
- for pmap_activate()/pmap_deactivate(), switch to using the
  existing ctx_lock, and push handling of it into ctx_alloc() the
  ctx_free() callers.

fixes easy to trigger deadlocks on systems with >2 cpus.  without
this patch i usually hang during boot.  with it, i was able to
push the machine hard for over 12 hours.

XXX: pullup-8, and maybe -7.


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.366 src/sys/arch/sparc/sparc/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/sparc/sparc

2018-05-31 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May 31 22:44:13 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
convert Lfp_null_fpstate (which is invoked if savefpstate() is called
with NULL) into a panic for DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.270 src/sys/arch/sparc/sparc/locore.s:1.271
--- src/sys/arch/sparc/sparc/locore.s:1.270	Fri Mar 16 09:29:24 2018
+++ src/sys/arch/sparc/sparc/locore.s	Thu May 31 22:44:13 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.270 2018/03/16 09:29:24 mrg Exp $	*/
+/*	$NetBSD: locore.s,v 1.271 2018/05/31 22:44:13 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -5754,24 +5754,20 @@ Lfp_finish:
 	retl
 	 std	%f30, [%o0 + FS_REGS + (4*30)]
 
-/*
- * We really should panic here but while we figure out what the bug is
- * that a remote CPU gets a NULL struct fpstate *, this lets the system
- * work at least seemingly stably.
- */
+/* Handle NULL fpstate argument for savefpstate */
 Lfp_null_fpstate:
-#if 1
+#ifdef DIAGNOSTIC
+	ld	[%o5 + CPUINFO_CPUNO], %o1
+	sethi	%hi(Lpanic_savefpstate), %o0
+	call	_C_LABEL(panic)
+	 or	%o0, %lo(Lpanic_savefpstate), %o0
+#else
 	sethi	%hi(CPUINFO_VA), %o5
 	ldd	[%o5 + CPUINFO_SAVEFPSTATE_NULL], %o2
 	inccc   %o3
 	addx%o2, 0, %o2
 	retl
 	 std	%o2, [%o5 + CPUINFO_SAVEFPSTATE_NULL]
-#else
-	ld	[%o5 + CPUINFO_CPUNO], %o1
-	sethi	%hi(Lpanic_savefpstate), %o0
-	call	_C_LABEL(panic)
-	 or	%o0, %lo(Lpanic_savefpstate), %o0
 #endif
 
 /*



CVS commit: src/sys/arch/sparc/sparc

2018-05-31 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May 31 22:44:13 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
convert Lfp_null_fpstate (which is invoked if savefpstate() is called
with NULL) into a panic for DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/sys/arch/sparc/sparc/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/sparc/sparc

2018-03-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Mar 16 09:29:24 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
remove obsolete ovbcopy().  it may be the very slightly bit
faster for larger copies, but slower for smaller ones.
i don't see any major benefit in keeping this code.

this is the final ovbcopy() reference in src.  you're welcome :-)


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.269 src/sys/arch/sparc/sparc/locore.s:1.270
--- src/sys/arch/sparc/sparc/locore.s:1.269	Sat Nov 25 04:11:37 2017
+++ src/sys/arch/sparc/sparc/locore.s	Fri Mar 16 09:29:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.269 2017/11/25 04:11:37 maya Exp $	*/
+/*	$NetBSD: locore.s,v 1.270 2018/03/16 09:29:24 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -5331,7 +5331,6 @@ ENTRY(qzero)
 
 ENTRY(bcopy)
 	cmp	%o2, BCOPY_SMALL
-Lbcopy_start:
 	bge,a	Lbcopy_fancy	! if >= this many, go be fancy.
 	btst	7, %o0		! (part of being fancy)
 
@@ -5494,164 +5493,6 @@ Lbcopy_done:
 1:
 	retl
 	 stb	%o4,[%o1]
-/*
- * ovbcopy(src, dst, len): like bcopy, but regions may overlap.
- */
-ENTRY(ovbcopy)
-	cmp	%o0, %o1	! src < dst?
-	bgeu	Lbcopy_start	! no, go copy forwards as via bcopy
-	cmp	%o2, BCOPY_SMALL! (check length for doublecopy first)
-
-	/*
-	 * Since src comes before dst, and the regions might overlap,
-	 * we have to do the copy starting at the end and working backwards.
-	 */
-	add	%o2, %o0, %o0	! src += len
-	add	%o2, %o1, %o1	! dst += len
-	bge,a	Lback_fancy	! if len >= BCOPY_SMALL, go be fancy
-	btst	3, %o0
-
-	/*
-	 * Not much to copy, just do it a byte at a time.
-	 */
-	deccc	%o2		! while (--len >= 0)
-	bl	1f
-	 .empty
-0:
-	dec	%o0		!	*--dst = *--src;
-	ldsb	[%o0], %o4
-	dec	%o1
-	deccc	%o2
-	bge	0b
-	stb	%o4, [%o1]
-1:
-	retl
-	nop
-
-	/*
-	 * Plenty to copy, try to be optimal.
-	 * We only bother with word/halfword/byte copies here.
-	 */
-Lback_fancy:
-!	btst	3, %o0		! done already
-	bnz	1f		! if ((src & 3) == 0 &&
-	btst	3, %o1		! (dst & 3) == 0)
-	bz,a	Lback_words	!	goto words;
-	dec	4, %o2		! (done early for word copy)
-
-1:
-	/*
-	 * See if the low bits match.
-	 */
-	xor	%o0, %o1, %o3	! t = src ^ dst;
-	btst	1, %o3
-	bz,a	3f		! if (t & 1) == 0, can do better
-	btst	1, %o0
-
-	/*
-	 * Nope; gotta do byte copy.
-	 */
-2:
-	dec	%o0		! do {
-	ldsb	[%o0], %o4	!	*--dst = *--src;
-	dec	%o1
-	deccc	%o2		! } while (--len != 0);
-	bnz	2b
-	stb	%o4, [%o1]
-	retl
-	nop
-
-3:
-	/*
-	 * Can do halfword or word copy, but might have to copy 1 byte first.
-	 */
-!	btst	1, %o0		! done earlier
-	bz,a	4f		! if (src & 1) {	/* copy 1 byte */
-	btst	2, %o3		! (done early)
-	dec	%o0		!	*--dst = *--src;
-	ldsb	[%o0], %o4
-	dec	%o1
-	stb	%o4, [%o1]
-	dec	%o2		!	len--;
-	btst	2, %o3		! }
-
-4:
-	/*
-	 * See if we can do a word copy ((t&2) == 0).
-	 */
-!	btst	2, %o3		! done earlier
-	bz,a	6f		! if (t & 2) == 0, can do word copy
-	btst	2, %o0		! (src&2, done early)
-
-	/*
-	 * Gotta do halfword copy.
-	 */
-	dec	2, %o2		! len -= 2;
-5:
-	dec	2, %o0		! do {
-	ldsh	[%o0], %o4	!	src -= 2;
-	dec	2, %o1		!	dst -= 2;
-	deccc	2, %o0		!	*(short *)dst = *(short *)src;
-	bge	5b		! } while ((len -= 2) >= 0);
-	sth	%o4, [%o1]
-	b	Lback_mopb	! goto mop_up_byte;
-	btst	1, %o2		! (len&1, done early)
-
-6:
-	/*
-	 * We can do word copies, but we might have to copy
-	 * one halfword first.
-	 */
-!	btst	2, %o0		! done already
-	bz	7f		! if (src & 2) {
-	dec	4, %o2		! (len -= 4, done early)
-	dec	2, %o0		!	src -= 2, dst -= 2;
-	ldsh	[%o0], %o4	!	*(short *)dst = *(short *)src;
-	dec	2, %o1
-	sth	%o4, [%o1]
-	dec	2, %o2		!	len -= 2;
-! }
-
-7:
-Lback_words:
-	/*
-	 * Do word copies (backwards), then mop up trailing halfword
-	 * and byte if any.
-	 */
-!	dec	4, %o2		! len -= 4, done already
-0:! do {
-	dec	4, %o0		!	src -= 4;
-	dec	4, %o1		!	src -= 4;
-	ld	[%o0], %o4	!	*(int *)dst = *(int *)src;
-	deccc	4, %o2		! } while ((len -= 4) >= 0);
-	bge	0b
-	st	%o4, [%o1]
-
-	/*
-	 * Check for trailing shortword.
-	 */
-	btst	2, %o2		! if (len & 2) {
-	bz,a	1f
-	btst	1, %o2		! (len&1, done early)
-	dec	2, %o0		!	src -= 2, dst -= 2;
-	ldsh	[%o0], %o4	!	*(short *)dst = *(short *)src;
-	dec	2, %o1
-	sth	%o4, [%o1]	! }
-	btst	1, %o2
-
-	/*
-	 * Check for trailing byte.
-	 */
-1:
-Lback_mopb:
-!	btst	1, %o2		! (done already)
-	bnz,a	1f		! if (len & 1) {
-	ldsb	[%o0 - 1], %o4	!	b = src[-1];
-	retl
-	nop
-1:
-	retl			!	dst[-1] = b;
-	stb	%o4, [%o1 - 1]	! }
 
 /*
  * kcopy() is exactly like bcopy except that it set pcb_onfault such that



CVS commit: src/sys/arch/sparc/sparc

2018-03-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Mar 16 09:29:24 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
remove obsolete ovbcopy().  it may be the very slightly bit
faster for larger copies, but slower for smaller ones.
i don't see any major benefit in keeping this code.

this is the final ovbcopy() reference in src.  you're welcome :-)


To generate a diff of this commit:
cvs rdiff -u -r1.269 -r1.270 src/sys/arch/sparc/sparc/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/sparc/sparc

2018-02-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  6 09:22:58 UTC 2018

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

Log Message:
workaround a problem -Warray-bounds triggers but isn't a problem
in practise, as described from this old commment:

/*
 * Set up pm_regmap for kernel to point NUREG *below* the beginning
 * of kernel regmap storage. Since the kernel only uses regions
 * above NUREG, we save storage space and can index kernel and
 * user regions in the same way.
 */


To generate a diff of this commit:
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/sparc/sparc/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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.362 src/sys/arch/sparc/sparc/pmap.c:1.363
--- src/sys/arch/sparc/sparc/pmap.c:1.362	Tue Jan 16 08:23:17 2018
+++ src/sys/arch/sparc/sparc/pmap.c	Tue Feb  6 09:22:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.362 2018/01/16 08:23:17 mrg Exp $ */
+/*	$NetBSD: pmap.c,v 1.363 2018/02/06 09:22:57 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.362 2018/01/16 08:23:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.363 2018/02/06 09:22:57 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -3214,7 +3214,10 @@ pmap_bootstrap4_4c(void *top, int nctx, 
 	 * above NUREG, we save storage space and can index kernel and
 	 * user regions in the same way.
 	 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
 	kernel_pmap_store.pm_regmap = kernel_regmap_store - NUREG;
+#pragma GCC diagnostic pop
 	for (i = NKREG; --i >= 0;) {
 #if defined(SUN4_MMU3L)
 		kernel_regmap_store[i].rg_smeg = reginval;
@@ -3592,7 +3595,10 @@ pmap_bootstrap4m(void *top)
 	 * above NUREG, we save storage space and can index kernel and
 	 * user regions in the same way.
 	 */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
 	kernel_pmap_store.pm_regmap = kernel_regmap_store - NUREG;
+#pragma GCC diagnostic pop
 	memset(kernel_regmap_store, 0, NKREG * sizeof(struct regmap));
 	memset(kernel_segmap_store, 0, NKREG * NSEGRG * sizeof(struct segmap));
 	for (i = NKREG; --i >= 0;) {



CVS commit: src/sys/arch/sparc/sparc

2018-02-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  6 09:22:58 UTC 2018

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

Log Message:
workaround a problem -Warray-bounds triggers but isn't a problem
in practise, as described from this old commment:

/*
 * Set up pm_regmap for kernel to point NUREG *below* the beginning
 * of kernel regmap storage. Since the kernel only uses regions
 * above NUREG, we save storage space and can index kernel and
 * user regions in the same way.
 */


To generate a diff of this commit:
cvs rdiff -u -r1.362 -r1.363 src/sys/arch/sparc/sparc/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/sparc/sparc

2018-02-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb  1 22:58:44 UTC 2018

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

Log Message:
"save fp ipi" is an interrupt type counter, mark it so.


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/sys/arch/sparc/sparc/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/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.252 src/sys/arch/sparc/sparc/cpu.c:1.253
--- src/sys/arch/sparc/sparc/cpu.c:1.252	Wed Jan 17 07:38:20 2018
+++ src/sys/arch/sparc/sparc/cpu.c	Thu Feb  1 22:58:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.252 2018/01/17 07:38:20 mrg Exp $ */
+/*	$NetBSD: cpu.c,v 1.253 2018/02/01 22:58:44 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.252 2018/01/17 07:38:20 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.253 2018/02/01 22:58:44 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -363,7 +363,7 @@ cpu_init_evcnt(struct cpu_info *cpi)
 	 * The "savefp null" counter should go away when the NULL
 	 * struct fpstate * bug is fixed.
 	 */
-	evcnt_attach_dynamic(>ci_savefpstate, EVCNT_TYPE_MISC,
+	evcnt_attach_dynamic(>ci_savefpstate, EVCNT_TYPE_INTR,
 			 NULL, cpu_name(cpi), "savefp ipi");
 	evcnt_attach_dynamic(>ci_savefpstate_null, EVCNT_TYPE_MISC,
 			 NULL, cpu_name(cpi), "savefp null ipi");



CVS commit: src/sys/arch/sparc/sparc

2018-02-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb  1 22:58:44 UTC 2018

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

Log Message:
"save fp ipi" is an interrupt type counter, mark it so.


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/sys/arch/sparc/sparc/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/sparc/sparc

2018-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 17 07:38:20 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: cpu.c cpuvar.h

Log Message:
fix previous:
CPUFLG_SUN4CACHEBUG was renamed to CACHE_TRAPPAGEBUG and moved
into the cacheinfo.  don't revive the no longer used value, but
fix the non-sun4m code to match cpu.c 1.251.


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/arch/sparc/sparc/cpu.c
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/sparc/sparc/cpuvar.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/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.251 src/sys/arch/sparc/sparc/cpu.c:1.252
--- src/sys/arch/sparc/sparc/cpu.c:1.251	Tue Jan 16 08:23:17 2018
+++ src/sys/arch/sparc/sparc/cpu.c	Wed Jan 17 07:38:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.251 2018/01/16 08:23:17 mrg Exp $ */
+/*	$NetBSD: cpu.c,v 1.252 2018/01/17 07:38:20 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.251 2018/01/16 08:23:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.252 2018/01/17 07:38:20 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -1187,7 +1187,7 @@ getcacheinfo_sun4(struct cpu_info *sc, i
 		ci->c_l2linesize = 4;
 		ci->c_split = 0;
 		ci->c_nlines = ci->c_totalsize >> ci->c_l2linesize;
-		sc->flags |= CPUFLG_SUN4CACHEBUG;
+		sc->cacheinfo.c_flags |= CACHE_TRAPPAGEBUG;
 		break;
 	case CPUTYP_4_400:
 		ci->c_vactype = VAC_WRITEBACK;
@@ -1321,7 +1321,7 @@ getcacheinfo_sun4c(struct cpu_info *sc, 
 	 * mysterious buserr-type variable)
 	 */
 	if (prom_getpropint(node, "buserr-type", 0) == 1)
-		sc->flags |= CPUFLG_SUN4CACHEBUG;
+		sc->cacheinfo.c_flags |= CACHE_TRAPPAGEBUG;
 }
 #endif /* SUN4C */
 

Index: src/sys/arch/sparc/sparc/cpuvar.h
diff -u src/sys/arch/sparc/sparc/cpuvar.h:1.96 src/sys/arch/sparc/sparc/cpuvar.h:1.97
--- src/sys/arch/sparc/sparc/cpuvar.h:1.96	Wed Jan 17 02:39:16 2018
+++ src/sys/arch/sparc/sparc/cpuvar.h	Wed Jan 17 07:38:20 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuvar.h,v 1.96 2018/01/17 02:39:16 christos Exp $ */
+/*	$NetBSD: cpuvar.h,v 1.97 2018/01/17 07:38:20 mrg Exp $ */
 
 /*
  *  Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -157,7 +157,6 @@ struct module_info {
 #define CPUFLG_HATCHED		0x1000	/* CPU is alive */
 #define CPUFLG_PAUSED		0x2000	/* CPU is paused */
 #define CPUFLG_GOTMSG		0x4000	/* CPU got an lev13 IPI */
-#define CPUFLG_SUN4CACHEBUG	0x8000	/* CPU has the sun4 cache bug */
 
 
 /*



CVS commit: src/sys/arch/sparc/sparc

2018-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 17 07:38:20 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: cpu.c cpuvar.h

Log Message:
fix previous:
CPUFLG_SUN4CACHEBUG was renamed to CACHE_TRAPPAGEBUG and moved
into the cacheinfo.  don't revive the no longer used value, but
fix the non-sun4m code to match cpu.c 1.251.


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/arch/sparc/sparc/cpu.c
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/sparc/sparc/cpuvar.h

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



re: CVS commit: src/sys/arch/sparc/sparc

2018-01-16 Thread matthew green
"Christos Zoulas" writes:
> Module Name:  src
> Committed By: christos
> Date: Wed Jan 17 02:39:16 UTC 2018
> 
> Modified Files:
>   src/sys/arch/sparc/sparc: cpuvar.h
> 
> Log Message:
> fix compilation

actually, this was renamed and moved, so this is also wrong.
i'll fix it.


.mrg.


CVS commit: src/sys/arch/sparc/sparc

2018-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 17 02:39:16 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: cpuvar.h

Log Message:
fix compilation


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/sparc/sparc/cpuvar.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/sparc/sparc

2018-01-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 17 02:39:16 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: cpuvar.h

Log Message:
fix compilation


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/sparc/sparc/cpuvar.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/sparc/sparc/cpuvar.h
diff -u src/sys/arch/sparc/sparc/cpuvar.h:1.95 src/sys/arch/sparc/sparc/cpuvar.h:1.96
--- src/sys/arch/sparc/sparc/cpuvar.h:1.95	Tue Jan 16 03:23:17 2018
+++ src/sys/arch/sparc/sparc/cpuvar.h	Tue Jan 16 21:39:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuvar.h,v 1.95 2018/01/16 08:23:17 mrg Exp $ */
+/*	$NetBSD: cpuvar.h,v 1.96 2018/01/17 02:39:16 christos Exp $ */
 
 /*
  *  Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -157,6 +157,7 @@ struct module_info {
 #define CPUFLG_HATCHED		0x1000	/* CPU is alive */
 #define CPUFLG_PAUSED		0x2000	/* CPU is paused */
 #define CPUFLG_GOTMSG		0x4000	/* CPU got an lev13 IPI */
+#define CPUFLG_SUN4CACHEBUG	0x8000	/* CPU has the sun4 cache bug */
 
 
 /*



CVS commit: src/sys/arch/sparc/sparc

2018-01-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jan 15 21:25:25 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: cache.c

Log Message:
vcache_flush_* event counters are not interrupt type.  mark them misc.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/sparc/sparc/cache.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/sparc/sparc/cache.c
diff -u src/sys/arch/sparc/sparc/cache.c:1.98 src/sys/arch/sparc/sparc/cache.c:1.99
--- src/sys/arch/sparc/sparc/cache.c:1.98	Fri Dec  1 22:57:07 2017
+++ src/sys/arch/sparc/sparc/cache.c	Mon Jan 15 21:25:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cache.c,v 1.98 2017/12/01 22:57:07 mrg Exp $ */
+/*	$NetBSD: cache.c,v 1.99 2018/01/15 21:25:25 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.98 2017/12/01 22:57:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.99 2018/01/15 21:25:25 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
@@ -78,19 +78,19 @@ __KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.
 #include 
 
 struct evcnt vcache_flush_pg =
-	EVCNT_INITIALIZER(EVCNT_TYPE_INTR,0,"vcfl","pg");
+	EVCNT_INITIALIZER(EVCNT_TYPE_MISC,0,"vcfl","pg");
 EVCNT_ATTACH_STATIC(vcache_flush_pg);
 struct evcnt vcache_flush_seg =
-	EVCNT_INITIALIZER(EVCNT_TYPE_INTR,0,"vcfl","seg");
+	EVCNT_INITIALIZER(EVCNT_TYPE_MISC,0,"vcfl","seg");
 EVCNT_ATTACH_STATIC(vcache_flush_seg);
 struct evcnt vcache_flush_reg =
-	EVCNT_INITIALIZER(EVCNT_TYPE_INTR,0,"vcfl","reg");
+	EVCNT_INITIALIZER(EVCNT_TYPE_MISC,0,"vcfl","reg");
 EVCNT_ATTACH_STATIC(vcache_flush_reg);
 struct evcnt vcache_flush_ctx =
-	EVCNT_INITIALIZER(EVCNT_TYPE_INTR,0,"vcfl","ctx");
+	EVCNT_INITIALIZER(EVCNT_TYPE_MISC,0,"vcfl","ctx");
 EVCNT_ATTACH_STATIC(vcache_flush_ctx);
 struct evcnt vcache_flush_range =
-	EVCNT_INITIALIZER(EVCNT_TYPE_INTR,0,"vcfl","rng");
+	EVCNT_INITIALIZER(EVCNT_TYPE_MISC,0,"vcfl","rng");
 EVCNT_ATTACH_STATIC(vcache_flush_range);
 
 int cache_alias_dist;		/* Cache anti-aliasing constants */



CVS commit: src/sys/arch/sparc/sparc

2018-01-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jan 15 21:25:25 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: cache.c

Log Message:
vcache_flush_* event counters are not interrupt type.  mark them misc.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/sparc/sparc/cache.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/sparc/sparc

2018-01-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jan 12 09:47:44 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: timer.c

Log Message:
fix hang at 4B microseconds (1h12 or so), and simplify part of the previous


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc/sparc/timer.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/sparc/sparc/timer.c
diff -u src/sys/arch/sparc/sparc/timer.c:1.33 src/sys/arch/sparc/sparc/timer.c:1.34
--- src/sys/arch/sparc/sparc/timer.c:1.33	Fri Jan 12 06:01:33 2018
+++ src/sys/arch/sparc/sparc/timer.c	Fri Jan 12 09:47:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.33 2018/01/12 06:01:33 mrg Exp $ */
+/*	$NetBSD: timer.c,v 1.34 2018/01/12 09:47:44 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.33 2018/01/12 06:01:33 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.34 2018/01/12 09:47:44 mrg Exp $");
 
 #include 
 #include 
@@ -162,17 +162,11 @@ timer_get_timecount(struct timecounter *
 
 	/*
 	 * This handles early-boot cases where the counter resets twice
-	 * before the offset is updated.
+	 * before the offset is updated, and we have a stupid check to
+	 * ensure overflow hasn't happened.
 	 */
-	if (res < cntr.lastres) {
-		if (fixup == 0)
-			fixup = cntr.limit;
-		while (res < cntr.lastres) {
-			if (res > UINT_MAX - fixup)
-break;
-			res += fixup;
-		}
-	}
+	if (res < cntr.lastres && res > (TMR_MASK+1) << 3)
+		res = cntr.lastres + 1;
 
 	cntr.lastres = res;
 



CVS commit: src/sys/arch/sparc/sparc

2018-01-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jan 12 09:47:44 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: timer.c

Log Message:
fix hang at 4B microseconds (1h12 or so), and simplify part of the previous


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc/sparc/timer.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/sparc/sparc

2018-01-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jan 12 06:01:34 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: timer.c timer_sun4m.c timerreg.h

Log Message:
fix time goes backwards problems on sparc.

there are a few things here:
- there's a race between reading the limit register (which clears
  the interrupt and the limit bit) and increasing the latest offset.
  this can happen easily if an interrupt comes between the read and
  the call to tickle_tc() that increases the offset (i obverved this
  actually happening.)
- in early boot, sometimes the counter can cycle twice before the
  tickle happens.

to handle these issues, add two workarounds:
- if the limit bit isn't set, but the counter value is less than
  the previous value, and the offset hasn't changed, use the same
  fixup as if the limit bit was set.  this handles the first case
  above.
- add a hard-workaround for never allowing returning a smaller
  value (except during 32 bit overflow): if the result is less than
  the last result, add fixups until it does (or until it would
  overflow.)

the first workaround fixes general run-time issues, and the second
fixes issues only seen during boot.

also expand some comments in timer_sun4m.c and re-enable the sun4m
sub-microsecond tmr_ustolim4m() support (but it's always called with
at least 'tick' microseconds, so the end result is the same.)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc/sparc/timer.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sparc/sparc/timer_sun4m.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/sparc/timerreg.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/sparc/sparc

2018-01-11 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Jan 12 06:01:34 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: timer.c timer_sun4m.c timerreg.h

Log Message:
fix time goes backwards problems on sparc.

there are a few things here:
- there's a race between reading the limit register (which clears
  the interrupt and the limit bit) and increasing the latest offset.
  this can happen easily if an interrupt comes between the read and
  the call to tickle_tc() that increases the offset (i obverved this
  actually happening.)
- in early boot, sometimes the counter can cycle twice before the
  tickle happens.

to handle these issues, add two workarounds:
- if the limit bit isn't set, but the counter value is less than
  the previous value, and the offset hasn't changed, use the same
  fixup as if the limit bit was set.  this handles the first case
  above.
- add a hard-workaround for never allowing returning a smaller
  value (except during 32 bit overflow): if the result is less than
  the last result, add fixups until it does (or until it would
  overflow.)

the first workaround fixes general run-time issues, and the second
fixes issues only seen during boot.

also expand some comments in timer_sun4m.c and re-enable the sun4m
sub-microsecond tmr_ustolim4m() support (but it's always called with
at least 'tick' microseconds, so the end result is the same.)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc/sparc/timer.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sparc/sparc/timer_sun4m.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/sparc/timerreg.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/sparc/sparc/timer.c
diff -u src/sys/arch/sparc/sparc/timer.c:1.32 src/sys/arch/sparc/sparc/timer.c:1.33
--- src/sys/arch/sparc/sparc/timer.c:1.32	Sun Jan 19 00:22:33 2014
+++ src/sys/arch/sparc/sparc/timer.c	Fri Jan 12 06:01:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.32 2014/01/19 00:22:33 mrg Exp $ */
+/*	$NetBSD: timer.c,v 1.33 2018/01/12 06:01:33 mrg Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.32 2014/01/19 00:22:33 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.33 2018/01/12 06:01:33 mrg Exp $");
 
 #include 
 #include 
@@ -85,55 +85,98 @@ void *sched_cookie;
  * timecounter local state
  */
 static struct counter {
-	volatile u_int *cntreg;	/* counter register */
+	__cpu_simple_lock_t lock; /* protects access to offset, reg, last* */
+	volatile u_int *cntreg;	/* counter register to read */
 	u_int limit;		/* limit we count up to */
 	u_int offset;		/* accumulated offset due to wraps */
 	u_int shift;		/* scaling for valid bits */
 	u_int mask;		/* valid bit mask */
-} cntr;
+	u_int lastcnt;		/* the last* values are used to notice */
+	u_int lastres;		/* and fix up cases where it would appear */
+	u_int lastoffset;	/* time went backwards. */
+} cntr __aligned(CACHE_LINE_SIZE);
 
 /*
  * define timecounter
  */
 
 static struct timecounter counter_timecounter = {
-	timer_get_timecount,	/* get_timecount */
-	0,			/* no poll_pps */
-	~0u,			/* counter_mask */
-	0,  /* frequency - set at initialisation */
-	"timer-counter",	/* name */
-	100,			/* quality */
-/* private reference */
+	.tc_get_timecount =	timer_get_timecount,
+	.tc_poll_pps =		NULL,
+	.tc_counter_mask =	~0u,
+	.tc_frequency =		0,
+	.tc_name =		"timer-counter",
+	.tc_quality =		100,
+	.tc_priv =		,
 };
 
 /*
  * timer_get_timecount provide current counter value
  */
+__attribute__((__optimize__("Os")))
 static u_int
 timer_get_timecount(struct timecounter *tc)
 {
-	struct counter *ctr = (struct counter *)tc->tc_priv;
-
-	u_int c, res, r;
+	u_int cnt, res, fixup, offset;
 	int s;
 
+	/*
+	 * We use splhigh/__cpu_simple_lock here as we don't want
+	 * any mutex or lockdebug overhead.  The lock protects a
+	 * bunch of the members of cntr that are written here to
+	 * deal with the various minor races to be observed and
+	 * worked around.
+	 */
 	s = splhigh();
-
-	res = c = *ctr->cntreg;
+	__cpu_simple_lock();
+	res = cnt = *cntr.cntreg;
 
 	res &= ~TMR_LIMIT;
+	offset = cntr.offset;
 
-	if (c != res) {
-		r = ctr->limit;
+	/*
+	 * There are 3 cases here:
+	 * - limit reached, interrupt not yet processed.
+	 * - count reset but offset the same, race between handling
+	 *   the interrupt and tickle_tc() updating the offset.
+	 * - normal case.
+	 *
+	 * For the first two cases, add the limit so that we avoid
+	 * time going backwards.
+	 */
+	if (cnt != res) {
+		fixup = cntr.limit;
+	} else if (res < cntr.lastcnt && offset == cntr.lastoffset) {
+		fixup = cntr.limit;
 	} else {
-		r = 0;
+		fixup = 0;
 	}
+
+	cntr.lastcnt = res;
+	cntr.lastoffset = offset;
 	
-	res >>= ctr->shift;
-	res  &= ctr->mask;
+	res >>= cntr.shift;
+	res  &= cntr.mask;
+
+	res += fixup + offset;
 
-	res += r + 

CVS commit: src/sys/arch/sparc/sparc

2018-01-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 10 01:49:05 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: memecc.c

Log Message:
s/level 25/level 15/ -- there's nothing higher than 15 on sparc, and
this is talking about NMI.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/sparc/memecc.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/sparc/sparc/memecc.c
diff -u src/sys/arch/sparc/sparc/memecc.c:1.16 src/sys/arch/sparc/sparc/memecc.c:1.17
--- src/sys/arch/sparc/sparc/memecc.c:1.16	Sat Oct 19 19:40:23 2013
+++ src/sys/arch/sparc/sparc/memecc.c	Wed Jan 10 01:49:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: memecc.c,v 1.16 2013/10/19 19:40:23 mrg Exp $	*/
+/*	$NetBSD: memecc.c,v 1.17 2018/01/10 01:49:05 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.16 2013/10/19 19:40:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: memecc.c,v 1.17 2018/01/10 01:49:05 mrg Exp $");
 
 #include 
 #include 
@@ -114,7 +114,7 @@ memecc_attach(device_t parent, device_t 
 }
 
 /*
- * Called if the MEMORY ERROR bit is set after a level 25 interrupt.
+ * Called if the MEMORY ERROR bit is set after a level 15 interrupt.
  */
 int
 memecc_error(void)



CVS commit: src/sys/arch/sparc/sparc

2018-01-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 10 01:49:05 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc: memecc.c

Log Message:
s/level 25/level 15/ -- there's nothing higher than 15 on sparc, and
this is talking about NMI.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/sparc/memecc.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/sparc/sparc

2017-12-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec  1 22:57:07 UTC 2017

Modified Files:
src/sys/arch/sparc/sparc: cache.c

Log Message:
note some bits no longer present in SuperSPARC-II.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/sparc/sparc/cache.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/sparc/sparc/cache.c
diff -u src/sys/arch/sparc/sparc/cache.c:1.97 src/sys/arch/sparc/sparc/cache.c:1.98
--- src/sys/arch/sparc/sparc/cache.c:1.97	Sun Mar  4 09:03:34 2007
+++ src/sys/arch/sparc/sparc/cache.c	Fri Dec  1 22:57:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cache.c,v 1.97 2007/03/04 09:03:34 macallan Exp $ */
+/*	$NetBSD: cache.c,v 1.98 2017/12/01 22:57:07 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.97 2007/03/04 09:03:34 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cache.c,v 1.98 2017/12/01 22:57:07 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_sparc_arch.h"
@@ -973,8 +973,8 @@ viking_pcache_flush_page(paddr_t pa, int
 		 * +---+-+---+-+---+-+---++
 		 *
 		 * PA: bits 12-35 of the physical address
-		 * S:  line shared bit
-		 * D:  line dirty bit
+		 * S:  line shared bit (not present on SuperSPARC-II)
+		 * D:  line dirty bit (not present on SuperSPARC-II)
 		 * V:  line valid bit
 		 */
 



CVS commit: src/sys/arch/sparc/sparc

2017-12-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Dec  1 22:57:07 UTC 2017

Modified Files:
src/sys/arch/sparc/sparc: cache.c

Log Message:
note some bits no longer present in SuperSPARC-II.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/sparc/sparc/cache.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/sparc/sparc

2017-11-24 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Nov 25 04:11:37 UTC 2017

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
Avoid an instruction requiring a higher alignment than we are guaranteed

Fixes PR port-sparc/52721: ddb errors on ps command
Thanks to mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/sys/arch/sparc/sparc/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/sparc/sparc/locore.s
diff -u src/sys/arch/sparc/sparc/locore.s:1.268 src/sys/arch/sparc/sparc/locore.s:1.269
--- src/sys/arch/sparc/sparc/locore.s:1.268	Sun Nov  4 00:32:47 2012
+++ src/sys/arch/sparc/sparc/locore.s	Sat Nov 25 04:11:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.268 2012/11/04 00:32:47 chs Exp $	*/
+/*	$NetBSD: locore.s,v 1.269 2017/11/25 04:11:37 maya Exp $	*/
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -6288,8 +6288,9 @@ ENTRY(longjmp)
 	cmp	%fp, %g7	! compare against desired frame
 	bl,a	1b		! if below,
 	 restore		!pop frame and loop
-	be,a	2f		! if there,
-	 ldd	[%g1+0], %o2	!fetch return %sp and pc, and get out
+	ld	[%g1+0], %o2	! fetch return %sp
+	be,a	2f		! we're there, get out
+	 ld	[%g1+4], %o3	! fetch return pc
 
 Llongjmpbotch:
 ! otherwise, went too far; bomb out



CVS commit: src/sys/arch/sparc/sparc

2017-11-24 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Sat Nov 25 04:11:37 UTC 2017

Modified Files:
src/sys/arch/sparc/sparc: locore.s

Log Message:
Avoid an instruction requiring a higher alignment than we are guaranteed

Fixes PR port-sparc/52721: ddb errors on ps command
Thanks to mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.268 -r1.269 src/sys/arch/sparc/sparc/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/sparc/sparc

2017-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  5 01:18:15 UTC 2017

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

Log Message:
fix type of addr.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc/sparc/kobj_machdep.c

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



CVS commit: src/sys/arch/sparc/sparc

2017-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  5 01:18:15 UTC 2017

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

Log Message:
fix type of addr.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc/sparc/kobj_machdep.c

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

Modified files:

Index: src/sys/arch/sparc/sparc/kobj_machdep.c
diff -u src/sys/arch/sparc/sparc/kobj_machdep.c:1.4 src/sys/arch/sparc/sparc/kobj_machdep.c:1.5
--- src/sys/arch/sparc/sparc/kobj_machdep.c:1.4	Fri Nov  3 05:59:08 2017
+++ src/sys/arch/sparc/sparc/kobj_machdep.c	Sat Nov  4 21:18:15 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kobj_machdep.c,v 1.4 2017/11/03 09:59:08 maxv Exp $	*/
+/*	$NetBSD: kobj_machdep.c,v 1.5 2017/11/05 01:18:15 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -126,9 +126,9 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
 	   bool isrela, bool local)
 {
 	const Elf_Rela *rela;
-	Elf_Addr *where;
+	Elf_Addr *where, addr;
 	Elf_Word value, mask;
-	uintptr_t tmp, addr;
+	uintptr_t tmp;
 	u_int symidx, type;
 	int error;
 



CVS commit: src/sys/arch/sparc/sparc

2017-03-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 26 12:38:24 UTC 2017

Modified Files:
src/sys/arch/sparc/sparc: openfirm.c

Log Message:
Add KASSERTs to catch access to NULL OF nodes early


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

2017-03-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 26 12:38:24 UTC 2017

Modified Files:
src/sys/arch/sparc/sparc: openfirm.c

Log Message:
Add KASSERTs to catch access to NULL OF nodes early


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sparc/sparc/openfirm.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/sparc/sparc/openfirm.c
diff -u src/sys/arch/sparc/sparc/openfirm.c:1.22 src/sys/arch/sparc/sparc/openfirm.c:1.23
--- src/sys/arch/sparc/sparc/openfirm.c:1.22	Thu Apr  7 19:46:39 2016
+++ src/sys/arch/sparc/sparc/openfirm.c	Sun Mar 26 12:38:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.c,v 1.22 2016/04/07 19:46:39 palle Exp $	*/
+/*	$NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.22 2016/04/07 19:46:39 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: openfirm.c,v 1.23 2017/03/26 12:38:24 martin Exp $");
 
 #include 
 #include 
@@ -166,6 +166,7 @@ OF_getproplen(int handle, const char *pr
 		cell_t size;
 	} args;
 
+	KASSERT(handle != 0);
 	args.name = ADR2CELL("getproplen");
 	args.nargs = 2;
 	args.nreturns = 1;
@@ -190,6 +191,7 @@ OF_getprop(int handle, const char *prop,
 		cell_t size;
 	} args;
 
+	KASSERT(handle != 0);
 	if (buflen > NBPG)
 		return -1;
 	args.name = ADR2CELL("getprop");



CVS commit: src/sys/arch/sparc/sparc

2017-01-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 18 21:33:26 UTC 2017

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

Log Message:
be more specific when identifying SuperSPARC CPUs


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/sys/arch/sparc/sparc/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/sparc/sparc

2017-01-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 18 21:33:26 UTC 2017

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

Log Message:
be more specific when identifying SuperSPARC CPUs


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/sys/arch/sparc/sparc/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/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.248 src/sys/arch/sparc/sparc/cpu.c:1.249
--- src/sys/arch/sparc/sparc/cpu.c:1.248	Fri Jul 25 17:21:32 2014
+++ src/sys/arch/sparc/sparc/cpu.c	Wed Jan 18 21:33:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.248 2014/07/25 17:21:32 nakayama Exp $ */
+/*	$NetBSD: cpu.c,v 1.249 2017/01/18 21:33:25 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.248 2014/07/25 17:21:32 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.249 2017/01/18 21:33:25 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -1986,6 +1986,12 @@ struct cpu_conf {
 	{ CPU_SUN4M, 1, 3, 1, ANY, "CY7C611", _cypress },
 	{ CPU_SUN4M, 1, 0xe, 1, 7, "RT620/625", _hypersparc },
 	{ CPU_SUN4M, 1, 0xf, 1, 7, "RT620/625", _hypersparc },
+	{ CPU_SUN4M, 4, 0, 0, 1, "SuperSPARC v3", _viking },
+	{ CPU_SUN4M, 4, 0, 0, 2, "SuperSPARC v4", _viking },
+	{ CPU_SUN4M, 4, 0, 0, 3, "SuperSPARC v5", _viking },
+	{ CPU_SUN4M, 4, 0, 0, 8, "SuperSPARC II v1", _viking },
+	{ CPU_SUN4M, 4, 0, 0, 10, "SuperSPARC II v2", _viking },
+	{ CPU_SUN4M, 4, 0, 0, 12, "SuperSPARC II v3", _viking },
 	{ CPU_SUN4M, 4, 0, 0, ANY, "TMS390Z50 v0 or TMS390Z55", _viking },
 	{ CPU_SUN4M, 4, 1, 0, ANY, "TMS390Z50 v1", _viking },
 	{ CPU_SUN4M, 4, 1, 4, ANY, "TMS390S10", _ms1 },



CVS commit: src/sys/arch/sparc/sparc

2017-01-11 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jan 11 12:14:32 UTC 2017

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

Log Message:
Don't cast the result of abs() to int, but the argument.


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

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

Modified files:

Index: src/sys/arch/sparc/sparc/db_disasm.c
diff -u src/sys/arch/sparc/sparc/db_disasm.c:1.21 src/sys/arch/sparc/sparc/db_disasm.c:1.22
--- src/sys/arch/sparc/sparc/db_disasm.c:1.21	Sun Oct  4 08:16:13 2015
+++ src/sys/arch/sparc/sparc/db_disasm.c	Wed Jan 11 12:14:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.21 2015/10/04 08:16:13 joerg Exp $ */
+/*	$NetBSD: db_disasm.c,v 1.22 2017/01/11 12:14:32 joerg Exp $ */
 
 /*
  * Copyright (c) 1994 David S. Miller, da...@nadzieja.rutgers.edu
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.21 2015/10/04 08:16:13 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.22 2017/01/11 12:14:32 joerg Exp $");
 
 #include 
 #include 
@@ -995,12 +995,12 @@ db_disasm(vaddr_t loc, bool altfmt)
 		case 'i':
 			/* simm13 -- signed */
 			val = SIGNEX(insn, 13);
-			db_printf("%s0x%x", SIGN(val), (int)abs(val));
+			db_printf("%s0x%x", SIGN(val), abs((int)val));
 			break;
 		case 'j':
 			/* simm11 -- signed */
 			val = SIGNEX(insn, 11);
-			db_printf("%s0x%x", SIGN(val), (int)abs(val));
+			db_printf("%s0x%x", SIGN(val), abs((int)val));
 			break;
 		case 'l':
 			val = (((insn>>20)&0x3)<<13)|(insn & 0x1fff);
@@ -1043,7 +1043,7 @@ db_disasm(vaddr_t loc, bool altfmt)
 			db_printf("[%%%s %c 0x%x]",
 regs[((insn >> 14) & 0x1f)],
 (int)((val<0)?'-':'+'),
-(int)abs(val));
+abs((int)val));
 			if (*f_ptr == '8')
 db_printf(" %%asi");
 			break;



  1   2   3   >