CVS commit: src/sys/arch/sparc64/sparc64

2024-02-17 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 17 19:36:07 UTC 2024

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

Log Message:
Ensure that the size of the stack is properly specified (2*USPACE) so it 
matches the allocation of stack pages done in pmap_bootstrap(). If this is not 
properly in sync, then the stack pointer may end up in the redzone right before 
the stack causing mmu faults. This issue has been observed on a T2000 (sun4v) 
system while probing the devices (pci/ebus/com) during bootstrap


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

2024-02-17 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 17 19:36:07 UTC 2024

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

Log Message:
Ensure that the size of the stack is properly specified (2*USPACE) so it 
matches the allocation of stack pages done in pmap_bootstrap(). If this is not 
properly in sync, then the stack pointer may end up in the redzone right before 
the stack causing mmu faults. This issue has been observed on a T2000 (sun4v) 
system while probing the devices (pci/ebus/com) during bootstrap


To generate a diff of this commit:
cvs rdiff -u -r1.433 -r1.434 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.433 src/sys/arch/sparc64/sparc64/locore.s:1.434
--- src/sys/arch/sparc64/sparc64/locore.s:1.433	Wed Mar  1 08:18:39 2023
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Feb 17 19:36:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.433 2023/03/01 08:18:39 riastradh Exp $	*/
+/*	$NetBSD: locore.s,v 1.434 2024/02/17 19:36:07 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5471,7 +5471,7 @@ ENTRY_NOPROFILE(cpu_initialize)	/* for c
 	!! and already accessible here)
 	flushw
 	LDPTR	[%l7 + CI_CPCB], %l0		! load PCB/uarea pointer
-	set	USPACE - TF_SIZE - CC64FSZ, %l1
+	set	2*USPACE - TF_SIZE - CC64FSZ, %l1
  	add	%l1, %l0, %l0
 #ifdef _LP64
 	andn	%l0, 0x0f, %l0			! Needs to be 16-byte aligned



CVS commit: src/sys/arch/sparc64/sparc64

2024-01-15 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Jan 15 08:13:45 UTC 2024

Modified Files:
src/sys/arch/sparc64/sparc64: intr.c trap.c

Log Message:
Fix typos in trap types and one log message.

OpenBSD fixed those over 20 years ago.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/sparc64/sparc64/intr.c
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2024-01-15 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Jan 15 08:13:45 UTC 2024

Modified Files:
src/sys/arch/sparc64/sparc64: intr.c trap.c

Log Message:
Fix typos in trap types and one log message.

OpenBSD fixed those over 20 years ago.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/sparc64/sparc64/intr.c
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/intr.c
diff -u src/sys/arch/sparc64/sparc64/intr.c:1.71 src/sys/arch/sparc64/sparc64/intr.c:1.72
--- src/sys/arch/sparc64/sparc64/intr.c:1.71	Sun Jan  9 20:30:04 2022
+++ src/sys/arch/sparc64/sparc64/intr.c	Mon Jan 15 08:13:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.71 2022/01/09 20:30:04 palle Exp $ */
+/*	$NetBSD: intr.c,v 1.72 2024/01/15 08:13:45 andvar Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.71 2022/01/09 20:30:04 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.72 2024/01/15 08:13:45 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -108,7 +108,7 @@ strayintr(const struct trapframe64 *fp, 
 
 	snprintb(buf, sizeof(buf), PSTATE_BITS,
 	(fp->tf_tstate>>TSTATE_PSTATE_SHIFT));
-	printf("stray interrupt ipl %u pc=%llx npc=%llx pstate=%s vecttored=%d\n",
+	printf("stray interrupt ipl %u pc=%llx npc=%llx pstate=%s vectored=%d\n",
 	fp->tf_pil, (unsigned long long)fp->tf_pc,
 	(unsigned long long)fp->tf_npc,  buf, vectored);
 

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.196 src/sys/arch/sparc64/sparc64/trap.c:1.197
--- src/sys/arch/sparc64/sparc64/trap.c:1.196	Mon Jan  8 19:33:49 2024
+++ src/sys/arch/sparc64/sparc64/trap.c	Mon Jan 15 08:13:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.196 2024/01/08 19:33:49 palle Exp $ */
+/*	$NetBSD: trap.c,v 1.197 2024/01/15 08:13:45 andvar Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.196 2024/01/08 19:33:49 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.197 2024/01/15 08:13:45 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -342,7 +342,7 @@ const char *trap_type[] = {
 	T, T, T, T, T, T, T, T, /* 128..12f */
 	T, T,			/* 130..131 */
 	"get condition codes",	/* 132 */
-	"set condision codes",	/* 133 */
+	"set condition codes",	/* 133 */
 	T, T, T, T,		/* 134..137 */
 	T, T, T, T, T, T, T, T, /* 138..13f */
 	T, T, T, T, T, T, T, T, /* 140..147 */
@@ -352,7 +352,7 @@ const char *trap_type[] = {
 	T, T, T, T,		/* 160..163 */
 	"SVID syscall64",	/* 164 */
 	"SPARC Intl syscall64",	/* 165 */
-	"OS vedor spec syscall",/* 166 */
+	"OS vendor spec syscall",	/* 166 */
 	"HW OEM syscall",	/* 167 */
 	"ret from deferred trap",	/* 168 */
 };



CVS commit: src/sys/arch/sparc64/sparc64

2024-01-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jan  8 19:33:49 UTC 2024

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

Log Message:
sun4v: only DFA (Data fault address) and DFA (Datafault context) are valid when 
a mem_address_not_aligned fault is triggered, so ajust debug printout to this


To generate a diff of this commit:
cvs rdiff -u -r1.195 -r1.196 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.195 src/sys/arch/sparc64/sparc64/trap.c:1.196
--- src/sys/arch/sparc64/sparc64/trap.c:1.195	Thu Oct  5 19:41:06 2023
+++ src/sys/arch/sparc64/sparc64/trap.c	Mon Jan  8 19:33:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.195 2023/10/05 19:41:06 ad Exp $ */
+/*	$NetBSD: trap.c,v 1.196 2024/01/08 19:33:49 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.195 2023/10/05 19:41:06 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.196 2024/01/08 19:33:49 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -747,20 +747,8 @@ dopanic:
 		  
 			printf("Alignment error: pid=%d.%d comm=%s pc=%lx\n",
 			   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, pc);
-			paddr_t mmufsa_ift_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ift);
-			paddr_t mmufsa_ifa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifa);
-			paddr_t mmufsa_ifc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifc);
-			paddr_t mmufsa_dft_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dft);
 			paddr_t mmufsa_dfa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfa);
 			paddr_t mmufsa_dfc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfc);
-			int64_t ift = ldxa(mmufsa_ift_addr, ASI_PHYS_CACHED);
-			printf("ift = %016lx\n", ift);
-			int64_t ifa = ldxa(mmufsa_ifa_addr, ASI_PHYS_CACHED);
-			printf("ifa = %016lx\n", ifa);
-			int64_t ifc = ldxa(mmufsa_ifc_addr, ASI_PHYS_CACHED);
-			printf("ifc = %016lx\n", ifc);
-			int64_t dft = ldxa(mmufsa_dft_addr, ASI_PHYS_CACHED);
-			printf("dft = %016lx\n", dft);
 			int64_t dfa = ldxa(mmufsa_dfa_addr, ASI_PHYS_CACHED);
 			printf("dfa = %016lx\n", dfa);
 			int64_t dfc = ldxa(mmufsa_dfc_addr, ASI_PHYS_CACHED);



CVS commit: src/sys/arch/sparc64/sparc64

2024-01-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jan  8 19:33:49 UTC 2024

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

Log Message:
sun4v: only DFA (Data fault address) and DFA (Datafault context) are valid when 
a mem_address_not_aligned fault is triggered, so ajust debug printout to this


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

2023-08-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Aug 29 20:17:02 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: static_edid.c

Log Message:
Update the horizontal sync offset based on the Naturetech video timing.
While here, correct the spelling of "Naturetech" in the data.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/static_edid.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/sparc64/sparc64/static_edid.c
diff -u src/sys/arch/sparc64/sparc64/static_edid.c:1.1 src/sys/arch/sparc64/sparc64/static_edid.c:1.2
--- src/sys/arch/sparc64/sparc64/static_edid.c:1.1	Sun Oct 11 19:39:22 2020
+++ src/sys/arch/sparc64/sparc64/static_edid.c	Tue Aug 29 20:17:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: static_edid.c,v 1.1 2020/10/11 19:39:22 jdc Exp $ */
+/*	$NetBSD: static_edid.c,v 1.2 2023/08/29 20:17:02 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.1 2020/10/11 19:39:22 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: static_edid.c,v 1.2 2023/08/29 20:17:02 jdc Exp $");
 #include 
 
 /* EDID blocks for some known hardware that doesn't provide its own */
@@ -46,13 +46,13 @@ uint8_t edid_meso999[128] = {
 /* 20 */	0x16, 0x50, 0x54, 0xa5, 0x4a, 0x80, 0x81, 0x40,
 /* 28 */	0x81, 0x80, 0x81, 0x8f, 0x95, 0x00, 0x01, 0x01,
 /* 30 */	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xab, 0x22,
-/* 38 */	0xa0, 0xa0, 0x50, 0x84, 0x1a, 0x30, 0x38, 0x20,
+/* 38 */	0xa0, 0xa0, 0x50, 0x84, 0x1a, 0x30, 0x30, 0x20,
 /* 40 */	0x36, 0x00, 0x9a, 0x01, 0x11, 0x00, 0x00, 0x1a,
 /* 48 */	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 /* 50 */	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 /* 58 */	0x00, 0x01, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x4e,
-/* 60 */	0x41, 0x74, 0x75, 0x72, 0x65, 0x74, 0x65, 0x63,
+/* 60 */	0x61, 0x74, 0x75, 0x72, 0x65, 0x74, 0x65, 0x63,
 /* 68 */	0x68, 0x0a, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfe,
 /* 70 */	0x00, 0x4d, 0x65, 0x73, 0x6f, 0x20, 0x39, 0x39,
-/* 78 */	0x39, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x00, 0xed
+/* 78 */	0x39, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x00, 0xd5
 };



