CVS commit: src/sys/arch/powerpc/ibm4xx

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 04:36:24 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Tiny cosmetic fix for previous. No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.94 src/sys/arch/powerpc/ibm4xx/pmap.c:1.95
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.94	Thu Sep 10 04:31:55 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Sep 10 04:36:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.94 2020/09/10 04:31:55 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.95 2020/09/10 04:36:24 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.94 2020/09/10 04:31:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.95 2020/09/10 04:36:24 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1160,9 +1160,9 @@ pmap_deactivate(struct lwp *l)
 void
 pmap_procwr(struct proc *p, vaddr_t va, size_t len)
 {
+	struct pmap *pm = p->p_vmspace->vm_map.pmap;
 
 	if (__predict_true(p == curproc)) {
-		struct pmap *pm = p->p_vmspace->vm_map.pmap;
 		int msr, ctx, opid;
 
 		/*
@@ -1203,7 +1203,6 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 			: "=" (msr), "=" (opid)
 			: "r" (ctx), "r" (va), "r" (len), "r" (CACHELINESIZE));
 	} else {
-		struct pmap *pm = p->p_vmspace->vm_map.pmap;
 		paddr_t pa;
 		vaddr_t tva, eva;
 		int tlen;



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 04:36:24 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Tiny cosmetic fix for previous. No functional changes.


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

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 04:31:55 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Real fix for pmap_procwr(), attempted in revs 1.85 and 1.87:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.85
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.87

ibm4xx has VIPT icache and operations in pmap_procwr() should be done with
DMMU enabled (write back dcache into memory and invalidate icache).

When p == curproc, this is trivial. However, p != curproc needs a special
care; we cannot rely upon TLB miss handler in user context. Therefore,
extract pa and operate against it.

Note that va below VM_MIN_KERNEL_ADDRESS (== 2GB at the moment) is reserved
for direct mapping.

Tested by gdb with WIP software single stepping for ibm4xx.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 04:31:55 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Real fix for pmap_procwr(), attempted in revs 1.85 and 1.87:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.85
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.87

ibm4xx has VIPT icache and operations in pmap_procwr() should be done with
DMMU enabled (write back dcache into memory and invalidate icache).

When p == curproc, this is trivial. However, p != curproc needs a special
care; we cannot rely upon TLB miss handler in user context. Therefore,
extract pa and operate against it.

Note that va below VM_MIN_KERNEL_ADDRESS (== 2GB at the moment) is reserved
for direct mapping.

Tested by gdb with WIP software single stepping for ibm4xx.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.93 src/sys/arch/powerpc/ibm4xx/pmap.c:1.94
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.93	Thu Sep 10 03:32:46 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Sep 10 04:31:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.93 2020/09/10 03:32:46 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.94 2020/09/10 04:31:55 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.93 2020/09/10 03:32:46 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.94 2020/09/10 04:31:55 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1160,42 +1160,72 @@ pmap_deactivate(struct lwp *l)
 void
 pmap_procwr(struct proc *p, vaddr_t va, size_t len)
 {
-	struct pmap *pm = p->p_vmspace->vm_map.pmap;
-	int msr, ctx, opid, step;
 
-	step = CACHELINESIZE;
+	if (__predict_true(p == curproc)) {
+		struct pmap *pm = p->p_vmspace->vm_map.pmap;
+		int msr, ctx, opid;
 
-	/*
-	 * Need to turn off IMMU and switch to user context.
-	 * (icbi uses DMMU).
-	 */
-	if (!(ctx = pm->pm_ctx)) {
-		/* No context -- assign it one */
-		ctx_alloc(pm);
-		ctx = pm->pm_ctx;
-	}
-	__asm volatile(
-		"mfmsr %0;"
-		"li %1, %7;"
-		"andc %1,%0,%1;"
-		"mtmsr %1;"
-		"isync;"
-		"mfpid %1;"
-		"mtpid %2;"
-		"isync;"
+		/*
+		 * Take it easy! TLB miss handler takes care of us.
+		 */
+
+		/*
+	 	 * Need to turn off IMMU and switch to user context.
+		 * (icbi uses DMMU).
+		 */
+
+		if (!(ctx = pm->pm_ctx)) {
+			/* No context -- assign it one */
+			ctx_alloc(pm);
+			ctx = pm->pm_ctx;
+		}
+
+		__asm volatile(
+			"mfmsr %0;"
+			"li %1,0x20;"		/* Turn off IMMU */
+			"andc %1,%0,%1;"
+			"ori %1,%1,0x10;"	/* Turn on DMMU for sure */
+			"mtmsr %1;"
+			"isync;"
+			"mfpid %1;"
+			"mtpid %2;"
+			"isync;"
 		"1:"
-		"dcbst 0,%3;"
-		"icbi 0,%3;"
-		"add %3,%3,%5;"
-		"addc. %4,%4,%6;"
-		"bge 1b;"
-		"sync;"
-		"mtpid %1;"
-		"mtmsr %0;"
-		"isync;"
-		: "=" (msr), "=" (opid)
-		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step),
-		  "K" (PSL_IR | PSL_DR));
+			"dcbst 0,%3;"
+			"icbi 0,%3;"
+			"add %3,%3,%5;"
+			"sub. %4,%4,%5;"
+			"bge 1b;"
+			"sync;"
+			"mtpid %1;"
+			"mtmsr %0;"
+			"isync;"
+			: "=" (msr), "=" (opid)
+			: "r" (ctx), "r" (va), "r" (len), "r" (CACHELINESIZE));
+	} else {
+		struct pmap *pm = p->p_vmspace->vm_map.pmap;
+		paddr_t pa;
+		vaddr_t tva, eva;
+		int tlen;
+
+		/*
+		 * For p != curproc, we cannot rely upon TLB miss handler in
+		 * user context. Therefore, extract pa and operate againt it.
+		 *
+		 * Note that va below VM_MIN_KERNEL_ADDRESS is reserved for
+		 * direct mapping.
+		 */
+
+		for (tva = va; len > 0; tva = eva, len -= tlen) {
+			eva = uimin(tva + len, trunc_page(tva + PAGE_SIZE));
+			tlen = eva - tva;
+			if (!pmap_extract(pm, tva, )) {
+/* XXX should be already unmapped */
+continue;
+			}
+			__syncicache((void *)pa, tlen);
+		}
+	}
 }
 
 static inline void



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 03:23:55 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
pmap_kenter_pa: Remove comment which says ``Have to remove any existing
mapping first.'' Contrary to this comment, pmap_kremove(9) has never
been called there since rev 1.1, and we don't for other ports also.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.91 src/sys/arch/powerpc/ibm4xx/pmap.c:1.92
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.91	Thu Sep 10 03:02:36 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Sep 10 03:23:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.91 2020/09/10 03:02:36 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.92 2020/09/10 03:23:55 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2020/09/10 03:02:36 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.92 2020/09/10 03:23:55 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -931,10 +931,6 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v
 	struct pmap *pm = pmap_kernel();
 
 	/*
-	 * Have to remove any existing mapping first.
-	 */
-
-	/*
 	 * Generate TTE.
 	 *
 	 * 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 03:23:55 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
pmap_kenter_pa: Remove comment which says ``Have to remove any existing
mapping first.'' Contrary to this comment, pmap_kremove(9) has never
been called there since rev 1.1, and we don't for other ports also.


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

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 03:02:36 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Introduce PV_VA() macro to extract va from pv->pv_va by clearing
PV_WIRED flag, and use it where appropriate.

There should be no functional changes. Only for safety in future.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.90 src/sys/arch/powerpc/ibm4xx/pmap.c:1.91
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.90	Mon Jul  6 10:40:21 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Sep 10 03:02:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.90 2020/07/06 10:40:21 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.91 2020/09/10 03:02:36 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2020/07/06 10:40:21 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.91 2020/09/10 03:02:36 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -156,7 +156,8 @@ static char *pmap_attrib;
 #define PV_WIRE(pv)	((pv)->pv_va |= PV_WIRED)
 #define PV_UNWIRE(pv)	((pv)->pv_va &= ~PV_WIRED)
 #define PV_ISWIRED(pv)	((pv)->pv_va & PV_WIRED)
-#define PV_CMPVA(va,pv)	(!(((pv)->pv_va ^ (va)) & (~PV_WIRED)))
+#define PV_VA(pv)	((pv)->pv_va & ~PV_WIRED)
+#define PV_CMPVA(va,pv)	(!(PV_VA(pv) ^ (va)))
 
 struct pv_entry {
 	struct pv_entry *pv_next;	/* Linked list of mappings */
@@ -1115,14 +1116,14 @@ pmap_page_protect(struct vm_page *pg, vm
 		npv = pv->pv_next;
 
 		pm = pv->pv_pm;
-		va = pv->pv_va;
+		va = PV_VA(pv);
 		pmap_protect(pm, va, va + PAGE_SIZE, prot);
 	}
 	/* Now check the head pv */
 	if (pvh->pv_pm) {
 		pv = pvh;
 		pm = pv->pv_pm;
-		va = pv->pv_va;
+		va = PV_VA(pv);
 		pmap_protect(pm, va, va + PAGE_SIZE, prot);
 	}
 }



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-09-09 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 10 03:02:36 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Introduce PV_VA() macro to extract va from pv->pv_va by clearing
PV_WIRED flag, and use it where appropriate.

There should be no functional changes. Only for safety in future.


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

2020-07-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jul 15 08:48:40 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Treat trap instruction from userland correctly in EXC_PGM handler;
raise SIGTRAP with TRAP_BRKPT instead of SIGILL.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.83 src/sys/arch/powerpc/ibm4xx/trap.c:1.84
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.83	Mon Jul  6 10:41:43 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Wed Jul 15 08:48:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.83 2020/07/06 10:41:43 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.84 2020/07/15 08:48:40 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -69,7 +69,7 @@
 #define	__UFETCHSTORE_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.83 2020/07/06 10:41:43 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.84 2020/07/15 08:48:40 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -309,27 +309,38 @@ vm_signal:
 		break;
 
 	case EXC_PGM|EXC_USER:
-		/*
-		 * Illegal insn:
-		 *
-		 * let's try to see if its FPU and can be emulated.
-		 */
 		curcpu()->ci_data.cpu_ntrap++;
-		pcb = lwp_getpcb(l);
 
-		if (__predict_false(!fpu_used_p(l))) {
-			memset(>pcb_fpu, 0, sizeof(pcb->pcb_fpu));
-			fpu_mark_used(l);
-		}
+		KSI_INIT_TRAP();
+		ksi.ksi_trap = EXC_PGM;
+		ksi.ksi_addr = (void *)tf->tf_srr0;
 
