CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-06-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 16 14:22:02 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: pmap.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1474):

sys/arch/hppa/hppa/pmap.c: revision 1.120

Re-reading the PA2.0 Cache Move-In rules tells me we do indeed need to
purge the translations from the TLBs in pmap_procwr.

PR/56867: hppa: intermittent SIGSEGV reports in t_ptrace_wait's stepN
and setstepN test cases


To generate a diff of this commit:
cvs rdiff -u -r1.100.20.1 -r1.100.20.2 src/sys/arch/hppa/hppa/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/hppa/hppa/pmap.c
diff -u src/sys/arch/hppa/hppa/pmap.c:1.100.20.1 src/sys/arch/hppa/hppa/pmap.c:1.100.20.2
--- src/sys/arch/hppa/hppa/pmap.c:1.100.20.1	Fri Jun 10 17:16:54 2022
+++ src/sys/arch/hppa/hppa/pmap.c	Thu Jun 16 14:22:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.100.20.1 2022/06/10 17:16:54 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.100.20.2 2022/06/16 14:22:02 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.100.20.1 2022/06/10 17:16:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.100.20.2 2022/06/16 14:22:02 martin Exp $");
 
 #include "opt_cputype.h"
 
@@ -1658,10 +1658,13 @@ pmap_activate(struct lwp *l)
 void
 pmap_procwr(struct proc *p, vaddr_t va, size_t len)
 {
-	pmap_t pmap = p->p_vmspace->vm_map.pmap;
+	const pmap_t pmap = p->p_vmspace->vm_map.pmap;
+	const pa_space_t space = pmap->pm_space;
 
-	fdcache(pmap->pm_space, va, len);
-	ficache(pmap->pm_space, va, len);
+	fdcache(space, va, len);
+	ficache(space, va, len);
+	pdtlb(space, va);
+	pitlb(space, va);
 }
 
 static inline void



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-06-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun 16 14:22:02 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: pmap.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1474):

sys/arch/hppa/hppa/pmap.c: revision 1.120

Re-reading the PA2.0 Cache Move-In rules tells me we do indeed need to
purge the translations from the TLBs in pmap_procwr.

PR/56867: hppa: intermittent SIGSEGV reports in t_ptrace_wait's stepN
and setstepN test cases


To generate a diff of this commit:
cvs rdiff -u -r1.100.20.1 -r1.100.20.2 src/sys/arch/hppa/hppa/pmap.c

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



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-06-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jun 10 16:28:16 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: trap.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1466):

sys/arch/hppa/hppa/trap.c: revision 1.119

Handle 'NA' (non-access) traps for the lpa and probe instructions.  The
change is inspired by OpenBSD with a bunch of my own, mainly stylistic,
changes.

Thanks to Tom Lane for the analysis.

PR/56118: sporadic app crashes in HPPA -current


To generate a diff of this commit:
cvs rdiff -u -r1.111.4.1 -r1.111.4.2 src/sys/arch/hppa/hppa/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/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.111.4.1 src/sys/arch/hppa/hppa/trap.c:1.111.4.2
--- src/sys/arch/hppa/hppa/trap.c:1.111.4.1	Sat Apr 25 10:52:56 2020
+++ src/sys/arch/hppa/hppa/trap.c	Fri Jun 10 16:28:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.111.4.1 2020/04/25 10:52:56 martin Exp $	*/
+/*	$NetBSD: trap.c,v 1.111.4.2 2022/06/10 16:28:16 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.111.4.1 2020/04/25 10:52:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.111.4.2 2022/06/10 16:28:16 martin Exp $");
 
 /* #define INTRDEBUG */
 /* #define TRAPDEBUG */
@@ -480,6 +480,93 @@ out:
 }
 #endif /* DEBUG */
 