CVS commit: src/sys/arch/sparc64/sparc64

2023-08-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Tue Aug 29 20:17:02 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: static_edid.c

Log Message:
Update the horizontal sync offset based on the Naturetech video timing.
While here, correct the spelling of "Naturetech" in the data.


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

2023-03-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  1 08:18:39 UTC 2023

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

Log Message:
sparc64: Optimization: Omit needless membar when triggering softint.

When we are triggering a softint, it can't already hold any mutexes.
So any path to mutex_exit(mtx) must go via mutex_enter(mtx), which is
always done with atomic r/m/w, and we need not issue any explicit
barrier between ci->ci_curlwp = softlwp and a potential load of
mtx->mtx_owner in mutex_exit.

PR kern/57240

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


To generate a diff of this commit:
cvs rdiff -u -r1.432 -r1.433 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.432 src/sys/arch/sparc64/sparc64/locore.s:1.433
--- src/sys/arch/sparc64/sparc64/locore.s:1.432	Thu Feb 23 14:56:56 2023
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Mar  1 08:18:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.432 2023/02/23 14:56:56 riastradh Exp $	*/
+/*	$NetBSD: locore.s,v 1.433 2023/03/01 08:18:39 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6847,7 +6847,13 @@ ENTRY(softint_fastintr)
 	or	%o3, %lo(USPACE - TF_SIZE - CC64FSZ - STKB), %o3
 	membar	#StoreStore		/* for mutex_enter; see cpu_switchto */
 	STPTR	%i0, [%l7 + %lo(CURLWP)]
-	membar	#StoreLoad		/* for mutex_enter; see cpu_switchto */
+	/*
+	 * No need for barrier after ci->ci_curlwp = softlwp -- when we
+	 * enter a softint lwp, it can't be holding any mutexes, so it
+	 * can't release any until after it has acquired them, so we
+	 * need not participate in the protocol with mutex_vector_enter
+	 * barriers here.
+	 */
 	add	%l1, %o3, %i6
 	STPTR	%l1, [%l6 + %lo(CPCB)]
 	stx	%i6, [%l1 + PCB_SP]



CVS commit: src/sys/arch/sparc64/sparc64

2023-03-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Mar  1 08:18:39 UTC 2023

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

Log Message:
sparc64: Optimization: Omit needless membar when triggering softint.

When we are triggering a softint, it can't already hold any mutexes.
So any path to mutex_exit(mtx) must go via mutex_enter(mtx), which is
always done with atomic r/m/w, and we need not issue any explicit
barrier between ci->ci_curlwp = softlwp and a potential load of
mtx->mtx_owner in mutex_exit.

PR kern/57240

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


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

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

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

Log Message:
sparc64: Add missing barriers in cpu_switchto.

Details in comments.

PR kern/57240

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


To generate a diff of this commit:
cvs rdiff -u -r1.431 -r1.432 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.431 src/sys/arch/sparc64/sparc64/locore.s:1.432
--- src/sys/arch/sparc64/sparc64/locore.s:1.431	Tue Jul  5 20:15:40 2022
+++ src/sys/arch/sparc64/sparc64/locore.s	Thu Feb 23 14:56:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.431 2022/07/05 20:15:40 andvar Exp $	*/
+/*	$NetBSD: locore.s,v 1.432 2023/02/23 14:56:56 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6731,9 +6731,28 @@ ENTRY(cpu_switchto)
 	 * Load the new lwp.  To load, we must change stacks and
 	 * alter cpcb and the window control registers, hence we must
 	 * keep interrupts disabled.
+	 *
+	 * 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.
 	 */
 
+	membar	#StoreStore
 	STPTR	%i1, [%l7 + %lo(CURLWP)]	! curlwp = l;
+	membar	#StoreLoad
 	STPTR	%l1, [%l6 + %lo(CPCB)]		! cpcb = newpcb;
 
 	ldx	[%l1 + PCB_SP], %i6
@@ -6826,7 +6845,9 @@ ENTRY(softint_fastintr)
 	sethi	%hi(USPACE - TF_SIZE - CC64FSZ - STKB), %o3
 	LDPTR	[%i0 + L_PCB], %l1		! l1 = softint pcb
 	or	%o3, %lo(USPACE - TF_SIZE - CC64FSZ - STKB), %o3
+	membar	#StoreStore		/* for mutex_enter; see cpu_switchto */
 	STPTR	%i0, [%l7 + %lo(CURLWP)]
+	membar	#StoreLoad		/* for mutex_enter; see cpu_switchto */
 	add	%l1, %o3, %i6
 	STPTR	%l1, [%l6 + %lo(CPCB)]
 	stx	%i6, [%l1 + PCB_SP]
@@ -6839,7 +6860,9 @@ ENTRY(softint_fastintr)
 
 	/* switch back to interrupted lwp */
 	ldx	[%l5 + PCB_SP], %i6
+	membar	#StoreStore		/* for mutex_enter; see cpu_switchto */
 	STPTR	%l0, [%l7 + %lo(CURLWP)]
+	membar	#StoreLoad		/* for mutex_enter; see cpu_switchto */
 	STPTR	%l5, [%l6 + %lo(CPCB)]
 
 	restore	! rewind register window



CVS commit: src/sys/arch/sparc64/sparc64

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

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

Log Message:
sparc64: Add missing barriers in cpu_switchto.

Details in comments.

PR kern/57240

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


To generate a diff of this commit:
cvs rdiff -u -r1.431 -r1.432 src/sys/arch/sparc64/sparc64/locore.s

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

2023-02-20 Thread Valery Ushakov
On Mon, Feb 20, 2023 at 15:41:04 +0100, Martin Husemann wrote:

> On Mon, Feb 20, 2023 at 05:15:33PM +0300, Valery Ushakov wrote:
> > them up, b/c you cannot amend that comment.  To add to the fun, I
> > think releng scripts just clone the commit message on pull ups, so
> > that comment gets splattered all over the target branches too.
> 
> Yes - I try to manually remove them (which is easy if they are at the
> end of the last commit log in the batch) durint the pullup.

Data point:

  $ hg log -b netbsd-9 | grep 'XXX.*pullup.*9' | wc -l
  74

-uwe


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

2023-02-20 Thread Valery Ushakov
On Mon, Feb 20, 2023 at 22:35:40 +0700, Robert Elz wrote:

> Date:Mon, 20 Feb 2023 16:47:01 +0300
> From:Valery Ushakov 
> Message-ID:  
> 
>   | I wonder if we should stop abusing commit messages as pull-up
>   | reminders.  These XXX will not convey any useful information a few
>   | months down the line...
> 
> I think they're useful (if only I remembered to add them all the
> times I should) - it allows someone looking at the commit log to
> easily determine that the change is also intended for another branch.
> Then one can check and see if it happened or not, and if not, send
> a reminder if it is important/needed.
> 
> If the pullup annotation is missing, I tend to assume that the change
> is not intended to be pulled up - either it isn't applicable, or is
> something new that isn't appropriate for older releases.
> 
> That's why I will sometimes even include pullup annotations for ancient
> versions of NetBSD, even though I know they will never happen (never get
> submitted, much less acted upon) - just as an indication that the problem
> being fixed exists from long ago.

In that case they have no business being "XXX" :)

-uwe


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

2023-02-20 Thread Robert Elz
Date:Mon, 20 Feb 2023 16:47:01 +0300
From:Valery Ushakov 
Message-ID:  

  | I wonder if we should stop abusing commit messages as pull-up
  | reminders.  These XXX will not convey any useful information a few
  | months down the line...

I think they're useful (if only I remembered to add them all the
times I should) - it allows someone looking at the commit log to
easily determine that the change is also intended for another branch.
Then one can check and see if it happened or not, and if not, send
a reminder if it is important/needed.

If the pullup annotation is missing, I tend to assume that the change
is not intended to be pulled up - either it isn't applicable, or is
something new that isn't appropriate for older releases.

That's why I will sometimes even include pullup annotations for ancient
versions of NetBSD, even though I know they will never happen (never get
submitted, much less acted upon) - just as an indication that the problem
being fixed exists from long ago.

kre



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

2023-02-20 Thread Martin Husemann
On Mon, Feb 20, 2023 at 05:15:33PM +0300, Valery Ushakov wrote:
> them up, b/c you cannot amend that comment.  To add to the fun, I
> think releng scripts just clone the commit message on pull ups, so
> that comment gets splattered all over the target branches too.

Yes - I try to manually remove them (which is easy if they are at the
end of the last commit log in the batch) durint the pullup.

Martin


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

2023-02-20 Thread Valery Ushakov
On Mon, Feb 20, 2023 at 13:57:32 +, Taylor R Campbell wrote:

> > > XXX pullup-8
> > > XXX pullup-9
> > > XXX pullup-10
> > 
> > I wonder if we should stop abusing commit messages as pull-up
> > reminders.  These XXX will not convey any useful information a few
> > months down the line...
> 
> Happy to try a better mechanism if you have suggestions, but this is
> the best one I've found so far!  If I don't mark commits this way, I'm
> almost guaranteed not to pull them up.

I'm not sure any exists even with modern VCS.  May be something like a
branch that is not closed until it is merged (pulled-up) to all the
intended destination (but then the very notion of the closed branch
requires something more modern than CVS).  The problem with the XXX in
the commit message is that you don't easily know if you _did_ pull
them up, b/c you cannot amend that comment.  To add to the fun, I
think releng scripts just clone the commit message on pull ups, so
that comment gets splattered all over the target branches too.

-uwe


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

2023-02-20 Thread Taylor R Campbell
> Date: Mon, 20 Feb 2023 16:47:01 +0300
> From: Valery Ushakov 
> 
> On Mon, Feb 20, 2023 at 13:30:23 +, Taylor R Campbell wrote:
> 
> > Module Name:src
> > Committed By:   riastradh
> > Date:   Mon Feb 20 13:30:23 UTC 2023
> > 
> > Modified Files:
> > src/sys/arch/sparc64/sparc64: lock_stubs.s
> > 
> > Log Message:
> > sparc64: Add missing LoadStore ordering for mutex_enter stub.
> > 
> > XXX pullup-8
> > XXX pullup-9
> > XXX pullup-10
> 
> I wonder if we should stop abusing commit messages as pull-up
> reminders.  These XXX will not convey any useful information a few
> months down the line...