-		if (fpu_emulate(tf, >pcb_fpu, )) {
-			if (ksi.ksi_signo == 0)	/* was emulated */
+		if (tf->tf_esr & ESR_PTR) {
+sigtrap:
+			if (p->p_raslist != NULL &&
+			ras_lookup(p, (void *)tf->tf_srr0) != (void *) -1) {
+tf->tf_srr1 += 4;
 break;
+			}
+			ksi.ksi_code = TRAP_BRKPT;
+			ksi.ksi_signo = SIGTRAP;
 		} else {
-			ksi.ksi_signo = SIGILL;
-			ksi.ksi_code = ILL_ILLOPC;
-			ksi.ksi_trap = EXC_PGM;
-			ksi.ksi_addr = (void *)tf->tf_srr0;
+			pcb = lwp_getpcb(l);
+
+			if (__predict_false(!fpu_used_p(l))) {
+memset(>pcb_fpu, 0, sizeof(pcb->pcb_fpu));
+fpu_mark_used(l);
+			}
+
+			if (fpu_emulate(tf, >pcb_fpu, )) {
+if (ksi.ksi_signo == 0)	/* was emulated */
+	break;
+else if (ksi.ksi_signo == SIGTRAP)
+	goto sigtrap;	/* XXX H/W bug? */
+			} else {
+ksi.ksi_code = ILL_ILLOPC;
+ksi.ksi_signo = SIGILL;
+			}
 		}
 
 		trapsignal(l, );



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jul 15 08:48:40 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Treat trap instruction from userland correctly in EXC_PGM handler;
raise SIGTRAP with TRAP_BRKPT instead of SIGILL.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-07-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jul 12 21:16:23 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: 4xx_trap_subr.S

Log Message:
Fix comment.

ibm4xx does not use powerpc/powerpc/trap_subr.S, but
powerpc/ibm4xx/trap_subr.S.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/powerpc/ibm4xx/4xx_trap_subr.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/powerpc/ibm4xx/4xx_trap_subr.S
diff -u src/sys/arch/powerpc/ibm4xx/4xx_trap_subr.S:1.8 src/sys/arch/powerpc/ibm4xx/4xx_trap_subr.S:1.9
--- src/sys/arch/powerpc/ibm4xx/4xx_trap_subr.S:1.8	Sun Mar  1 23:23:36 2020
+++ src/sys/arch/powerpc/ibm4xx/4xx_trap_subr.S	Sun Jul 12 21:16:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: 4xx_trap_subr.S,v 1.8 2020/03/01 23:23:36 rin Exp $	*/
+/*	$NetBSD: 4xx_trap_subr.S,v 1.9 2020/07/12 21:16:23 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 /* This file provides necessary handlers for 405GP CPU
- * It should be included in locore.S after powerpc/powerpc/trap_subr.S
+ * It should be included in locore.S after powerpc/ibm4xx/trap_subr.S
  */
 
 	.text



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Jul 12 21:16:23 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: 4xx_trap_subr.S

Log Message:
Fix comment.

ibm4xx does not use powerpc/powerpc/trap_subr.S, but
powerpc/ibm4xx/trap_subr.S.


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

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 13:10:19 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c

Log Message:
Set cpu_psluserset, cpu_pslusermod, cpu_pslusermask for MODULAR.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/powerpc/ibm4xx/ibm4xx_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/powerpc/ibm4xx/ibm4xx_machdep.c
diff -u src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.31 src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.32
--- src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.31	Mon Jul  6 10:34:23 2020
+++ src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c	Mon Jul  6 13:10:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibm4xx_machdep.c,v 1.31 2020/07/06 10:34:23 rin Exp $	*/
+/*	$NetBSD: ibm4xx_machdep.c,v 1.32 2020/07/06 13:10:19 rin Exp $	*/
 /*	Original: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */
 
 /*
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.31 2020/07/06 10:34:23 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.32 2020/07/06 13:10:19 rin Exp $");
 
 #include "ksyms.h"
 
@@ -115,6 +115,12 @@ char msgbuf[MSGBUFSIZE];
 void *startsym, *endsym;
 #endif
 
+#ifdef MODULAR
+register_t cpu_psluserset = PSL_USERSET;
+register_t cpu_pslusermod = PSL_USERMOD;
+register_t cpu_pslusermask = PSL_USERMASK;
+#endif
+
 /*
  * Trap vectors
  */



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 13:10:19 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c

Log Message:
Set cpu_psluserset, cpu_pslusermod, cpu_pslusermask for MODULAR.


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

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



CVS commit: src/sys/arch/powerpc/ibm4xx/pci

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:49:41 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx/pci: pci_machdep.c

Log Message:
Include missing opt_pci.h


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/ibm4xx/pci/pci_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/powerpc/ibm4xx/pci/pci_machdep.c
diff -u src/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c:1.11 src/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c:1.12
--- src/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c:1.11	Fri Oct  2 05:22:51 2015
+++ src/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c	Mon Jul  6 10:49:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.11 2015/10/02 05:22:51 msaitoh Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.12 2020/07/06 10:49:41 rin Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -43,7 +43,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.11 2015/10/02 05:22:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.12 2020/07/06 10:49:41 rin Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_pci.h"
+#endif
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx/pci

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:49:41 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx/pci: pci_machdep.c

Log Message:
Include missing opt_pci.h


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/ibm4xx/pci/pci_machdep.c

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



CVS commit: src/sys/arch/powerpc/ibm4xx/openbios

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:48:54 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx/openbios: locore.S

Log Message:
Do not silently #undef PPC_4XX_NOCACHE, which results in terrible confusion.
Raise #error instead.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/ibm4xx/openbios/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/powerpc/ibm4xx/openbios

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:48:54 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx/openbios: locore.S

Log Message:
Do not silently #undef PPC_4XX_NOCACHE, which results in terrible confusion.
Raise #error instead.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/powerpc/ibm4xx/openbios/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/powerpc/ibm4xx/openbios/locore.S
diff -u src/sys/arch/powerpc/ibm4xx/openbios/locore.S:1.14 src/sys/arch/powerpc/ibm4xx/openbios/locore.S:1.15
--- src/sys/arch/powerpc/ibm4xx/openbios/locore.S:1.14	Mon Jul  6 10:44:38 2020
+++ src/sys/arch/powerpc/ibm4xx/openbios/locore.S	Mon Jul  6 10:48:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.14 2020/07/06 10:44:38 rin Exp $	*/
+/*	$NetBSD: locore.S,v 1.15 2020/07/06 10:48:54 rin Exp $	*/
 /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
 
 /*
@@ -67,7 +67,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#undef PPC_4XX_NOCACHE
+#ifdef PPC_4XX_NOCACHE
+#error "Fix me"
+#endif
 
 #include "assym.h"
 #include "ksyms.h"



CVS commit: src/sys/arch/powerpc/ibm4xx/openbios

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:44:38 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx/openbios: locore.S

Log Message:
Drop unused opt_lockdebug.h, opt_multiprocessor.h, and opt_ppcarch.h.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/ibm4xx/openbios/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/powerpc/ibm4xx/openbios/locore.S
diff -u src/sys/arch/powerpc/ibm4xx/openbios/locore.S:1.13 src/sys/arch/powerpc/ibm4xx/openbios/locore.S:1.14
--- src/sys/arch/powerpc/ibm4xx/openbios/locore.S:1.13	Mon Jul  6 09:34:17 2020
+++ src/sys/arch/powerpc/ibm4xx/openbios/locore.S	Mon Jul  6 10:44:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.13 2020/07/06 09:34:17 rin Exp $	*/
+/*	$NetBSD: locore.S,v 1.14 2020/07/06 10:44:38 rin Exp $	*/
 /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
 
 /*
@@ -74,10 +74,7 @@
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
-#include "opt_lockdebug.h"
 #include "opt_modular.h"
-#include "opt_multiprocessor.h"
-#include "opt_ppcarch.h"
 #include "opt_ppcparam.h"
 #endif
 



CVS commit: src/sys/arch/powerpc/ibm4xx/openbios

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:44:38 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx/openbios: locore.S

Log Message:
Drop unused opt_lockdebug.h, opt_multiprocessor.h, and opt_ppcarch.h.


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

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:42:21 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap_subr.S

Log Message:
Include required opt_*.h for sure.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/ibm4xx/trap_subr.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/powerpc/ibm4xx/trap_subr.S
diff -u src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.28 src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.29
--- src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.28	Sun Mar  1 23:23:36 2020
+++ src/sys/arch/powerpc/ibm4xx/trap_subr.S	Mon Jul  6 10:42:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.28 2020/03/01 23:23:36 rin Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.29 2020/07/06 10:42:21 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -73,6 +73,11 @@
  *	#include 
  */
 
+#ifdef _KERNEL_OPT
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#endif
+
 /*
  * XXX Interrupt and spill stacks need to be per-CPU.
  */



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:42:21 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap_subr.S

Log Message:
Include required opt_*.h for sure.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/powerpc/ibm4xx/trap_subr.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/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:41:43 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
- Drop unused opt_altivec.h.
- Include missing opt_ppcarch.h.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.82 src/sys/arch/powerpc/ibm4xx/trap.c:1.83
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.82	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Mon Jul  6 10:41:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.82 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.83 2020/07/06 10:41:43 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -69,12 +69,12 @@
 #define	__UFETCHSTORE_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.82 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.83 2020/07/06 10:41:43 rin Exp $");
 
 #ifdef _KERNEL_OPT
-#include "opt_altivec.h"
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
+#include "opt_ppcarch.h"
 #endif
 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:41:43 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
- Drop unused opt_altivec.h.
- Include missing opt_ppcarch.h.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:40:21 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Include missing opt_ddb.h.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.89 src/sys/arch/powerpc/ibm4xx/pmap.c:1.90
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.89	Mon Jun 29 06:51:32 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Mon Jul  6 10:40:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.89 2020/06/29 06:51:32 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.90 2020/07/06 10:40:21 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2020/06/29 06:51:32 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2020/07/06 10:40:21 rin Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_ddb.h"
+#endif
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:40:21 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Include missing opt_ddb.h.


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

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:35:29 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pic_uic.c

Log Message:
Include missing opt_ppcarch.h and opt_uic.h.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/powerpc/ibm4xx/pic_uic.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/powerpc/ibm4xx/pic_uic.c
diff -u src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.6 src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.7
--- src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.6	Mon Jul  6 09:34:16 2020
+++ src/sys/arch/powerpc/ibm4xx/pic_uic.c	Mon Jul  6 10:35:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_uic.c,v 1.6 2020/07/06 09:34:16 rin Exp $	*/
+/*	$NetBSD: pic_uic.c,v 1.7 2020/07/06 10:35:28 rin Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_uic.c,v 1.6 2020/07/06 09:34:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_uic.c,v 1.7 2020/07/06 10:35:28 rin Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_ppcarch.h"
+#include "opt_uic.h"
+#endif
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-07-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul  6 10:35:29 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pic_uic.c

Log Message:
Include missing opt_ppcarch.h and opt_uic.h.


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

2020-06-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun 29 06:51:32 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Remove evcnt(9) counter for tlbhit; there's no way to observe TLB hits
from kernel, and it just counted intersection b/w tlbmiss and tlbenter.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-06-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun 29 06:51:32 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Remove evcnt(9) counter for tlbhit; there's no way to observe TLB hits
from kernel, and it just counted intersection b/w tlbmiss and tlbenter.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.88 src/sys/arch/powerpc/ibm4xx/pmap.c:1.89
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.88	Fri Jun 19 07:31:59 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Mon Jun 29 06:51:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.88 2020/06/19 07:31:59 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.89 2020/06/29 06:51:32 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.88 2020/06/19 07:31:59 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2020/06/29 06:51:32 rin Exp $");
 
 #include 
 #include 
@@ -123,14 +123,11 @@ static int pmap_bootstrap_done = 0;
 /* Event counters */
 struct evcnt tlbmiss_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
 	NULL, "cpu", "tlbmiss");
-struct evcnt tlbhit_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
-	NULL, "cpu", "tlbhit");
 struct evcnt tlbflush_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
 	NULL, "cpu", "tlbflush");
 struct evcnt tlbenter_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
 	NULL, "cpu", "tlbenter");
 EVCNT_ATTACH_STATIC(tlbmiss_ev);
-EVCNT_ATTACH_STATIC(tlbhit_ev);
 EVCNT_ATTACH_STATIC(tlbflush_ev);
 EVCNT_ATTACH_STATIC(tlbenter_ev);
 
@@ -1496,7 +1493,6 @@ pmap_tlbmiss(vaddr_t va, int ctx)
 		tte = TTE_PA(va) | TTE_ZONE(ZONE_PRIV) | TTE_SZ_16M | TTE_WR;
 #endif
 	}
-	tlbhit_ev.ev_count++;
 	ppc4xx_tlb_enter(ctx, va, tte);
 
 	return 0;



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:31:59 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c pmap.c trap.c

Log Message:
Try to sanitize usage of isync and sync instructions.

According to reference manuals of 4xx, isync is "context synchronization",
which satisfies both 1 and 2:

1. instructions preceding it complete in the context that existed before it
2. instructions following it complete in the context that exists after it

Whereas sync (== msync for 440) is "execution synchronization", which
satisfies just 1, not 2. At the same time, sync guarantees "storage
synchronization", by which any previous storage references completes
before any subsequent instructions begin to execute.