+
+#define __PABITS(x, y)		__BITS(31 - (x), 31 - (y))
+#define __PABIT(x)		__BIT(31 - (x))
+
+#define LPA_MASK \
+ (  __PABITS(0, 5) | \
+__PABITS(18, 25))
+#define LPA	 \
+ (__SHIFTIN(1,  __PABITS(0, 5))| \
+  __SHIFTIN(0x4d, __PABITS(18, 25)))
+
+
+#define PROBE_ENCS	(0x46 | 0xc6 | 0x47 | 0xc7)
+#define PROBE_PL	__PABITS(14, 15)
+#define PROBE_IMMED	__PABIT(18)
+#define PROBE_RW	__PABIT(25)
+
+#define PROBE_MASK   \
+((  __PABITS(0, 5) | \
+__PABITS(18, 25)   | \
+__PABIT(26))   ^ \
+ (PROBE_IMMED | PROBE_RW))
+
+#define PROBE	 \
+((__SHIFTIN(1,  __PABITS(0, 5))| \
+  __SHIFTIN(PROBE_ENCS, __PABITS(18, 25))  | \
+  __SHIFTIN(0,  __PABIT(26)))  ^ \
+ (PROBE_IMMED | PROBE_RW))
+
+/* for hppa64 */
+CTASSERT(sizeof(register_t) == sizeof(u_int));
+size_t hppa_regmap[] = {
+	0,	/* r0 is special case */
+	offsetof(struct trapframe, tf_r1  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_rp  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r3  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r4  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r5  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r6  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r7  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r8  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r9  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r10 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r11 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r12 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r13 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r14 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r15 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r16 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r17 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r18 ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_t4  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_t3  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_t2  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_t1  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_arg3) / sizeof(register_t),
+	offsetof(struct trapframe, tf_arg2) / sizeof(register_t),
+	offsetof(struct trapframe, tf_arg1) / sizeof(register_t),
+	offsetof(struct trapframe, tf_arg0) / sizeof(register_t),
+	offsetof(struct trapframe, tf_dp  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_ret0) / sizeof(register_t),
+	offsetof(struct trapframe, tf_ret1) / sizeof(register_t),
+	offsetof(struct trapframe, tf_sp  ) / sizeof(register_t),
+	offsetof(struct trapframe, tf_r31 ) / sizeof(register_t),
+};
+
+
+static inline register_t
+tf_getregno(struct trapframe *tf, u_int regno)
+{
+	register_t *tf_reg = (register_t *)tf;
+	if (regno == 0)
+		return 0;
+	else
+		return tf_reg[hppa_regmap[regno]];
+}
+
+static inline void
+tf_setregno(struct trapframe *tf, u_int regno, register_t val)
+{
+	register_t *tf_reg = (register_t *)tf;
+	if (regno == 0)
+		return;
+	else
+		tf_reg[hppa_regmap[regno]] = val;
+}
+
 void
 trap(int type, struct trapframe *frame)
 {
@@ -593,6 +680,7 @@ trap(int type, struct trapframe *frame)
 		mtctl(frame->tf_

CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-06-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jun 10 16:28:16 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: trap.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1466):

sys/arch/hppa/hppa/trap.c: revision 1.119

Handle 'NA' (non-access) traps for the lpa and probe instructions.  The
change is inspired by OpenBSD with a bunch of my own, mainly stylistic,
changes.

Thanks to Tom Lane for the analysis.

PR/56118: sporadic app crashes in HPPA -current


To generate a diff of this commit:
cvs rdiff -u -r1.111.4.1 -r1.111.4.2 src/sys/arch/hppa/hppa/trap.c

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



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-05-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May 14 11:38:32 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: idle_machdep.c machdep.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1448):

sys/arch/hppa/hppa/idle_machdep.c: revision 1.4
sys/arch/hppa/hppa/machdep.c: revision 1.17

Add some special NOPs to help qemu.
thanks to Helge Deller for the heads-up.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.4.1 src/sys/arch/hppa/hppa/idle_machdep.c
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/arch/hppa/hppa/machdep.c

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

Modified files:

Index: src/sys/arch/hppa/hppa/idle_machdep.c
diff -u src/sys/arch/hppa/hppa/idle_machdep.c:1.3 src/sys/arch/hppa/hppa/idle_machdep.c:1.3.4.1
--- src/sys/arch/hppa/hppa/idle_machdep.c:1.3	Mon Apr 15 20:45:08 2019
+++ src/sys/arch/hppa/hppa/idle_machdep.c	Sat May 14 11:38:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: idle_machdep.c,v 1.3 2019/04/15 20:45:08 skrll Exp $	*/
+/*	$NetBSD: idle_machdep.c,v 1.3.4.1 2022/05/14 11:38:31 martin Exp $	*/
 
 /*
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: idle_machdep.c,v 1.3 2019/04/15 20:45:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: idle_machdep.c,v 1.3.4.1 2022/05/14 11:38:31 martin Exp $");
 
 #include 
 #include 
@@ -36,5 +36,8 @@ __KERNEL_RCSID(0, "$NetBSD: idle_machdep
 void
 cpu_idle(void)
 {
-	/* do nothing */
+/*
+	 * This NOP instruction is used by qemu to detect the idle loop.
+	 */
+	__asm volatile("or	%%r10,%%r10,%%r10" ::: "memory");
 }