Happy to try a better mechanism if you have suggestions, but this is
the best one I've found so far!  If I don't mark commits this way, I'm
almost guaranteed not to pull them up.


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

2023-02-20 Thread Valery Ushakov
On Mon, Feb 20, 2023 at 13:30:23 +, Taylor R Campbell wrote:

> Module Name:  src
> Committed By: riastradh
> Date: Mon Feb 20 13:30:23 UTC 2023
> 
> Modified Files:
>   src/sys/arch/sparc64/sparc64: lock_stubs.s
> 
> Log Message:
> sparc64: Add missing LoadStore ordering for mutex_enter stub.
> 
> XXX pullup-8
> XXX pullup-9
> XXX pullup-10

I wonder if we should stop abusing commit messages as pull-up
reminders.  These XXX will not convey any useful information a few
months down the line...

-uwe


CVS commit: src/sys/arch/sparc64/sparc64

2023-02-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 20 13:30:36 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: lock_stubs.s

Log Message:
sparc64: Rename internal barrier macros to be clearer.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/sparc64/lock_stubs.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/sparc64/sparc64/lock_stubs.s
diff -u src/sys/arch/sparc64/sparc64/lock_stubs.s:1.12 src/sys/arch/sparc64/sparc64/lock_stubs.s:1.13
--- src/sys/arch/sparc64/sparc64/lock_stubs.s:1.12	Mon Feb 20 13:30:22 2023
+++ src/sys/arch/sparc64/sparc64/lock_stubs.s	Mon Feb 20 13:30:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.12 2023/02/20 13:30:22 riastradh Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.13 2023/02/20 13:30:36 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
@@ -41,11 +41,11 @@
 #define	CURLWP	(CPUINFO_VA+CI_CURLWP)
 
 #if defined(MULTIPROCESSOR)
-#define	MB_READ	membar #LoadLoad | #LoadStore
-#define	MB_MEM	membar #LoadStore | #StoreStore
+#define	MB_ACQ	membar #LoadLoad | #LoadStore
+#define	MB_REL	membar #LoadStore | #StoreStore
 #else
-#define	MB_READ	/* nothing */
-#define	MB_MEM	/* nothing */
+#define	MB_ACQ	/* nothing */
+#define	MB_REL	/* nothing */
 #endif
 
 #if !defined(LOCKDEBUG)
@@ -58,7 +58,7 @@ ENTRY(mutex_enter)
 	sethi	%hi(CURLWP), %o1
 	LDPTR	[%o1 + %lo(CURLWP)], %o1	! current thread
 	CASPTR	[%o0], %g0, %o1			! compare-and-swap
-	MB_READ
+	MB_ACQ
 	brnz,pn	%o1, 1f! lock was unowned?
 	 nop
 	retl	! - yes, done
@@ -76,7 +76,7 @@ ENTRY(mutex_exit)
 	sethi	%hi(CURLWP), %o1
 	LDPTR	[%o1 + %lo(CURLWP)], %o1	! current thread
 	clr	%o2! new value (0)
-	MB_MEM
+	MB_REL
 	CASPTR	[%o0], %o1, %o2			! compare-and-swap
 	cmp	%o1, %o2
 	bne,pn	CCCR, 1f			! nope, hard case



CVS commit: src/sys/arch/sparc64/sparc64

2023-02-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 20 13:30:36 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: lock_stubs.s

Log Message:
sparc64: Rename internal barrier macros to be clearer.

No functional change intended.


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

2023-02-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 20 13:30:23 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: lock_stubs.s

Log Message:
sparc64: Add missing LoadStore ordering for mutex_enter stub.

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


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/sparc64/lock_stubs.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/sparc64/sparc64/lock_stubs.s
diff -u src/sys/arch/sparc64/sparc64/lock_stubs.s:1.11 src/sys/arch/sparc64/sparc64/lock_stubs.s:1.12
--- src/sys/arch/sparc64/sparc64/lock_stubs.s:1.11	Wed Apr  6 22:47:57 2022
+++ src/sys/arch/sparc64/sparc64/lock_stubs.s	Mon Feb 20 13:30:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.11 2022/04/06 22:47:57 riastradh Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.12 2023/02/20 13:30:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 #define	CURLWP	(CPUINFO_VA+CI_CURLWP)
 
 #if defined(MULTIPROCESSOR)
-#define	MB_READ	membar #LoadLoad
+#define	MB_READ	membar #LoadLoad | #LoadStore
 #define	MB_MEM	membar #LoadStore | #StoreStore
 #else
 #define	MB_READ	/* nothing */



CVS commit: src/sys/arch/sparc64/sparc64

2023-02-20 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 20 13:30:23 UTC 2023

Modified Files:
src/sys/arch/sparc64/sparc64: lock_stubs.s

Log Message:
sparc64: Add missing LoadStore ordering for mutex_enter stub.

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


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

2023-01-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jan 24 23:23:31 UTC 2023

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

Log Message:
sparc64/db_trace.c: Don't dereference; use db_read_bytes.

Makes crash(8) and ddb match, and avoids crashing in ddb when you
feed in a bad lwp pointer!


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.56 src/sys/arch/sparc64/sparc64/db_trace.c:1.57
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.56	Tue Jan 24 23:23:12 2023
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Tue Jan 24 23:23:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.56 2023/01/24 23:23:12 riastradh Exp $ */
+/*	$NetBSD: db_trace.c,v 1.57 2023/01/24 23:23:31 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.56 2023/01/24 23:23:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.57 2023/01/24 23:23:31 riastradh Exp $");
 
 #include 
 #include 
@@ -127,12 +127,8 @@ db_stack_trace_print(db_expr_t addr, boo
 			}
 			(*pr)("lid %d ", l.l_lid);
 			pcb = lwp_getpcb();
-#ifndef _KERNEL
 			db_read_bytes((db_addr_t)>pcb_sp,
 			sizeof(frame), (char *));
-#else
-			frame = (vaddr_t)pcb->pcb_sp;
-#endif
 			(*pr)("at %p\n", frame);
 		} else {
 			frame = (vaddr_t)addr;



CVS commit: src/sys/arch/sparc64/sparc64

2023-01-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jan 24 23:23:31 UTC 2023

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

Log Message:
sparc64/db_trace.c: Don't dereference; use db_read_bytes.

Makes crash(8) and ddb match, and avoids crashing in ddb when you
feed in a bad lwp pointer!


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

2023-01-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jan 24 23:23:12 UTC 2023

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

Log Message:
sparc64/db_trace.c: Nix trailing whitespace.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.55 src/sys/arch/sparc64/sparc64/db_trace.c:1.56
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.55	Sun May 31 11:28:52 2020
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Tue Jan 24 23:23:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $ */
+/*	$NetBSD: db_trace.c,v 1.56 2023/01/24 23:23:12 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.56 2023/01/24 23:23:12 riastradh Exp $");
 
 #include 
 #include 
@@ -57,7 +57,7 @@ void db_print_window(uint64_t);
 #endif
 
 #ifdef _KERNEL
-#define	KLOAD(x)	probeget((paddr_t)(u_long)&(x), ASI_PRIMARY, sizeof(x))	
+#define	KLOAD(x)	probeget((paddr_t)(u_long)&(x), ASI_PRIMARY, sizeof(x))
 #else
 static long
 kload(db_addr_t addr)
@@ -153,12 +153,12 @@ db_stack_trace_print(db_expr_t addr, boo
 		if (frame & 1) {
 			f64 = (struct frame64 *)(frame + BIAS);
 			pc = (db_addr_t)KLOAD(f64->fr_pc);
-		
+
 			frame = KLOAD(f64->fr_fp);
 		} else {
 			f32 = (struct frame32 *)(frame);
 			pc = (db_addr_t)KLOAD(f32->fr_pc);
-		
+
 			frame = (long)KLOAD(f32->fr_fp);
 		}
 
@@ -175,13 +175,13 @@ db_stack_trace_print(db_expr_t addr, boo
 		if (!INKERNEL(frame))
 			break;
 #endif
-		
+
 		db_find_sym_and_offset(pc, , );
 		if (name == NULL)
 			name = "?";
-		
+
 		(*pr)("%s(", name);
-		
+
 		/*
 		 * Print %i0..%i5; hope these still reflect the
 		 * actual arguments somewhat...
@@ -216,7 +216,7 @@ db_dump_window(db_expr_t addr, bool have
 
 	/* Traverse window stack */
 	for (i=0; ifr_fp;
 		else frame = (uint64_t)((struct frame32 *)(u_long)frame)->fr_fp;
 	}
@@ -226,13 +226,13 @@ db_dump_window(db_expr_t addr, bool have
 }
 #endif
 