Tested on 405 over months.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/powerpc/ibm4xx/pmap.c
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/copyinstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.13 src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.14
--- src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.13	Thu Mar  5 01:15:35 2020
+++ src/sys/arch/powerpc/ibm4xx/copyinstr.c	Fri Jun 19 07:31:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyinstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $	*/
+/*	$NetBSD: copyinstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $");
 
 #include 
 #include 
@@ -75,22 +75,22 @@ copyinstr(const void *udaddr, void *kadd
 		"mfmsr %0;"			/* Save MSR */
 		"li %1,0x20;"
 		"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
+		"isync;"
 		"mfpid %1;"			/* Save old PID */
-		"sync; isync;"
 
 		"1: "
-		"mtpid %4; sync;"		/* Load user ctx */
+		"mtpid %4; isync;"		/* Load user ctx */
 		"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
-		"sync; isync;"
-		"mtpid %1; sync;"
+		"sync;"
+		"mtpid %1; isync;"
 		"stb %2,0(%6); dcbst 0,%6; addi %6,%6,1;"
 		/* Store kernel byte */
-		"sync; isync;"
 		"or. %2,%2,%2;"
+		"sync;"
 		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
 
 		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
-		"sync; isync;"
+		"isync;"
 		"mfctr %3;"			/* Restore resid */
 		: "=" (msr), "=" (pid), "=" (data), "+r" (resid)
 		: "r" (ctx), "b" (udaddr), "b" (kaddr));
Index: src/sys/arch/powerpc/ibm4xx/copyoutstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.13 src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.14
--- src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.13	Thu Mar  5 01:15:35 2020
+++ src/sys/arch/powerpc/ibm4xx/copyoutstr.c	Fri Jun 19 07:31:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyoutstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $	*/
+/*	$NetBSD: copyoutstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.14 2020/06/19 07:31:59 rin Exp $");
 
 #include 
 #include 
@@ -75,22 +75,22 @@ copyoutstr(const void *kaddr, void *udad
 		"mfmsr %0;"			/* Save MSR */
 		"li %1,0x20;"
 		"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
+		"isync;"
 		"mfpid %1;"			/* Save old PID */
-		"sync; isync;"
 
 		"1:"
-		"mtpid %1; sync;"
+		"mtpid %1; isync;"
 		"lbz %2,0(%6); addi %6,%6,1;"	/* Store kernel byte */
-		"sync; isync;"
-		"mtpid %4; sync;"		/* Load user ctx */
+		"sync;"
+		"mtpid %4; isync;"		/* Load user ctx */
 		"stb %2,0(%5); dcbst 0,%5; addi %5,%5,1;"
 		/* Load byte */
-		"sync; isync;"
 		"or. %2,%2,%2;"
+		"sync;"
 		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
 
 		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
-		"sync; isync;"
+		"isync;"
 		"mfctr %3;"			/* Restore resid */
 		: "=" (msr), "=" (pid), "=" (data), "+r" (resid)
 		: "r" (ctx), "b" (udaddr), "b" (kaddr));

Index: src/sys/arch/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.87 src/sys/arch/powerpc/ibm4xx/pmap.c:1.88
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.87	Fri Jun 19 07:15:21 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Fri Jun 19 07:31:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.87 2020/06/19 07:15:21 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.88 2020/06/19 07:31:59 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.87 2020/06/19 07:15:21 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.88 2020/06/19 07:31:59 rin Exp $");
 
 #include 
 #include 
@@ -1178,19 +1178,20 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		"li %1, 

CVS commit: src/sys/arch/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:31:59 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c pmap.c trap.c

Log Message:
Try to sanitize usage of isync and sync instructions.

According to reference manuals of 4xx, isync is "context synchronization",
which satisfies both 1 and 2:

1. instructions preceding it complete in the context that existed before it
2. instructions following it complete in the context that exists after it

Whereas sync (== msync for 440) is "execution synchronization", which
satisfies just 1, not 2. At the same time, sync guarantees "storage
synchronization", by which any previous storage references completes
before any subsequent instructions begin to execute.

Tested on 405 over months.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.c
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/powerpc/ibm4xx/pmap.c
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:24:41 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Return correct signo and si_code to userland when page fault.
Taken from powerpc/trap.c. Found by tests in lib/libc/sys.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:24:41 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Return correct signo and si_code to userland when page fault.
Taken from powerpc/trap.c. Found by tests in lib/libc/sys.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.79 src/sys/arch/powerpc/ibm4xx/trap.c:1.80
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.79	Fri Jun 19 07:19:19 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Fri Jun 19 07:24:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.79 2020/06/19 07:19:19 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.80 2020/06/19 07:24:41 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.79 2020/06/19 07:19:19 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.80 2020/06/19 07:24:41 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -247,16 +247,28 @@ out:
 			break;
 		}
 		KSI_INIT_TRAP();
-		ksi.ksi_signo = SIGSEGV;
 		ksi.ksi_trap = EXC_DSI;
 		ksi.ksi_addr = (void *)tf->tf_dear;
-		if (rv == ENOMEM) {
-			printf("UVM: pid %d (%s) lid %d, uid %d killed: "
-			"out of swap\n",
-			p->p_pid, p->p_comm, l->l_lid,
-			l->l_cred ?
-			kauth_cred_geteuid(l->l_cred) : -1);
+vm_signal:
+		switch (rv) {
+		case EINVAL:
+			ksi.ksi_signo = SIGBUS;
+			ksi.ksi_code = BUS_ADRERR;
+			break;
+		case EACCES:
+			ksi.ksi_signo = SIGSEGV;
+			ksi.ksi_code = SEGV_ACCERR;
+			break;
+		case ENOMEM:
 			ksi.ksi_signo = SIGKILL;
+			printf("UVM: pid %d.%d (%s), uid %d killed: "
+			   "out of swap\n", p->p_pid, l->l_lid, p->p_comm,
+			   l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1);
+			break;
+		default:
+			ksi.ksi_signo = SIGSEGV;
+			ksi.ksi_code = SEGV_MAPERR;
+			break;
 		}
 		trapsignal(l, );
 		break;
@@ -274,11 +286,9 @@ out:
 			break;
 		}
 		KSI_INIT_TRAP();
-		ksi.ksi_signo = SIGSEGV;
 		ksi.ksi_trap = EXC_ISI;
 		ksi.ksi_addr = (void *)tf->tf_srr0;
-		ksi.ksi_code = (rv == EACCES ? SEGV_ACCERR : SEGV_MAPERR);
-		trapsignal(l, );
+		goto vm_signal;
 		break;
 
 	case EXC_AST|EXC_USER:



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:19:19 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Return error code from uvm layer on fault, instead of hard-coded 1.
Found by some tests in tests/lib/libc/sys.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.78 src/sys/arch/powerpc/ibm4xx/trap.c:1.79
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.78	Fri Feb 21 15:15:48 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Fri Jun 19 07:19:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.78 2020/02/21 15:15:48 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.79 2020/06/19 07:19:19 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2020/02/21 15:15:48 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.79 2020/06/19 07:19:19 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -221,7 +221,7 @@ out:
 tf->tf_cr = fb->fb_cr;
 tf->tf_fixreg[1] = fb->fb_sp;
 tf->tf_fixreg[2] = fb->fb_r2;
-tf->tf_fixreg[3] = 1; /* Return TRUE */
+tf->tf_fixreg[3] = rv;
 memcpy(>tf_fixreg[13], fb->fb_fixreg,
 sizeof(fb->fb_fixreg));
 return;



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:19:19 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Return error code from uvm layer on fault, instead of hard-coded 1.
Found by some tests in tests/lib/libc/sys.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:15:21 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Oops, commit log was missing. It should be:

Revert rev 1.85:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.85

Not clearly documented in reference manual, but the previous code seems
correct; the operations must be carried out with DMMU disabled. Otherwise,
WIP software single step for userland does not work correctly (stalled
indefinitely at pmap_procwr()).

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.86 src/sys/arch/powerpc/ibm4xx/pmap.c:1.87
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.86	Fri Jun 19 07:14:19 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Fri Jun 19 07:15:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.86 2020/06/19 07:14:19 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.87 2020/06/19 07:15:21 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.86 2020/06/19 07:14:19 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.87 2020/06/19 07:15:21 rin Exp $");
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:15:21 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Oops, commit log was missing. It should be:

Revert rev 1.85:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/ibm4xx/pmap.c#rev1.85

Not clearly documented in reference manual, but the previous code seems
correct; the operations must be carried out with DMMU disabled. Otherwise,
WIP software single step for userland does not work correctly (stalled
indefinitely at pmap_procwr()).

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:14:20 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-06-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jun 19 07:14:20 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.85 src/sys/arch/powerpc/ibm4xx/pmap.c:1.86
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.85	Thu Mar  5 11:44:54 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Fri Jun 19 07:14:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.85 2020/03/05 11:44:54 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.86 2020/06/19 07:14:19 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.85 2020/03/05 11:44:54 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.86 2020/06/19 07:14:19 rin Exp $");
 
 #include 
 #include 
@@ -1175,9 +1175,8 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 	}
 	__asm volatile(
 		"mfmsr %0;"
-		"li %1,0x20;"		/* Turn off IMMU */
+		"li %1, %7;"
 		"andc %1,%0,%1;"
-		"ori %1,%1,0x10;"	/* Turn on DMMU for sure */
 		"mtmsr %1;"
 		"sync;isync;"
 		"mfpid %1;"
@@ -1193,7 +1192,8 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		"mtmsr %0;"
 		"sync; isync"
 		: "=" (msr), "=" (opid)
-		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step));
+		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step),
+		  "K" (PSL_IR | PSL_DR));
 }
 
 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 11:44:54 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Fix pmap_procwr().

While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-03-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 11:44:54 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Fix pmap_procwr().

While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.84 src/sys/arch/powerpc/ibm4xx/pmap.c:1.85
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.84	Thu Mar  5 02:14:52 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Mar  5 11:44:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.84 2020/03/05 02:14:52 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.85 2020/03/05 11:44:54 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.84 2020/03/05 02:14:52 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.85 2020/03/05 11:44:54 rin Exp $");
 
 #include 
 #include 
@@ -1175,8 +1175,9 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 	}
 	__asm volatile(
 		"mfmsr %0;"
-		"li %1, %7;"
+		"li %1,0x20;"		/* Turn off IMMU */
 		"andc %1,%0,%1;"
+		"ori %1,%1,0x10;"	/* Turn on DMMU for sure */
 		"mtmsr %1;"
 		"sync;isync;"
 		"mfpid %1;"
@@ -1192,8 +1193,7 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		"mtmsr %0;"
 		"sync; isync"
 		: "=" (msr), "=" (opid)
-		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step),
-		  "K" (PSL_IR | PSL_DR));
+		: "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step));
 }
 
 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 11:33:14 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pic_uic.c

Log Message:
Remove unused macros.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/ibm4xx/pic_uic.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/powerpc/ibm4xx/pic_uic.c
diff -u src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.4 src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.5
--- src/sys/arch/powerpc/ibm4xx/pic_uic.c:1.4	Tue Nov 19 12:46:43 2013
+++ src/sys/arch/powerpc/ibm4xx/pic_uic.c	Thu Mar  5 11:33:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_uic.c,v 1.4 2013/11/19 12:46:43 kiyohara Exp $	*/
+/*	$NetBSD: pic_uic.c,v 1.5 2020/03/05 11:33:14 rin Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_uic.c,v 1.4 2013/11/19 12:46:43 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_uic.c,v 1.5 2020/03/05 11:33:14 rin Exp $");
 
 #include 
 #include 
@@ -295,12 +295,6 @@ struct pic_ops pic_uic2 = {
 #endif /* MULTIUIC */
 #endif /* !PPC_IBM403 */
 
-/* Write External Enable Immediate */
-#define	wrteei(en) 		__asm volatile ("wrteei %0" : : "K"(en))
-
-/* Enforce In Order Execution of I/O */
-#define	eieio() 		__asm volatile ("eieio")
-
 /*
  * Set up interrupt mapping array.
  */



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 11:33:14 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pic_uic.c