Index: src/sys/arch/hppa/hppa/machdep.c
diff -u src/sys/arch/hppa/hppa/machdep.c:1.10 src/sys/arch/hppa/hppa/machdep.c:1.10.4.1
--- src/sys/arch/hppa/hppa/machdep.c:1.10	Sat Apr  6 03:06:25 2019
+++ src/sys/arch/hppa/hppa/machdep.c	Sat May 14 11:38:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.10 2019/04/06 03:06:25 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.10.4.1 2022/05/14 11:38:31 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10.4.1 2022/05/14 11:38:31 martin Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -1459,8 +1459,13 @@ cpu_reboot(int howto, char *user_boot_st
 		:: "r" (CMD_RESET), "r" (HPPA_LBCAST + iomod_command));
 	}
 
-	for (;;)
-		/* loop while bus reset is coming up */ ;
+	for (;;) {
+		/*
+		 * loop while bus reset is coming up.  This NOP instruction
+		 * is used by qemu to detect the 'death loop'.
+		 */
+		__asm volatile("or %%r31, %%r31, %%r31" ::: "memory");
+	}
 	/* NOTREACHED */
 }
 



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-05-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May 14 11:38:32 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: idle_machdep.c machdep.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1448):

sys/arch/hppa/hppa/idle_machdep.c: revision 1.4
sys/arch/hppa/hppa/machdep.c: revision 1.17

Add some special NOPs to help qemu.
thanks to Helge Deller for the heads-up.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.4.1 src/sys/arch/hppa/hppa/idle_machdep.c
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/arch/hppa/hppa/machdep.c

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



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-05-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May 14 11:32:43 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: hppa_machdep.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1446):

sys/arch/hppa/hppa/hppa_machdep.c: revision 1.33

port-hppa/56830: RAS support is slightly incorrect on hppa

When searching for RAS use tf_iioq_head without the HPPA_PC_PRIV_MASK bits
set.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.34.1 src/sys/arch/hppa/hppa/hppa_machdep.c

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

Modified files:

Index: src/sys/arch/hppa/hppa/hppa_machdep.c
diff -u src/sys/arch/hppa/hppa/hppa_machdep.c:1.29 src/sys/arch/hppa/hppa/hppa_machdep.c:1.29.34.1
--- src/sys/arch/hppa/hppa/hppa_machdep.c:1.29	Mon Feb 24 07:23:43 2014
+++ src/sys/arch/hppa/hppa/hppa_machdep.c	Sat May 14 11:32:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: hppa_machdep.c,v 1.29 2014/02/24 07:23:43 skrll Exp $	*/
+/*	$NetBSD: hppa_machdep.c,v 1.29.34.1 2022/05/14 11:32:43 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.29 2014/02/24 07:23:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.29.34.1 2022/05/14 11:32:43 martin Exp $");
 
 #include 
 #include 
@@ -279,7 +279,9 @@ hppa_ras(struct lwp *l)
 
 	p = l->l_proc;
 	tf = l->l_md.md_regs;
-	rasaddr = (intptr_t)ras_lookup(p, (void *)tf->tf_iioq_head);
+
+	rasaddr = (intptr_t)ras_lookup(p,
+	(void *)(tf->tf_iioq_head & ~HPPA_PC_PRIV_MASK));
 	if (rasaddr != -1) {
 		rasaddr |= HPPA_PC_PRIV_USER;
 		tf->tf_iioq_head = rasaddr;



CVS commit: [netbsd-9] src/sys/arch/hppa/hppa

2022-05-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat May 14 11:32:43 UTC 2022

Modified Files:
src/sys/arch/hppa/hppa [netbsd-9]: hppa_machdep.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1446):

sys/arch/hppa/hppa/hppa_machdep.c: revision 1.33

port-hppa/56830: RAS support is slightly incorrect on hppa

When searching for RAS use tf_iioq_head without the HPPA_PC_PRIV_MASK bits
set.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.34.1 src/sys/arch/hppa/hppa/hppa_machdep.c

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