-void 
+void
 db_print_window(uint64_t frame)
 {
 	if (frame & 1) {
 		struct frame64* f = (struct frame64*)(u_long)(frame + BIAS);
 
-		db_printf("frame64 %p locals, ins:\n", f);		
+		db_printf("frame64 %p locals, ins:\n", f);
 		if (INKERNEL(f)) {
 			db_printf("%llx %llx %llx %llx ",
   (unsigned long long)f->fr_local[0],
@@ -245,12 +245,12 @@ db_print_window(uint64_t frame)
   (unsigned long long)f->fr_local[6],
   (unsigned long long)f->fr_local[7]);
 			db_printf("%llx %llx %llx %llx ",
-  (unsigned long long)f->fr_arg[0],	
+  (unsigned long long)f->fr_arg[0],
   (unsigned long long)f->fr_arg[1],
   (unsigned long long)f->fr_arg[2],
   (unsigned long long)f->fr_arg[3]);
 			db_printf("%llx %llx %llx=sp %llx=pc:",
-  (unsigned long long)f->fr_arg[4],	
+  (unsigned long long)f->fr_arg[4],
   (unsigned long long)f->fr_arg[5],
   (unsigned long long)f->fr_fp,
   (unsigned long long)f->fr_pc);
@@ -276,7 +276,7 @@ db_print_window(uint64_t frame)
   (unsigned long long)f->fr_arg[5],
   (unsigned long long)f->fr_fp,
   (unsigned long long)f->fr_pc);
-			db_printf("\n");	 
+			db_printf("\n");
 		}
 	} else {
 		struct frame32* f = (struct frame32*)(u_long)frame;
@@ -297,14 +297,14 @@ db_print_window(uint64_t frame)
 			if (copyin(f, , sizeof(fr))) return;
 			f = 
 			db_printf("%8x %8x %8x %8x %8x %8x %8x %8x\n",
-  f->fr_local[0], f->fr_local[1], 
+  f->fr_local[0], f->fr_local[1],
   f->fr_local[2], f->fr_local[3],
-  f->fr_local[4], f->fr_local[5], 
+  f->fr_local[4], f->fr_local[5],
   f->fr_local[6], f->fr_local[7]);
 			db_printf("%8x %8x %8x %8x %8x %8x %8x=sp %8x=pc\n",
-  f->fr_arg[0], f->fr_arg[1], 
+  f->fr_arg[0], f->fr_arg[1],
   f->fr_arg[2], f->fr_arg[3],
-  f->fr_arg[4], f->fr_arg[5], 
+  f->fr_arg[4], f->fr_arg[5],
   f->fr_fp, f->fr_pc);
 		}
 	}
@@ -391,7 +391,7 @@ db_dump_trap(db_expr_t addr, bool have_a
 		  tf, (unsigned long long)tf->tf_tstate,
 		  (unsigned long long)tf->tf_pc,
 		  (unsigned long long)tf->tf_npc);
-	db_printf("y: %x\tpil: %d\toldpil: %d\tfault: %llx\ttt: %x\tGlobals:\n", 
+	db_printf("y: %x\tpil: %d\toldpil: %d\tfault: %llx\ttt: %x\tGlobals:\n",
 		  (int)tf->tf_y, (int)tf->tf_pil, (int)tf->tf_oldpil,
 		  (unsigned long long)tf->tf_fault, (int)tf->tf_tt);
 	db_printf("%016llx %016llx %016llx %016llx\n",



CVS commit: src/sys/arch/sparc64/sparc64

2023-01-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jan 24 23:23:12 UTC 2023

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

Log Message:
sparc64/db_trace.c: Nix trailing whitespace.

No functional change intended.


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

2022-05-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May 16 21:28:06 UTC 2022

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h locore.s trap.c

Log Message:
try to handle ultrasparc III* "fast ecc error" traps.

i had a sunblade 2500 reset with this trap recently, and the
manual says it should have been recoverable.  in particular,
the US IIIv2 manual says in section 12.4.4.2 that the i-cache
won't see this data ever (so nothing needed there), and that
the d-cache needs to be disabled, and all the entries flushed,
and then re-enabled.

tested with a "trap 0x70" from kernel space, that trap.c
converted the "0x170" back to "0x70" (with an ADVANCE).  this
code not commited.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.427 -r1.428 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.193 -r1.194 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/cache.h
diff -u src/sys/arch/sparc64/sparc64/cache.h:1.30 src/sys/arch/sparc64/sparc64/cache.h:1.31
--- src/sys/arch/sparc64/sparc64/cache.h:1.30	Sat Dec 11 19:24:21 2021
+++ src/sys/arch/sparc64/sparc64/cache.h	Mon May 16 21:28:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cache.h,v 1.30 2021/12/11 19:24:21 mrg Exp $ */
+/*	$NetBSD: cache.h,v 1.31 2022/05/16 21:28:05 mrg Exp $ */
 
 /*
  * Copyright (c) 2011 Matthew R. Green
@@ -93,6 +93,7 @@ extern	int	icache_size;
 void 	dcache_flush_page_us(paddr_t);	/* flush page from D$ */
 void 	dcache_flush_page_usiii(paddr_t); /* flush page from D$ */
 void 	sp_blast_dcache(int, int);	/* Clear entire D$ */
+void 	sp_blast_dcache_disabled(int, int); /* Above with D$ disable. */
 void 	blast_icache_us(void);		/* Clear entire I$ */
 void 	blast_icache_usiii(void);	/* Clear entire I$ */
 

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.427 src/sys/arch/sparc64/sparc64/locore.s:1.428
--- src/sys/arch/sparc64/sparc64/locore.s:1.427	Sat Apr  3 17:01:24 2021
+++ src/sys/arch/sparc64/sparc64/locore.s	Mon May 16 21:28:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.427 2021/04/03 17:01:24 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.428 2022/05/16 21:28:05 mrg Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6193,8 +6193,10 @@ ENTRY(sp_tlb_flush_all_usiii)
 
 /*
  * sp_blast_dcache(int dcache_size, int dcache_line_size)
+ * sp_blast_dcache_disabled(int dcache_size, int dcache_line_size)
  *
- * Clear out all of D$ regardless of contents
+ * Clear out all of D$ regardless of contents.  The latter one also
+ * disables the D$ while doing so.
  */
 	.align 8
 ENTRY(sp_blast_dcache)
@@ -6227,6 +6229,46 @@ ENTRY(sp_blast_dcache)
 	 wrpr	%o3, %pstate
 #endif
 
+	.align 8
+ENTRY(sp_blast_dcache_disabled)
+/*
+ * We turn off interrupts for the duration to prevent RED exceptions.
+ */
+#ifdef PROF
+	save	%sp, -CC64FSZ, %sp
+#endif
+
+	rdpr	%pstate, %o3
+	sub	%o0, %o1, %o0
+	andn	%o3, PSTATE_IE, %o4			! Turn off PSTATE_IE bit
+	wrpr	%o4, 0, %pstate
+
+	ldxa[%g0] ASI_MCCR, %o5
+	andn	%o5, MCCR_DCACHE_EN, %o4		! Turn off the D$
+	stxa	%o4, [%g0] ASI_MCCR
+	flush 	%g0
+
+1:
+	stxa	%g0, [%o0] ASI_DCACHE_TAG
+	membar	#Sync
+	brnz,pt	%o0, 1b
+	 sub	%o0, %o1, %o0
+
+	sethi	%hi(KERNBASE), %o2
+	flush	%o2
+	membar	#Sync
+
+	stxa	%o5, [%g0] ASI_MCCR			! Restore the D$
+	flush 	%g0
+#ifdef PROF
+	wrpr	%o3, %pstate
+	ret
+	 restore
+#else
+	retl
+	 wrpr	%o3, %pstate
+#endif
+
 #ifdef MULTIPROCESSOR
 /*
  * void sparc64_ipi_blast_dcache(int dcache_size, int dcache_line_size)

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.193 src/sys/arch/sparc64/sparc64/trap.c:1.194
--- src/sys/arch/sparc64/sparc64/trap.c:1.193	Tue Feb  2 08:18:42 2021
+++ src/sys/arch/sparc64/sparc64/trap.c	Mon May 16 21:28:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $ */
+/*	$NetBSD: trap.c,v 1.194 2022/05/16 21:28:05 mrg Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.194 2022/05/16 21:28:05 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -561,6 +561,11 @@ trap(struct trapframe64 *tf, unsigned in
 		} else if (type == T_ECCERR) {
 			ecc_corrected_error(type, pc);
 			return;
+		} else if (type == T_FAST_ECC_ERROR) {
+			/* Disable D$, clear error, enable D$, continue. */
+			membar_Sync();
+			sp_blast_dcache_disabled(dcache_size, dcache_line_size);
+			return;
 		}
 		goto dopanic;
 	}



CVS commit: src/sys/arch/sparc64/sparc64

2022-05-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon May 16 21:28:06 UTC 2022

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h locore.s trap.c

Log Message:
try to handle ultrasparc III* "fast ecc error" traps.

i had a sunblade 2500 reset with this trap recently, and the
manual says it should have been recoverable.  in particular,
the US IIIv2 manual says in section 12.4.4.2 that the i-cache
won't see this data ever (so nothing needed there), and that
the d-cache needs to be disabled, and all the entries flushed,
and then re-enabled.

tested with a "trap 0x70" from kernel space, that trap.c
converted the "0x170" back to "0x70" (with an ADVANCE).  this
code not commited.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.427 -r1.428 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.193 -r1.194 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2022-04-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  6 22:48:22 UTC 2022

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