Log Message:
Remove unused macros.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/powerpc/ibm4xx/pic_uic.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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:35:00 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.82 src/sys/arch/powerpc/ibm4xx/pmap.c:1.83
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.82	Thu Mar  5 01:33:36 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Mar  5 01:35:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.82 2020/03/05 01:33:36 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.83 2020/03/05 01:35:00 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.82 2020/03/05 01:33:36 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.83 2020/03/05 01:35:00 rin Exp $");
 
 #include 
 #include 
@@ -1183,7 +1183,7 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		"mtpid %2;"
 		"sync; isync;"
 		"1:"
-		"dcbf 0,%3;"
+		"dcbst 0,%3;"
 		"icbi 0,%3;"
 		"add %3,%3,%5;"
 		"addc. %4,%4,%6;"



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:35:00 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:33:36 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.81 src/sys/arch/powerpc/ibm4xx/pmap.c:1.82
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.81	Thu Mar  5 01:31:27 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Mar  5 01:33:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.81 2020/03/05 01:31:27 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.82 2020/03/05 01:33:36 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.81 2020/03/05 01:31:27 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.82 2020/03/05 01:33:36 rin Exp $");
 
 #include 
 #include 
@@ -1321,8 +1321,8 @@ ppc4xx_tlb_enter(int ctx, vaddr_t va, u_
 	__asm volatile(
 		"mfmsr %0;"			/* Save MSR */
 		"li %1,0;"
-		"tlbwe %1,%3,0;"		/* Invalidate old entry. */
 		"mtmsr %1;"			/* Clear MSR */
+		"tlbwe %1,%3,0;"		/* Invalidate old entry. */
 		"mfpid %1;"			/* Save old PID */
 		"mtpid %2;"			/* Load translation ctx */
 		"sync; isync;"



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:33:36 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:31:27 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Misc non-critical fixes.

- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.80 src/sys/arch/powerpc/ibm4xx/pmap.c:1.81
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.80	Fri Feb 21 13:16:16 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Mar  5 01:31:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.80 2020/02/21 13:16:16 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.81 2020/03/05 01:31:27 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.80 2020/02/21 13:16:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.81 2020/03/05 01:31:27 rin Exp $");
 
 #include 
 #include 
@@ -1173,7 +1173,8 @@ pmap_procwr(struct proc *p, vaddr_t va, 
 		ctx_alloc(pm);
 		ctx = pm->pm_ctx;
 	}
-	__asm volatile("mfmsr %0;"
+	__asm volatile(
+		"mfmsr %0;"
 		"li %1, %7;"
 		"andc %1,%0,%1;"
 		"mtmsr %1;"
@@ -1207,7 +1208,8 @@ ppc4xx_tlb_flush(vaddr_t va, int pid)
 	if (!pid)
 		return;
 
-	__asm( 	"mfpid %1;"		/* Save PID */
+	__asm volatile(
+		"mfpid %1;"		/* Save PID */
 		"mfmsr %2;"		/* Save MSR */
 		"li %0,0;"		/* Now clear MSR */
 		"mtmsr %0;"
@@ -1225,7 +1227,6 @@ ppc4xx_tlb_flush(vaddr_t va, int pid)
 		: "=" (i), "=" (found), "=" (msr)
 		: "r" (va), "r" (pid));
 	if (found && !TLB_LOCKED(i)) {
-
 		/* Now flush translation */
 		__asm volatile(
 			"tlbwe %0,%1,0;"
@@ -1308,7 +1309,7 @@ ppc4xx_tlb_enter(int ctx, vaddr_t va, u_
 	idx = ppc4xx_tlb_find_victim();
 
 #ifdef DIAGNOSTIC
-	if ((idx < tlb_nreserved) || (idx >= NTLB)) {
+	if ((idx < tlb_nreserved) || (idx >= NTLB) || (idx & 63) == 0) {
 		panic("ppc4xx_tlb_enter: replacing entry %ld", idx);
 	}
 #endif
@@ -1325,10 +1326,6 @@ ppc4xx_tlb_enter(int ctx, vaddr_t va, u_
 		"mfpid %1;"			/* Save old PID */
 		"mtpid %2;"			/* Load translation ctx */
 		"sync; isync;"
-#ifdef DEBUG
-		"andi. %3,%3,63;"
-		"tweqi %3,0;" 			/* X DEBUG trap on index 0 */
-#endif
 		"tlbwe %4,%3,1; tlbwe %5,%3,0;"	/* Set TLB */
 		"sync; isync;"
 		"mtpid %1; mtmsr %0;"		/* Restore PID and MSR */



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:31:27 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Misc non-critical fixes.

- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:21:09 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: cpu.c

Log Message:
Cosmetic change. No binary changes.


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

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:21:09 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: cpu.c

Log Message:
Cosmetic change. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/cpu.c
diff -u src/sys/arch/powerpc/ibm4xx/cpu.c:1.33 src/sys/arch/powerpc/ibm4xx/cpu.c:1.34
--- src/sys/arch/powerpc/ibm4xx/cpu.c:1.33	Mon Mar 24 19:29:59 2014
+++ src/sys/arch/powerpc/ibm4xx/cpu.c	Thu Mar  5 01:21:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.33 2014/03/24 19:29:59 christos Exp $	*/
+/*	$NetBSD: cpu.c,v 1.34 2020/03/05 01:21:09 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.33 2014/03/24 19:29:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.34 2020/03/05 01:21:09 rin Exp $");
 
 #include 
 #include 
@@ -317,6 +317,6 @@ dcache_wbinv_page(vaddr_t va)
 		for (size_t i = 0; i < PAGE_SIZE; i += dcache_line_size) {
 			__asm volatile("dcbf %0,%1" : : "b" (va), "r" (i));
 		}
-		__asm volatile("sync;isync" : : );
+		__asm volatile("sync; isync" : : );
 	}
 }



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:15:35 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
Cosmetic changes. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx/copyinstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.12 src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.13
--- src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.12	Thu Mar  5 01:13:00 2020
+++ src/sys/arch/powerpc/ibm4xx/copyinstr.c	Thu Mar  5 01:15:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyinstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $	*/
+/*	$NetBSD: copyinstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $");
 
 #include 
 #include 
@@ -82,12 +82,13 @@ copyinstr(const void *udaddr, void *kadd
 		"mtpid %4; sync;"		/* Load user ctx */
 		"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
 		"sync; isync;"
-		"mtpid %1;sync;"
+		"mtpid %1; sync;"
 		"stb %2,0(%6); dcbst 0,%6; addi %6,%6,1;"
 		/* Store kernel byte */
 		"sync; isync;"
 		"or. %2,%2,%2;"
 		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
+
 		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
 		"sync; isync;"
 		"mfctr %3;"			/* Restore resid */
Index: src/sys/arch/powerpc/ibm4xx/copyoutstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.12 src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.13
--- src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.12	Thu Mar  5 01:13:00 2020
+++ src/sys/arch/powerpc/ibm4xx/copyoutstr.c	Thu Mar  5 01:15:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyoutstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $	*/
+/*	$NetBSD: copyoutstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.13 2020/03/05 01:15:35 rin Exp $");
 
 #include 
 #include 
@@ -79,7 +79,7 @@ copyoutstr(const void *kaddr, void *udad
 		"sync; isync;"
 
 		"1:"
-		"mtpid %1;sync;"
+		"mtpid %1; sync;"
 		"lbz %2,0(%6); addi %6,%6,1;"	/* Store kernel byte */
 		"sync; isync;"
 		"mtpid %4; sync;"		/* Load user ctx */



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:15:35 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
Cosmetic changes. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:13:00 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx/copyinstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.11 src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.12
--- src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.11	Thu Mar  5 01:10:57 2020
+++ src/sys/arch/powerpc/ibm4xx/copyinstr.c	Thu Mar  5 01:13:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyinstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $	*/
+/*	$NetBSD: copyinstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $");
 
 #include 
 #include 
@@ -83,7 +83,7 @@ copyinstr(const void *udaddr, void *kadd
 		"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
 		"sync; isync;"
 		"mtpid %1;sync;"
-		"stb %2,0(%6); dcbf 0,%6; addi %6,%6,1;"
+		"stb %2,0(%6); dcbst 0,%6; addi %6,%6,1;"
 		/* Store kernel byte */
 		"sync; isync;"
 		"or. %2,%2,%2;"
Index: src/sys/arch/powerpc/ibm4xx/copyoutstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.11 src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.12
--- src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.11	Thu Mar  5 01:10:57 2020
+++ src/sys/arch/powerpc/ibm4xx/copyoutstr.c	Thu Mar  5 01:13:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyoutstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $	*/
+/*	$NetBSD: copyoutstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.12 2020/03/05 01:13:00 rin Exp $");
 
 #include 
 #include 
@@ -83,7 +83,7 @@ copyoutstr(const void *kaddr, void *udad
 		"lbz %2,0(%6); addi %6,%6,1;"	/* Store kernel byte */
 		"sync; isync;"
 		"mtpid %4; sync;"		/* Load user ctx */
-		"stb %2,0(%5); dcbf 0,%5; addi %5,%5,1;"
+		"stb %2,0(%5); dcbst 0,%5; addi %5,%5,1;"
 		/* Load byte */
 		"sync; isync;"
 		"or. %2,%2,%2;"



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:13:00 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
Use dcbst instead of dcbf to flush cache; the former does not invalidate
the cache line, which should be used immediately in most cases.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:10:57 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx/copyinstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.10 src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.11
--- src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.10	Thu Mar  5 00:54:13 2020
+++ src/sys/arch/powerpc/ibm4xx/copyinstr.c	Thu Mar  5 01:10:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyinstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $	*/
+/*	$NetBSD: copyinstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $");
 
 #include 
 #include 
@@ -46,7 +46,8 @@ int
 copyinstr(const void *udaddr, void *kaddr, size_t len, size_t *done)
 {
 	struct pmap *pm = curproc->p_vmspace->vm_map.pmap;
-	int rv, msr, pid, tmp, ctx;
+	size_t resid;
+	int rv, msr, pid, data, ctx;
 	struct faultbuf env;
 
 	if (__predict_false(len == 0)) {
@@ -68,6 +69,7 @@ copyinstr(const void *udaddr, void *kadd
 		ctx = pm->pm_ctx;
 	}
 
+	resid = len;
 	__asm volatile(
 		"mtctr %3;"			/* Set up counter */
 		"mfmsr %0;"			/* Save MSR */
@@ -76,8 +78,6 @@ copyinstr(const void *udaddr, void *kadd
 		"mfpid %1;"			/* Save old PID */
 		"sync; isync;"
 
-		"li %3,0;"			/* Clear len */
-
 		"1: "
 		"mtpid %4; sync;"		/* Load user ctx */
 		"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
@@ -86,16 +86,19 @@ copyinstr(const void *udaddr, void *kadd
 		"stb %2,0(%6); dcbf 0,%6; addi %6,%6,1;"
 		/* Store kernel byte */
 		"sync; isync;"
-		"addi %3,%3,1;"			/* Inc len */
 		"or. %2,%2,%2;"
 		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
 		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
 		"sync; isync;"
-		: "=" (msr), "=" (pid), "=" (tmp), "+b" (len)
+		"mfctr %3;"			/* Restore resid */
+		: "=" (msr), "=" (pid), "=" (data), "+r" (resid)
 		: "r" (ctx), "b" (udaddr), "b" (kaddr));
 
 	curpcb->pcb_onfault = NULL;
 	if (done)
-		*done = len;
-	return 0;
+		*done = len - resid;
+	if (resid == 0 && (char)data != '\0')
+		return ENAMETOOLONG;
+	else
+		return 0;
 }
Index: src/sys/arch/powerpc/ibm4xx/copyoutstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.10 src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.11
--- src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.10	Thu Mar  5 00:54:13 2020
+++ src/sys/arch/powerpc/ibm4xx/copyoutstr.c	Thu Mar  5 01:10:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyoutstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $	*/
+/*	$NetBSD: copyoutstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.11 2020/03/05 01:10:57 rin Exp $");
 
 #include 
 #include 
@@ -46,7 +46,8 @@ int
 copyoutstr(const void *kaddr, void *udaddr, size_t len, size_t *done)
 {
 	struct pmap *pm = curproc->p_vmspace->vm_map.pmap;
-	int rv, msr, pid, tmp, ctx;
+	size_t resid;
+	int rv, msr, pid, data, ctx;
 	struct faultbuf env;
 
 	if (__predict_false(len == 0)) {
@@ -68,6 +69,7 @@ copyoutstr(const void *kaddr, void *udad
 		ctx = pm->pm_ctx;
 	}
 
+	resid = len;
 	__asm volatile(
 		"mtctr %3;"			/* Set up counter */
 		"mfmsr %0;"			/* Save MSR */
@@ -76,8 +78,6 @@ copyoutstr(const void *kaddr, void *udad
 		"mfpid %1;"			/* Save old PID */
 		"sync; isync;"
 
-		"li %3,0;"			/* Clear len */
-
 		"1:"
 		"mtpid %1;sync;"
 		"lbz %2,0(%6); addi %6,%6,1;"	/* Store kernel byte */
@@ -86,17 +86,20 @@ copyoutstr(const void *kaddr, void *udad
 		"stb %2,0(%5); dcbf 0,%5; addi %5,%5,1;"
 		/* Load byte */
 		"sync; isync;"
-		"addi %3,%3,1;"			/* Inc len */
 		"or. %2,%2,%2;"
 		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
 
 		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
 		"sync; isync;"
-		: "=" (msr), "=" (pid), "=" (tmp), "+b" (len)
+		"mfctr %3;"			/* Restore resid */
+		: "=" (msr), "=" (pid), "=" (data), "+r" (resid)
 		: "r" (ctx), "b" (udaddr), "b" (kaddr));
 
 	curpcb->pcb_onfault = NULL;
 	if (done)
-		*done = len;
-	return 0;
+		*done = len - resid;
+	if (resid == 0 && (char)data != '\0')
+		return ENAMETOOLONG;
+	else
+		return 0;
 }



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 01:10:57 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
copy{in,out}str: Correctly return ENAMETOOLONG if source is not
NUL-terminated.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 00:54:13 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
copy{in,out}str: sync style with booke.

- early return in case of len == 0
- *done = 0 on fault


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx/copyinstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.9 src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.10
--- src/sys/arch/powerpc/ibm4xx/copyinstr.c:1.9	Sat Mar 20 23:31:29 2010
+++ src/sys/arch/powerpc/ibm4xx/copyinstr.c	Thu Mar  5 00:54:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyinstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $	*/
+/*	$NetBSD: copyinstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyinstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $");
 
 #include 
 #include 
@@ -49,11 +49,16 @@ copyinstr(const void *udaddr, void *kadd
 	int rv, msr, pid, tmp, ctx;
 	struct faultbuf env;
 
+	if (__predict_false(len == 0)) {
+		if (done)
+			*done = 0;
+		return 0;
+	}
+
 	if ((rv = setfault())) {
 		curpcb->pcb_onfault = NULL;
-		/*  -- len may be lost on a fault */
 		if (done)
-			*done = len;
+			*done = 0;
 		return rv;
 	}
 
@@ -63,34 +68,32 @@ copyinstr(const void *udaddr, void *kadd
 		ctx = pm->pm_ctx;
 	}
 
-	if (len) {
-		__asm volatile("mtctr %3;"		/* Set up counter */
-			"mfmsr %0;"			/* Save MSR */
-			"li %1,0x20; "
-			"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
-			"mfpid %1;"			/* Save old PID */
-			"sync; isync;"
-
-			"li %3,0;"			/* Clear len */
-
-			"1: "
-			"mtpid %4; sync;"		/* Load user ctx */
-			"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
-			"sync; isync;"
-			"mtpid %1;sync;"
-			"stb %2,0(%6);  dcbf 0,%6; addi %6,%6,1;"	/* Store kernel byte */
-			"sync; isync;"
-			"addi %3,%3,1;"			/* Inc len */
-			"or. %2,%2,%2;"
-			"bdnzf 2,1b;"			/*
-			 * while(ctr-- && !zero)
-			 */
-
-			"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
-			"sync; isync;"
-			: "=" (msr), "=" (pid), "=" (tmp), "+b" (len)
-			: "r" (ctx), "b" (udaddr), "b" (kaddr));
-	}
+	__asm volatile(
+		"mtctr %3;"			/* Set up counter */
+		"mfmsr %0;"			/* Save MSR */
+		"li %1,0x20;"
+		"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
+		"mfpid %1;"			/* Save old PID */
+		"sync; isync;"
+
+		"li %3,0;"			/* Clear len */
+
+		"1: "
+		"mtpid %4; sync;"		/* Load user ctx */
+		"lbz %2,0(%5); addi %5,%5,1;"	/* Load byte */
+		"sync; isync;"
+		"mtpid %1;sync;"
+		"stb %2,0(%6); dcbf 0,%6; addi %6,%6,1;"
+		/* Store kernel byte */
+		"sync; isync;"
+		"addi %3,%3,1;"			/* Inc len */
+		"or. %2,%2,%2;"
+		"bdnzf 2,1b;"			/* while(ctr-- && !zero) */
+		"mtpid %1; mtmsr %0;"		/* Restore PID, MSR */
+		"sync; isync;"
+		: "=" (msr), "=" (pid), "=" (tmp), "+b" (len)
+		: "r" (ctx), "b" (udaddr), "b" (kaddr));
+
 	curpcb->pcb_onfault = NULL;
 	if (done)
 		*done = len;
Index: src/sys/arch/powerpc/ibm4xx/copyoutstr.c
diff -u src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.9 src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.10
--- src/sys/arch/powerpc/ibm4xx/copyoutstr.c:1.9	Sat Mar 20 23:31:29 2010
+++ src/sys/arch/powerpc/ibm4xx/copyoutstr.c	Thu Mar  5 00:54:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: copyoutstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $	*/
+/*	$NetBSD: copyoutstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.9 2010/03/20 23:31:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copyoutstr.c,v 1.10 2020/03/05 00:54:13 rin Exp $");
 
 #include 
 #include 
@@ -49,11 +49,16 @@ copyoutstr(const void *kaddr, void *udad
 	int rv, msr, pid, tmp, ctx;
 	struct faultbuf env;
 
+	if (__predict_false(len == 0)) {
+		if (done)
+			*done = 0;
+		return 0;
+	}
+
 	if ((rv = setfault())) {
 		curpcb->pcb_onfault = NULL;
-		/*  -- len may be lost on a fault */
 		if (done)
-			*done = len;
+			*done = 0;
 		return rv;
 	}
 
@@ -63,34 +68,33 @@ copyoutstr(const void *kaddr, void *udad
 		ctx = pm->pm_ctx;
 	}
 
-	if (len) {
-		__asm volatile("mtctr %3;"		/* Set up counter */
-			"mfmsr %0;"			/* Save MSR */
-			"li %1,0x20; "
-			"andc %1,%0,%1; mtmsr %1;"	/* Disable IMMU */
-			"mfpid %1;"			/* Save old PID */
-			"sync; isync;"
-
-			"li %3,0;"			/* Clear len */
-
-			"1:"
-			"mtpid %1;sync;"
-			"lbz %2,0(%6); addi %6,%6,1;"	/* Store kernel byte */
-			"sync; isync;"
-			"mtpid %4; sync;"		/* Load user ctx */
-			"stb %2,0(%5);  dcbf 0,%5; addi %5,%5,1;"	/* Load byte */
-			"sync; isync;"
-			"addi %3,%3,1;"			/* Inc len */
-			"or. %2,%2,%2;"
-			

CVS commit: src/sys/arch/powerpc/ibm4xx

2020-03-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Mar  5 00:54:13 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: copyinstr.c copyoutstr.c

Log Message:
copy{in,out}str: sync style with booke.

- early return in case of len == 0
- *done = 0 on fault


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/ibm4xx/copyinstr.c \
src/sys/arch/powerpc/ibm4xx/copyoutstr.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/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 15:15:48 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Do not try to recovery from data page fault in interrupt context;
catch up belatedly with powerpc/trap.c rev 1.49 and etc.:


http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.49


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.77 src/sys/arch/powerpc/ibm4xx/trap.c:1.78
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.77	Fri Feb 21 14:49:57 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Fri Feb 21 15:15:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.77 2020/02/21 14:49:57 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.78 2020/02/21 15:15:48 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.77 2020/02/21 14:49:57 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2020/02/21 15:15:48 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -182,7 +182,15 @@ trap(struct trapframe *tf)
 		{
 			struct vm_map *map;
 			vaddr_t va;
-			struct faultbuf *fb = NULL;
+			struct faultbuf *fb;
+
+			pcb = lwp_getpcb(l);
+			fb = pcb->pcb_onfault;
+
+			if (curcpu()->ci_idepth >= 0) {
+rv = EFAULT;
+goto out;
+			}
 
 			va = tf->tf_dear;
 			if (tf->tf_pid == KERNEL_PID) {
@@ -200,13 +208,12 @@ trap(struct trapframe *tf)
 			(ftype & VM_PROT_WRITE) ? "write" : "read",
 			(void *)va, tf->tf_esr));
 
-			pcb = lwp_getpcb(l);
-			fb = pcb->pcb_onfault;
 			pcb->pcb_onfault = NULL;
 			rv = uvm_fault(map, trunc_page(va), ftype);
 			pcb->pcb_onfault = fb;
 			if (rv == 0)
 return;
+out:
 			if (fb != NULL) {
 tf->tf_pid = KERNEL_PID;
 tf->tf_srr0 = fb->fb_pc;



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 15:15:48 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Do not try to recovery from data page fault in interrupt context;
catch up belatedly with powerpc/trap.c rev 1.49 and etc.:


http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/powerpc/powerpc/trap.c#rev1.49


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 14:49:58 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Tiny improvements to copyin() and copyout():

- Use lwz/stw instead of 4-byte lswi/stswi for 405 and later, which
  support unaligned word load/store by hardware. In many cases, both
  source and destination are aligned on word boundaries.

- Use dcbst instead of dcbf to flush cache. The former does not
  invalidate the cache line. Copied data should be used soon after.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 14:49:58 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Tiny improvements to copyin() and copyout():

- Use lwz/stw instead of 4-byte lswi/stswi for 405 and later, which
  support unaligned word load/store by hardware. In many cases, both
  source and destination are aligned on word boundaries.

- Use dcbst instead of dcbf to flush cache. The former does not
  invalidate the cache line. Copied data should be used soon after.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.76 src/sys/arch/powerpc/ibm4xx/trap.c:1.77
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.76	Fri Feb 21 14:27:20 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Fri Feb 21 14:49:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.76 2020/02/21 14:27:20 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.77 2020/02/21 14:49:57 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.76 2020/02/21 14:27:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.77 2020/02/21 14:49:57 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -428,12 +428,20 @@ copyin(const void *udaddr, void *kaddr, 
 		"   beq- 2f;"			/* No words. Go do bytes */
 		"   mtctr %[count];"
 		"1: mtpid %[ctx]; sync;"
+#ifdef PPC_IBM403
 		"   lswi %[tmp],%[udaddr],4;"	/* Load user word */
+#else
+		"   lwz %[tmp],0(%[udaddr]);"
+#endif
 		"   addi %[udaddr],%[udaddr],0x4;" /* next udaddr word */
 		"   sync; isync;"
 		"   mtpid %[pid]; sync;"
+#ifdef PPC_IBM403
 		"   stswi %[tmp],%[kaddr],4;"	/* Store kernel word */
-		"   dcbf 0,%[kaddr];"		/* flush cache */
+#else
+		"   stw %[tmp],0(%[kaddr]);"
+#endif
+		"   dcbst 0,%[kaddr];"		/* flush cache */
 		"   addi %[kaddr],%[kaddr],0x4;" /* next udaddr word */
 		"   sync; isync;"
 		"   bdnz 1b;"			/* repeat */
@@ -448,7 +456,7 @@ copyin(const void *udaddr, void *kaddr, 
 		"   sync; isync;"
 		"   mtpid %[pid]; sync;"
 		"   stb %[tmp],0(%[kaddr]);"	/* Store kernel byte */
-		"   dcbf 0,%[kaddr];"		/* flush cache */
+		"   dcbst 0,%[kaddr];"		/* flush cache */
 		"   addi %[kaddr],%[kaddr],0x1;"
 		"   sync; isync;"
 		"   b 3b;"
@@ -527,12 +535,20 @@ copyout(const void *kaddr, void *udaddr,
 		"   beq- 2f;"			/* No words. Go do bytes */
 		"   mtctr %[count];"
 		"1: mtpid %[pid]; sync;"
+#ifdef PPC_IBM403
 		"   lswi %[tmp],%[kaddr],4;"	/* Load kernel word */
+#else
+		"   lwz %[tmp],0(%[kaddr]);"
+#endif
 		"   addi %[kaddr],%[kaddr],0x4;" /* next kaddr word */
 		"   sync; isync;"
 		"   mtpid %[ctx]; sync;"
+#ifdef PPC_IBM403
 		"   stswi %[tmp],%[udaddr],4;"	/* Store user word */
-		"   dcbf 0,%[udaddr];"		/* flush cache */
+#else
+		"   stw %[tmp],0(%[udaddr]);"
+#endif
+		"   dcbst 0,%[udaddr];"		/* flush cache */
 		"   addi %[udaddr],%[udaddr],0x4;" /* next udaddr word */
 		"   sync; isync;"
 		"   bdnz 1b;"			/* repeat */
@@ -547,7 +563,7 @@ copyout(const void *kaddr, void *udaddr,
 		"   sync; isync;"
 		"   mtpid %[ctx]; sync;"
 		"   stb %[tmp],0(%[udaddr]);"	/* Store user byte */
-		"   dcbf 0,%[udaddr];"		/* flush cache */
+		"   dcbst 0,%[udaddr];"		/* flush cache */
 		"   addi %[udaddr],%[udaddr],0x1;"
 		"   sync; isync;"
 		"   b 3b;"



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 14:27:20 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Cosmetic changes for assembler codes. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.75 src/sys/arch/powerpc/ibm4xx/trap.c:1.76
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.75	Fri Feb 21 13:32:31 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Fri Feb 21 14:27:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.75 2020/02/21 13:32:31 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.76 2020/02/21 14:27:20 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.75 2020/02/21 13:32:31 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.76 2020/02/21 14:27:20 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -418,43 +418,45 @@ copyin(const void *udaddr, void *kaddr, 
 	}
 
 	__asm volatile(
-		"   mfmsr %[msr];"  /* Save MSR */
-		"   li %[pid],0x20; "
-		"   andc %[pid],%[msr],%[pid]; mtmsr %[pid];"   /* Disable IMMU */
-		"   mfpid %[pid];"  /* Save old PID */
+		"   mfmsr %[msr];"		/* Save MSR */
+		"   li %[pid],0x20;"
+		"   andc %[pid],%[msr],%[pid]; mtmsr %[pid];" /* Disable IMMU */
+		"   mfpid %[pid];"		/* Save old PID */
 		"   sync; isync;"
 
-		"   srwi. %[count],%[len],0x2;" /* How many words? */
-		"   beq-  2f;"  /* No words. Go do bytes */
+		"   srwi. %[count],%[len],0x2;"	/* How many words? */
+		"   beq- 2f;"			/* No words. Go do bytes */
 		"   mtctr %[count];"
 		"1: mtpid %[ctx]; sync;"
-		"   lswi %[tmp],%[udaddr],4;"   /* Load user word */
-		"   addi %[udaddr],%[udaddr],0x4;"  /* next udaddr word */
+		"   lswi %[tmp],%[udaddr],4;"	/* Load user word */
+		"   addi %[udaddr],%[udaddr],0x4;" /* next udaddr word */
 		"   sync; isync;"
-		"   mtpid %[pid];sync;"
-		"   stswi %[tmp],%[kaddr],4;"/* Store kernel word */
-		"   dcbf 0,%[kaddr];"   /* flush cache */
-		"   addi %[kaddr],%[kaddr],0x4;"/* next udaddr word */
+		"   mtpid %[pid]; sync;"
+		"   stswi %[tmp],%[kaddr],4;"	/* Store kernel word */
+		"   dcbf 0,%[kaddr];"		/* flush cache */
+		"   addi %[kaddr],%[kaddr],0x4;" /* next udaddr word */
 		"   sync; isync;"
-		"   bdnz 1b;"   /* repeat */
+		"   bdnz 1b;"			/* repeat */
 
-		"2: andi. %[count],%[len],0x3;" /* How many remaining bytes? */
+		"2: andi. %[count],%[len],0x3;"	/* How many remaining bytes? */
 		"   addi %[count],%[count],0x1;"
 		"   mtctr %[count];"
-		"3: bdz 10f;"   /* while count */
-		"   mtpid %[ctx];sync;"
-		"   lbz %[tmp],0(%[udaddr]);"   /* Load user byte */
-		"   addi %[udaddr],%[udaddr],0x1;"  /* next udaddr byte */
+		"3: bdz 10f;"			/* while count */
+		"   mtpid %[ctx]; sync;"
+		"   lbz %[tmp],0(%[udaddr]);"	/* Load user byte */
+		"   addi %[udaddr],%[udaddr],0x1;" /* next udaddr byte */
 		"   sync; isync;"
 		"   mtpid %[pid]; sync;"
-		"   stb %[tmp],0(%[kaddr]);"/* Store kernel byte */
-		"   dcbf 0,%[kaddr];"   /* flush cache */
+		"   stb %[tmp],0(%[kaddr]);"	/* Store kernel byte */
+		"   dcbf 0,%[kaddr];"		/* flush cache */
 		"   addi %[kaddr],%[kaddr],0x1;"
 		"   sync; isync;"
 		"   b 3b;"
-		"10:mtpid %[pid]; mtmsr %[msr]; sync; isync;" /* Restore PID and MSR */
+		"10:mtpid %[pid]; mtmsr %[msr]; sync; isync;"
+		/* Restore PID and MSR */
 		: [msr] "=" (msr), [pid] "=" (pid), [tmp] "=" (tmp)
-		: [udaddr] "b" (udaddr), [ctx] "b" (ctx), [kaddr] "b" (kaddr), [len] "b" (len), [count] "b" (count));
+		: [udaddr] "b" (udaddr), [ctx] "b" (ctx), [kaddr] "b" (kaddr),
+		  [len] "b" (len), [count] "b" (count));
 
 	curpcb->pcb_onfault = NULL;
 	return 0;
@@ -515,43 +517,45 @@ copyout(const void *kaddr, void *udaddr,
 	}
 
 	__asm volatile(
-		"   mfmsr %[msr];"  /* Save MSR */ \
-		"   li %[pid],0x20; " \
-		"   andc %[pid],%[msr],%[pid]; mtmsr %[pid];"   /* Disable IMMU */ \
-		"   mfpid %[pid];"  /* Save old PID */ \
+		"   mfmsr %[msr];"		/* Save MSR */
+		"   li %[pid],0x20;"
+		"   andc %[pid],%[msr],%[pid]; mtmsr %[pid];" /* Disable IMMU */
+		"   mfpid %[pid];"		/* Save old PID */
 		"   sync; isync;"
 
-		"   srwi. %[count],%[len],0x2;" /* How many words? */
-		"   beq-  2f;"  /* No words. Go do bytes */
+		"   srwi. %[count],%[len],0x2;"	/* How many words? */
+		"   beq- 2f;"			/* No words. Go do bytes */
 		"   mtctr %[count];"
-		"1: mtpid %[pid];sync;"
-		"   lswi %[tmp],%[kaddr],4;"/* Load kernel word */
-		"   addi %[kaddr],%[kaddr],0x4;"/* next kaddr word */
+		"1: mtpid %[pid]; sync;"
+		"   lswi %[tmp],%[kaddr],4;"	/* Load kernel word */
+		"   addi 

CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 14:27:20 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Cosmetic changes for assembler codes. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 13:32:31 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Comment out badaddr() and badaddr_read() on ibm4xx for now.

They are not used nor exposed externally in any header file; these
functions may have never been tested so far.

Enable them again when necessary.

Note that badaddr() for oea is used by macppc port, where it is
declared as an external function.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 13:32:31 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Comment out badaddr() and badaddr_read() on ibm4xx for now.

They are not used nor exposed externally in any header file; these
functions may have never been tested so far.

Enable them again when necessary.

Note that badaddr() for oea is used by macppc port, where it is
declared as an external function.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.74 src/sys/arch/powerpc/ibm4xx/trap.c:1.75
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.74	Thu Feb 20 06:36:04 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Fri Feb 21 13:32:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.74 2020/02/20 06:36:04 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.75 2020/02/21 13:32:31 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.74 2020/02/20 06:36:04 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.75 2020/02/21 13:32:31 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -116,9 +116,11 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7
 static int fix_unaligned(struct lwp *l, struct trapframe *tf);
 
 void trap(struct trapframe *);	/* Called from locore / trap_subr */
-/* Why are these not defined in a header? */
+#if 0
+/* Not currently used nor exposed externally in any header file */
 int badaddr(void *, size_t);
 int badaddr_read(void *, size_t, int *);
+#endif
 int ctx_setup(int, int);
 
 #ifdef DEBUG
@@ -616,6 +618,7 @@ kcopy(const void *src, void *dst, size_t
 	return 0;
 }
 
+#if 0
 int
 badaddr(void *addr, size_t size)
 {
@@ -666,6 +669,7 @@ badaddr_read(void *addr, size_t size, in
 
 	return 0;
 }
+#endif
 
 /*
  * For now, this only deals with the particular unaligned access case



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 13:16:16 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
In ppc4xx_tlb_find_victim(), mark kernel stack page TLBF_REF instead of
TLBF_USED. This should be originally intended behavior of this code
segment, because

- TLBF_USED is already checked just before, so marking this page
  TLBF_USED is no-op.
- TLBF_REF flag exempts that page from being flushed from TLB in next
  scan, when kernel stack may be still there with high probability.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.79 src/sys/arch/powerpc/ibm4xx/pmap.c:1.80
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.79	Thu Feb 20 05:34:37 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Fri Feb 21 13:16:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.79 2020/02/20 05:34:37 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.80 2020/02/21 13:16:16 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.79 2020/02/20 05:34:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.80 2020/02/21 13:16:16 rin Exp $");
 
 #include 
 #include 
@@ -1276,7 +1276,7 @@ ppc4xx_tlb_find_victim(void)
 			(tlb_info[tlbnext].ti_ctx == KERNEL_PID) &&
 			 (flags & TLBF_USED)) {
 /* Kernel stack page */
-flags |= TLBF_USED;
+flags |= TLBF_REF;
 tlb_info[tlbnext].ti_flags = flags;
 			} else {
 /* Found it! */



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Feb 21 13:16:16 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
In ppc4xx_tlb_find_victim(), mark kernel stack page TLBF_REF instead of
TLBF_USED. This should be originally intended behavior of this code
segment, because

- TLBF_USED is already checked just before, so marking this page
  TLBF_USED is no-op.
- TLBF_REF flag exempts that page from being flushed from TLB in next
  scan, when kernel stack may be still there with high probability.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 06:36:05 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Oops, sort header again. My bad...


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 06:36:05 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Oops, sort header again. My bad...


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.73 src/sys/arch/powerpc/ibm4xx/trap.c:1.74
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.73	Thu Feb 20 05:57:49 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Thu Feb 20 06:36:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.73 2020/02/20 05:57:49 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.74 2020/02/20 06:36:04 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.73 2020/02/20 05:57:49 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.74 2020/02/20 06:36:04 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -96,10 +96,10 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:57:49 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Convert mi_userret(9) into powerpc-specific userret().

This is necessary in order to support RAS.

There are some sanity checks in userret() as well.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:57:49 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Convert mi_userret(9) into powerpc-specific userret().

This is necessary in order to support RAS.

There are some sanity checks in userret() as well.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.72 src/sys/arch/powerpc/ibm4xx/trap.c:1.73
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.72	Thu Feb 20 05:55:24 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Thu Feb 20 05:57:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.72 2020/02/20 05:55:24 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.73 2020/02/20 05:57:49 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.72 2020/02/20 05:55:24 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.73 2020/02/20 05:57:49 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -82,7 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7
 #include 
 #include 
 #include 
-#include 
 
 #if defined(KGDB)
 #include 
@@ -97,6 +96,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -348,8 +348,8 @@ brain_damage:
 		panic("trap");
 	}
 
-	/* Invoke MI userret code */
-	mi_userret(l);
+	/* Invoke powerpc userret code */
+	userret(l, tf);
 }
 
 int



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:55:24 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Sort more headers...


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.71 src/sys/arch/powerpc/ibm4xx/trap.c:1.72
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.71	Thu Feb 20 05:46:08 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Thu Feb 20 05:55:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.71 2020/02/20 05:46:08 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.72 2020/02/20 05:55:24 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.71 2020/02/20 05:46:08 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.72 2020/02/20 05:55:24 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -76,13 +76,13 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7
 #define	__UFETCHSTORE_PRIVATE
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #if defined(KGDB)
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:55:24 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Sort more headers...


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

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:46:08 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Sort headers.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.70 src/sys/arch/powerpc/ibm4xx/trap.c:1.71
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.70	Sun Apr  7 05:25:55 2019
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Thu Feb 20 05:46:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.70 2019/04/07 05:25:55 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.71 2020/02/20 05:46:08 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.70 2019/04/07 05:25:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.71 2020/02/20 05:46:08 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -100,10 +100,10 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.7
 
 #include 
 #include 
-#include 
 
 #include 
 #include 
+#include 
 #include 
 
 #include 



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:46:08 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Sort headers.


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

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:34:37 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Clear ti_ctx when flushing a TLB entry for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.78 src/sys/arch/powerpc/ibm4xx/pmap.c:1.79
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.78	Thu Feb 20 05:21:54 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Feb 20 05:34:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.78 2020/02/20 05:21:54 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.79 2020/02/20 05:34:37 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.78 2020/02/20 05:21:54 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.79 2020/02/20 05:34:37 rin Exp $");
 
 #include 
 #include 
@@ -1535,6 +1535,7 @@ ctx_flush(int cnum)
 #endif
 			/* Invalidate particular TLB entry regardless of locked status */
 			__asm volatile("tlbwe %0,%1,0" : :"r"(0),"r"(i));
+			tlb_info[i].ti_ctx = 0;
 			tlb_info[i].ti_flags = 0;
 		}
 	}



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:34:37 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Clear ti_ctx when flushing a TLB entry for clarity.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:21:55 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Fix off-by-one error for ctx (ASID).

Note that NUM_CTX = 256 = 0 stands for disabling protection by ASID.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.77 src/sys/arch/powerpc/ibm4xx/pmap.c:1.78
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.77	Thu Feb 20 05:13:16 2020
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Feb 20 05:21:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.77 2020/02/20 05:13:16 rin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.78 2020/02/20 05:21:54 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77 2020/02/20 05:13:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.78 2020/02/20 05:21:54 rin Exp $");
 
 #include 
 #include 
@@ -1563,7 +1563,7 @@ ctx_alloc(struct pmap *pm)
 	/* Find a likely context. */
 	cnum = next;
 	do {
-		if ((++cnum) > NUMCTX)
+		if ((++cnum) >= NUMCTX)
 			cnum = MINCTX;
 	} while (ctxbusy[cnum] != NULL && cnum != next);
 
@@ -1573,7 +1573,7 @@ oops:
 		cnum = MINCTX; /* Never steal ctx 0 or 1 */
 	if (ctx_flush(cnum)) {
 		/* oops -- something's wired. */
-		if ((++cnum) > NUMCTX)
+		if ((++cnum) >= NUMCTX)
 			cnum = MINCTX;
 		goto oops;
 	}



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:21:55 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Fix off-by-one error for ctx (ASID).

Note that NUM_CTX = 256 = 0 stands for disabling protection by ASID.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:13:16 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Fix NULL dereference; "pap" argument of pmap_extract(9) can be NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.76 src/sys/arch/powerpc/ibm4xx/pmap.c:1.77
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.76	Sat Dec 24 19:02:16 2016
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Thu Feb 20 05:13:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.76 2016/12/24 19:02:16 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.77 2020/02/20 05:13:16 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76 2016/12/24 19:02:16 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.77 2020/02/20 05:13:16 rin Exp $");
 
 #include 
 #include 
@@ -1021,7 +1021,7 @@ pmap_extract(struct pmap *pm, vaddr_t va
 	int s;
 
 	s = splvm();
-	if (pm->pm_ptbl[seg] && (pa = pm->pm_ptbl[seg][ptn])) {
+	if (pm->pm_ptbl[seg] && (pa = pm->pm_ptbl[seg][ptn]) && pap) {
 		*pap = TTE_PA(pa) | (va & PGOFSET);
 	}
 	splx(s);



CVS commit: src/sys/arch/powerpc/ibm4xx

2020-02-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Feb 20 05:13:16 UTC 2020

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Fix NULL dereference; "pap" argument of pmap_extract(9) can be NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/dev

2019-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Dec 15 09:38:40 UTC 2019

Modified Files:
src/sys/arch/powerpc/ibm4xx/dev: com_opb.c

Log Message:
Belatedly catch up with MI com(4) change in com.c rev. 1.351:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/ic/com.c#rev1.351

XXX
pullup to netbsd-9


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/powerpc/ibm4xx/dev/com_opb.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/powerpc/ibm4xx/dev/com_opb.c
diff -u src/sys/arch/powerpc/ibm4xx/dev/com_opb.c:1.22 src/sys/arch/powerpc/ibm4xx/dev/com_opb.c:1.23
--- src/sys/arch/powerpc/ibm4xx/dev/com_opb.c:1.22	Sat Dec  8 17:46:12 2018
+++ src/sys/arch/powerpc/ibm4xx/dev/com_opb.c	Sun Dec 15 09:38:40 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: com_opb.c,v 1.22 2018/12/08 17:46:12 thorpej Exp $ */
+/* $NetBSD: com_opb.c,v 1.23 2019/12/15 09:38:40 rin Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com_opb.c,v 1.22 2018/12/08 17:46:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_opb.c,v 1.23 2019/12/15 09:38:40 rin Exp $");
 
 #include 
 #include 
@@ -143,9 +143,6 @@ void
 com_opb_cnattach(int com_freq, int conaddr, int conspeed, int conmode)
 {
 	static int attached = 0;
-#if (NCOM > 0)
-	struct com_regs	regs;
-#endif
 
 	if (attached)
 		return;
@@ -153,12 +150,8 @@ com_opb_cnattach(int com_freq, int conad
 
 #if (NCOM > 0)
 	/* We *know* the com-console attaches to opb */
-	regs.cr_iot = opb_get_bus_space_tag();
-	regs.cr_iobase = conaddr;
-	regs.cr_nports = COM_NPORTS;
-	/* regs.ioh is initialized by comcnattach */
-
-	if (comcnattach1(, conspeed, com_freq, COM_TYPE_NORMAL, conmode))
+	if (comcnattach(opb_get_bus_space_tag(), conaddr, conspeed, com_freq,
+	COM_TYPE_NORMAL, conmode))
 		panic("can't init serial console @%x", conaddr);
 	else
 		return;



CVS commit: src/sys/arch/powerpc/ibm4xx/dev

2019-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Dec 15 09:38:40 UTC 2019

Modified Files:
src/sys/arch/powerpc/ibm4xx/dev: com_opb.c

Log Message:
Belatedly catch up with MI com(4) change in com.c rev. 1.351:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/ic/com.c#rev1.351

XXX
pullup to netbsd-9


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

2016-12-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 28 09:36:02 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap_subr.S

Log Message:
PR port-powerpc/51367: kernel panic for powerpc/ibm4xx with "option DDB"

Stop using ddbstk/ipkdbstk to make nested traps possible, which avoids
kernel panics reported in the PR.

Suggested and approved by matt.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/ibm4xx/trap_subr.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/powerpc/ibm4xx/trap_subr.S
diff -u src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.25 src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.26
--- src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.25	Mon Dec 26 20:28:00 2016
+++ src/sys/arch/powerpc/ibm4xx/trap_subr.S	Wed Dec 28 09:36:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.25 2016/12/26 20:28:00 rin Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.26 2016/12/28 09:36:02 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -191,20 +191,9 @@ _C_LABEL(extsize) = .-_C_LABEL(extint)
 /*
  * In case of DDB we want a separate trap catcher for it
  */
-	.lcomm	ddbstk,INTSTK,16	/* ddb stack */
-
 	.globl	_C_LABEL(ddblow),_C_LABEL(ddbsize)
 _C_LABEL(ddblow):
-	mtsprg1	%r1			/* save SP */
-	GET_CPUINFO(%r1)
-	stmw	%r28,CI_DDBSAVE(%r1)	/* free r28-r31 */
-	mflr	%r28			/* save LR */
-	mfcr	%r29			/* save CR */
-	mfsrr0	%r30
-	mfsrr1	%r31
-	stmw	%r30,(CI_DDBSAVE+CPUSAVE_SRR0)(%r1)	/* save srr0/srr1 */
-	lis	%r1,ddbstk+INTSTK-CALLFRAMELEN@ha	/* get new SP */
-	addi	%r1,%r1,ddbstk+INTSTK-CALLFRAMELEN@l
+	ACCESS_PROLOG(CI_DDBSAVE)
 	bla	ddbtrap
 _C_LABEL(ddbsize) = .-_C_LABEL(ddblow)
 #endif	/* DDB || KGDB */
@@ -213,21 +202,9 @@ _C_LABEL(ddbsize) = .-_C_LABEL(ddblow)
 /*
  * In case of IPKDB we want a separate trap catcher for it
  */
-
-	.lcomm	ipkdbstk,INTSTK,16	/* ipkdb stack */
-
 	.globl	_C_LABEL(ipkdblow),_C_LABEL(ipkdbsize)
 _C_LABEL(ipkdblow):
-	mtsprg1	%r1			/* save SP */
-	GET_CPUINFO(%r1)
-	stmw	%r28,CI_IPKDBSAVE(%r1)	/* free r28-r31 */
-	mflr	%r28			/* save LR */
-	mfcr	%r29			/* save CR */
-	mfsrr0	%r30
-	mfsrr1	%r31
-	stmw	%r30,(CI_IPKDBSAVE+CPUSAVE_SRR0)(%r1)	/* save srr0/srr1 */
-	lis	%r1,ipkdbstk+INTSTK-CALLFRAMELEN@ha	/* get new SP */
-	addi	%r1,%r1,ipkdbstk+INTSTK-CALLFRAMELEN@l
+	ACCESS_PROLOG(CI_IPKDBSAVE)
 	bla	ipkdbtrap
 _C_LABEL(ipkdbsize) = .-_C_LABEL(ipkdblow)
 #endif	/* IPKDB */



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 28 09:36:02 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap_subr.S

Log Message:
PR port-powerpc/51367: kernel panic for powerpc/ibm4xx with "option DDB"

Stop using ddbstk/ipkdbstk to make nested traps possible, which avoids
kernel panics reported in the PR.

Suggested and approved by matt.


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

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 21:54:00 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Remove wrong comment which was copy-and-pasted from somewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 21:54:00 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Remove wrong comment which was copy-and-pasted from somewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.68 src/sys/arch/powerpc/ibm4xx/trap.c:1.69
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.68	Fri Dec 16 06:29:11 2016
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Mon Dec 26 21:54:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.68 2016/12/16 06:29:11 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.69 2016/12/26 21:54:00 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.68 2016/12/16 06:29:11 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69 2016/12/26 21:54:00 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -172,10 +172,6 @@ trap(struct trapframe *tf)
 		trapsignal(l, );
 		break;
 
-	/*
-	 * If we could not find and install appropriate TLB entry, fall through.
-	 */
-
 	case EXC_DSI:
 		/* FALLTHROUGH */
 	case EXC_DTMISS:



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 21:25:08 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c

Log Message:
Assert that the size of a trap handler does not exceed its room.

XXX
The debug exception is critical for ibm4xx. Since rev 1.24, we use the critical
trap hundler for it. Sorry for the wrong commit log for rev 1.24.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/ibm4xx/ibm4xx_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/powerpc/ibm4xx/ibm4xx_machdep.c
diff -u src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.24 src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.25
--- src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.24	Mon Dec 26 20:28:00 2016
+++ src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c	Mon Dec 26 21:25:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibm4xx_machdep.c,v 1.24 2016/12/26 20:28:00 rin Exp $	*/
+/*	$NetBSD: ibm4xx_machdep.c,v 1.25 2016/12/26 21:25:08 rin Exp $	*/
 /*	Original: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */
 
 /*
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.24 2016/12/26 20:28:00 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.25 2016/12/26 21:25:08 rin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -193,6 +193,7 @@ ibm4xx_init(vaddr_t startkernel, vaddr_t
 	}
 
 	for (size_t i = 0; i < __arraycount(trap_table); i++) {
+		KASSERT(trap_table[i].exc_size <= 0x100);
 		trap_copy(trap_table[i].exc_addr, trap_table[i].exc_vector,
 		trap_table[i].exc_size);
 	}



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 21:25:08 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c

Log Message:
Assert that the size of a trap handler does not exceed its room.

XXX
The debug exception is critical for ibm4xx. Since rev 1.24, we use the critical
trap hundler for it. Sorry for the wrong commit log for rev 1.24.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c

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



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 20:28:00 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c trap_subr.S

Log Message:
No need to have same trap handlers in trap_subr.S.
No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/ibm4xx/trap_subr.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/powerpc/ibm4xx

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 20:28:00 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c trap_subr.S

Log Message:
No need to have same trap handlers in trap_subr.S.
No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/powerpc/ibm4xx/trap_subr.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/powerpc/ibm4xx/ibm4xx_machdep.c
diff -u src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.23 src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.24
--- src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c:1.23	Mon Dec 26 20:16:29 2016
+++ src/sys/arch/powerpc/ibm4xx/ibm4xx_machdep.c	Mon Dec 26 20:28:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibm4xx_machdep.c,v 1.23 2016/12/26 20:16:29 rin Exp $	*/
+/*	$NetBSD: ibm4xx_machdep.c,v 1.24 2016/12/26 20:28:00 rin Exp $	*/
 /*	Original: ibm40x_machdep.c,v 1.3 2005/01/17 17:19:36 shige Exp $ */
 
 /*
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.23 2016/12/26 20:16:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibm4xx_machdep.c,v 1.24 2016/12/26 20:28:00 rin Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -123,14 +123,11 @@ void *startsym, *endsym;
  */
 extern const uint32_t defaulttrap[], defaultsize;
 extern const uint32_t sctrap[], scsize;
-extern const uint32_t alitrap[], alisize;
-extern const uint32_t dsitrap[], dsisize;
-extern const uint32_t isitrap[], isisize;
-extern const uint32_t mchktrap[], mchksize;
+extern const uint32_t accesstrap[], accesssize;
+extern const uint32_t criticaltrap[], criticalsize;
 extern const uint32_t tlbimiss4xx[], tlbim4size;
 extern const uint32_t tlbdmiss4xx[], tlbdm4size;
 extern const uint32_t pitfitwdog[], pitfitwdogsize;
-extern const uint32_t debugtrap[], debugsize;
 extern const uint32_t errata51handler[], errata51size;
 #if defined(DDB)
 extern const uint32_t ddblow[], ddbsize;
@@ -139,14 +136,13 @@ extern const uint32_t ipkdblow[], ipkdbs
 #endif
 static const struct exc_info trap_table[] = {
 	{ EXC_SC,	sctrap,		(uintptr_t) },
-	{ EXC_ALI,	alitrap,	(uintptr_t) },
-	{ EXC_DSI,	dsitrap,	(uintptr_t) },
-	{ EXC_ISI,	isitrap,	(uintptr_t) },
-	{ EXC_MCHK,	mchktrap,	(uintptr_t) },
+	{ EXC_ALI,	accesstrap,	(uintptr_t) },
+	{ EXC_DSI,	accesstrap,	(uintptr_t) },
+	{ EXC_MCHK,	criticaltrap,	(uintptr_t) },
 	{ EXC_ITMISS,	tlbimiss4xx,	(uintptr_t) },
 	{ EXC_DTMISS,	tlbdmiss4xx,	(uintptr_t) },
 	{ EXC_PIT,	pitfitwdog,	(uintptr_t) },
-	{ EXC_DEBUG,	debugtrap,	(uintptr_t) },
+	{ EXC_DEBUG,	criticaltrap,	(uintptr_t) },
 	{ (EXC_DTMISS|EXC_ALI),
 			errata51handler, (uintptr_t) },
 #if defined(DDB)

Index: src/sys/arch/powerpc/ibm4xx/trap_subr.S
diff -u src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.24 src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.25
--- src/sys/arch/powerpc/ibm4xx/trap_subr.S:1.24	Sat Feb  9 11:22:51 2013
+++ src/sys/arch/powerpc/ibm4xx/trap_subr.S	Mon Dec 26 20:28:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap_subr.S,v 1.24 2013/02/09 11:22:51 kiyohara Exp $	*/
+/*	$NetBSD: trap_subr.S,v 1.25 2016/12/26 20:28:00 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -105,7 +105,7 @@
 	mfcr	%r29;			/* save CR */		\
 	mfdear	%r30;		\
 	mfesr	%r31;		\
-	stmw	%r30,(savearea+CPUSAVE_DEAR)(%r1);		\
+	stmw	%r30,(savearea+CPUSAVE_DEAR)(%r1); /* save esr/dear */ \
 	mfsrr0	%r30;		\
 	mfsrr1	%r31; /* Test whether we already had PR set */	\
 	stmw	%r30,(savearea+CPUSAVE_SRR0)(%r1); /* save srr0/srr1 */	\
@@ -172,18 +172,10 @@ _C_LABEL(name ## size) = .-_C_LABEL(name
 	addi	%r1,%r1,USPACE-CALLFRAMELEN; /* stack is top of user struct */ \
 1:
 
-/*
- * This code gets copied to all the trap vectors
- * (except ISI/DSI, ALI, the interrupts, and possibly the debugging
- * traps when using IPKDB).
- */
 	.text
 	STANDARD_EXC_HANDLER(default)
-	ACCESS_EXC_HANDLER(ali)
-	ACCESS_EXC_HANDLER(dsi)
-	ACCESS_EXC_HANDLER(isi)
-	STANDARD_EXC_HANDLER(debug)
-	CRITICAL_EXC_HANDLER(mchk)
+	ACCESS_EXC_HANDLER(access)
+	CRITICAL_EXC_HANDLER(critical)
 
 /*
  * This one for the external interrupt handler.
@@ -258,7 +250,8 @@ _C_LABEL(ipkdbsize) = .-_C_LABEL(ipkdblo
 /*
  * FRAME_SETUP assumes:
  *	SPRG1		SP (r1)
- *	savearea	r28-r31,DEAR,ESR,SRR0,SRR1 (DEAR & ESR only for DSI traps)
+ *	savearea	r28-r31,DEAR,ESR,SRR0,SRR1
+ *			(DEAR & ESR only for access traps)
  *	%r28		LR
  *	%r29		CR
  *	%r1		kernel stack



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-26 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Dec 26 20:16:29 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: ibm4xx_machdep.c

Log Message:
We cannot have DDB and IPKDB at the same time.


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

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



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-24 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Dec 24 19:02:16 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Conform API use of uvm_hotplug(9) to documented behaviour:

When testing for an invalid uvm_physseg_t,
compare with UVM_PHYSSEG_TYPE_INVALID which is implementation agnostic.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.75 src/sys/arch/powerpc/ibm4xx/pmap.c:1.76
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.75	Sat Dec 24 18:07:31 2016
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Sat Dec 24 19:02:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.75 2016/12/24 18:07:31 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.76 2016/12/24 19:02:16 cherry Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75 2016/12/24 18:07:31 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76 2016/12/24 19:02:16 cherry Exp $");
 
 #include 
 #include 
@@ -201,7 +201,7 @@ pa_to_pv(paddr_t pa)
 	psize_t pg;
 
 	bank = uvm_physseg_find(atop(pa), );
-	if (bank == -1)
+	if (bank == UVM_PHYSSEG_TYPE_INVALID)
 		return NULL;
 	return _physseg_get_pmseg(bank)->pvent[pg];
 }
@@ -213,7 +213,7 @@ pa_to_attr(paddr_t pa)
 	psize_t pg;
 
 	bank = uvm_physseg_find(atop(pa), );
-	if (bank == -1)
+	if (bank == UVM_PHYSSEG_TYPE_INVALID)
 		return NULL;
 	return _physseg_get_pmseg(bank)->attrs[pg];
 }



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-24 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Dec 24 19:02:16 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
Conform API use of uvm_hotplug(9) to documented behaviour:

When testing for an invalid uvm_physseg_t,
compare with UVM_PHYSSEG_TYPE_INVALID which is implementation agnostic.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2016-12-24 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Dec 24 18:07:31 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
introduce evbppc pmap to the uvm_hotplug(9) API

Should fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx/pmap.c
diff -u src/sys/arch/powerpc/ibm4xx/pmap.c:1.74 src/sys/arch/powerpc/ibm4xx/pmap.c:1.75
--- src/sys/arch/powerpc/ibm4xx/pmap.c:1.74	Fri Dec 23 07:15:27 2016
+++ src/sys/arch/powerpc/ibm4xx/pmap.c	Sat Dec 24 18:07:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.74 2016/12/23 07:15:27 cherry Exp $	*/
+/*	$NetBSD: pmap.c,v 1.75 2016/12/24 18:07:31 cherry Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.74 2016/12/23 07:15:27 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.75 2016/12/24 18:07:31 cherry Exp $");
 
 #include 
 #include 
@@ -197,23 +197,25 @@ static int ppc4xx_tlb_size_mask(size_t, 
 struct pv_entry *
 pa_to_pv(paddr_t pa)
 {
-	int bank, pg;
+	uvm_physseg_t bank;
+	psize_t pg;
 
 	bank = uvm_physseg_find(atop(pa), );
 	if (bank == -1)
 		return NULL;
-	return _PHYSMEM_PTR(bank)->pmseg.pvent[pg];
+	return _physseg_get_pmseg(bank)->pvent[pg];
 }
 
 static inline char *
 pa_to_attr(paddr_t pa)
 {
-	int bank, pg;
+	uvm_physseg_t bank;
+	psize_t pg;
 
 	bank = uvm_physseg_find(atop(pa), );
 	if (bank == -1)
 		return NULL;
-	return _PHYSMEM_PTR(bank)->pmseg.attrs[pg];
+	return _physseg_get_pmseg(bank)->attrs[pg];
 }
 
 /*
@@ -473,10 +475,12 @@ pmap_init(void)
 
 	pv = pv_table;
 	attr = pmap_attrib;
-	for (bank = 0; bank < vm_nphysseg; bank++) {
-		sz = VM_PHYSMEM_PTR(bank)->end - VM_PHYSMEM_PTR(bank)->start;
-		VM_PHYSMEM_PTR(bank)->pmseg.pvent = pv;
-		VM_PHYSMEM_PTR(bank)->pmseg.attrs = attr;
+	for (bank = uvm_physseg_get_first();
+	 uvm_physseg_valid_p(bank);
+	 bank = uvm_physseg_get_next(bank)) {
+		sz = uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank);
+		uvm_physseg_get_pmseg(bank)->pvent = pv;
+		uvm_physseg_get_pmseg(bank)->attrs = attr;
 		pv += sz;
 		attr += sz;
 	}



CVS commit: src/sys/arch/powerpc/ibm4xx

2016-12-24 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sat Dec 24 18:07:31 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: pmap.c

Log Message:
introduce evbppc pmap to the uvm_hotplug(9) API

Should fix build.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/powerpc/ibm4xx/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/powerpc/ibm4xx

2016-12-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Dec 16 06:29:11 UTC 2016

Modified Files:
src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
Remove needless goto's. No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/powerpc/ibm4xx/trap.c

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



  1   2   >