Log Message:
sparc64/pmap: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.314 -r1.315 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.314 src/sys/arch/sparc64/sparc64/pmap.c:1.315
--- src/sys/arch/sparc64/sparc64/pmap.c:1.314	Sat Mar 12 15:32:31 2022
+++ src/sys/arch/sparc64/sparc64/pmap.c	Wed Apr  6 22:48:21 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.314 2022/03/12 15:32:31 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.315 2022/04/06 22:48:21 riastradh Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.314 2022/03/12 15:32:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.315 2022/04/06 22:48:21 riastradh Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -163,6 +163,7 @@ static void ctx_free(struct pmap *, stru
 static __inline void
 dmmu_set_secondary_context(uint ctx)
 {
+
 	if (!CPU_ISSUN4V)
 		__asm volatile(
 			"stxa %0,[%1]%2;	"
@@ -175,7 +176,6 @@ dmmu_set_secondary_context(uint ctx)
 			"membar #Sync		"
 			: : "r" (ctx), "r" (CTX_SECONDARY), "n" (ASI_MMU_CONTEXTID)
 			: "memory");
-		
 }
 
 /*
@@ -564,7 +564,7 @@ pmap_mp_init(void)
 			if (CPU_ISSUN4V)
 tp[i].data |= SUN4V_TLB_X;
 		}
-			
+
 		DPRINTF(PDB_BOOT1, ("xtlb[%d]: Tag: %" PRIx64 " Data: %"
 PRIx64 "\n", i, tp[i].tag, tp[i].data));
 	}



CVS commit: src/sys/arch/sparc64/sparc64

2022-04-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Apr  6 22:48:22 UTC 2022

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

Log Message:
sparc64/pmap: Nix trailing whitespace.


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

2022-01-09 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Jan  9 20:30:04 UTC 2022

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

Log Message:
sun4v: enable sun4v_intr_xxx() function previously imported from OpenBSD. Note 
that the sun4v_intr_devino_to_sysino() function is adapted to match OpenBSD 
version 1.57 (the introduction of INTR_DEVINO is done in revision 1.58)


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

2022-01-09 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Jan  9 20:30:04 UTC 2022

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

Log Message:
sun4v: enable sun4v_intr_xxx() function previously imported from OpenBSD. Note 
that the sun4v_intr_devino_to_sysino() function is adapted to match OpenBSD 
version 1.57 (the introduction of INTR_DEVINO is done in revision 1.58)


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/intr.c
diff -u src/sys/arch/sparc64/sparc64/intr.c:1.70 src/sys/arch/sparc64/sparc64/intr.c:1.71
--- src/sys/arch/sparc64/sparc64/intr.c:1.70	Sat Jul  3 19:18:55 2021
+++ src/sys/arch/sparc64/sparc64/intr.c	Sun Jan  9 20:30:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.70 2021/07/03 19:18:55 palle Exp $ */
+/*	$NetBSD: intr.c,v 1.71 2022/01/09 20:30:04 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.70 2021/07/03 19:18:55 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.71 2022/01/09 20:30:04 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -368,22 +368,16 @@ softint_trigger(uintptr_t machdep)
 
 uint64_t sun4v_group_interrupt_major;
 
-#if 0
-XXX notyet
-wint64_t
+int64_t
 sun4v_intr_devino_to_sysino(uint64_t devhandle, uint64_t devino, uint64_t *ino)
 {
 	if (sun4v_group_interrupt_major < 3)
 		return hv_intr_devino_to_sysino(devhandle, devino, ino);
 
-	KASSERT(INTVEC(devino) == devino);
-	*ino = devino | INTR_DEVINO;
+	*ino = devino;
 	return H_EOK;
 }
-#endif
 
-#if 0
-XXX notyet		
 int64_t
 sun4v_intr_setcookie(uint64_t devhandle, uint64_t ino, uint64_t cookie_value)
 {
@@ -392,10 +386,7 @@ sun4v_intr_setcookie(uint64_t devhandle,
 	
 	return hv_vintr_setcookie(devhandle, ino, cookie_value);
 }
-#endif
 
-#if 0
-XXX notyet		
 int64_t
 sun4v_intr_setenabled(uint64_t devhandle, uint64_t ino, uint64_t intr_enabled)
 {
@@ -404,10 +395,7 @@ sun4v_intr_setenabled(uint64_t devhandle
 
 	return hv_vintr_setenabled(devhandle, ino, intr_enabled);
 }
-#endif
 
-#if 0
-XXX notyet		
 int64_t
 sun4v_intr_setstate(uint64_t devhandle, uint64_t ino, uint64_t intr_state)
 {
@@ -416,10 +404,7 @@ sun4v_intr_setstate(uint64_t devhandle, 
 
 	return hv_vintr_setstate(devhandle, ino, intr_state);
 }
-#endif
 
-#if 0
-XXX notyet		
 int64_t
 sun4v_intr_settarget(uint64_t devhandle, uint64_t ino, uint64_t cpuid)
 {
@@ -428,6 +413,5 @@ sun4v_intr_settarget(uint64_t devhandle,
 
 	return hv_vintr_settarget(devhandle, ino, cpuid);
 }
-#endif
 
 #endif



CVS commit: src/sys/arch/sparc64/sparc64

2022-01-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jan  1 11:56:15 UTC 2022

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

Log Message:
Remove an "#ifdef DIAGNOSTIC", KASSERT() always conumes its expression.


To generate a diff of this commit:
cvs rdiff -u -r1.312 -r1.313 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.312 src/sys/arch/sparc64/sparc64/pmap.c:1.313
--- src/sys/arch/sparc64/sparc64/pmap.c:1.312	Sat Mar 14 14:05:43 2020
+++ src/sys/arch/sparc64/sparc64/pmap.c	Sat Jan  1 11:56:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.312 2020/03/14 14:05:43 ad Exp $	*/
+/*	$NetBSD: pmap.c,v 1.313 2022/01/01 11:56:15 hannken Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.312 2020/03/14 14:05:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.313 2022/01/01 11:56:15 hannken Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -1537,9 +1537,7 @@ pmap_destroy(struct pmap *pm)
 
 	/* we could be a little smarter and leave pages zeroed */
 	while ((pg = TAILQ_FIRST(>pm_ptps)) != NULL) {
-#ifdef DIAGNOSTIC
 		struct vm_page_md *md = VM_PAGE_TO_MD(pg);
-#endif
 
 		TAILQ_REMOVE(>pm_ptps, pg, pageq.queue);
 		KASSERT(md->mdpg_pvh.pv_pmap == NULL);



CVS commit: src/sys/arch/sparc64/sparc64

2022-01-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jan  1 11:56:15 UTC 2022

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

Log Message:
Remove an "#ifdef DIAGNOSTIC", KASSERT() always conumes its expression.


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

2019-07-18 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Jul 18 18:21:45 UTC 2019

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

Log Message:
sun4v: added some missing comments to the code in pcbspill


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

2019-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 22 15:10:13 UTC 2019

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

Log Message:
Add missing include to fix the crash(8) build, from Tobias Ulmer, PR 
port-sparc64/54221


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.52 src/sys/arch/sparc64/sparc64/db_trace.c:1.53
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.52	Wed May 22 07:40:09 2019
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Wed May 22 15:10:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.52 2019/05/22 07:40:09 martin Exp $ */
+/*	$NetBSD: db_trace.c,v 1.53 2019/05/22 15:10:13 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.52 2019/05/22 07:40:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.53 2019/05/22 15:10:13 martin Exp $");
 
 #include 
 #include 
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 



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

2019-05-22 Thread Tobias Ulmer
Oh, should've tested that. Survived kernels and distribution:

diff --git a/sys/arch/sparc64/sparc64/db_trace.c 
b/sys/arch/sparc64/sparc64/db_trace.c
index f5e35e79dd51..d94e5eb2d2ef 100644
--- a/sys/arch/sparc64/sparc64/db_trace.c
+++ b/sys/arch/sparc64/sparc64/db_trace.c
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.52 2019/05/22 
07:40:09 martin Exp $")
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 


On Wed, May 22, 2019 at 03:02:13PM +0200, J. Hannken-Illjes wrote:
> This breaks the build of usr.sbin/crash:
> 
> /work/build/src/usr.sbin/crash/../../sys/arch/sparc64/sparc64/db_trace.c: In 
> function 'db_stack_trace_print':
> /work/build/src/usr.sbin/crash/../../sys/arch/sparc64/sparc64/db_trace.c:166:37:
>  error: 'VM_MAX_KERNEL_ADDRESS' undeclared (first use in this function); did 
> you mean 'VM_MAXADDRESS'?
> if (frame < KERNBASE || frame >= VM_MAX_KERNEL_ADDRESS)
>  ^
>  VM_MAXADDRESS
> /work/build/src/usr.sbin/crash/../../sys/arch/sparc64/sparc64/db_trace.c:166:37:
>  note: each undeclared identifier is reported only once for each function it 
> appears in
> 
> --
> J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig
> 
> > On 22. May 2019, at 09:40, Martin Husemann  wrote:
> > 
> > Module Name:src
> > Committed By:   martin
> > Date:   Wed May 22 07:40:09 UTC 2019
> > 
> > Modified Files:
> > src/sys/arch/sparc64/sparc64: db_trace.c
> > 
> > Log Message:
> > Fix previous and use the original patch from PR port-sparc64/54221
> > instead (XXX should fix comments in param.h)
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.51 -r1.52 src/sys/arch/sparc64/sparc64/db_trace.c
> > 
> > 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/sparc64/sparc64

2019-05-22 Thread J. Hannken-Illjes
This breaks the build of usr.sbin/crash:

/work/build/src/usr.sbin/crash/../../sys/arch/sparc64/sparc64/db_trace.c: In 
function 'db_stack_trace_print':
/work/build/src/usr.sbin/crash/../../sys/arch/sparc64/sparc64/db_trace.c:166:37:
 error: 'VM_MAX_KERNEL_ADDRESS' undeclared (first use in this function); did 
you mean 'VM_MAXADDRESS'?
if (frame < KERNBASE || frame >= VM_MAX_KERNEL_ADDRESS)
 ^
 VM_MAXADDRESS
/work/build/src/usr.sbin/crash/../../sys/arch/sparc64/sparc64/db_trace.c:166:37:
 note: each undeclared identifier is reported only once for each function it 
appears in

--
J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig

> On 22. May 2019, at 09:40, Martin Husemann  wrote:
> 
> Module Name:  src
> Committed By: martin
> Date: Wed May 22 07:40:09 UTC 2019
> 
> Modified Files:
>   src/sys/arch/sparc64/sparc64: db_trace.c
> 
> Log Message:
> Fix previous and use the original patch from PR port-sparc64/54221
> instead (XXX should fix comments in param.h)
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.51 -r1.52 src/sys/arch/sparc64/sparc64/db_trace.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 



signature.asc
Description: Message signed with OpenPGP


CVS commit: src/sys/arch/sparc64/sparc64

2019-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 22 07:40:09 UTC 2019

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

Log Message:
Fix previous and use the original patch from PR port-sparc64/54221
instead (XXX should fix comments in param.h)


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

2019-05-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 22 07:40:09 UTC 2019

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

Log Message:
Fix previous and use the original patch from PR port-sparc64/54221
instead (XXX should fix comments in param.h)


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.51 src/sys/arch/sparc64/sparc64/db_trace.c:1.52
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.51	Wed May 22 04:17:39 2019
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Wed May 22 07:40:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.51 2019/05/22 04:17:39 martin Exp $ */
+/*	$NetBSD: db_trace.c,v 1.52 2019/05/22 07:40:09 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.51 2019/05/22 04:17:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.52 2019/05/22 07:40:09 martin Exp $");
 
 #include 
 #include 
@@ -163,7 +163,7 @@ db_stack_trace_print(db_expr_t addr, boo
 		if (kernel_only) {
 			if (pc < KERNBASE || pc >= KERNEND)
 break;
-			if (frame < KERNBASE || frame >= KERNEND)
+			if (frame < KERNBASE || frame >= VM_MAX_KERNEL_ADDRESS)
 break;
 		} else {
 			if (frame == 0 || frame == (vaddr_t)-1)



CVS commit: src/sys/arch/sparc64/sparc64

2019-05-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 22 04:17:39 UTC 2019

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

Log Message:
Relax test for valid stack frame address (now that we have multiple kernel
stacks since ... a long time). Just test for a valid kernel VA, using
the same test as for "pc".
Very close to a patch suggested by Tobias Ulmer in PR port-sparc64/54221.


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

2019-05-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 22 04:17:39 UTC 2019

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

Log Message:
Relax test for valid stack frame address (now that we have multiple kernel
stacks since ... a long time). Just test for a valid kernel VA, using
the same test as for "pc".
Very close to a patch suggested by Tobias Ulmer in PR port-sparc64/54221.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.50 src/sys/arch/sparc64/sparc64/db_trace.c:1.51
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.50	Mon Mar  4 20:17:46 2013
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Wed May 22 04:17:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.50 2013/03/04 20:17:46 christos Exp $ */
+/*	$NetBSD: db_trace.c,v 1.51 2019/05/22 04:17:39 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.50 2013/03/04 20:17:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.51 2019/05/22 04:17:39 martin Exp $");
 
 #include 
 #include 
@@ -163,7 +163,7 @@ db_stack_trace_print(db_expr_t addr, boo
 		if (kernel_only) {
 			if (pc < KERNBASE || pc >= KERNEND)
 break;
-			if (frame < KERNBASE || frame >= EINTSTACK)
+			if (frame < KERNBASE || frame >= KERNEND)
 break;
 		} else {
 			if (frame == 0 || frame == (vaddr_t)-1)



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

2019-01-04 Thread matthew green
"Martin Husemann" writes:
> Module Name:  src
> Committed By: martin
> Date: Fri Jan  4 16:25:06 UTC 2019
> 
> Modified Files:
>   src/sys/arch/sparc64/sparc64: autoconf.c
> 
> Log Message:
> PR port-sparc64/53830: adapt QEMU workarounds to newer OpenBIOS device
> tree layout.

why this part?

+   regs[0] = 42;

it seems useless.

thanks.


.mrg.


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

2017-08-27 Thread matthew green
"Palle Lyckegaard" writes:
> Module Name:  src
> Committed By: palle
> Date: Sun Aug 27 19:31:44 UTC 2017
> 
> Modified Files:
>   src/sys/arch/sparc64/sparc64: cpu.c
> 
> Log Message:
> sun4v: Change clk and sclk variables to unsigned type so modern faster
> systems with CPU frequencies above 2 Ghz are shown correctly. Example
> is a 3599.910 MHz SPARC T5-2 system that otherwise is shown
> incorrectly as -695.-57 MHz. Based on code from OpenBSD cpu.c rev.
> 1.41. Verified on sun4u using qemu and sun4v on SPARC T5-2

cool :)

shouldn't we move to a 64 bit value?  4.3ghz isn't far away from 3.6..


.mrg.


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

2017-02-12 Thread Palle Lyckegaard

fixed thanks



On Sun, 12 Feb 2017, Takeshi Nakayama wrote:


Date: Sun, 12 Feb 2017 04:28:58
From: Takeshi Nakayama <nakay...@netbsd.org>
To: source-changes-d@NetBSD.org, pa...@netbsd.org
Subject: Re: CVS commit: src/sys/arch/sparc64/sparc64


"Palle Lyckegaard" <pa...@netbsd.org> wrote



Module Name:src
Committed By:   palle
Date:   Sat Feb 11 23:41:36 UTC 2017

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

Log Message:
sun4v: Fix calculation of mmu data fault address (pointer arithmetic)


paddr_t is "unsigned long int" or "unsigned long long int", so not
a pointer.  Why did you add "/ sizeof(paddr_t)" ?

-- Takeshi Nakayama



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

2017-02-11 Thread Takeshi Nakayama
>>> "Palle Lyckegaard"  wrote

> Module Name:  src
> Committed By: palle
> Date: Sat Feb 11 23:41:36 UTC 2017
> 
> Modified Files:
>   src/sys/arch/sparc64/sparc64: trap.c
> 
> Log Message:
> sun4v: Fix calculation of mmu data fault address (pointer arithmetic)

paddr_t is "unsigned long int" or "unsigned long long int", so not
a pointer.  Why did you add "/ sizeof(paddr_t)" ?

-- Takeshi Nakayama


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

2015-11-22 Thread matthew green
thanks for fixing these problems.  i was espcially amused by the
code that was if (copyout() || copyout() || suword()).

> Modified Files:
>   src/sys/arch/sparc64/sparc64: machdep.c netbsd32_machdep.c
>   sunos_machdep.c
> 
> Log Message:
> remove all MD uses of suword(), replace by copyout()

hmm..

+   sp = (register32_t)(uintptr_t)oldsp;

there are macros for doing this, aren't there?

i have an uncommited patch for netbsd32 that adds checks to ensure
that any such "truncation" actually doesn't modify the value if
DIAGNOSTIC, and it should apply to the above, but it's really hard
to find the above in other code...

thanks.


.mrg.


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

2015-11-08 Thread matthew green
> Module Name:  src
> Committed By: christos
> Date: Mon Nov  9 02:13:41 UTC 2015
> 
> Modified Files:
>   src/sys/arch/sparc64/sparc64: syscall.c
> 
> Log Message:
> fix printf formats.

yuck, can't you just use PRId64 instead of the casts?  these are
int64 members.  also, using %# vs 0x% :-)


.mrg.


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

2014-11-03 Thread Palle Lyckegaard

On Mon, 3 Nov 2014, matthew green wrote:


we don't need the #ifdef's here.  CPU_ISSUN4V is 0 for
normal kernels, so the above is compiled out anyway.
there's a bunch of other places this is done as well that
we don't need it.. could you this up at some point?




sure will do


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

2014-11-03 Thread matthew green

  we don't need the #ifdef's here.  CPU_ISSUN4V is 0 for
  normal kernels, so the above is compiled out anyway.
  there's a bunch of other places this is done as well that
  we don't need it.. could you this up at some point?

totally gimplished that up :-)  clean of course :-)

 sure will do

thanks.


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

2014-11-02 Thread matthew green

+ #ifdef SUN4V
+   if (CPU_ISSUN4V)
+   func = sparc64_ipi_dcache_flush_page_sun4v;
+   else if (CPU_IS_USIII_UP())
+ #else 
if (CPU_IS_USIII_UP())
+ #endif
func = sparc64_ipi_dcache_flush_page_usiii;

we don't need the #ifdef's here.  CPU_ISSUN4V is 0 for
normal kernels, so the above is compiled out anyway.
there's a bunch of other places this is done as well that
we don't need it.. could you this up at some point?

thanks.


.mrg.


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

2013-09-13 Thread Martin Husemann
On Thu, Sep 12, 2013 at 10:12:23PM +0900, Takeshi Nakayama wrote:
 This change provides a chance to select a prefer timecounter to
 users via sysctl kern.timecounter.hardware.
 
 stick-counter's quality is larger than tick-counter's one. The
 default choice becomes to stick-counter, so it's no problem.

Once we offer different cpu speeds we will have to stop adding %tick as
timesource option for that cpu, so this should automatically all work
well.

Martin


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

2013-09-12 Thread Takeshi Nakayama
 Michael macallan1...@gmail.com wrote

 Hello,
 
 on Thursday 22 August 2013 06:00:43 Takeshi Nakayama wrote:
  Module Name:src
  Committed By:   nakayama
  Date:   Thu Aug 22 10:00:43 UTC 2013
 
  Modified Files:
  src/sys/arch/sparc64/sparc64: clock.c
 
  Log Message:
  Make timecounter tick-counter mandatory.
 
 This is going to bite us when we actually mess with the CPU's clock speed ( 
 which is the whole point of using %stick and STICK )

This change provides a chance to select a prefer timecounter to
users via sysctl kern.timecounter.hardware.

stick-counter's quality is larger than tick-counter's one. The
default choice becomes to stick-counter, so it's no problem.

-- Takeshi Nakayama


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

2012-03-03 Thread David Laight
On Sat, Mar 03, 2012 at 03:17:32AM +, Takeshi Nakayama wrote:
 Module Name:  src
 Committed By: nakayama
 Date: Sat Mar  3 03:17:32 UTC 2012
 
 Modified Files:
   src/sys/arch/sparc64/sparc64: locore.s
 
 Log Message:
 Fix the root cause of the hack disable optimizations for uvm_bio.c
 on 32 bit kernels.
 
 gcc converts a division in the calculation of UBC_UMAP_ADDR macro
 to multiplication (smul or combination of add/sll), and the
 register of its result contains a garbage in upper 32 bits (the
 upper 32 bits of smul/add/sll's result isn't zero cleared).
 
 Then it passes to pseg_get{,_real} through pmap_extract without the
 zero clear of upper 32 bits in the optimization case.  So the
 result of pseg_get and pmap_extact sometimes gets screwed up.

Is that a gcc bug?

Or are the high register bits usually undefined for 32bit values,
and this to do with using 64bit asm in a 32bit kernel?

David

-- 
David Laight: da...@l8s.co.uk


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

2012-03-03 Thread Takeshi Nakayama
 David Laight da...@l8s.co.uk wrote

 Is that a gcc bug?

I don't know.

 Or are the high register bits usually undefined for 32bit values,
 and this to do with using 64bit asm in a 32bit kernel?

But I guess it's undefined from looking at the generated codes.
Our kernel code is shared between 32-bit and 64-bit, and 64-bit asm
is usually used in locore.s.

-- Takeshi Nakayama


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

2012-03-03 Thread Martin Husemann
On Sat, Mar 03, 2012 at 08:50:50AM +, David Laight wrote:
 
 Is that a gcc bug?

No, gcc calls a function with 32bit abi and expects it to ignore the upper bits
in that register.

The patch makes it so. Good catch!

Martin


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

2012-03-02 Thread Alistair Crooks
On Sat, Mar 03, 2012 at 03:17:32AM +, Takeshi Nakayama wrote:
 Module Name:  src
 Committed By: nakayama
 Date: Sat Mar  3 03:17:32 UTC 2012
 
 Modified Files:
   src/sys/arch/sparc64/sparc64: locore.s
 
 Log Message:
 Fix the root cause of the hack disable optimizations for uvm_bio.c
 on 32 bit kernels.
 
 gcc converts a division in the calculation of UBC_UMAP_ADDR macro
 to multiplication (smul or combination of add/sll), and the
 register of its result contains a garbage in upper 32 bits (the
 upper 32 bits of smul/add/sll's result isn't zero cleared).
 
 Then it passes to pseg_get{,_real} through pmap_extract without the
 zero clear of upper 32 bits in the optimization case.  So the
 result of pseg_get and pmap_extact sometimes gets screwed up.

Oh, good catch!

Thanks for fixing this one.

Best,
Al


CVS commit: src/sys/arch/sparc64/sparc64

2010-03-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Mar 10 06:57:23 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: db_interface.c locore.s pmap.c

Log Message:
XXX: workaround we'd like to remove when pmap / uvm locking is cleaned up:

- rename pseg_get() and pseg_set() to pseg_get_real() and pseg_set_real().
- if USE_LOCKSAFE_PSEG_GETSET is defined, which it current is by default,
  define pseg_[gs]et() in terms of functions that take a new pseg_lock
  mutex at IPL_VM while calling into the real functions.

this seems to avoid the pseg_set() crashes we've seen:
  1 - spare needed, when pseg_get() just worked for this pmap
  2 - the 2rd ldxa via ASI_PHYS_CACHED in pseg_set() loads garbage
  into %o4, and causes the 3rd ldxa to fault


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc64/sparc64/db_interface.c
cvs rdiff -u -r1.326 -r1.327 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.258 -r1.259 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2010-03-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Mar 10 06:57:23 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: db_interface.c locore.s pmap.c

Log Message:
XXX: workaround we'd like to remove when pmap / uvm locking is cleaned up:

- rename pseg_get() and pseg_set() to pseg_get_real() and pseg_set_real().
- if USE_LOCKSAFE_PSEG_GETSET is defined, which it current is by default,
  define pseg_[gs]et() in terms of functions that take a new pseg_lock
  mutex at IPL_VM while calling into the real functions.

this seems to avoid the pseg_set() crashes we've seen:
  1 - spare needed, when pseg_get() just worked for this pmap
  2 - the 2rd ldxa via ASI_PHYS_CACHED in pseg_set() loads garbage
  into %o4, and causes the 3rd ldxa to fault


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc64/sparc64/db_interface.c
cvs rdiff -u -r1.326 -r1.327 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.258 -r1.259 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/db_interface.c
diff -u src/sys/arch/sparc64/sparc64/db_interface.c:1.123 src/sys/arch/sparc64/sparc64/db_interface.c:1.124
--- src/sys/arch/sparc64/sparc64/db_interface.c:1.123	Sat Mar  6 08:08:29 2010
+++ src/sys/arch/sparc64/sparc64/db_interface.c	Wed Mar 10 06:57:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.123 2010/03/06 08:08:29 mrg Exp $ */
+/*	$NetBSD: db_interface.c,v 1.124 2010/03/10 06:57:22 mrg Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.123 2010/03/06 08:08:29 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_interface.c,v 1.124 2010/03/10 06:57:22 mrg Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -650,7 +650,8 @@
 	}
 }
 
-int64_t pseg_get(struct pmap *, vaddr_t);
+/* XXX no locking; shouldn't matter */
+int64_t pseg_get_real(struct pmap *, vaddr_t);
 
 void
 db_dump_pmap(struct pmap *pm)
@@ -706,7 +707,7 @@
 	if (have_addr) {
 		/* lookup an entry for this VA */
 		
-		if ((data = pseg_get(pmap_kernel(), (vaddr_t)addr))) {
+		if ((data = pseg_get_real(pmap_kernel(), (vaddr_t)addr))) {
 			db_printf(pmap_kernel(%p)-pm_segs[%lx][%lx][%lx]=%qx\n,
   (void *)(uintptr_t)addr, (u_long)va_to_seg(addr),
   (u_long)va_to_dir(addr), (u_long)va_to_pte(addr),

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.326 src/sys/arch/sparc64/sparc64/locore.s:1.327
--- src/sys/arch/sparc64/sparc64/locore.s:1.326	Mon Mar  8 08:59:06 2010
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Mar 10 06:57:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.326 2010/03/08 08:59:06 mrg Exp $	*/
+/*	$NetBSD: locore.s,v 1.327 2010/03/10 06:57:22 mrg Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6568,14 +6568,15 @@
 	retl
 	 mov	%o4, %g1		! Restore g1
 #endif
+
 /*
- * extern int64_t pseg_get(struct pmap *pm, vaddr_t addr);
+ * extern int64_t pseg_get_real(struct pmap *pm, vaddr_t addr);
  *
  * Return TTE at addr in pmap.  Uses physical addressing only.
  * pmap-pm_physaddr must by the physical address of pm_segs
  *
  */
-ENTRY(pseg_get)
+ENTRY(pseg_get_real)
 !	flushw			! Make sure we don't have stack probs  lose hibits of %o
 	ldx	[%o0 + PM_PHYS], %o2			! pmap-pm_segs
 
@@ -6637,13 +6638,13 @@
 /*
  * In 32-bit mode:
  *
- * extern int pseg_set(struct pmap* %o0, vaddr_t addr %o1, int64_t tte %o2:%o3,
- *			 paddr_t spare %o4:%o5);
+ * extern int pseg_set_real(struct pmap* %o0, vaddr_t addr %o1,
+ *			int64_t tte %o2:%o3, paddr_t spare %o4:%o5);
  *
  * In 64-bit mode:
  *
- * extern int pseg_set(struct pmap* %o0, vaddr_t addr %o1, int64_t tte %o2,
- *			paddr_t spare %o3);
+ * extern int pseg_set_real(struct pmap* %o0, vaddr_t addr %o1,
+ *			int64_t tte %o2, paddr_t spare %o3);
  *
  * Set a pseg entry to a particular TTE value.  Return values are:
  *
@@ -6673,7 +6674,7 @@
  * The counters are 32 bit or 64 bit wide, depending on the kernel type we are
  * running!
  */
-ENTRY(pseg_set)
+ENTRY(pseg_set_real)
 #ifndef _LP64
 	sllx	%o4, 32, %o4! Put args into 64-bit format
 	sllx	%o2, 32, %o2! Shift to high 32-bits

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.258 src/sys/arch/sparc64/sparc64/pmap.c:1.259
--- src/sys/arch/sparc64/sparc64/pmap.c:1.258	Mon Mar  8 08:59:06 2010
+++ src/sys/arch/sparc64/sparc64/pmap.c	Wed Mar 10 06:57:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.258 2010/03/08 08:59:06 mrg Exp $	*/
+/*	$NetBSD: pmap.c,v 1.259 2010/03/10 06:57:22 mrg Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.258 2010/03/08 08:59:06 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.259 

CVS commit: src/sys/arch/sparc64/sparc64

2010-03-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Mar  8 08:59:06 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h ipifuncs.c locore.s pmap.c

Log Message:
blast_dcache() SMP friendly:

- blast_dcache() becomes sp_blast_dcache(dcache_size, dcache_line_size)
- new smp_blast_dcache(sparc64_cpuset_t) that blasts the D$ on this cpuset
- sparc64_ipi_blast_dcache() to support the above
- in pmap_remove_all(), when freeing mmu contexts for this pmap, mark
  the set of cpus to blast the d$ on as well and convert the
  blast_dcache() call into smp_blast_dcache() on the cpus who ran this
  pmap, or, sp_blast_dcache(dcache_size, dcache_line_size)
- convert the remaining blast_dcache() in machdep.c to sp_blast_dcache()
- in pmap_destroy()/pmap_remove_all() take the pmap_lock() always since
  we assert it is held always.

with these changes, NFS builds on the U60 seem to be stable now, and
the USIII machines also can often complete a single build.sh run now,
diskful or diskless.

reviewed by mlelstv and partially by martin, tested by martin and myself,
with some ideas from chuq as well.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sparc64/sparc64/ipifuncs.c
cvs rdiff -u -r1.325 -r1.326 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.257 -r1.258 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2010-03-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Mar  8 04:18:48 UTC 2010

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

Log Message:
- when given boot -1, apply the !MULTIPROCESSOR cpu_match() criteria.

- don't print cache sizes * associativity.  this has been wrong for years.


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

2010-03-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Mar  8 04:18:48 UTC 2010

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

Log Message:
- when given boot -1, apply the !MULTIPROCESSOR cpu_match() criteria.

- don't print cache sizes * associativity.  this has been wrong for years.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.90 src/sys/arch/sparc64/sparc64/cpu.c:1.91
--- src/sys/arch/sparc64/sparc64/cpu.c:1.90	Sat Mar  6 08:08:29 2010
+++ src/sys/arch/sparc64/sparc64/cpu.c	Mon Mar  8 04:18:48 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.90 2010/03/06 08:08:29 mrg Exp $ */
+/*	$NetBSD: cpu.c,v 1.91 2010/03/08 04:18:48 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.90 2010/03/06 08:08:29 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.91 2010/03/08 04:18:48 mrg Exp $);
 
 #include opt_multiprocessor.h
 
@@ -198,14 +198,16 @@
 	if (strcmp(cf-cf_name, ma-ma_name) != 0)
 		return 0;
 
-#ifndef MULTIPROCESSOR
 	/*
 	 * If we are going to only attach a single cpu, make sure
 	 * to pick the one we are running on right now.
 	 */
-	if (upaid_from_node(ma-ma_node) != CPU_UPAID)
-		return 0;
+	if (upaid_from_node(ma-ma_node) != CPU_UPAID) {
+#ifdef MULTIPROCESSOR
+		if (boothowto  RB_MD1)
 #endif
+			return 0;
+	}
 
 	return 1;
 }
@@ -314,8 +316,7 @@
 		/* void */;
 	if ((1  i) != l  l)
 		panic(bad icache line size %d, l);
-	totalsize = icachesize *
-		prom_getpropint(node, icache-associativity, 1);
+	totalsize = icachesize;
 	if (totalsize == 0)
 		totalsize = l *
 			prom_getpropint(node, icache-nlines, 64) *
@@ -344,8 +345,7 @@
 		/* void */;
 	if ((1  i) != l  l)
 		panic(bad dcache line size %d, l);
-	totalsize = dcachesize *
-		prom_getpropint(node, dcache-associativity, 1);
+	totalsize = dcachesize;
 	if (totalsize == 0)
 		totalsize = l *
 			prom_getpropint(node, dcache-nlines, 128) *
@@ -369,9 +369,7 @@
 		/* void */;
 	if ((1  i) != l  l)
 		panic(bad ecache line size %d, l);
-	totalsize = 
-		prom_getpropint(node, ecache-size, 0) *
-		prom_getpropint(node, ecache-associativity, 1);
+	totalsize = prom_getpropint(node, ecache-size, 0);
 	if (totalsize == 0)
 		totalsize = l *
 			prom_getpropint(node, ecache-nlines, 32768) *



CVS commit: src/sys/arch/sparc64/sparc64

2010-03-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Mar  4 08:11:42 UTC 2010

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

Log Message:
avoid a build error in the previous for !DEBUG kernels.


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

2010-03-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Mar  4 08:11:42 UTC 2010

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

Log Message:
avoid a build error in the previous for !DEBUG kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.255 src/sys/arch/sparc64/sparc64/pmap.c:1.256
--- src/sys/arch/sparc64/sparc64/pmap.c:1.255	Thu Mar  4 08:01:35 2010
+++ src/sys/arch/sparc64/sparc64/pmap.c	Thu Mar  4 08:11:42 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.255 2010/03/04 08:01:35 mrg Exp $	*/
+/*	$NetBSD: pmap.c,v 1.256 2010/03/04 08:11:42 mrg Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.255 2010/03/04 08:01:35 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.256 2010/03/04 08:11:42 mrg Exp $);
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -308,8 +308,8 @@
 	int pvfirst;
 	int pvsearch;
 } remove_stats;
-#define	ENTER_STAT(x)	enter_stats.x ++
-#define	REMOVE_STAT(x)	remove_stats.x ++
+#define	ENTER_STAT(x)	do { enter_stats.x ++; } while (0)
+#define	REMOVE_STAT(x)	do { remove_stats.x ++; } while (0)
 
 #define	PDB_CREATE		0x01
 #define	PDB_DESTROY		0x02
@@ -339,8 +339,8 @@
 #define	BDPRINTF(n, f)	if (pmapdebug  (n)) prom_printf f
 #define	DPRINTF(n, f)	if (pmapdebug  (n)) printf f
 #else
-#define	ENTER_STAT(x)
-#define	REMOVE_STAT(x)
+#define	ENTER_STAT(x)	do { /* nothing */ } while (0)
+#define	REMOVE_STAT(x)	do { /* nothing */ } while (0)
 #define	BDPRINTF(n, f)
 #define	DPRINTF(n, f)
 #endif



CVS commit: src/sys/arch/sparc64/sparc64

2010-02-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb 28 11:43:40 UTC 2010

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

Log Message:
Add support for direct configuration of i2c devices


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

2010-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Mar  1 01:14:58 UTC 2010

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

Log Message:
Don't call frame-buffer-adr since it doesn't work as expected by the code
that got cargo culted over from macppc. While there shut up some leftover
debug printf.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.170 src/sys/arch/sparc64/sparc64/autoconf.c:1.171
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.170	Sun Feb 28 13:59:05 2010
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Mon Mar  1 01:14:58 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.170 2010/02/28 13:59:05 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.171 2010/03/01 01:14:58 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.170 2010/02/28 13:59:05 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.171 2010/03/01 01:14:58 macallan Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -1128,8 +1128,6 @@
 		prop_dictionary_set_uint32(dict, depth, 8);
 	}
 	OF_getprop(console_node, address, fbaddr, sizeof(fbaddr));
-	if (fbaddr == 0)
-		OF_interpret(frame-buffer-adr, 0, 1, fbaddr);
 	if (fbaddr != 0) {
 	
 		pmap_extract(pmap_kernel(), fbaddr, fbpa);
@@ -1164,7 +1162,6 @@
 		return;
 	if (OF_getprop(options, output-device, output_device, 256) == 0)
 		return;
-	printf(output-device: %s\n, output_device);
 	/* find the mode string if there is one */
 	pos = strstr(output_device, :r);
 	if (pos == NULL)



CVS commit: src/sys/arch/sparc64/sparc64

2010-02-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb 24 09:49:36 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h ipifuncs.c locore.s pmap.c

Log Message:
when handing back page table pages to UVM, flush them from the dcache
on all CPUs.

idea from skrll@, and makes my disk-based SB2000 stable.

tested on U60, SB2000 and SB2500.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc64/sparc64/ipifuncs.c
cvs rdiff -u -r1.320 -r1.321 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.252 -r1.253 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2010-02-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb 24 10:11:53 UTC 2010

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

Log Message:
check for TLB_V bit for valid tte entries, not against zero.
KASSERT() the 3rd call to pseg_get() in pmap_page_cache() like the other 2.


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

2010-02-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb 24 06:05:35 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h ipifuncs.c

Log Message:
fix MULTIPROCESSOR build for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc64/sparc64/ipifuncs.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/sparc64/sparc64

2010-02-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb 22 00:16:31 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c cache.h cpu.c locore.s

Log Message:
- store the maximum [id]cache size / line size for each cpu

- remove patch_kernel() since it isn't necessary and has been patching
  the wrong thing in general.

- implement USIII versions of blast_icache(), dcache_flush_page() and
  cache_flush_phys().  use the newly recorded cache size/line sizes.

- in winfixsave, flush the D$ with the right size index and ops.  this
  kills one of the wrong tag-inval patches.

- for blast_dcache(), use the newly recorded dcache_size/line_size.

- for blast_icache(), use the newly recorded cache size/line sizes.
  for the USIII verison, disable the I$ while writing to ASI_ICACHE_TAG.

these changes removed several hard coded cache sizes values, some very
wrong kernel patching, and seem to make the current failure modes for
USIII less common, but not gone.


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.168 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/sparc64/sparc64/cpu.c
cvs rdiff -u -r1.317 -r1.318 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2010-02-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb 15 09:56:34 UTC 2010

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

Log Message:
use TLB_SIZE_SPITFIRE in a couple of places, and note that the
{print,dump}_[id]tlb() versions are currently spitfire specific.


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

2010-02-15 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Mon Feb 15 11:46:54 UTC 2010

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

Log Message:
Fix linker error of GENERIC32 kernel.


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

2010-02-15 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb 15 12:46:24 UTC 2010

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

Log Message:
- don't flush 32-bit entries for 64-bit code, it does not seem to be
  necessary.  #define TLB_FLUSH_LOWVA to turn it back on.
- remove the #if 0'd code in sparc64_ipi_flush_pte_usiii(), i have
  verified that it is not required.
- add a missing membar #Sync to sp_tlb_flush_pte_usiii().


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

2010-02-13 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Feb 13 08:56:29 UTC 2010

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

Log Message:
in pmap_growkernel(), make sure we only mutex_exit() if we mutex_enter()ed.


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

2010-02-13 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Feb 13 22:29:55 UTC 2010

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

Log Message:
remove KTR support.  it's never been a working part of netbsd src tree.


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

2010-02-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  2 03:07:06 UTC 2010

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

Log Message:
for now, reduce a few #ifdef SPITFIRE cases by introducing a new
ASI_DCACHE_TAG_OR_INV that is either ASI_DCACHE_{TAG,_INVALIDATE}.

increase the common code in cache_flush_phys().


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

2010-01-31 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Feb  1 03:43:27 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h locore.s

Log Message:
remove unused icache_flush_page() implementation.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/sparc64/cache.h
cvs rdiff -u -r1.305 -r1.306 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64

2010-01-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jan 23 21:46:59 UTC 2010

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

Log Message:
fix a comment.


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

2010-01-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jan 23 22:55:04 UTC 2010

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

Log Message:
remove CHKPT() macro and uses.  it's likely wrong in SMP land and probably 
should
be replaced with KTR-style uses if necessary.


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

2010-01-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jan 23 23:06:28 UTC 2010

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

Log Message:
remove most of the code that writes debugging info DATA_START + offset.


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

2010-01-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jan 23 23:39:27 UTC 2010

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

Log Message:
remove the final uses of DATA_START.

now we can remove the 16KB space reserved at the start of the data segment,
and i now understand why i wrote this now removed comment 3.5 years ago:
this shouldn't be needed... but kernel usually hangs without it


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

2010-01-15 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Jan 15 23:57:07 UTC 2010

Modified Files:
src/sys/arch/sparc64/sparc64: ipifuncs.c

Log Message:
UltraSPARC-IIIi CPUs select the BUSY/NACK pair in the interrupt
vector dispatch status register based on the lower two bits of the
ITID.

From OpenBSD and details are described in the section 10.4.3 of
UltraSPARC IIIi Processor User's Manual.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/sparc64/ipifuncs.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/sparc64/sparc64

2010-01-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jan 10 15:07:53 UTC 2010

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

Log Message:
s/cpu_switch/cpu_switchto/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.246 src/sys/arch/sparc64/sparc64/pmap.c

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