CVS commit: [netbsd-6-0] src/sys/arch/sparc64/conf

2018-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun  7 18:06:38 UTC 2018

Modified Files:
src/sys/arch/sparc64/conf [netbsd-6-0]: GENERIC32 NONPLUS

Log Message:
Fix fallout from ticket #1500: COMPAT_SVR4* has been disabled, do not
disable it here again.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.140.108.1 src/sys/arch/sparc64/conf/GENERIC32
cvs rdiff -u -r1.58 -r1.58.108.1 src/sys/arch/sparc64/conf/NONPLUS

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

Modified files:

Index: src/sys/arch/sparc64/conf/GENERIC32
diff -u src/sys/arch/sparc64/conf/GENERIC32:1.140 src/sys/arch/sparc64/conf/GENERIC32:1.140.108.1
--- src/sys/arch/sparc64/conf/GENERIC32:1.140	Fri Jun 30 10:27:48 2006
+++ src/sys/arch/sparc64/conf/GENERIC32	Thu Jun  7 18:06:38 2018
@@ -1,13 +1,13 @@
-# $NetBSD: GENERIC32,v 1.140 2006/06/30 10:27:48 tsutsui Exp $
+# $NetBSD: GENERIC32,v 1.140.108.1 2018/06/07 18:06:38 martin Exp $
 #
 # GENERIC machine description file for 32-bit kernel
 #
 
 include 	"arch/sparc64/conf/GENERIC"
 
-#ident		"GENERIC32-$Revision: 1.140 $"
+#ident		"GENERIC32-$Revision: 1.140.108.1 $"
 
 include 	"arch/sparc64/conf/std.sparc64-32"
 
 no options 	COMPAT_NETBSD32
-no options 	COMPAT_SVR4_32
+#no options 	COMPAT_SVR4_32

Index: src/sys/arch/sparc64/conf/NONPLUS
diff -u src/sys/arch/sparc64/conf/NONPLUS:1.58 src/sys/arch/sparc64/conf/NONPLUS:1.58.108.1
--- src/sys/arch/sparc64/conf/NONPLUS:1.58	Fri Jun 30 10:27:48 2006
+++ src/sys/arch/sparc64/conf/NONPLUS	Thu Jun  7 18:06:38 2018
@@ -1,9 +1,9 @@
-# 	$NetBSD: NONPLUS,v 1.58 2006/06/30 10:27:48 tsutsui Exp $
+# 	$NetBSD: NONPLUS,v 1.58.108.1 2018/06/07 18:06:38 martin Exp $
 
 include "arch/sparc64/conf/NONPLUS64"
 include "arch/sparc64/conf/std.sparc64-32"
 
-#ident 		"NONPLUS-$Revision: 1.58 $"
+#ident 		"NONPLUS-$Revision: 1.58.108.1 $"
 
 no options 	COMPAT_NETBSD32	# NetBSD/sparc binary compatibility
-no options 	COMPAT_SVR4_32	# 32-bit SVR4 binaries
+#no options 	COMPAT_SVR4_32	# 32-bit SVR4 binaries



CVS commit: [netbsd-6-0] src/sys/arch/amiga/amiga

2018-04-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 10 11:29:55 UTC 2018

Modified Files:
src/sys/arch/amiga/amiga [netbsd-6-0]: cc.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1544):

sys/arch/amiga/amiga/cc.c: revision 1.27 (patch)

spl leak, found by mootja


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.20.1 src/sys/arch/amiga/amiga/cc.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/amiga/amiga/cc.c
diff -u src/sys/arch/amiga/amiga/cc.c:1.22 src/sys/arch/amiga/amiga/cc.c:1.22.20.1
--- src/sys/arch/amiga/amiga/cc.c:1.22	Mon Dec 20 00:25:25 2010
+++ src/sys/arch/amiga/amiga/cc.c	Tue Apr 10 11:29:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cc.c,v 1.22 2010/12/20 00:25:25 matt Exp $	*/
+/*	$NetBSD: cc.c,v 1.22.20.1 2018/04/10 11:29:55 martin Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cc.c,v 1.22 2010/12/20 00:25:25 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cc.c,v 1.22.20.1 2018/04/10 11:29:55 martin Exp $");
 
 #include 
 #include 
@@ -504,9 +504,10 @@ alloc_chipmem(u_long size)
 	while (size > mn->size && mn != (void *)&free_list)
 		mn = mn->free_link.cqe_next;
 
-	if (mn == (void *)&free_list)
+	if (mn == (void *)&free_list) {
+		splx(s);
 		return(NULL);
-
+	}
 	if ((mn->size - size) <= sizeof (*mn)) {
 		/*
 		 * our allocation would not leave room



CVS commit: [netbsd-6-0] src/sys/arch/sparc/sparc

2018-03-13 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue Mar 13 16:48:01 UTC 2018

Modified Files:
src/sys/arch/sparc/sparc [netbsd-6-0]: timer.c timer_sun4m.c timerreg.h

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1519):
sys/arch/sparc/sparc/timer_sun4m.c: 1.33 1.34 1.31
sys/arch/sparc/sparc/timer.c: 1.33
sys/arch/sparc/sparc/timer.c: 1.33 1.34
sys/arch/sparc/sparc/timerreg.h: 1.33 1.34 1.31 1.10
fix time goes backwards problems on sparc.
there are a few things here:
- there's a race between reading the limit register (which clears
  the interrupt and the limit bit) and increasing the latest offset.
  this can happen easily if an interrupt comes between the read and
  the call to tickle_tc() that increases the offset (i obverved this
  actually happening.)
- in early boot, sometimes the counter can cycle twice before the
  tickle happens.
to handle these issues, add two workarounds:
- if the limit bit isn't set, but the counter value is less than
  the previous value, and the offset hasn't changed, use the same
  fixup as if the limit bit was set.  this handles the first case
  above.
- add a hard-workaround for never allowing returning a smaller
  value (except during 32 bit overflow): if the result is less than
  the last result, add fixups until it does (or until it would
  overflow.)
the first workaround fixes general run-time issues, and the second
fixes issues only seen during boot.
also expand some comments in timer_sun4m.c and re-enable the sun4m
sub-microsecond tmr_ustolim4m() support (but it's always called with
at least 'tick' microseconds, so the end result is the same.)
fix hang at 4B microseconds (1h12 or so), and simplify part of the previous


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.12.1 src/sys/arch/sparc/sparc/timer.c
cvs rdiff -u -r1.28 -r1.28.14.1 src/sys/arch/sparc/sparc/timer_sun4m.c
cvs rdiff -u -r1.9 -r1.9.124.1 src/sys/arch/sparc/sparc/timerreg.h

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

Modified files:

Index: src/sys/arch/sparc/sparc/timer.c
diff -u src/sys/arch/sparc/sparc/timer.c:1.29 src/sys/arch/sparc/sparc/timer.c:1.29.12.1
--- src/sys/arch/sparc/sparc/timer.c:1.29	Sun Jul 17 23:18:23 2011
+++ src/sys/arch/sparc/sparc/timer.c	Tue Mar 13 16:48:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: timer.c,v 1.29 2011/07/17 23:18:23 mrg Exp $ */
+/*	$NetBSD: timer.c,v 1.29.12.1 2018/03/13 16:48:01 snj Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.29 2011/07/17 23:18:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: timer.c,v 1.29.12.1 2018/03/13 16:48:01 snj Exp $");
 
 #include 
 #include 
@@ -83,56 +83,93 @@ static u_int timer_get_timecount(struct 
  * timecounter local state
  */
 static struct counter {
-	volatile u_int *cntreg;	/* counter register */
+	__cpu_simple_lock_t lock; /* protects access to offset, reg, last* */
+	volatile u_int *cntreg;	/* counter register to read */
 	u_int limit;		/* limit we count up to */
 	u_int offset;		/* accumulated offet due to wraps */
 	u_int shift;		/* scaling for valid bits */
 	u_int mask;		/* valid bit mask */
-} cntr;
+	u_int lastcnt;		/* the last* values are used to notice */
+	u_int lastres;		/* and fix up cases where it would appear */
+	u_int lastoffset;	/* time went backwards. */
+} cntr __aligned(CACHE_LINE_SIZE);
 
 /*
  * define timecounter
  */
 
 static struct timecounter counter_timecounter = {
-	timer_get_timecount,	/* get_timecount */
-	0,			/* no poll_pps */
-	~0u,			/* counter_mask */
-	0,  /* frequency - set at initialisation */
-	"timer-counter",	/* name */
-	100,			/* quality */
-	&cntr			/* private reference */
+	.tc_get_timecount =	timer_get_timecount,
+	.tc_poll_pps =		NULL,
+	.tc_counter_mask =	~0u,
+	.tc_frequency =		0,
+	.tc_name =		"timer-counter",
+	.tc_quality =		100,
+	.tc_priv =		&cntr,
 };
 
 /*
  * timer_get_timecount provide current counter value
  */
+__attribute__((__optimize__("Os")))
 static u_int
 timer_get_timecount(struct timecounter *tc)
 {
-	struct counter *ctr = (struct counter *)tc->tc_priv;
-
-	u_int c, res, r;
+	u_int cnt, res, fixup, offset;
 	int s;
 
-
+	/*
+	 * We use splhigh/__cpu_simple_lock here as we don't want
+	 * any mutex or lockdebug overhead.  The lock protects a
+	 * bunch of the members of cntr that are written here to
+	 * deal with the various minor races to be observed and
+	 * worked around.
+	 */
 	s = splhigh();
 
-	res = c = *ctr->cntreg;
+	__cpu_simple_lock(&cntr.lock);
+	res = cnt = *cntr.cntreg;
 
 	res  &= ~TMR_LIMIT;
+	offset = cntr.offset;
 
-	if (c != res) {
-		r = ctr->limit;
+	/*
+	 * There are 3 cases here:
+	 * - limit reached, interrupt not yet processed.
+	 * - count reset but offset the same, race between handling
+	 *   the interrupt and tickle_tc() updating the offset.
+	 * - normal case.
+	 *
+	 * For the first t

CVS commit: [netbsd-6-0] src/sys/arch

2018-02-19 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Feb 19 20:55:45 UTC 2018

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: machdep.c
src/sys/arch/amd64/include [netbsd-6-0]: segments.h
src/sys/arch/i386/i386 [netbsd-6-0]: machdep.c
src/sys/arch/i386/include [netbsd-6-0]: segments.h
src/sys/arch/x86/x86 [netbsd-6-0]: vm_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1517):
sys/arch/amd64/amd64/machdep.c: 1.280 via patch
sys/arch/amd64/include/segments.h: 1.34 via patch
sys/arch/i386/i386/machdep.c: 1.800
sys/arch/i386/include/segments.h: 1.64
sys/arch/x86/x86/vm_machdep.c: 1.30
Fix a huge privilege separation vulnerability in Xen-amd64.
On amd64 the kernel runs in ring3, like userland, and therefore SEL_KPL
equals SEL_UPL. While Xen can make a distinction between usermode and
kernelmode in %cs, it can't when it comes to iopl. Since we set SEL_KPL
in iopl, Xen sees SEL_UPL, and allows (unprivileged) userland processes
to read and write to the CPU ports.
It is easy, then, to completely escalate privileges; by reprogramming the
PIC, by reading the ATA disks, by intercepting the keyboard interrupts
(keylogger), etc.
Declare IOPL_KPL, set to 1 on Xen-amd64, which allows the kernel to use
the ports but not userland. I didn't test this change on i386, but it
seems fine enough.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.7.2.2 -r1.175.2.7.2.3 \
src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.22 -r1.22.14.1 src/sys/arch/amd64/include/segments.h
cvs rdiff -u -r1.717.2.7.4.1 -r1.717.2.7.4.2 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.54 -r1.54.16.1 src/sys/arch/i386/include/segments.h
cvs rdiff -u -r1.14 -r1.14.6.1 src/sys/arch/x86/x86/vm_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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.2 src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.3
--- src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.2	Tue Aug  8 11:55:20 2017
+++ src/sys/arch/amd64/amd64/machdep.c	Mon Feb 19 20:55:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.175.2.7.2.2 2017/08/08 11:55:20 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.175.2.7.2.3 2018/02/19 20:55:44 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.7.2.2 2017/08/08 11:55:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.7.2.3 2018/02/19 20:55:44 snj Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -477,7 +477,7 @@ x86_64_proc0_tss_ldt_init(void)
 	pcb->pcb_fs = 0;
 	pcb->pcb_gs = 0;
 	pcb->pcb_rsp0 = (uvm_lwp_getuarea(l) + KSTACK_SIZE - 16) & ~0xf;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 
 	pmap_kernel()->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;

Index: src/sys/arch/amd64/include/segments.h
diff -u src/sys/arch/amd64/include/segments.h:1.22 src/sys/arch/amd64/include/segments.h:1.22.14.1
--- src/sys/arch/amd64/include/segments.h:1.22	Mon Feb  7 03:54:45 2011
+++ src/sys/arch/amd64/include/segments.h	Mon Feb 19 20:55:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.22 2011/02/07 03:54:45 chs Exp $	*/
+/*	$NetBSD: segments.h,v 1.22.14.1 2018/02/19 20:55:44 snj Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -107,6 +107,12 @@
 #define	ISLDT(s)	((s) & SEL_LDT)	/* is it local or global */
 #define	SEL_LDT		4		/* local descriptor table */	
 
+#ifdef XEN
+#define IOPL_KPL	1
+#else
+#define IOPL_KPL	SEL_KPL
+#endif
+
 /* Dynamically allocated TSSs and LDTs start (byte offset) */
 #define SYSSEL_START	(NGDT_MEM << 3)
 #define DYNSEL_START	(SYSSEL_START + (NGDT_SYS << 4))

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.717.2.7.4.1 src/sys/arch/i386/i386/machdep.c:1.717.2.7.4.2
--- src/sys/arch/i386/i386/machdep.c:1.717.2.7.4.1	Tue Aug  8 11:55:20 2017
+++ src/sys/arch/i386/i386/machdep.c	Mon Feb 19 20:55:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.717.2.7.4.1 2017/08/08 11:55:20 martin Exp $	*/
+/*	$NetBSD: machdep.c,v 1.717.2.7.4.2 2018/02/19 20:55:44 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.717.2.7.4.1 2017/08/08 11:55:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.717.2.7.4.2 2018/02/19 20:55:44 snj Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -509,7 +509,7 @@ i386_proc0_tss_ldt_init(void)
 	pmap_kernel()->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL);
 	pcb->pcb_cr0 = rcr0() & ~CR0_TS;
 	pcb->pcb_esp0 = uvm_lwp_getuarea(l) + KSTACK_SIZE - 16;
-	pcb->pcb_iopl = SEL_KPL;
+	pcb->pcb_iopl = IOPL_KPL;
 	l->l_md.md_regs = (struct trapframe *)pc

CVS commit: [netbsd-6-0] src/sys/arch/mips/mips

2017-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Nov  8 21:28:18 UTC 2017

Modified Files:
src/sys/arch/mips/mips [netbsd-6-0]: pmap.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1390):
sys/arch/mips/mips/pmap.c: 1.221-1.223
Fix a bug introduced by me in 1.214 where unmanaged mappings would be
affected by calls to pmap_page_protect which is wrong.  Now PV_KENTER
mappings are left intact.
Thanks to chuq for spotting my mistake and reviewing this diff.
Thanks to everyone who tested it as well.
Fix PR/51288 reproducable panic on evbmips64-eb (erlite)
pmap_page_remove from the previous change neglected to terminate the pv
list correctly when it started with an initial unmanaged mapping and
subsequent managed mappings.  Fix this.
Fix MIPS3_NO_PV_UNCACHED alias handling by looping through the pv_list
looking for bad aliases and removing the bad entries.  That is, revert
to the code before the matt-mips64 merge.
Additionally, fix the pmap_update call to not use the (recently
  removed/freed) pv for the pmap_t.
Fixes the following two PRs
PR/49903: Panic during installation on WorkPad Z50 (hpcmips) whilst 
uncompressing base.tgz
PR/51226: Install bug for hpcmips NetBSD V7 using FTP Full installation


To generate a diff of this commit:
cvs rdiff -u -r1.207.2.1.4.2 -r1.207.2.1.4.3 src/sys/arch/mips/mips/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/mips/mips/pmap.c
diff -u src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.2 src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.3
--- src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.2	Wed Nov  8 21:22:48 2017
+++ src/sys/arch/mips/mips/pmap.c	Wed Nov  8 21:28:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.207.2.1.4.2 2017/11/08 21:22:48 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.207.2.1.4.3 2017/11/08 21:28:18 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.1.4.2 2017/11/08 21:22:48 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.1.4.3 2017/11/08 21:28:18 snj Exp $");
 
 /*
  *	Manages physical address maps.
@@ -316,6 +316,7 @@ u_int		pmap_page_colormask;
 	 (pm) == curlwp->l_proc->p_vmspace->vm_map.pmap)
 
 /* Forward function declarations */
+void pmap_page_remove(struct vm_page *);
 void pmap_remove_pv(pmap_t, vaddr_t, struct vm_page *, bool);
 void pmap_enter_pv(pmap_t, vaddr_t, struct vm_page *, u_int *, int);
 pt_entry_t *pmap_pte(pmap_t, vaddr_t);
@@ -1063,6 +1064,10 @@ pmap_page_protect(struct vm_page *pg, vm
 			while (pv != NULL) {
 const pmap_t pmap = pv->pv_pmap;
 const uint16_t gen = PG_MD_PVLIST_GEN(md);
+if (pv->pv_va & PV_KENTER) {
+	pv = pv->pv_next;
+	continue;
+}
 va = trunc_page(pv->pv_va);
 PG_MD_PVLIST_UNLOCK(md);
 pmap_protect(pmap, va, va + PAGE_SIZE, prot);
@@ -1087,17 +1092,7 @@ pmap_page_protect(struct vm_page *pg, vm
 		if (pmap_clear_mdpage_attributes(md, PG_MD_EXECPAGE)) {
 			PMAP_COUNT(exec_uncached_page_protect);
 		}
-		(void)PG_MD_PVLIST_LOCK(md, false);
-		pv = &md->pvh_first;
-		while (pv->pv_pmap != NULL) {
-			const pmap_t pmap = pv->pv_pmap;
-			va = trunc_page(pv->pv_va);
-			PG_MD_PVLIST_UNLOCK(md);
-			pmap_remove(pmap, va, va + PAGE_SIZE);
-			pmap_update(pmap);
-			(void)PG_MD_PVLIST_LOCK(md, false);
-		}
-		PG_MD_PVLIST_UNLOCK(md);
+		pmap_page_remove(pg);
 	}
 }
 
@@ -2069,6 +2064,32 @@ pmap_set_modified(paddr_t pa)
 / pv_entry management /
 
 static void
+pmap_check_alias(struct vm_page *pg)
+{
+#ifdef MIPS3_PLUS	/* XXX mmu XXX */
+#ifndef MIPS3_NO_PV_UNCACHED
+	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
+
+	if (MIPS_HAS_R4K_MMU && PG_MD_UNCACHED_P(md)) {
+		/*
+		 * Page is currently uncached, check if alias mapping has been
+		 * removed.  If it was, then reenable caching.
+		 */
+		pv_entry_t pv = &md->pvh_first;
+		pv_entry_t pv0 = pv->pv_next;
+
+		for (; pv0; pv0 = pv0->pv_next) {
+			if (mips_cache_badalias(pv->pv_va, pv0->pv_va))
+break;
+		}
+		if (pv0 == NULL)
+			pmap_page_cache(pg, true);
+	}
+#endif
+#endif	/* MIPS3_PLUS */
+}
+
+static void
 pmap_check_pvlist(struct vm_page_md *md)
 {
 #ifdef PARANOIADIAG
@@ -2155,12 +2176,12 @@ again:
 			 * be mapped with one index at any given time.
 			 */
 
-			if (mips_cache_badalias(pv->pv_va, va)) {
-for (npv = pv; npv; npv = npv->pv_next) {
-	vaddr_t nva = trunc_page(npv->pv_va);
-	pmap_remove(npv->pv_pmap, nva,
-	nva + PAGE_SIZE);
-	pmap_update(npv->pv_pmap);
+			for (npv = pv; npv; npv = npv->pv_next) {
+vaddr_t nva = trunc_page(npv->pv_va);
+pmap_t npm = npv->pv_pmap;
+if (mips_cache_badalias(nva, va)) {
+	pmap_remove(npm, nva, nva + PAGE_SIZE);
+	pmap_update(npm);
 	goto again;
 }
 			}
@@ -2283,6 +2304,114 @@ again:
 }
 
 /*
+ * Remove this page from all physical maps in 

CVS commit: [netbsd-6-0] src/sys/arch/mips

2017-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Nov  8 21:22:48 UTC 2017

Modified Files:
src/sys/arch/mips/include [netbsd-6-0]: pmap.h
src/sys/arch/mips/mips [netbsd-6-0]: pmap.c pmap_segtab.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1068):
sys/arch/mips/include/pmap.h: revision 1.63
sys/arch/mips/mips/pmap.c: revision 1.214
sys/arch/mips/mips/pmap_segtab.c: revision 1.8
Deal with incompatible cache aliases. Specifically,
- always flush an ephemeral page on unmap
- track unmanaged mappings (mappings entered via pmap_kenter_pa) for
aliases where required and handle appropriately (via pmap_enter_pv)
Hopefully this (finally) addresses the instability reported in the
following PRs:
PR/44900 - R5000/Rm5200 mips ports are broken
PR/46890 - upcoming NetBSD 6.0 release is very unstable / unusable on cobalt 
qube 2
PR/48628 - cobalt and hpcmips ports are dead


To generate a diff of this commit:
cvs rdiff -u -r1.61.8.1 -r1.61.8.1.4.1 src/sys/arch/mips/include/pmap.h
cvs rdiff -u -r1.207.2.1.4.1 -r1.207.2.1.4.2 src/sys/arch/mips/mips/pmap.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.1.4.1 src/sys/arch/mips/mips/pmap_segtab.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/mips/include/pmap.h
diff -u src/sys/arch/mips/include/pmap.h:1.61.8.1 src/sys/arch/mips/include/pmap.h:1.61.8.1.4.1
--- src/sys/arch/mips/include/pmap.h:1.61.8.1	Thu Jul  5 18:39:42 2012
+++ src/sys/arch/mips/include/pmap.h	Wed Nov  8 21:22:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.61.8.1 2012/07/05 18:39:42 riz Exp $	*/
+/*	$NetBSD: pmap.h,v 1.61.8.1.4.1 2017/11/08 21:22:48 snj Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -283,6 +283,7 @@ void	pmap_prefer(vaddr_t, vaddr_t *, vsi
 #endif /* MIPS3_PLUS */
 
 #define	PMAP_STEAL_MEMORY	/* enable pmap_steal_memory() */
+#define	PMAP_ENABLE_PMAP_KMPAGE	/* enable the PMAP_KMPAGE flag */
 
 /*
  * Alternate mapping hooks for pool pages.  Avoids thrashing the TLB.
@@ -329,6 +330,7 @@ typedef struct pv_entry {
 	struct pv_entry	*pv_next;	/* next pv_entry */
 	struct pmap	*pv_pmap;	/* pmap where mapping lies */
 	vaddr_t		pv_va;		/* virtual address for mapping */
+#define	PV_KENTER	0x001
 } *pv_entry_t;
 
 #define	PG_MD_UNCACHED		0x0001	/* page is mapped uncached */

Index: src/sys/arch/mips/mips/pmap.c
diff -u src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.1 src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.2
--- src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.1	Wed Nov  8 21:17:46 2017
+++ src/sys/arch/mips/mips/pmap.c	Wed Nov  8 21:22:48 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.207.2.1.4.1 2017/11/08 21:17:46 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.207.2.1.4.2 2017/11/08 21:22:48 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.1.4.1 2017/11/08 21:17:46 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.1.4.2 2017/11/08 21:22:48 snj Exp $");
 
 /*
  *	Manages physical address maps.
@@ -317,7 +317,7 @@ u_int		pmap_page_colormask;
 
 /* Forward function declarations */
 void pmap_remove_pv(pmap_t, vaddr_t, struct vm_page *, bool);
-void pmap_enter_pv(pmap_t, vaddr_t, struct vm_page *, u_int *);
+void pmap_enter_pv(pmap_t, vaddr_t, struct vm_page *, u_int *, int);
 pt_entry_t *pmap_pte(pmap_t, vaddr_t);
 
 /*
@@ -386,13 +386,13 @@ pmap_page_syncicache(struct vm_page *pg)
 	}
 	PG_MD_PVLIST_UNLOCK(md);
 	kpreempt_disable();
-	pmap_tlb_syncicache(md->pvh_first.pv_va, onproc);
+	pmap_tlb_syncicache(trunc_page(md->pvh_first.pv_va), onproc);
 	kpreempt_enable();
 #else
 	if (MIPS_HAS_R4K_MMU) {
 		if (PG_MD_CACHED_P(md)) {
 			mips_icache_sync_range_index(
-			md->pvh_first.pv_va, PAGE_SIZE);
+			trunc_page(md->pvh_first.pv_va), PAGE_SIZE);
 		}
 	} else {
 		mips_icache_sync_range(MIPS_PHYS_TO_KSEG0(VM_PAGE_TO_PHYS(pg)),
@@ -436,10 +436,10 @@ pmap_map_ephemeral_page(struct vm_page *
 		 */
 		(void)PG_MD_PVLIST_LOCK(md, false);
 		if (PG_MD_CACHED_P(md)
-		&& mips_cache_badalias(pv->pv_va, va))
-			mips_dcache_wbinv_range_index(pv->pv_va, PAGE_SIZE);
-		if (pv->pv_pmap == NULL)
-			pv->pv_va = va;
+		&& mips_cache_badalias(pv->pv_va, va)) {
+			mips_dcache_wbinv_range_index(trunc_page(pv->pv_va),
+			PAGE_SIZE);
+		}
 		PG_MD_PVLIST_UNLOCK(md);
 	}
 
@@ -450,23 +450,13 @@ static void
 pmap_unmap_ephemeral_page(struct vm_page *pg, vaddr_t va,
 	pt_entry_t old_pt_entry)
 {
-	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
-	pv_entry_t pv = &md->pvh_first;
-	
-	if (MIPS_CACHE_VIRTUAL_ALIAS) {
-		(void)PG_MD_PVLIST_LOCK(md, false);
-		if (PG_MD_CACHED_P(md)
-		|| (pv->pv_pmap != NULL
-			&& mips_cache_badalias(pv->pv_va, va))) {
 
-			/*
-			 * If this page was previously cached or we had to use an
-			 * incompatible alias and it has a valid mapping, flush it
-			 * from the cache.
-			 */
-			mips_dcache_wb

CVS commit: [netbsd-6-0] src/sys/arch/mips/mips

2017-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Nov  8 21:17:46 UTC 2017

Modified Files:
src/sys/arch/mips/mips [netbsd-6-0]: pmap.c vm_machdep.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1056):
sys/arch/mips/mips/pmap.c: revision 1.210-1.213
sys/arch/mips/mips/vm_machdep.c: revision 1.143
Fix a logic inversion introduced with the matt-nb5-mips64 for
pmap_{zero,copy}_page cache alias handing. The check previously used
PG_MD_UNCACHED_P, where it now uses PG_MD_CACHED_P, when considering if
a cache invalidation is required.
Additionally flush the cache for the uarea va to avoid potential (future)
cache aliases in cpu_uarea_free when handing pages back to uvm for later
use.
ok matt@
Hopefully this addresses the instability reported in the following PRs:
PR/44900 - R5000/Rm5200 mips ports are broken
PR/46170 - NetBSD/cobalt 6.0_BETA does not boot
PR/46890 - upcoming NetBSD 6.0 release is very unstable / unusable on cobalt 
qube 2
PR/48628 - cobalt and hpcmips ports are dead
Grab pv_list lock in pmap_unmap_ephemeral_page only when needed.
Make PARANOIADIAG compile.
Use pmap_tlb_asid_check to reduce code c&p.


To generate a diff of this commit:
cvs rdiff -u -r1.207.2.1 -r1.207.2.1.4.1 src/sys/arch/mips/mips/pmap.c
cvs rdiff -u -r1.141 -r1.141.12.1 src/sys/arch/mips/mips/vm_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/mips/mips/pmap.c
diff -u src/sys/arch/mips/mips/pmap.c:1.207.2.1 src/sys/arch/mips/mips/pmap.c:1.207.2.1.4.1
--- src/sys/arch/mips/mips/pmap.c:1.207.2.1	Thu Jul  5 18:39:42 2012
+++ src/sys/arch/mips/mips/pmap.c	Wed Nov  8 21:17:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.207.2.1 2012/07/05 18:39:42 riz Exp $	*/
+/*	$NetBSD: pmap.c,v 1.207.2.1.4.1 2017/11/08 21:17:46 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.1 2012/07/05 18:39:42 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.207.2.1.4.1 2017/11/08 21:17:46 snj Exp $");
 
 /*
  *	Manages physical address maps.
@@ -453,19 +453,21 @@ pmap_unmap_ephemeral_page(struct vm_page
 	struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
 	pv_entry_t pv = &md->pvh_first;
 	
-	(void)PG_MD_PVLIST_LOCK(md, false);
-	if (MIPS_CACHE_VIRTUAL_ALIAS
-	&& (PG_MD_UNCACHED_P(md)
-		|| (pv->pv_pmap != NULL
-		&& mips_cache_badalias(pv->pv_va, va {
-		/*
-		 * If this page was previously uncached or we had to use an
-		 * incompatible alias and it has a valid mapping, flush it
-		 * from the cache.
-		 */
-		mips_dcache_wbinv_range(va, PAGE_SIZE);
+	if (MIPS_CACHE_VIRTUAL_ALIAS) {
+		(void)PG_MD_PVLIST_LOCK(md, false);
+		if (PG_MD_CACHED_P(md)
+		|| (pv->pv_pmap != NULL
+			&& mips_cache_badalias(pv->pv_va, va))) {
+
+			/*
+			 * If this page was previously cached or we had to use an
+			 * incompatible alias and it has a valid mapping, flush it
+			 * from the cache.
+			 */
+			mips_dcache_wbinv_range(va, PAGE_SIZE);
+		}
+		PG_MD_PVLIST_UNLOCK(md);
 	}
-	PG_MD_PVLIST_UNLOCK(md);
 #ifndef _LP64
 	/*
 	 * If we had to map using a page table entry, unmap it now.
@@ -575,7 +577,7 @@ pmap_bootstrap(void)
 
 	/*
 	 * Now actually allocate the kernel PTE array (must be done
-	 * after virtual_end is initialized).
+	 * after mips_virtual_end is initialized).
 	 */
 	Sysmap = (pt_entry_t *)
 	uvm_pageboot_alloc(sizeof(pt_entry_t) * Sysmapsize);
@@ -1023,15 +1025,7 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va
 	if (eva > VM_MAXUSER_ADDRESS)
 		panic("pmap_remove: uva not in range");
 	if (PMAP_IS_ACTIVE(pmap)) {
-		struct pmap_asid_info * const pai = PMAP_PAI(pmap, curcpu());
-		uint32_t asid;
-
-		__asm volatile("mfc0 %0,$10; nop" : "=r"(asid));
-		asid = (MIPS_HAS_R4K_MMU) ? (asid & 0xff) : (asid & 0xfc0) >> 6;
-		if (asid != pai->pai_asid) {
-			panic("inconsistency for active TLB flush: %d <-> %d",
-			asid, pai->pai_asid);
-		}
+		pmap_tlb_asid_check();
 	}
 #endif
 #ifdef PMAP_FAULTINFO
@@ -1214,15 +1208,7 @@ pmap_protect(pmap_t pmap, vaddr_t sva, v
 	if (eva > VM_MAXUSER_ADDRESS)
 		panic("pmap_protect: uva not in range");
 	if (PMAP_IS_ACTIVE(pmap)) {
-		struct pmap_asid_info * const pai = PMAP_PAI(pmap, curcpu());
-		uint32_t asid;
-
-		__asm volatile("mfc0 %0,$10; nop" : "=r"(asid));
-		asid = (MIPS_HAS_R4K_MMU) ? (asid & 0xff) : (asid & 0xfc0) >> 6;
-		if (asid != pai->pai_asid) {
-			panic("inconsistency for active TLB update: %d <-> %d",
-			asid, pai->pai_asid);
-		}
+		pmap_tlb_asid_check();
 	}
 #endif
 
@@ -1586,6 +1572,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 
 #ifdef PARANOIADIAG
 	if (PMAP_IS_ACTIVE(pmap)) {
+		struct pmap_asid_info * const pai = PMAP_PAI(pmap, curcpu());
 		uint32_t asid;
 
 		__asm volatile("mfc0 %0,$10; nop" : "=r"(asid));
@@ -1774,7 +1761,7 @@ pmap_unwire(pmap_t pmap, vaddr_t va)
 	if (pmap == pmap_kernel

CVS commit: [netbsd-6-0] src/sys/arch/i386/i386

2017-10-13 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Oct 13 08:03:00 UTC 2017

Modified Files:
src/sys/arch/i386/i386 [netbsd-6-0]: vector.S

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1505):
sys/arch/i386/i386/i386_trap.S: revision 1.12 via patch
Pfff, use %ss and not %ds. The latter is controlled by userland, the former
contains the kernel value (flat); FreeBSD fixed this too a few weeks ago.
As I said earlier, this dtrace code is complete bullshit.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.59.12.1 src/sys/arch/i386/i386/vector.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/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.59 src/sys/arch/i386/i386/vector.S:1.59.12.1
--- src/sys/arch/i386/i386/vector.S:1.59	Sun Jun 12 03:35:42 2011
+++ src/sys/arch/i386/i386/vector.S	Fri Oct 13 08:03:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.59 2011/06/12 03:35:42 rmind Exp $	*/
+/*	$NetBSD: vector.S,v 1.59.12.1 2017/10/13 08:03:00 snj Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.59 2011/06/12 03:35:42 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vector.S,v 1.59.12.1 2017/10/13 08:03:00 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -773,7 +773,7 @@ IDTVEC(trap05)
 	SUPERALIGN_TEXT
 IDTVEC(trap06)
 	/* Check if there is no DTrace hook registered. */
-	cmpl	$0,dtrace_invop_jump_addr
+	cmpl	$0,%ss:dtrace_invop_jump_addr
 	je	norm_ill
 
 	/* Check if this is a user fault. */



CVS commit: [netbsd-6-0] src/sys/arch/sparc64/sparc64

2017-09-04 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Sep  4 16:03:21 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-6-0]: compat_13_machdep.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1501):
sys/arch/sparc64/sparc64/compat_13_machdep.c: revision 1.24
Apply only CCR. Otherwise userland could set PSTATE_PRIV in %pstate and get
kernel privileges on the hardware.
ok martin


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.24.1 \
src/sys/arch/sparc64/sparc64/compat_13_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/sparc64/sparc64/compat_13_machdep.c
diff -u src/sys/arch/sparc64/sparc64/compat_13_machdep.c:1.23 src/sys/arch/sparc64/sparc64/compat_13_machdep.c:1.23.24.1
--- src/sys/arch/sparc64/sparc64/compat_13_machdep.c:1.23	Sat Nov 21 04:16:52 2009
+++ src/sys/arch/sparc64/sparc64/compat_13_machdep.c	Mon Sep  4 16:03:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_13_machdep.c,v 1.23 2009/11/21 04:16:52 rmind Exp $	*/
+/*	$NetBSD: compat_13_machdep.c,v 1.23.24.1 2017/09/04 16:03:21 snj Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.23 2009/11/21 04:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.23.24.1 2017/09/04 16:03:21 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -129,7 +129,7 @@ compat_13_sys_sigreturn(struct lwp *l, c
 		return (EINVAL);
 	/* take only psr ICC field */
 #ifdef __arch64__
-	tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | scp->sc_tstate;
+	tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | (scp->sc_tstate & TSTATE_CCR);
 #else
 	tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | PSRCC_TO_TSTATE(scp->sc_psr);
 #endif



CVS commit: [netbsd-6-0] src/sys/arch/i386/conf

2017-08-26 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Aug 26 16:26:06 UTC 2017

Modified Files:
src/sys/arch/i386/conf [netbsd-6-0]: GENERIC

Log Message:
Apply patch (requested by maxv in ticket #1466):
Disable vm86 by default. The use case is limited, and the potential
for damage is too high.


To generate a diff of this commit:
cvs rdiff -u -r1.1066.2.7 -r1.1066.2.7.4.1 src/sys/arch/i386/conf/GENERIC

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/i386/conf/GENERIC
diff -u src/sys/arch/i386/conf/GENERIC:1.1066.2.7 src/sys/arch/i386/conf/GENERIC:1.1066.2.7.4.1
--- src/sys/arch/i386/conf/GENERIC:1.1066.2.7	Wed Aug 15 15:33:00 2012
+++ src/sys/arch/i386/conf/GENERIC	Sat Aug 26 16:26:06 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1066.2.7 2012/08/15 15:33:00 sborrill Exp $
+# $NetBSD: GENERIC,v 1.1066.2.7.4.1 2017/08/26 16:26:06 snj Exp $
 #
 # GENERIC machine description file
 #
@@ -22,12 +22,12 @@ include 	"arch/i386/conf/std.i386"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.1066.2.7 $"
+#ident 		"GENERIC-$Revision: 1.1066.2.7.4.1 $"
 
 maxusers	64		# estimated number of users
 
 # CPU-related options.
-options 	VM86		# virtual 8086 emulation
+#options 	VM86		# virtual 8086 emulation
 options 	USER_LDT	# user-settable LDT; used by WINE
 #options 	PAE		# PAE mode (36 bits physical addressing)
 



CVS commit: [netbsd-6-0] src/sys/arch/mac68k/nubus

2017-08-12 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Aug 12 16:37:30 UTC 2017

Modified Files:
src/sys/arch/mac68k/nubus [netbsd-6-0]: if_netdock_nubus.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1472):
sys/arch/mac68k/nubus/if_netdock_nubus.c: revision 1.26
Avoid memory leak in netdock_get.
If top is null, this is the first time through and nothing else will
free m.
>From Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.20.1 src/sys/arch/mac68k/nubus/if_netdock_nubus.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/mac68k/nubus/if_netdock_nubus.c
diff -u src/sys/arch/mac68k/nubus/if_netdock_nubus.c:1.21 src/sys/arch/mac68k/nubus/if_netdock_nubus.c:1.21.20.1
--- src/sys/arch/mac68k/nubus/if_netdock_nubus.c:1.21	Mon Apr  5 07:19:30 2010
+++ src/sys/arch/mac68k/nubus/if_netdock_nubus.c	Sat Aug 12 16:37:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_netdock_nubus.c,v 1.21 2010/04/05 07:19:30 joerg Exp $	*/
+/*	$NetBSD: if_netdock_nubus.c,v 1.21.20.1 2017/08/12 16:37:29 snj Exp $	*/
 
 /*
  * Copyright (C) 2000,2002 Daishi Kato 
@@ -43,7 +43,7 @@
 /***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.21 2010/04/05 07:19:30 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.21.20.1 2017/08/12 16:37:29 snj Exp $");
 
 #include 
 #include 
@@ -803,6 +803,8 @@ netdock_get(struct netdock_softc *sc, in
 			if ((m->m_flags & M_EXT) == 0) {
 if (top)
 	m_freem(top);
+else
+	m_freem(m);
 return (NULL);
 			}
 			len = MCLBYTES;



CVS commit: [netbsd-6-0] src/sys/arch/newsmips/apbus

2017-08-12 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Aug 12 16:28:58 UTC 2017

Modified Files:
src/sys/arch/newsmips/apbus [netbsd-6-0]: if_sn.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1471):
sys/arch/newsmips/apbus/if_sn.c: revision 1.39
Avoid memory leak in sonic_get.
If this is the first time around, top is null and nothing else will
free m.
>From Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.20.1 src/sys/arch/newsmips/apbus/if_sn.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/newsmips/apbus/if_sn.c
diff -u src/sys/arch/newsmips/apbus/if_sn.c:1.33 src/sys/arch/newsmips/apbus/if_sn.c:1.33.20.1
--- src/sys/arch/newsmips/apbus/if_sn.c:1.33	Mon Apr  5 07:19:31 2010
+++ src/sys/arch/newsmips/apbus/if_sn.c	Sat Aug 12 16:28:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sn.c,v 1.33 2010/04/05 07:19:31 joerg Exp $	*/
+/*	$NetBSD: if_sn.c,v 1.33.20.1 2017/08/12 16:28:58 snj Exp $	*/
 
 /*
  * National Semiconductor  DP8393X SONIC Driver
@@ -16,7 +16,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.33 2010/04/05 07:19:31 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.33.20.1 2017/08/12 16:28:58 snj Exp $");
 
 #include "opt_inet.h"
 
@@ -1093,7 +1093,10 @@ sonic_get(struct sn_softc *sc, void *pkt
 		if (datalen >= MINCLSIZE) {
 			MCLGET(m, M_DONTWAIT);
 			if ((m->m_flags & M_EXT) == 0) {
-if (top) m_freem(top);
+if (top)
+	m_freem(top);
+else
+	m_freem(m);
 return 0;
 			}
 			len = MCLBYTES;



CVS commit: [netbsd-6-0] src/sys/arch

2017-08-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  8 11:55:20 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: locore.S machdep.c trap.c
src/sys/arch/i386/i386 [netbsd-6-0]: locore.S machdep.c trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1464):

sys/arch/i386/i386/trap.c: revision 1.288   (patch)
sys/arch/i386/i386/machdep.c:  revision 1.783   (patch)
sys/arch/i386/i386/locore.S:   revision 1.146   (patch)
sys/arch/amd64/amd64/locore.S: revision 1.122,1.124 (patch)
sys/arch/amd64/amd64/machdep.c revision 1.254   (patch)
sys/arch/amd64/amd64/trap.c:   revision 1.95-1.96   (patch)

Remove the osyscall call gate and emulate it. There is a
one-instruction race in it that could panic the kernel.

Restore the ability to run netbsd 1.0 32-bit executables by checking
for the relevant lcall instruction in the trap handler and treating it
as a syscall.


To generate a diff of this commit:
cvs rdiff -u -r1.66.2.1 -r1.66.2.1.4.1 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.175.2.7.2.1 -r1.175.2.7.2.2 \
src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.69.2.1.4.1 -r1.69.2.1.4.2 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.95.10.2 -r1.95.10.2.4.1 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.717.2.7 -r1.717.2.7.4.1 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.262.12.1 -r1.262.12.2 src/sys/arch/i386/i386/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/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.66.2.1 src/sys/arch/amd64/amd64/locore.S:1.66.2.1.4.1
--- src/sys/arch/amd64/amd64/locore.S:1.66.2.1	Fri Apr 20 23:32:14 2012
+++ src/sys/arch/amd64/amd64/locore.S	Tue Aug  8 11:55:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.66.2.1 2012/04/20 23:32:14 riz Exp $	*/
+/*	$NetBSD: locore.S,v 1.66.2.1.4.1 2017/08/08 11:55:20 martin Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -1209,26 +1209,6 @@ NENTRY(child_trampoline)
 	.globl  _C_LABEL(osyscall_return)
 
 /*
- * oosyscall()
- *
- * Old call gate entry for syscall. only needed if we're
- * going to support running old i386 NetBSD 1.0 or ibcs2 binaries, etc,
- * on NetBSD/amd64.
- * The 64bit call gate can't request that arguments be copied from the
- * user stack (which the i386 code uses to get a gap for the flags).
- * push/pop are :: cycles.
- */
-IDTVEC(oosyscall)
-	/* Set rflags in trap frame. */
-	pushq	(%rsp)		# move user's %eip
-	pushq	16(%rsp)	# and %cs
-	popq	8(%rsp)
-	pushfq
-	popq	16(%rsp)
-	pushq	$7		# size of instruction for restart
-	jmp	osyscall1
-
-/*
  * osyscall()
  *
  * Trap gate entry for int $80 syscall, also used by sigreturn.
@@ -1240,7 +1220,6 @@ IDTVEC(osyscall)
 	addq $0x10,%rsp
 #endif
 	pushq	$2		# size of instruction for restart
-osyscall1:
 	pushq	$T_ASTFLT	# trap # for doing ASTs
 	INTRENTRY
 	STI(si)

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.1 src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.2
--- src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.1	Sat Apr 20 10:00:58 2013
+++ src/sys/arch/amd64/amd64/machdep.c	Tue Aug  8 11:55:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.175.2.7.2.1 2013/04/20 10:00:58 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.175.2.7.2.2 2017/08/08 11:55:20 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.7.2.1 2013/04/20 10:00:58 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.7.2.2 2017/08/08 11:55:20 martin Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1575,7 +1575,6 @@ typedef void (vector)(void);
 extern vector IDTVEC(syscall);
 extern vector IDTVEC(syscall32);
 extern vector IDTVEC(osyscall);
-extern vector IDTVEC(oosyscall);
 extern vector *IDTVEC(exceptions)[];
 
 static void
@@ -1838,10 +1837,7 @@ init_x86_64(paddr_t first_avail)
 	set_mem_segment(GDT_ADDR_MEM(gdtstore, GUDATA_SEL), 0,
 	x86_btop(VM_MAXUSER_ADDRESS) - 1, SDT_MEMRWA, SEL_UPL, 1, 0, 1);
 
-	/* make ldt gates and memory segments */
-	setgate((struct gate_descriptor *)(ldtstore + LSYS5CALLS_SEL),
-	&IDTVEC(oosyscall), 0, SDT_SYS386CGT, SEL_UPL,
-	GSEL(GCODE_SEL, SEL_KPL));
+	/* make ldt memory segments */
 	*(struct mem_segment_descriptor *)(ldtstore + LUCODE_SEL) =
 	*GDT_ADDR_MEM(gdtstore, GUCODE_SEL);
 	*(struct mem_segment_descriptor *)(ldtstore + LUDATA_SEL) =
@@ -1873,16 +1869,6 @@ init_x86_64(paddr_t first_avail)
 	set_mem_segment(ldt_segp, 0, x86_btop(VM_MAXUSER_ADDRESS32) - 1,
 	SDT_MEMRWA, SEL_UPL, 1, 1, 0);
 
-	/*
-	 * Other entries.
-	 */
-	memcpy((struct gate_descriptor *)(ldtstore + LSOL26CALLS_SEL),
-	(struct gate_descriptor *)(ldtstore + LSYS5CALLS_SEL),
-	sizeof (struct gate_descriptor));
-	me

CVS commit: [netbsd-6-0] src/sys/arch/i386/stand/misc

2017-06-03 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Jun  3 16:46:52 UTC 2017

Modified Files:
src/sys/arch/i386/stand/misc [netbsd-6-0]: rawr32.exe.uue

Log Message:
Pull up following revision(s) (requested by martin in ticket #1454):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)


To generate a diff of this commit:
cvs rdiff -u -r1.4.10.1 -r1.4.10.2 \
src/sys/arch/i386/stand/misc/rawr32.exe.uue

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

diffs are larger than 1MB and have been omitted


CVS commit: [netbsd-6-0] src/sys/arch

2017-03-25 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Mar 25 17:20:07 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: trap.c
src/sys/arch/i386/i386 [netbsd-6-0]: trap.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #1446):
sys/arch/amd64/amd64/trap.c: revision 1.94
sys/arch/i386/i386/trap.c: revision 1.287
Mmh, allow iret to be handled when an #SS fault (T_STKFLT) happens. Even
if the sdm is far from being clear, it appears that iret can trigger an #SS
fault if %ss points to a writable but non-present segment; in which case
the kernel would panic, thinking the fault was internal to it.
In particular, userland can create a broken segment in the ldt with
USER_LDT, update its %ss with setcontext and trigger the panic. I don't
think amd64 is affected since USER_LDT does not exist there, and the
changes on tf_ss seem correct - but I'm still adding T_STKFLT for safety.


To generate a diff of this commit:
cvs rdiff -u -r1.69.2.1 -r1.69.2.1.4.1 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.262 -r1.262.12.1 src/sys/arch/i386/i386/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/amd64/amd64/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.69.2.1 src/sys/arch/amd64/amd64/trap.c:1.69.2.1.4.1
--- src/sys/arch/amd64/amd64/trap.c:1.69.2.1	Sun Jun  3 21:45:10 2012
+++ src/sys/arch/amd64/amd64/trap.c	Sat Mar 25 17:20:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $	*/
+/*	$NetBSD: trap.c,v 1.69.2.1.4.1 2017/03/25 17:20:07 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1 2012/06/03 21:45:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69.2.1.4.1 2017/03/25 17:20:07 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -294,6 +294,7 @@ trap(struct trapframe *frame)
 	case T_PROTFLT:
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.262 src/sys/arch/i386/i386/trap.c:1.262.12.1
--- src/sys/arch/i386/i386/trap.c:1.262	Wed Sep  7 09:24:55 2011
+++ src/sys/arch/i386/i386/trap.c	Sat Mar 25 17:20:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $	*/
+/*	$NetBSD: trap.c,v 1.262.12.1 2017/03/25 17:20:07 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262 2011/09/07 09:24:55 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.262.12.1 2017/03/25 17:20:07 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -405,6 +405,7 @@ trap(struct trapframe *frame)
 #endif
 	case T_SEGNPFLT:
 	case T_ALIGNFLT:
+	case T_STKFLT:
 	case T_TSSFLT:
 		if (p == NULL)
 			goto we_re_toast;



CVS commit: [netbsd-6-0] src/sys/arch/x86

2017-03-06 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Mar  6 08:17:49 UTC 2017

Modified Files:
src/sys/arch/x86/include [netbsd-6-0]: pmap.h
src/sys/arch/x86/x86 [netbsd-6-0]: pmap.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1441):
sys/arch/x86/x86/pmap.c: revision 1.241 via patch
sys/arch/x86/include/pmap.h: revision 1.63 via patch
Should be PG_k, doesn't change anything.
--
Remove PG_u from the kernel pages on Xen. Otherwise there is no privilege
separation between the kernel and userland.
On Xen-amd64, the kernel runs in ring3 just like userland, and the
separation is guaranteed by the hypervisor - each syscall/trap is
intercepted by Xen and sent manually to the kernel. Before that, the
hypervisor modifies the page tables so that the kernel becomes accessible.
Later, when returning to userland, the hypervisor removes the kernel pages
and flushes the TLB.
However, TLB flushes are costly, and in order to reduce the number of pages
flushed Xen marks the userland pages as global, while keeping the kernel
ones as local. This way, when returning to userland, only the kernel pages
get flushed - which makes sense since they are the only ones that got
removed from the mapping.
Xen differentiates the userland pages by looking at their PG_u bit in the
PTE; if a page has this bit then Xen tags it as global, otherwise Xen
manually adds the bit but keeps the page as local. The thing is, since we
set PG_u in the kernel pages, Xen believes our kernel pages are in fact
userland pages, so it marks them as global. Therefore, when returning to
userland, the kernel pages indeed get removed from the page tree, but are
not flushed from the TLB. Which means that they are still accessible.
With this - and depending on the DTLB size - userland has a small window
where it can read/write to the last kernel pages accessed, which is enough
to completely escalate privileges: the sysent structure systematically gets
read when performing a syscall, and chances are that it will still be
cached in the TLB. Userland can then use this to patch a chosen syscall,
make it point to a userland function, retrieve %gs and compute the address
of its credentials, and finally grant itself root privileges.


To generate a diff of this commit:
cvs rdiff -u -r1.49.2.2 -r1.49.2.2.4.1 src/sys/arch/x86/include/pmap.h
cvs rdiff -u -r1.164.2.4.4.1 -r1.164.2.4.4.2 src/sys/arch/x86/x86/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/x86/include/pmap.h
diff -u src/sys/arch/x86/include/pmap.h:1.49.2.2 src/sys/arch/x86/include/pmap.h:1.49.2.2.4.1
--- src/sys/arch/x86/include/pmap.h:1.49.2.2	Wed May  9 03:22:52 2012
+++ src/sys/arch/x86/include/pmap.h	Mon Mar  6 08:17:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.49.2.2 2012/05/09 03:22:52 riz Exp $	*/
+/*	$NetBSD: pmap.h,v 1.49.2.2.4.1 2017/03/06 08:17:49 snj Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -182,15 +182,7 @@ struct pmap {
 	((pmap)->pm_pdirpa[0] + (index) * sizeof(pd_entry_t))
 #endif
 
-/* 
- * flag to be used for kernel mappings: PG_u on Xen/amd64, 
- * 0 otherwise.
- */
-#if defined(XEN) && defined(__x86_64__)
-#define PG_k PG_u
-#else
 #define PG_k 0
-#endif
 
 /*
  * MD flags that we use for pmap_enter and pmap_kenter_pa:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.164.2.4.4.1 src/sys/arch/x86/x86/pmap.c:1.164.2.4.4.2
--- src/sys/arch/x86/x86/pmap.c:1.164.2.4.4.1	Thu Jul 14 07:09:39 2016
+++ src/sys/arch/x86/x86/pmap.c	Mon Mar  6 08:17:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.164.2.4.4.1 2016/07/14 07:09:39 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.164.2.4.4.2 2017/03/06 08:17:49 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.4.4.1 2016/07/14 07:09:39 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.4.4.2 2017/03/06 08:17:49 snj Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1467,7 +1467,7 @@ pmap_bootstrap(vaddr_t kva_start)
 	memset((void *) (xen_dummy_user_pgd + KERNBASE), 0, PAGE_SIZE);
 	/* Mark read-only */
 	HYPERVISOR_update_va_mapping(xen_dummy_user_pgd + KERNBASE,
-	pmap_pa2pte(xen_dummy_user_pgd) | PG_u | PG_V, UVMF_INVLPG);
+	pmap_pa2pte(xen_dummy_user_pgd) | PG_k | PG_V, UVMF_INVLPG);
 	/* Pin as L4 */
 	xpq_queue_pin_l4_table(xpmap_ptom_masked(xen_dummy_user_pgd));
 #endif /* __x86_64__ */
@@ -2064,7 +2064,7 @@ pmap_pdp_ctor(void *arg, void *v, int fl
 	 * this pdir will NEVER be active in kernel mode
 	 * so mark recursive entry invalid
 	 */
-	pdir[PDIR_SLOT_PTE] = pmap_pa2pte(pdirpa) | PG_u;
+	pdir[PDIR_SLOT_PTE] = pmap_pa2pte(pdirpa) | PG_k;
 	/*
 	 * PDP constructed this way won't be for kernel,
 	 * hence we don't put kernel mappings on Xen.



CVS commit: [netbsd-6-0] src/sys/arch/amd64/amd64

2017-02-04 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Feb  5 05:59:33 UTC 2017

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: copy.S

Log Message:
Apply patch (requested by maxv in ticket #1431):
suword: Don't allow 4 bytes to overflow beyond the userland space.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.20.1 src/sys/arch/amd64/amd64/copy.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/amd64/amd64/copy.S
diff -u src/sys/arch/amd64/amd64/copy.S:1.18 src/sys/arch/amd64/amd64/copy.S:1.18.20.1
--- src/sys/arch/amd64/amd64/copy.S:1.18	Wed Jul  7 01:13:29 2010
+++ src/sys/arch/amd64/amd64/copy.S	Sun Feb  5 05:59:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.18 2010/07/07 01:13:29 chs Exp $	*/
+/*	$NetBSD: copy.S,v 1.18.20.1 2017/02/05 05:59:33 snj Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -413,7 +413,7 @@ ENTRY(fubyte)
 
 ENTRY(suword)
 	DEFERRED_SWITCH_CHECK
-	movq	$VM_MAXUSER_ADDRESS-4,%r11
+	movq	$VM_MAXUSER_ADDRESS-8,%r11
 	cmpq	%r11,%rdi
 	ja	_C_LABEL(fusuaddrfault)
 



CVS commit: [netbsd-6-0] src/sys/arch/sparc64/sparc64

2016-09-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep 24 13:19:09 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-6-0]: locore.s

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1408):
sys/arch/sparc64/sparc64/locore.s: revision 1.401
Fix RAS for 32-bit kernels.  trapframe is always 64-bit.


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

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.2 src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.3
--- src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.2	Sun Nov 15 21:01:52 2015
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Sep 24 13:19:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.338.8.2.4.2 2015/11/15 21:01:52 bouyer Exp $	*/
+/*	$NetBSD: locore.s,v 1.338.8.2.4.3 2016/09/24 13:19:09 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5203,12 +5203,12 @@ ENTRY(cpu_switchto)
 	brz,pt	%o1, Lsw_noras		! no, skip RAS check
 	 LDPTR	[%i1 + L_TF], %l3	! pointer to trap frame
 	call	_C_LABEL(ras_lookup)
-	 LDPTR	[%l3 + TF_PC], %o1
+	 ldx	[%l3 + TF_PC], %o1
 	cmp	%o0, -1
-	be,pt	%xcc, Lsw_noras
+	be,pt	CCCR, Lsw_noras
 	 add	%o0, 4, %o1
-	STPTR	%o0, [%l3 + TF_PC]	! store rewound %pc
-	STPTR	%o1, [%l3 + TF_NPC]	! and %npc
+	stx	%o0, [%l3 + TF_PC]	! store rewound %pc
+	stx	%o1, [%l3 + TF_NPC]	! and %npc
 
 Lsw_noras:
 



CVS commit: [netbsd-6-0] src/sys/arch/sparc64/sparc64

2016-09-24 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep 24 13:06:48 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-6-0]: kobj_machdep.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1405):
sys/arch/sparc64/sparc64/kobj_machdep.c: revision 1.5
sys/arch/sparc64/sparc64/kobj_machdep.c: revision 1.6
Follow rev. 1.54, 1.55 of libexec/ld.elf_so/arch/sparc64/mdreloc.c.
The target of the OLO10 relocation is the simd13 field of the instruction,
so use a 13 bit target mask.
Fixes PR kern/51436 (I broke this myself in rev 1.4)


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

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/kobj_machdep.c
diff -u src/sys/arch/sparc64/sparc64/kobj_machdep.c:1.4 src/sys/arch/sparc64/sparc64/kobj_machdep.c:1.4.20.1
--- src/sys/arch/sparc64/sparc64/kobj_machdep.c:1.4	Sun May  2 11:43:30 2010
+++ src/sys/arch/sparc64/sparc64/kobj_machdep.c	Sat Sep 24 13:06:47 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kobj_machdep.c,v 1.4 2010/05/02 11:43:30 martin Exp $	*/
+/*	$NetBSD: kobj_machdep.c,v 1.4.20.1 2016/09/24 13:06:47 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2001 Jake Burkholder.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.4 2010/05/02 11:43:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.4.20.1 2016/09/24 13:06:47 bouyer Exp $");
 
 #define	ELFSIZE		ARCH_ELFSIZE
 
@@ -164,15 +164,15 @@ static const long reloc_target_bitmask[]
 	_BM(22), _BM(10),		/* _HIPLT22, LOPLT10 */
 	_BM(32), _BM(22), _BM(10),	/* _PCPLT32, _PCPLT22, _PCPLT10 */
 	_BM(10), _BM(11), -1,		/* _10, _11, _64 */
-	_BM(10), _BM(22),		/* _OLO10, _HH22 */
+	_BM(13), _BM(22),		/* _OLO10, _HH22 */
 	_BM(10), _BM(22),		/* _HM10, _LM22 */
 	_BM(22), _BM(10), _BM(22),	/* _PC_HH22, _PC_HM10, _PC_LM22 */
 	_BM(16), _BM(19),		/* _WDISP16, _WDISP19 */
 	-1,/* GLOB_JMP */
-	_BM(7), _BM(5), _BM(6)		/* _7, _5, _6 */
+	_BM(7), _BM(5), _BM(6),		/* _7, _5, _6 */
 	-1, -1,/* DISP64, PLT64 */
 	_BM(22), _BM(13),		/* HIX22, LOX10 */
-	_BM(22), _BM(10), _BM(13),	/* H44, M44, L44 */
+	_BM(22), _BM(10), _BM(12),	/* H44, M44, L44 */
 	-1, -1, _BM(16),		/* REGISTER, UA64, UA16 */
 #undef _BM
 };



CVS commit: [netbsd-6-0] src/sys/arch/i386/stand/misc

2016-08-28 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Aug 28 10:40:38 UTC 2016

Modified Files:
src/sys/arch/i386/stand/misc [netbsd-6-0]: rawr32.exe.uue

Log Message:
Pull up following revision(s) (requested by martin in ticket #1385):
sys/arch/i386/stand/misc/rawr32.exe.uue: sync to revision 1.6
New Rawrite32 release


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/arch/i386/stand/misc/rawr32.exe.uue

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

diffs are larger than 1MB and have been omitted


CVS commit: [netbsd-6-0] src/sys/arch/x86/x86

2016-07-14 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul 14 07:09:39 UTC 2016

Modified Files:
src/sys/arch/x86/x86 [netbsd-6-0]: pmap.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1365):
sys/arch/x86/x86/pmap.c: revision 1.190
Operation pmap_pp_clear_attrs() may remove the "used" attribute from a page
that is still cached in the TLB of other CPUs.
Call pmap_tlb_shootnow() here before enabling preemption to clear the
TLB entries on other CPUs.
Should prevent tmpfs data corruption under load.
Ok: Chuck Silvers


To generate a diff of this commit:
cvs rdiff -u -r1.164.2.4 -r1.164.2.4.4.1 src/sys/arch/x86/x86/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/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.164.2.4 src/sys/arch/x86/x86/pmap.c:1.164.2.4.4.1
--- src/sys/arch/x86/x86/pmap.c:1.164.2.4	Wed May  9 03:22:53 2012
+++ src/sys/arch/x86/x86/pmap.c	Thu Jul 14 07:09:39 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.164.2.4 2012/05/09 03:22:53 riz Exp $	*/
+/*	$NetBSD: pmap.c,v 1.164.2.4.4.1 2016/07/14 07:09:39 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.4 2012/05/09 03:22:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.164.2.4.4.1 2016/07/14 07:09:39 snj Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3717,6 +3717,7 @@ startover:
 	}
 	result = pp->pp_attrs & clearbits;
 	pp->pp_attrs &= ~clearbits;
+	pmap_tlb_shootnow();
 	kpreempt_enable();
 
 	return result != 0;



CVS commit: [netbsd-6-0] src/sys/arch/x86

2016-07-13 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Jul 14 06:48:19 UTC 2016

Modified Files:
src/sys/arch/x86/include [netbsd-6-0]: cpufunc.h
src/sys/arch/x86/x86 [netbsd-6-0]: errata.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1361):
sys/arch/x86/include/cpufunc.h: revision 1.19
sys/arch/x86/x86/errata.c: revision 1.23
Adapt prototypes and usage of rdmsr_locked() and wrmsr_locked() to
their implementation.  Both functions don't take the passcode as
argument.
As wrmsr_locked() no longer writes the passcode to the msr the
erratum 721 on my Opteron 2356 really gets patched and cc1 no longer
crashes with SIGSEGV.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.14.1 src/sys/arch/x86/include/cpufunc.h
cvs rdiff -u -r1.19.14.1 -r1.19.14.1.4.1 src/sys/arch/x86/x86/errata.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/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.13 src/sys/arch/x86/include/cpufunc.h:1.13.14.1
--- src/sys/arch/x86/include/cpufunc.h:1.13	Sat Sep 24 10:32:52 2011
+++ src/sys/arch/x86/include/cpufunc.h	Thu Jul 14 06:48:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.13 2011/09/24 10:32:52 jym Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.13.14.1 2016/07/14 06:48:19 snj Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -117,12 +117,12 @@ void	x86_reset(void);
 #define	OPTERON_MSR_PASSCODE	0x9c5a203aU
 
 uint64_t	rdmsr(u_int);
-uint64_t	rdmsr_locked(u_int, u_int);
+uint64_t	rdmsr_locked(u_int);
 int		rdmsr_safe(u_int, uint64_t *);
 uint64_t	rdtsc(void);
 uint64_t	rdpmc(u_int);
 void		wrmsr(u_int, uint64_t);
-void		wrmsr_locked(u_int, u_int, uint64_t);
+void		wrmsr_locked(u_int, uint64_t);
 void		setfs(int);
 void		setusergs(int);
 

Index: src/sys/arch/x86/x86/errata.c
diff -u src/sys/arch/x86/x86/errata.c:1.19.14.1 src/sys/arch/x86/x86/errata.c:1.19.14.1.4.1
--- src/sys/arch/x86/x86/errata.c:1.19.14.1	Mon Apr  9 18:02:25 2012
+++ src/sys/arch/x86/x86/errata.c	Thu Jul 14 06:48:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: errata.c,v 1.19.14.1 2012/04/09 18:02:25 riz Exp $	*/
+/*	$NetBSD: errata.c,v 1.19.14.1.4.1 2016/07/14 06:48:19 snj Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.19.14.1 2012/04/09 18:02:25 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.19.14.1.4.1 2016/07/14 06:48:19 snj Exp $");
 
 #include 
 #include 
@@ -294,7 +294,7 @@ x86_errata_testmsr(struct cpu_info *ci, 
 
 	(void)ci;
 
-	val = rdmsr_locked(e->e_data1, OPTERON_MSR_PASSCODE);
+	val = rdmsr_locked(e->e_data1);
 	if ((val & e->e_data2) != 0)
 		return FALSE;
 
@@ -309,10 +309,10 @@ x86_errata_setmsr(struct cpu_info *ci, e
 
 	(void)ci;
 
-	val = rdmsr_locked(e->e_data1, OPTERON_MSR_PASSCODE);
+	val = rdmsr_locked(e->e_data1);
 	if ((val & e->e_data2) != 0)
 		return FALSE;
-	wrmsr_locked(e->e_data1, OPTERON_MSR_PASSCODE, val | e->e_data2);
+	wrmsr_locked(e->e_data1, val | e->e_data2);
 	aprint_debug_dev(ci->ci_dev, "erratum %d patched\n",
 	e->e_num);
 



CVS commit: [netbsd-6-0] src/sys/arch/xen

2016-01-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Jan  8 21:24:37 UTC 2016

Modified Files:
src/sys/arch/xen/include/xen-public/io [netbsd-6-0]: ring.h
src/sys/arch/xen/xen [netbsd-6-0]: pciback.c xbdback_xenbus.c
xennetback_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1358):
sys/arch/xen/include/xen-public/io/ring.h: revision 1.3 via patch
sys/arch/xen/xen/pciback.c: revision 1.10 via patch
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.62 via patch
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.54 via patch
Apply patch from xsa155: make sure that the backend won't read parts of the
request again (possibly because of compiler optimisations), by using
copies and barrier.
>From XSA155:
The compiler can emit optimizations in the PV backend drivers which
can lead to double fetch vulnerabilities. Specifically the shared
memory between the frontend and backend can be fetched twice (during
which time the frontend can alter the contents) possibly leading to
arbitrary code execution in backend.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.10.1 src/sys/arch/xen/include/xen-public/io/ring.h
cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/arch/xen/xen/pciback.c
cvs rdiff -u -r1.55.2.1.4.2 -r1.55.2.1.4.3 \
src/sys/arch/xen/xen/xbdback_xenbus.c
cvs rdiff -u -r1.47 -r1.47.12.1 src/sys/arch/xen/xen/xennetback_xenbus.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/xen/include/xen-public/io/ring.h
diff -u src/sys/arch/xen/include/xen-public/io/ring.h:1.2 src/sys/arch/xen/include/xen-public/io/ring.h:1.2.10.1
--- src/sys/arch/xen/include/xen-public/io/ring.h:1.2	Wed Dec  7 15:40:15 2011
+++ src/sys/arch/xen/include/xen-public/io/ring.h	Fri Jan  8 21:24:37 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ring.h,v 1.2 2011/12/07 15:40:15 cegger Exp $ */
+/* $NetBSD: ring.h,v 1.2.10.1 2016/01/08 21:24:37 snj Exp $ */
 /**
  * ring.h
  * 
@@ -236,6 +236,20 @@ typedef struct __name##_back_ring __name
 #define RING_GET_REQUEST(_r, _idx)  \
 (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req))
 
+/*
+ * Get a local copy of a request.
+ *
+ * Use this in preference to RING_GET_REQUEST() so all processing is
+ * done on a local copy that cannot be modified by the other end.
+ *
+ * Note that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 may cause this
+ * to be ineffective where _req is a struct which consists of only bitfields.
+ */
+#define RING_COPY_REQUEST(_r, _idx, _req) do {\
+	/* Use volatile to force the copy into _req. */			\
+	*(_req) = *(volatile typeof(_req))RING_GET_REQUEST(_r, _idx);	\
+} while (0)
+
 #define RING_GET_RESPONSE(_r, _idx) \
 (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp))
 

Index: src/sys/arch/xen/xen/pciback.c
diff -u src/sys/arch/xen/xen/pciback.c:1.7 src/sys/arch/xen/xen/pciback.c:1.7.8.1
--- src/sys/arch/xen/xen/pciback.c:1.7	Thu Feb  2 19:43:01 2012
+++ src/sys/arch/xen/xen/pciback.c	Fri Jan  8 21:24:37 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: pciback.c,v 1.7 2012/02/02 19:43:01 tls Exp $  */
+/*  $NetBSD: pciback.c,v 1.7.8.1 2016/01/08 21:24:37 snj Exp $  */
 
 /*
  * Copyright (c) 2009 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.7 2012/02/02 19:43:01 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pciback.c,v 1.7.8.1 2016/01/08 21:24:37 snj Exp $");
 
 #include "opt_xen.h"
 
@@ -188,6 +188,7 @@ struct pb_xenbus_instance {
 	/* communication with the domU */
 unsigned int pbx_evtchn; /* our even channel */
 struct xen_pci_sharedinfo *pbx_sh_info;
+struct xen_pci_op op;
 grant_handle_t pbx_shinfo_handle; /* to unmap shared page */
 };
 
@@ -712,13 +713,16 @@ pciback_xenbus_evthandler(void * arg)
 {
 	struct pb_xenbus_instance *pbxi = arg;
 	struct pciback_pci_dev *pbd;
-	struct xen_pci_op *op = &pbxi->pbx_sh_info->op;
+	struct xen_pci_op *op = &pbxi->op;
 	u_int bus, dev, func;
 
 	hypervisor_clear_event(pbxi->pbx_evtchn);
 	if (xen_atomic_test_bit(&pbxi->pbx_sh_info->flags,
 	_XEN_PCIF_active) == 0)
 		return 0;
+
+	memcpy(op, &pbxi->pbx_sh_info->op, sizeof (struct xen_pci_op));
+	__insn_barrier();
 	if (op->domain != 0) {
 		aprint_error("pciback: domain %d != 0", op->domain);
 		op->err = XEN_PCI_ERR_dev_not_found;
@@ -785,6 +789,8 @@ pciback_xenbus_evthandler(void * arg)
 		aprint_error("pciback: unknown cmd %d\n", op->cmd);
 		op->err = XEN_PCI_ERR_not_implemented;
 	}
+	pbxi->pbx_sh_info->op.value = op->value;
+	pbxi->pbx_sh_info->op.err = op->err;
 end:
 	xen_atomic_clear_bit(&pbxi->pbx_sh_info->flags, _XEN_PCIF_active);
 	hypervisor_notify_via_evtchn(pbxi->pbx_evtchn);

Index: src/sys/arch/xen/xen/xbdback_xenbus.c
dif

CVS commit: [netbsd-6-0] src/sys/arch/xen/xen

2015-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov 16 07:53:01 UTC 2015

Modified Files:
src/sys/arch/xen/xen [netbsd-6-0]: xbdback_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1347):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.61
Fix typo which caused the kenrel thread to be created with a 0 priority.
This would cause the thread to be almost never scheduled when a userland
process could use all CPU.
Should fix the problem reported by Torbj?rn Granlund on port-xen@


To generate a diff of this commit:
cvs rdiff -u -r1.55.2.1.4.1 -r1.55.2.1.4.2 \
src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.55.2.1.4.1 src/sys/arch/xen/xen/xbdback_xenbus.c:1.55.2.1.4.2
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.55.2.1.4.1	Thu Nov  7 20:18:50 2013
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Mon Nov 16 07:53:01 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.55.2.1.4.1 2013/11/07 20:18:50 snj Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.55.2.1.4.2 2015/11/16 07:53:01 msaitoh Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.55.2.1.4.1 2013/11/07 20:18:50 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.55.2.1.4.2 2015/11/16 07:53:01 msaitoh Exp $");
 
 #include 
 #include 
@@ -648,7 +648,7 @@ xbdback_connect(struct xbdback_instance 
 	hypervisor_enable_event(xbdi->xbdi_evtchn);
 	hypervisor_notify_via_evtchn(xbdi->xbdi_evtchn);
 
-	if (kthread_create(IPL_NONE, KTHREAD_MPSAFE, NULL,
+	if (kthread_create(PRI_NONE, KTHREAD_MPSAFE, NULL,
 	xbdback_thread, xbdi, NULL, "%s", xbdi->xbdi_name) == 0)
 		return 0;
 



CVS commit: [netbsd-6-0] src/sys/arch/sparc64/sparc64

2015-11-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 15 21:01:52 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-6-0]: locore.s netbsd32_machdep.c
vm_machdep.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1343):
sys/arch/sparc64/sparc64/locore.s: revision 1.386
sys/arch/sparc64/sparc64/vm_machdep.c: revision 1.101
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.105
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.106
Basically revert r1.246 of locore.s and r1.73 of vm_machdep.c:
Remove special case handling for userland lwps from cpu_lwp_fork,
instead do it in lwp_trampoline when we first return to userland.
which was a stupid idea - since we did now set all fork child's %tstate
(and thus %pstate when back in userland) to the current kernel's userland
default. This meant we lost the address mask bit for 32bit processes and
all memory model details for 64bit ones.
Move it back to cpu_lwp_fork and fix the condition to only do it once when
forking init.
Fix kmem_free() size mismatch
Convert siginfo to 32bit version before copying it out to 32bit userland.


To generate a diff of this commit:
cvs rdiff -u -r1.338.8.2.4.1 -r1.338.8.2.4.2 \
src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.96.2.1 -r1.96.2.1.4.1 \
src/sys/arch/sparc64/sparc64/netbsd32_machdep.c
cvs rdiff -u -r1.98 -r1.98.12.1 src/sys/arch/sparc64/sparc64/vm_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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.1 src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.2
--- src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.1	Sat Dec 14 19:33:45 2013
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Nov 15 21:01:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.338.8.2.4.1 2013/12/14 19:33:45 bouyer Exp $	*/
+/*	$NetBSD: locore.s,v 1.338.8.2.4.2 2015/11/15 21:01:52 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5369,12 +5369,6 @@ ENTRY(lwp_trampoline)
 	 mov	%l1, %o0
 
 	/*
-	 * Going to userland - set proper tstate in trap frame
-	 */
-	set	(ASI_PRIMARY_NO_FAULT<
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.96.2.1 2012/05/21 15:25:56 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.96.2.1.4.1 2015/11/15 21:01:52 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -322,6 +322,7 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	int sig = ksi->ksi_signo;
 	ucontext32_t uc;
 	struct sparc32_sigframe_siginfo *fp;
+	siginfo32_t si32;	
 	netbsd32_intptr_t catcher;
 	struct trapframe64 *tf = l->l_md.md_tf;
 	struct rwindow32 *oldsp, *newsp;
@@ -342,15 +343,16 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	else
 		fp = (struct sparc32_sigframe_siginfo *)oldsp;
 	fp = (struct sparc32_sigframe_siginfo*)((u_long)(fp - 1) & ~7);
+
 	/*
 	 * Build the signal context to be used by sigreturn.
 	 */
+	memset(&uc, 0, sizeof uc);
 	uc.uc_flags = _UC_SIGMASK |
 		((l->l_sigstk.ss_flags & SS_ONSTACK)
 			? _UC_SETSTACK : _UC_CLRSTACK);
 	uc.uc_sigmask = *mask;
 	uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
-	memset(&uc.uc_stack, 0, sizeof(uc.uc_stack));
 
 	sendsig_reset(l, sig);
 
@@ -365,9 +367,10 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	 */
 	mutex_exit(p->p_lock);
 	cpu_getmcontext32(l, &uc.uc_mcontext, &uc.uc_flags);
+	netbsd32_si_to_si32(&si32, (const siginfo_t *)&ksi->ksi_info);
 	ucsz = (int)(intptr_t)&uc.__uc_pad - (int)(intptr_t)&uc;
 	newsp = (struct rwindow32*)((intptr_t)fp - sizeof(struct frame32));
-	error = (copyout(&ksi->ksi_info, &fp->sf_si, sizeof ksi->ksi_info) ||
+	error = (copyout(&si32, &fp->sf_si, sizeof si32) ||
 	copyout(&uc, &fp->sf_uc, ucsz) ||
 	suword(&newsp->rw_in[6], (intptr_t)oldsp));
 	mutex_enter(p->p_lock);
@@ -1367,7 +1370,8 @@ startlwp32(void *arg)
 	error = cpu_setmcontext32(l, &uc->uc_mcontext, uc->uc_flags);
 	KASSERT(error == 0);
 
-	kmem_free(uc, sizeof(ucontext32_t));
+	/* Note: we are freeing ucontext_t, not ucontext32_t. */
+	kmem_free(arg, sizeof(ucontext_t));
 	userret(l, 0, 0);
 }
 

Index: src/sys/arch/sparc64/sparc64/vm_machdep.c
diff -u src/sys/arch/sparc64/sparc64/vm_machdep.c:1.98 src/sys/arch/sparc64/sparc64/vm_machdep.c:1.98.12.1
--- src/sys/arch/sparc64/sparc64/vm_machdep.c:1.98	Sat Oct  8 08:49:07 2011
+++ src/sys/arch/sparc64/sparc64/vm_machdep.c	Sun Nov 15 21:01:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.98 2011/10/08 08:49:07 nakayama Exp $ */
+/*	$NetBSD: vm_machdep.c,v 1.98.12.1 2015/11/15 21:01:52 bouyer Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.98 2011/10/08 08:49:07 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.98.12.1 2015/11/15 21:01:52 bouyer Exp 

CVS commit: [netbsd-6-0] src/sys/arch/x86/x86

2015-11-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 15 20:57:08 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-6-0]: sys_machdep.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1341):
sys/arch/x86/x86/sys_machdep.c: revision 1.29
fix broken error handling; error was used uninitialized. Changing the
compilation flags broke all threaded programs for me.
XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.25.14.1 src/sys/arch/x86/x86/sys_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/x86/x86/sys_machdep.c
diff -u src/sys/arch/x86/x86/sys_machdep.c:1.25 src/sys/arch/x86/x86/sys_machdep.c:1.25.14.1
--- src/sys/arch/x86/x86/sys_machdep.c:1.25	Mon Oct 10 15:15:28 2011
+++ src/sys/arch/x86/x86/sys_machdep.c	Sun Nov 15 20:57:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_machdep.c,v 1.25 2011/10/10 15:15:28 jakllsch Exp $	*/
+/*	$NetBSD: sys_machdep.c,v 1.25.14.1 2015/11/15 20:57:08 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.25 2011/10/10 15:15:28 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.25.14.1 2015/11/15 20:57:08 bouyer Exp $");
 
 #include "opt_mtrr.h"
 #include "opt_perfctrs.h"
@@ -657,7 +657,6 @@ x86_set_sdbase(void *arg, char which, lw
 #else
 	struct pcb *pcb;
 	vaddr_t base;
-	int error;
 
 	if (l->l_proc->p_flag & PK_32) {
 		return x86_set_sdbase32(arg, which, l, direct);
@@ -666,7 +665,7 @@ x86_set_sdbase(void *arg, char which, lw
 	if (direct) {
 		base = (vaddr_t)arg;
 	} else {
-		error = copyin(arg, &base, sizeof(base));
+		int error = copyin(arg, &base, sizeof(base));
 		if (error != 0)
 			return error;
 	}
@@ -674,10 +673,6 @@ x86_set_sdbase(void *arg, char which, lw
 	if (base >= VM_MAXUSER_ADDRESS)
 		return EINVAL;
 
-	if (error) {
-		return error;
-	}
-
 	pcb = lwp_getpcb(l);
 
 	kpreempt_disable();
@@ -697,7 +692,7 @@ x86_set_sdbase(void *arg, char which, lw
 	}
 	kpreempt_enable();
 
-	return error;
+	return 0;
 #endif
 }
 



CVS commit: [netbsd-6-0] src/sys/arch/x86/x86

2015-11-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Nov 15 20:52:09 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-6-0]: bus_dma.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1339):
sys/arch/x86/x86/bus_dma.c: revision 1.72
sys/arch/x86/x86/bus_dma.c: revision 1.73
sys/arch/x86/x86/bus_dma.c: revision 1.74
- If we succeeded allocating a buffer that did not need bouncing before, but
  the buffer in the previous mapping did, clear the bounce bit. Fixes the
  ld_virtio.c bug with machines 8GB and dd if=/dev/zero of=crash bs=1g count=4.
- Allocate with M_ZERO instead of doing memset
- The panic string can take a format, use it.
- When checking for the bounce buffer boundary check addr + len < limit, not
  addr < limit.
make sure we have a cookie before we try to clear it.
fix operator precedence.


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.68.14.1 src/sys/arch/x86/x86/bus_dma.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/x86/x86/bus_dma.c
diff -u src/sys/arch/x86/x86/bus_dma.c:1.68 src/sys/arch/x86/x86/bus_dma.c:1.68.14.1
--- src/sys/arch/x86/x86/bus_dma.c:1.68	Fri Oct 14 18:28:04 2011
+++ src/sys/arch/x86/x86/bus_dma.c	Sun Nov 15 20:52:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.68 2011/10/14 18:28:04 bouyer Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.68.14.1 2015/11/15 20:52:09 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.68 2011/10/14 18:28:04 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.68.14.1 2015/11/15 20:52:09 bouyer Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -283,11 +283,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	error = 0;
 	mapsize = sizeof(struct x86_bus_dmamap) +
 	(sizeof(bus_dma_segment_t) * (nsegments - 1));
-	if ((mapstore = malloc(mapsize, M_DMAMAP,
-	(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+	if ((mapstore = malloc(mapsize, M_DMAMAP, M_ZERO |
+	((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK))) == NULL)
 		return (ENOMEM);
 
-	memset(mapstore, 0, mapsize);
 	map = (struct x86_bus_dmamap *)mapstore;
 	map->_dm_size = size;
 	map->_dm_segcnt = nsegments;
@@ -323,12 +322,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
 	/*
 	 * Allocate our cookie.
 	 */
-	if ((cookiestore = malloc(cookiesize, M_DMAMAP,
-	(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) {
+	if ((cookiestore = malloc(cookiesize, M_DMAMAP, M_ZERO |
+	((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK))) == NULL) {
 		error = ENOMEM;
 		goto out;
 	}
-	memset(cookiestore, 0, cookiesize);
 	cookie = (struct x86_bus_dma_cookie *)cookiestore;
 	cookie->id_flags = cookieflags;
 	map->_dm_cookie = cookie;
@@ -391,6 +389,8 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dm
 	}
 	error = _bus_dmamap_load_buffer(t, map, buf, buflen, vm, flags);
 	if (error == 0) {
+		if (cookie != NULL)
+			cookie->id_flags &= ~X86_DMA_IS_BOUNCING;
 		map->dm_mapsize = buflen;
 		return 0;
 	}
@@ -789,7 +789,7 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 	 */
 	if ((ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0 &&
 	(ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0)
-		panic("_bus_dmamap_sync: mix PRE and POST");
+		panic("%s: mix PRE and POST", __func__);
 
 #ifdef DIAGNOSTIC
 	if ((ops & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTREAD)) != 0) {
@@ -916,16 +916,17 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 	}
 
 	case X86_DMA_BUFTYPE_RAW:
-		panic("_bus_dmamap_sync: X86_DMA_BUFTYPE_RAW");
+		panic("%s: X86_DMA_BUFTYPE_RAW", __func__);
 		break;
 
 	case X86_DMA_BUFTYPE_INVALID:
-		panic("_bus_dmamap_sync: X86_DMA_BUFTYPE_INVALID");
+		panic("%s: X86_DMA_BUFTYPE_INVALID", __func__);
 		break;
 
 	default:
-		printf("unknown buffer type %d\n", cookie->id_buftype);
-		panic("_bus_dmamap_sync");
+		panic("%s: unknown buffer type %d", __func__,
+		cookie->id_buftype);
+		break;
 	}
 end:
 	if (ops & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTWRITE)) {
@@ -1233,19 +1234,20 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t,
 		curaddr = _BUS_VIRT_TO_BUS(pmap, vaddr);
 
 		/*
+		 * Compute the segment size, and adjust counts.
+		 */
+		sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
+		if (buflen < sgsize)
+			sgsize = buflen;
+
+		/*
 		 * If we're beyond the bounce threshold, notify
 		 * the caller.
 		 */
 		if (map->_dm_bounce_thresh != 0 &&
-		curaddr >= map->_dm_bounce_thresh)
+		curaddr + sgsize >= map->_dm_bounce_thresh)
 			return (EINVAL);
 
-		/*
-		 * Compute the segment size, and adjust counts.
-		 */
-		sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
-		if (buflen < sgsize)
-			sgsize = buflen;
 
 		error = _bus_dmamap_load_busaddr(t, map, curaddr, sgsize);
 		if (error)



CVS commit: [netbsd-6-0] src/sys/arch/xen/xen

2015-05-26 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 27 05:57:14 UTC 2015

Modified Files:
src/sys/arch/xen/xen [netbsd-6-0]: xenevt.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1299):
sys/arch/xen/xen/xenevt.c: revision 1.42
Fix off by one error, pointed out by Wei Liu in port-xen/49919


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.10.1 src/sys/arch/xen/xen/xenevt.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/xen/xen/xenevt.c
diff -u src/sys/arch/xen/xen/xenevt.c:1.39 src/sys/arch/xen/xen/xenevt.c:1.39.10.1
--- src/sys/arch/xen/xen/xenevt.c:1.39	Sat Dec  3 22:41:40 2011
+++ src/sys/arch/xen/xen/xenevt.c	Wed May 27 05:57:14 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: xenevt.c,v 1.39 2011/12/03 22:41:40 bouyer Exp $  */
+/*  $NetBSD: xenevt.c,v 1.39.10.1 2015/05/27 05:57:14 msaitoh Exp $  */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.39 2011/12/03 22:41:40 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.39.10.1 2015/05/27 05:57:14 msaitoh Exp $");
 
 #include "opt_xen.h"
 #include 
@@ -479,7 +479,7 @@ xenevt_fwrite(struct file *fp, off_t *of
 	if (uio->uio_resid == 0)
 		return (0);
 	nentries = uio->uio_resid / sizeof(uint16_t);
-	if (nentries > NR_EVENT_CHANNELS)
+	if (nentries >= NR_EVENT_CHANNELS)
 		return EMSGSIZE;
 	chans = kmem_alloc(nentries * sizeof(uint16_t), KM_SLEEP);
 	if (chans == NULL)
@@ -572,7 +572,7 @@ xenevt_fioctl(struct file *fp, u_long cm
 	{
 		struct ioctl_evtchn_unbind *unbind = addr;
 		
-		if (unbind->port > NR_EVENT_CHANNELS)
+		if (unbind->port >= NR_EVENT_CHANNELS)
 			return EINVAL;
 		mutex_enter(&devevent_lock);
 		if (devevent[unbind->port] != d) {
@@ -593,7 +593,7 @@ xenevt_fioctl(struct file *fp, u_long cm
 	{
 		struct ioctl_evtchn_notify *notify = addr;
 		
-		if (notify->port > NR_EVENT_CHANNELS)
+		if (notify->port >= NR_EVENT_CHANNELS)
 			return EINVAL;
 		mutex_enter(&devevent_lock);
 		if (devevent[notify->port] != d) {



CVS commit: [netbsd-6-0] src/sys/arch/sparc/stand/ofwboot

2015-04-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Apr 16 09:19:50 UTC 2015

Modified Files:
src/sys/arch/sparc/stand/ofwboot [netbsd-6-0]: Locore.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1285):
sys/arch/sparc/stand/ofwboot/Locore.c: revision 1.14
Fix kernel loading failures from partitions started from over first
4GB of disks on sparc64.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.16.1 src/sys/arch/sparc/stand/ofwboot/Locore.c

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

Modified files:

Index: src/sys/arch/sparc/stand/ofwboot/Locore.c
diff -u src/sys/arch/sparc/stand/ofwboot/Locore.c:1.12 src/sys/arch/sparc/stand/ofwboot/Locore.c:1.12.16.1
--- src/sys/arch/sparc/stand/ofwboot/Locore.c:1.12	Sat May 21 15:50:42 2011
+++ src/sys/arch/sparc/stand/ofwboot/Locore.c	Thu Apr 16 09:19:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: Locore.c,v 1.12 2011/05/21 15:50:42 tsutsui Exp $	*/
+/*	$NetBSD: Locore.c,v 1.12.16.1 2015/04/16 09:19:50 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -302,8 +302,8 @@ OF_seek(int handle, u_quad_t pos)
 	args.nargs = 3;
 	args.nreturns = 1;
 	args.handle = HDL2CELL(handle);
-	args.poshi = HDL2CELL(pos >> 32);
-	args.poslo = HDL2CELL(pos);
+	args.poshi = HDQ2CELL_HI(pos);
+	args.poslo = HDQ2CELL_LO(pos);
 	if (openfirmware(&args) == -1) {
 		return -1;
 	}



CVS commit: [netbsd-6-0] src/sys/arch/arm/broadcom

2014-12-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Dec 21 20:21:28 UTC 2014

Modified Files:
src/sys/arch/arm/broadcom [netbsd-6-0]: bcm2835_tmr.c

Log Message:
Pull up following revision(s) (requested by nat in ticket #1214):
sys/arch/arm/broadcom/bcm2835_tmr.c: revision 1.4
Clear status of BCM2835_STIMER_M3 only as timer comparison reg 0 and 2
are used by the VideoCore on Raspberry Pi.  This fixes audio playback.
Addresses PR 48805.
This commit was approved by skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.2.4.1 src/sys/arch/arm/broadcom/bcm2835_tmr.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/arm/broadcom/bcm2835_tmr.c
diff -u src/sys/arch/arm/broadcom/bcm2835_tmr.c:1.1.2.2 src/sys/arch/arm/broadcom/bcm2835_tmr.c:1.1.2.2.4.1
--- src/sys/arch/arm/broadcom/bcm2835_tmr.c:1.1.2.2	Thu Aug  9 06:36:50 2012
+++ src/sys/arch/arm/broadcom/bcm2835_tmr.c	Sun Dec 21 20:21:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2835_tmr.c,v 1.1.2.2 2012/08/09 06:36:50 jdc Exp $	*/
+/*	$NetBSD: bcm2835_tmr.c,v 1.1.2.2.4.1 2014/12/21 20:21:28 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_tmr.c,v 1.1.2.2 2012/08/09 06:36:50 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_tmr.c,v 1.1.2.2.4.1 2014/12/21 20:21:28 msaitoh Exp $");
 
 #include 
 #include 
@@ -204,7 +204,7 @@ clockhandler(void *arg)
 	if (!(status & BCM2835_STIMER_M3))
 		return 0;
 
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_STIMER_CS, status);
+	bus_space_write_4(sc->sc_iot, sc->sc_ioh, BCM2835_STIMER_CS, BCM2835_STIMER_M3);
 
 	hardclock(frame);
 



CVS commit: [netbsd-6-0] src/sys/arch/sparc64/sparc64

2014-11-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Nov  9 06:55:34 UTC 2014

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-6-0]: machdep.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1176):
sys/arch/sparc64/sparc64/machdep.c: revision 1.280
sys/arch/sparc64/sparc64/machdep.c: revision 1.274
Remove duplicate/unused declarations.
Sync cpu_reboot with i386:
- avoid sync and unmount after panic.
- remove vfs_shutdown, we call vfs_sync_all and vfs_unmount* instead.
- resurrect doshutdownhooks since some drivers still use it (eg. sab(4)).


To generate a diff of this commit:
cvs rdiff -u -r1.265.2.1 -r1.265.2.1.4.1 \
src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/machdep.c
diff -u src/sys/arch/sparc64/sparc64/machdep.c:1.265.2.1 src/sys/arch/sparc64/sparc64/machdep.c:1.265.2.1.4.1
--- src/sys/arch/sparc64/sparc64/machdep.c:1.265.2.1	Mon May 21 15:25:56 2012
+++ src/sys/arch/sparc64/sparc64/machdep.c	Sun Nov  9 06:55:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.265.2.1 2012/05/21 15:25:56 riz Exp $ */
+/*	$NetBSD: machdep.c,v 1.265.2.1.4.1 2014/11/09 06:55:34 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.265.2.1 2012/05/21 15:25:56 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.265.2.1.4.1 2014/11/09 06:55:34 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -156,13 +156,10 @@ extern vaddr_t avail_end;
 #ifdef MODULAR
 vaddr_t module_start, module_end;
 static struct vm_map module_map_store;
-extern struct vm_map *module_map;
 #endif
 
 int	physmem;
 
-extern	void *msgbufaddr;
-
 /*
  * Maximum number of DMA segments we'll allow in dmamem_load()
  * routines.  Can be overridden in config files, etc.
@@ -609,12 +606,13 @@ cpu_reboot(int howto, char *user_boot_st
 	 */
 	maybe_dump(howto);
 
-	if ((howto & RB_NOSYNC) == 0 && !syncdone) {
-		extern struct lwp lwp0;
-
+	/*
+	 * If we've panic'd, don't make the situation potentially
+	 * worse by syncing or unmounting the file systems.
+	 */
+	if ((howto & RB_NOSYNC) == 0 && panicstr == NULL) {
 		if (!syncdone) {
-		syncdone = true;
-		vfs_shutdown();
+			syncdone = true;
 			/* XXX used to force unmount as well, here */
 			vfs_sync_all(l);
 			/*
@@ -642,6 +640,7 @@ cpu_reboot(int howto, char *user_boot_st
 	splhigh();
 
 haltsys:
+	doshutdownhooks();
 
 #ifdef MULTIPROCESSOR
 	/* Stop all secondary cpus */



CVS commit: [netbsd-6-0] src/sys/arch

2014-11-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Nov  3 16:47:29 UTC 2014

Modified Files:
src/sys/arch/sparc/dev [netbsd-6-0]: fd.c
src/sys/arch/sparc64/dev [netbsd-6-0]: fdc.c
src/sys/arch/sun3/dev [netbsd-6-0]: fd.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1139):
sys/arch/sun3/dev/fd.c: revision 1.78
sys/arch/sparc/dev/fd.c: revision 1.155
sys/arch/sparc64/dev/fdc.c: revision 1.42
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c:1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c rev 1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
Note sun3 still uses gcc 4.5.4 but also panicked by this old bug,
so probably this problem was triggered by not gcc 4.8 but struct disk
changes (struct disk_geom was added in  rev 1.58),
which increased sizeof(struct fd_softc) from 248 bytes to 296 bytes.
(i.e. now struct fd_softc could be allocated in a different pool block,
 probably near the wrong pointer of the struct disklabel)
Anyway, this fix should be pullued up to netbsd-7.
(probably I'm the only user of floppy on sun3 though)


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.150.14.1 src/sys/arch/sparc/dev/fd.c
cvs rdiff -u -r1.36 -r1.36.14.1 src/sys/arch/sparc64/dev/fdc.c
cvs rdiff -u -r1.72 -r1.72.14.1 src/sys/arch/sun3/dev/fd.c

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

Modified files:

Index: src/sys/arch/sparc/dev/fd.c
diff -u src/sys/arch/sparc/dev/fd.c:1.150 src/sys/arch/sparc/dev/fd.c:1.150.14.1
--- src/sys/arch/sparc/dev/fd.c:1.150	Sun Jul 17 23:18:23 2011
+++ src/sys/arch/sparc/dev/fd.c	Mon Nov  3 16:47:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $	*/
+/*	$NetBSD: fd.c,v 1.150.14.1 2014/11/03 16:47:29 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.150 2011/07/17 23:18:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.150.14.1 2014/11/03 16:47:29 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -2227,7 +2227,7 @@ fdgetdisklabel(dev_t dev)
 	struct cpu_disklabel *clp = fd->sc_dk.dk_cpulabel;
 
 	memset(lp, 0, sizeof(struct disklabel));
-	memset(lp, 0, sizeof(struct cpu_disklabel));
+	memset(clp, 0, sizeof(struct cpu_disklabel));
 
 	lp->d_type = DTYPE_FLOPPY;
 	lp->d_secsize = FD_BSIZE(fd);

Index: src/sys/arch/sparc64/dev/fdc.c
diff -u src/sys/arch/sparc64/dev/fdc.c:1.36 src/sys/arch/sparc64/dev/fdc.c:1.36.14.1
--- src/sys/arch/sparc64/dev/fdc.c:1.36	Mon Aug  8 14:49:06 2011
+++ src/sys/arch/sparc64/dev/fdc.c	Mon Nov  3 16:47:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdc.c,v 1.36 2011/08/08 14:49:06 jakllsch Exp $	*/
+/*	$NetBSD: fdc.c,v 1.36.14.1 2014/11/03 16:47:29 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.36 2011/08/08 14:49:06 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.36.14.1 2014/11/03 16:47:29 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -2413,7 +2413,7 @@ fdgetdisklabel(dev_t dev)
 	struct cpu_disklabel *clp = fd->sc_dk.dk_cpulabel;
 
 	memset(lp, 0, sizeof(struct disklabel));
-	memset(lp, 0, sizeof(struct cpu_disklabel));
+	memset(clp, 0, sizeof(struct cpu_disklabel));
 
 	lp->d_type = DTYPE_FLOPPY;
 	lp->d_secsize = FD_BSIZE(fd);

Index: src/sys/arch/sun3/dev/fd.c
diff -u src/sys/arch/sun3/dev/fd.c:1.72 src/sys/arch/sun3/dev/fd.c:1.72.14.1
--- src/sys/arch/sun3/dev/fd.c:1.72	Sat Jul 16 20:25:28 2011
+++ src/sys/arch/sun3/dev/fd.c	Mon Nov  3 16:47:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.72 2011/07/16 20:25:28 mrg Exp $	*/
+/*	$NetBSD: fd.c,v 1.72.14.1 2014/11/03 16:47:29 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.72 2011/07/16 20:25:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.72.14.1 2014/11/03 16:47:29 msaitoh Exp $");
 
 #include "opt_ddb.h"
 
@@ -1855,7 +1855,7 @@ fdgetdisklabel(dev_t dev)
 	struct cpu_disklabel *clp = fd->sc_dk.dk_cpulabel;
 
 	memse

CVS commit: [netbsd-6-0] src/sys/arch/next68k/next68k

2014-09-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Sep  8 20:44:21 UTC 2014

Modified Files:
src/sys/arch/next68k/next68k [netbsd-6-0]: pmap_bootstrap.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1008):
sys/arch/next68k/next68k/pmap_bootstrap.c: revision 1.43
Move physmem calculations before nptpage initialization.
Should fix next68k specific part of PR port-m68k/45915
(panic: pmap_enter_ptpage: can't get KPT page), and
this is the last possible m68k MD part of this PR.
Note this change is not tested on the actual machine (yet),
but as noted in comment next68k/pmap_bootstrap.c is based on
the mvme68k one which has been fixed by the similar diff.
Should be pulled up to all netbsd-6 branches.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.8.1 src/sys/arch/next68k/next68k/pmap_bootstrap.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/next68k/next68k/pmap_bootstrap.c
diff -u src/sys/arch/next68k/next68k/pmap_bootstrap.c:1.42 src/sys/arch/next68k/next68k/pmap_bootstrap.c:1.42.8.1
--- src/sys/arch/next68k/next68k/pmap_bootstrap.c:1.42	Fri Feb 10 06:28:39 2012
+++ src/sys/arch/next68k/next68k/pmap_bootstrap.c	Mon Sep  8 20:44:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.42 2012/02/10 06:28:39 mhitch Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.42.8.1 2014/09/08 20:44:21 msaitoh Exp $	*/
 
 /*
  * This file was taken from mvme68k/mvme68k/pmap_bootstrap.c
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.42 2012/02/10 06:28:39 mhitch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.42.8.1 2014/09/08 20:44:21 msaitoh Exp $");
 
 #include "opt_m68k_arch.h"
 
@@ -111,6 +111,42 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 #endif
 
 	/*
+	 * Initialize the mem_clusters[] array for the crash dump
+	 * code.  While we're at it, compute the total amount of
+	 * physical memory in the system.
+	 */
+	for (i = 0; i < VM_PHYSSEG_MAX; i++) {
+		if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
+		RELOC(phys_seg_list[i].ps_end, paddr_t)) {
+			/*
+			 * No more memory.
+			 */
+			break;
+		}
+
+		/*
+		 * Make sure these are properly rounded.
+		 */
+		RELOC(phys_seg_list[i].ps_start, paddr_t) =
+		m68k_round_page(RELOC(phys_seg_list[i].ps_start,
+	  paddr_t));
+		RELOC(phys_seg_list[i].ps_end, paddr_t) =
+		m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
+	  paddr_t));
+
+		size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
+		RELOC(phys_seg_list[i].ps_start, paddr_t);
+
+		RELOC(mem_clusters[i].start, u_quad_t) =
+		RELOC(phys_seg_list[i].ps_start, paddr_t);
+		RELOC(mem_clusters[i].size, u_quad_t) = size;
+
+		RELOC(physmem, int) += size >> PGSHIFT;
+
+		RELOC(mem_cluster_cnt, int) += 1;
+	}
+
+	/*
 	 * Calculate important physical addresses:
 	 *
 	 *	lwp0upa		lwp0 u-area		UPAGES pages
@@ -484,42 +520,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 	RELOC(lwp0uarea, vaddr_t) = lwp0upa - firstpa;
 
 	/*
-	 * Initialize the mem_clusters[] array for the crash dump
-	 * code.  While we're at it, compute the total amount of
-	 * physical memory in the system.
-	 */
-	for (i = 0; i < VM_PHYSSEG_MAX; i++) {
-		if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
-		RELOC(phys_seg_list[i].ps_end, paddr_t)) {
-			/*
-			 * No more memory.
-			 */
-			break;
-		}
-
-		/*
-		 * Make sure these are properly rounded.
-		 */
-		RELOC(phys_seg_list[i].ps_start, paddr_t) =
-		m68k_round_page(RELOC(phys_seg_list[i].ps_start,
-	  paddr_t));
-		RELOC(phys_seg_list[i].ps_end, paddr_t) =
-		m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
-	  paddr_t));
-
-		size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
-		RELOC(phys_seg_list[i].ps_start, paddr_t);
-
-		RELOC(mem_clusters[i].start, u_quad_t) =
-		RELOC(phys_seg_list[i].ps_start, paddr_t);
-		RELOC(mem_clusters[i].size, u_quad_t) = size;
-
-		RELOC(physmem, int) += size >> PGSHIFT;
-
-		RELOC(mem_cluster_cnt, int) += 1;
-	}
-
-	/*
 	 * Scoot the start of available on-board RAM forward to
 	 * account for:
 	 *



CVS commit: [netbsd-6-0] src/sys/arch/atari/dev

2014-02-21 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Feb 21 12:27:28 UTC 2014

Modified Files:
src/sys/arch/atari/dev [netbsd-6-0]: ite.c

Log Message:
Pull up the following revisions(s) (requested by tsutsui in ticket #1033):
sys/arch/atari/dev/ite.c:   revision 1.72

Fix kernel crash when a user tries to switch to nonexistent terminal.
Fixes PR/48599.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.14.1 src/sys/arch/atari/dev/ite.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/atari/dev/ite.c
diff -u src/sys/arch/atari/dev/ite.c:1.71 src/sys/arch/atari/dev/ite.c:1.71.14.1
--- src/sys/arch/atari/dev/ite.c:1.71	Sun Jun  5 16:25:12 2011
+++ src/sys/arch/atari/dev/ite.c	Fri Feb 21 12:27:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite.c,v 1.71 2011/06/05 16:25:12 tsutsui Exp $	*/
+/*	$NetBSD: ite.c,v 1.71.14.1 2014/02/21 12:27:28 sborrill Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.71 2011/06/05 16:25:12 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.71.14.1 2014/02/21 12:27:28 sborrill Exp $");
 
 #include "opt_ddb.h"
 
@@ -665,8 +665,8 @@ ite_switch(int unit)
 	struct ite_softc	*sc;
 	extern const struct cdevsw view_cdevsw;
 
-	sc = getitesp(unit);
-	if ((sc->flags & (ITE_ATTACHED | ITE_INITED)) == 0)
+	sc = device_lookup_private(&ite_cd, unit);
+	if (sc == NULL || (sc->flags & (ITE_ATTACHED | ITE_INITED)) == 0)
 		return;
 
 	/*



CVS commit: [netbsd-6-0] src/sys/arch/evbsh3/t_sh7706lan

2014-01-12 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 12 12:38:35 UTC 2014

Modified Files:
src/sys/arch/evbsh3/t_sh7706lan [netbsd-6-0]: ssumci.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #1007):
sys/arch/evbsh3/t_sh7706lan/ssumci.c: revision 1.3
fix CS bit.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.8.1 src/sys/arch/evbsh3/t_sh7706lan/ssumci.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/evbsh3/t_sh7706lan/ssumci.c
diff -u src/sys/arch/evbsh3/t_sh7706lan/ssumci.c:1.2 src/sys/arch/evbsh3/t_sh7706lan/ssumci.c:1.2.8.1
--- src/sys/arch/evbsh3/t_sh7706lan/ssumci.c:1.2	Sat Jan 21 19:44:29 2012
+++ src/sys/arch/evbsh3/t_sh7706lan/ssumci.c	Sun Jan 12 12:38:35 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ssumci.c,v 1.2 2012/01/21 19:44:29 nonaka Exp $	*/
+/*	$NetBSD: ssumci.c,v 1.2.8.1 2014/01/12 12:38:35 bouyer Exp $	*/
 
 /*-
  * Copyright (C) 2010 NONAKA Kimihiro 
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssumci.c,v 1.2 2012/01/21 19:44:29 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssumci.c,v 1.2.8.1 2014/01/12 12:38:35 bouyer Exp $");
 
 #include 
 #include 
@@ -151,7 +151,7 @@ do {	\
 #define SCPDR_CMD	0x04
 #define	SCPCR_CS_MASK	0x000C
 #define	SCPCR_CS_OUT	0x0004
-#define	SCPDR_CS	0x08
+#define	SCPDR_CS	0x02
 #define	SCPCR_EJECT	0x00C0
 #define	SCPDR_EJECT	0x08
 



CVS commit: [netbsd-6-0] src/sys/arch/xen/xen

2013-12-17 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Dec 17 22:39:49 UTC 2013

Modified Files:
src/sys/arch/xen/xen [netbsd-6-0]: evtchn.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #995):
sys/arch/xen/xen/evtchn.c: revision 1.70
Remove the "evtchn_do_event: handler %p didn't lower ipl %d %d\n" printf.
With help from Robert Elz we've finally figured out what's going on, and
it actually isn't a bug in the handler, but related to spin mutexes.
When a spin mutex is released, the IPL isn't lowered back if the
curcpu is holding other spin mutexes. This is because mutexes may not
be released in order (and, in this case, the CPU in interrupted while
it holds a spin mutex at IPL < IPL_SCHED).
Also remove the test and resetting the IPL, it will be reset anyway
inside the loop, or at the end of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.62.8.1 src/sys/arch/xen/xen/evtchn.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/xen/xen/evtchn.c
diff -u src/sys/arch/xen/xen/evtchn.c:1.62 src/sys/arch/xen/xen/evtchn.c:1.62.8.1
--- src/sys/arch/xen/xen/evtchn.c:1.62	Sun Feb 12 14:24:08 2012
+++ src/sys/arch/xen/xen/evtchn.c	Tue Dec 17 22:39:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.62 2012/02/12 14:24:08 jym Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.62.8.1 2013/12/17 22:39:49 riz Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62 2012/02/12 14:24:08 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.62.8.1 2013/12/17 22:39:49 riz Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -347,13 +347,6 @@ splx:
 	ih_fun = (void *)ih->ih_fun;
 	ih_fun(ih->ih_arg, regs);
 	cli();
-	if (ci->ci_ilevel != i) {
-		printf("evtchn_do_event: "
-		"handler %p didn't lower "
-		"ipl %d %d\n",
-		ih_fun, ci->ci_ilevel, i);
-		ci->ci_ilevel = i;
-	}
 }
 hypervisor_enable_ipl(i);
 /* more pending IPLs may have been registered */



CVS commit: [netbsd-6-0] src/sys/arch/sparc64/sparc64

2013-12-14 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Dec 14 19:33:45 UTC 2013

Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-6-0]: locore.s

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #994):
sys/arch/sparc64/sparc64/locore.s: revision 1.350
Increase an interrupt depth only in the case of hardware interrupts,
and remove the ci_idepth trick in softint_fastintr.
Fixes the following diagnostic panic reported in port-sparc64.
  panic: kernel diagnostic assertion "!cpu_intr_p()" failed: file
  "../../../../kern/subr_xcall.c", line 351


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

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2 src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2.4.1
--- src/sys/arch/sparc64/sparc64/locore.s:1.338.8.2	Wed Mar 21 16:10:21 2012
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Dec 14 19:33:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.338.8.2 2012/03/21 16:10:21 riz Exp $	*/
+/*	$NetBSD: locore.s,v 1.338.8.2.4.1 2013/12/14 19:33:45 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3281,12 +3281,6 @@ ENTRY_NOPROFILE(sparc_interrupt)
 	 LDPTR	[%g3 + %lo(CPUINFO_VA+CI_TICK_IH)], %g5
 0:
 
-	! Increment the per-cpu interrupt level
-	sethi	%hi(CPUINFO_VA+CI_IDEPTH), %g1
-	ld	[%g1 + %lo(CPUINFO_VA+CI_IDEPTH)], %g2
-	inc	%g2
-	st	%g2, [%g1 + %lo(CPUINFO_VA+CI_IDEPTH)]
-
 #ifdef TRAPSTATS
 	sethi	%hi(_C_LABEL(kintrcnt)), %g1
 	sethi	%hi(_C_LABEL(uintrcnt)), %g2
@@ -3375,6 +3369,17 @@ ENTRY_NOPROFILE(sparc_interrupt)
 	
 	wrpr	%l6, %pil
 
+#define SOFTINT_INT \
+	(1

CVS commit: [netbsd-6-0] src/sys/arch/xen/xen

2013-11-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Nov  7 20:18:50 UTC 2013

Modified Files:
src/sys/arch/xen/xen [netbsd-6-0]: xbdback_xenbus.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #974):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.58
Add more XENPRINTF() to xbdback_connect()
in xbdback_backend_changed(), fix memory leak.
Do not free an uninitialized pointer in xbdback_connect(). Should fix
 hypervisor or dom0 reboot when using windows PV drivers, as reported
 by several users on port-xen.


To generate a diff of this commit:
cvs rdiff -u -r1.55.2.1 -r1.55.2.1.4.1 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.55.2.1 src/sys/arch/xen/xen/xbdback_xenbus.c:1.55.2.1.4.1
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.55.2.1	Tue Jun  5 15:36:00 2012
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Thu Nov  7 20:18:50 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.55.2.1 2012/06/05 15:36:00 jdc Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.55.2.1.4.1 2013/11/07 20:18:50 snj Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.55.2.1 2012/06/05 15:36:00 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.55.2.1.4.1 2013/11/07 20:18:50 snj Exp $");
 
 #include 
 #include 
@@ -531,6 +531,7 @@ xbdback_connect(struct xbdback_instance 
 	const char *proto;
 	struct xenbus_device *xbusd = xbdi->xbdi_xbusd;
 
+	XENPRINTF(("xbdback %s: connect\n", xbusd->xbusd_path));
 	/* read comunication informations */
 	err = xenbus_read_ul(NULL, xbusd->xbusd_otherend,
 	"ring-ref", &ring_ref, 10);
@@ -539,6 +540,7 @@ xbdback_connect(struct xbdback_instance 
 		xbusd->xbusd_otherend);
 		return -1;
 	}
+	XENPRINTF(("xbdback %s: connect ring-ref %lu\n", xbusd->xbusd_path, ring_ref));
 	err = xenbus_read_ul(NULL, xbusd->xbusd_otherend,
 	"event-channel", &revtchn, 10);
 	if (err) {
@@ -546,12 +548,15 @@ xbdback_connect(struct xbdback_instance 
 		xbusd->xbusd_otherend);
 		return -1;
 	}
+	XENPRINTF(("xbdback %s: connect revtchn %lu\n", xbusd->xbusd_path, revtchn));
 	err = xenbus_read(NULL, xbusd->xbusd_otherend, "protocol",
 	&len, &xsproto);
 	if (err) {
 		xbdi->xbdi_proto = XBDIP_NATIVE;
 		proto = "unspecified";
+		XENPRINTF(("xbdback %s: connect no xsproto\n", xbusd->xbusd_path));
 	} else {
+		XENPRINTF(("xbdback %s: connect xsproto %s\n", xbusd->xbusd_path, xsproto));
 		if (strcmp(xsproto, XEN_IO_PROTO_ABI_NATIVE) == 0) {
 			xbdi->xbdi_proto = XBDIP_NATIVE;
 			proto = XEN_IO_PROTO_ABI_NATIVE;
@@ -567,8 +572,8 @@ xbdback_connect(struct xbdback_instance 
 			free(xsproto, M_DEVBUF);
 			return -1;
 		}
+		free(xsproto, M_DEVBUF);
 	}
-	free(xsproto, M_DEVBUF);
 
 	/* allocate VA space and map rings */
 	xbdi->xbdi_ring_va = uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
@@ -578,6 +583,7 @@ xbdback_connect(struct xbdback_instance 
 		"can't get VA for ring", xbusd->xbusd_otherend);
 		return -1;
 	}
+	XENPRINTF(("xbdback %s: connect va 0x%" PRIxVADDR "\n", xbusd->xbusd_path, xbdi->xbdi_ring_va));
 
 	grop.host_addr = xbdi->xbdi_ring_va;
 	grop.flags = GNTMAP_host_map;
@@ -593,6 +599,7 @@ xbdback_connect(struct xbdback_instance 
 		goto err;
 	}
 	xbdi->xbdi_ring_handle = grop.handle;
+	XENPRINTF(("xbdback %s: connect grhandle %d\n", xbusd->xbusd_path, grop.handle));
 
 	switch(xbdi->xbdi_proto) {
 	case XBDIP_NATIVE:
@@ -627,6 +634,7 @@ xbdback_connect(struct xbdback_instance 
 		"can't bind event channel", xbusd->xbusd_otherend);
 		goto err2;
 	}
+	XENPRINTF(("xbdback %s: connect evchannel %d\n", xbusd->xbusd_path, xbdi->xbdi_evtchn));
 	xbdi->xbdi_evtchn = evop.u.bind_interdomain.local_port;
 
 	event_set_handler(xbdi->xbdi_evtchn, xbdback_evthandler,
@@ -766,6 +774,7 @@ xbdback_backend_changed(struct xenbus_wa
 		xbdi->xbdi_ro = false;
 	else
 		xbdi->xbdi_ro = true;
+	free(mode, M_DEVBUF);
 	major = major(xbdi->xbdi_dev);
 	devname = devsw_blk2name(major);
 	if (devname == NULL) {



CVS commit: [netbsd-6-0] src/sys/arch/x86/pci

2013-10-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Oct 20 13:18:48 UTC 2013

Modified Files:
src/sys/arch/x86/pci [netbsd-6-0]: pci_machdep.c

Log Message:
Apply patchm requested by gson in ticket #963:
sys/arch/x86/pci/pci_machdep.c  1.61 via patch

Force PCI mode 1 when running under QEMU, to work around
QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug.  Fixes PR kern/45671.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.54.6.1 src/sys/arch/x86/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/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.54 src/sys/arch/x86/pci/pci_machdep.c:1.54.6.1
--- src/sys/arch/x86/pci/pci_machdep.c:1.54	Wed Feb 15 16:30:29 2012
+++ src/sys/arch/x86/pci/pci_machdep.c	Sun Oct 20 13:18:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.54 2012/02/15 16:30:29 tsutsui Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.54.6.1 2013/10/20 13:18:48 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.54 2012/02/15 16:30:29 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.54.6.1 2013/10/20 13:18:48 bouyer Exp $");
 
 #include 
 #include 
@@ -522,6 +522,7 @@ pci_mode_detect(void)
 	uint32_t sav, val;
 	int i;
 	pcireg_t idreg;
+	extern char cpu_brand_string[];
 
 	if (pci_mode != -1)
 		return pci_mode;
@@ -551,6 +552,13 @@ pci_mode_detect(void)
 			return (pci_mode);
 		}
 	}
+if (memcmp(cpu_brand_string, "QEMU", 4) == 0) {
+		/* PR 45671, https://bugs.launchpad.net/qemu/+bug/897771 */
+#ifdef DEBUG
+		printf("forcing PCI mode 1 for QEMU\n");
+#endif
+		return (pci_mode);
+	}
 
 	/*
 	 * Strong check for standard compliant mode 1:



CVS commit: [netbsd-6-0] src/sys/arch/mvme68k

2013-09-26 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Sep 26 15:58:31 UTC 2013

Modified Files:
src/sys/arch/mvme68k/include [netbsd-6-0]: prom.h
src/sys/arch/mvme68k/stand [netbsd-6-0]: Makefile.booters
src/sys/arch/mvme68k/stand/libbug [netbsd-6-0]: outln.c outstr.c
src/sys/arch/mvme68k/stand/libsa [netbsd-6-0]: Makefile Makefile.inc

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #954):
sys/arch/mvme68k/stand/libbug/outln.c: revision 1.4
sys/arch/mvme68k/stand/libsa/Makefile.inc: revision 1.6
sys/arch/mvme68k/stand/Makefile.booters: revision 1.24
sys/arch/mvme68k/include/prom.h: revision 1.18
sys/arch/mvme68k/stand/libsa/Makefile: revision 1.34
sys/arch/mvme68k/stand/libbug/outstr.c: revision 1.4
Explicitly link SRT0.o (Standalone RunTime startup code) first.
This is my fault on changes to make mvme68k bootloaders use MI libsa:
http://mail-index.netbsd.org/source-changes/2011/01/02/msg016539.html
MVME PROM requires raw binaries (by objcopy -O binary) so we have to
make sure the entry point is located at the first address of the binaries.
The problem (6.1 netboot fails with an illegal instruction message)
is reported by Andrew Gillham on port-mvme68k@:
http://mail-index.netbsd.org/port-mvme68k/2013/09/17/msg82.html
Note mvme68k bootloadres in netbsd-6 still have another bug triggered
by gcc-4.5.
Should be pulled up to netbsd-6 branches.
Make MVMEPROM_ARG2() macro take two args in a single asm statement.
Fixes a problem that a wrong address is passed to the MVMEPROM outstr
function (then caused garbages on screen) after we switched to gcc-4.5.
Reported and confirmed by Andrew Gillham on port-mvme68k@:
http://mail-index.NetBSD.org/port-mvme68k/2013/09/17/msg84.html
http://mail-index.NetBSD.org/port-mvme68k/2013/09/19/msg85.html
http://mail-index.NetBSD.org/port-mvme68k/2013/09/22/msg95.html
http://mail-index.NetBSD.org/port-mvme68k/2013/09/22/msg97.html
No error on "build.sh -m mvme68k build" builds.
Should be pulled up to netbsd-6 branches.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.124.1 src/sys/arch/mvme68k/include/prom.h
cvs rdiff -u -r1.22 -r1.22.16.1 src/sys/arch/mvme68k/stand/Makefile.booters
cvs rdiff -u -r1.3 -r1.3.56.1 src/sys/arch/mvme68k/stand/libbug/outln.c \
src/sys/arch/mvme68k/stand/libbug/outstr.c
cvs rdiff -u -r1.33 -r1.33.20.1 src/sys/arch/mvme68k/stand/libsa/Makefile
cvs rdiff -u -r1.5 -r1.5.20.1 src/sys/arch/mvme68k/stand/libsa/Makefile.inc

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/mvme68k/include/prom.h
diff -u src/sys/arch/mvme68k/include/prom.h:1.17 src/sys/arch/mvme68k/include/prom.h:1.17.124.1
--- src/sys/arch/mvme68k/include/prom.h:1.17	Sat Dec 24 23:24:01 2005
+++ src/sys/arch/mvme68k/include/prom.h	Thu Sep 26 15:58:31 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: prom.h,v 1.17 2005/12/24 23:24:01 perry Exp $	*/
+/*	$NetBSD: prom.h,v 1.17.124.1 2013/09/26 15:58:31 riz Exp $	*/
 
 /*
  * Copyright (c) 1995 Theo de Raadt
@@ -155,8 +155,10 @@ struct mvmeprom_args {
 	__asm volatile ("clrl %sp@-")
 #define MVMEPROM_ARG1(arg) \
 	__asm volatile ("movel %0, %%sp@-"::"d" (arg))
-#define MVMEPROM_ARG2(arg) \
-	__asm volatile ("movel %0, %%sp@-"::"d" (arg))
+#define MVMEPROM_ARG2(arg0, arg1)\
+	__asm volatile ("movel %0, %%sp@-;"			\
+			"movel %1, %%sp@-;"			\
+			:: "d" (arg0), "d" (arg1):)
 #define MVMEPROM_GETRES(ret) \
 	__asm volatile ("movel %%sp@+,%0": "=d" (ret):)
 #define MVMEPROM_GETSR(ret) \

Index: src/sys/arch/mvme68k/stand/Makefile.booters
diff -u src/sys/arch/mvme68k/stand/Makefile.booters:1.22 src/sys/arch/mvme68k/stand/Makefile.booters:1.22.16.1
--- src/sys/arch/mvme68k/stand/Makefile.booters:1.22	Sat Jan 22 19:19:20 2011
+++ src/sys/arch/mvme68k/stand/Makefile.booters	Thu Sep 26 15:58:31 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.22 2011/01/22 19:19:20 joerg Exp $
+#	$NetBSD: Makefile.booters,v 1.22.16.1 2013/09/26 15:58:31 riz Exp $
 
 S?=		${.CURDIR}/../../../..
 MDEC_DIR?=	/usr/mdec
@@ -59,6 +59,8 @@ LIBSA_DIR!=	cd ${LIB_SA_DIR} && ${PRINTO
 LIBSA=		${LIBSA_DIR}/lib/sa/libsa.a
 LIBKERN=	${LIBSA_DIR}/lib/kern/libkern.a
 
+SRTOBJ?= ${LIBSA_DIR}/SRT0.o
+
 LIB_BUG_DIR=	${.CURDIR}/../libbug
 LIBBUG_DIR!=	cd ${LIB_BUG_DIR} && ${PRINTOBJDIR}
 LIBBUG=${LIBBUG_DIR}/libbug.a

Index: src/sys/arch/mvme68k/stand/libbug/outln.c
diff -u src/sys/arch/mvme68k/stand/libbug/outln.c:1.3 src/sys/arch/mvme68k/stand/libbug/outln.c:1.3.56.1
--- src/sys/arch/mvme68k/stand/libbug/outln.c:1.3	Sat Jan 12 09:54:31 2008
+++ src/sys/arch/mvme68k/stand/libbug/outln.c	Thu Sep 26 15:58:31 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: outln.c,v 1.3 2008/01/12 09:54:31 tsutsui Exp $	*/
+/*	$NetBSD: outln.c,v 1.3.56.1 2013/09/26 15:58:31 riz Exp $	*/
 
 /*
  * bug routines -- assumes that the necessary sections of memory
@@ -13,7 +13,6 @@ void
 mvme

CVS commit: [netbsd-6-0] src/sys/arch/mvmeppc/stand

2013-09-23 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Sep 23 14:27:23 UTC 2013

Modified Files:
src/sys/arch/mvmeppc/stand [netbsd-6-0]: Makefile.booters
src/sys/arch/mvmeppc/stand/libsa [netbsd-6-0]: Makefile Makefile.inc

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #955):
sys/arch/mvmeppc/stand/libsa/Makefile.inc: revision 1.2
sys/arch/mvmeppc/stand/Makefile.booters: revision 1.13
sys/arch/mvmeppc/stand/libsa/Makefile: revision 1.11
Explicitly link srt0.o (Standalone RunTime startup code) first.
Taken from the similar fix of mvme68k:
http://mail-index.netbsd.org/source-changes/2013/09/21/msg047819.html
MVME PROM requires raw binaries (by objcopy -O binary) so we have to
make sure the entry point is located at the first address of the binaries.
The original changes to switch to using MI libsa is:
http://mail-index.netbsd.org/source-changes/2011/01/02/msg016563.html
Should be pulled up to netbsd-6 branches.
(though untested since there seems no users of mvmeppc)


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.16.1 src/sys/arch/mvmeppc/stand/Makefile.booters
cvs rdiff -u -r1.10 -r1.10.20.1 src/sys/arch/mvmeppc/stand/libsa/Makefile
cvs rdiff -u -r1.1 -r1.1.22.1 src/sys/arch/mvmeppc/stand/libsa/Makefile.inc

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/mvmeppc/stand/Makefile.booters
diff -u src/sys/arch/mvmeppc/stand/Makefile.booters:1.12 src/sys/arch/mvmeppc/stand/Makefile.booters:1.12.16.1
--- src/sys/arch/mvmeppc/stand/Makefile.booters:1.12	Sat Jan 22 19:19:20 2011
+++ src/sys/arch/mvmeppc/stand/Makefile.booters	Mon Sep 23 14:27:23 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.12 2011/01/22 19:19:20 joerg Exp $
+#	$NetBSD: Makefile.booters,v 1.12.16.1 2013/09/23 14:27:23 riz Exp $
 
 S?=		${.CURDIR}/../../../..
 MDEC_DIR?=	/usr/mdec
@@ -56,6 +56,8 @@ LIBSA_DIR!=	cd ${LIB_SA_DIR} && ${PRINTO
 LIBSA=		${LIBSA_DIR}/lib/sa/libsa.a
 LIBKERN=	${LIBSA_DIR}/lib/kern/libkern.a
 
+SRTOBJ?= ${LIBSA_DIR}/srt0.o
+
 #WRTVID_BOOT_DIR=  ${.CURDIR}/../wrtvid
 #WRTVID_DIR!=	cd ${WRTVID_BOOT_DIR} && ${PRINTOBJDIR}
 #WRTVID=${WRTVID_DIR}/wrtvid

Index: src/sys/arch/mvmeppc/stand/libsa/Makefile
diff -u src/sys/arch/mvmeppc/stand/libsa/Makefile:1.10 src/sys/arch/mvmeppc/stand/libsa/Makefile:1.10.20.1
--- src/sys/arch/mvmeppc/stand/libsa/Makefile:1.10	Sun Jan  2 09:40:52 2011
+++ src/sys/arch/mvmeppc/stand/libsa/Makefile	Mon Sep 23 14:27:23 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.10 2011/01/02 09:40:52 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.10.20.1 2013/09/23 14:27:23 riz Exp $
 
 S!= cd ${.CURDIR}/../../../..; pwd
 
@@ -32,7 +32,9 @@ LIBKERN= ${KERNLIB}
 
 LIBS= ${LIBSA} ${LIBKERN}
 
-all realall: ${LIBS}
+CLEANFILES+=	srt0.o
+
+all realall: ${LIBS} srt0.o
 
 cleandir distclean: .WAIT cleanlibdir
  

Index: src/sys/arch/mvmeppc/stand/libsa/Makefile.inc
diff -u src/sys/arch/mvmeppc/stand/libsa/Makefile.inc:1.1 src/sys/arch/mvmeppc/stand/libsa/Makefile.inc:1.1.22.1
--- src/sys/arch/mvmeppc/stand/libsa/Makefile.inc:1.1	Sun Jan  2 09:40:52 2011
+++ src/sys/arch/mvmeppc/stand/libsa/Makefile.inc	Mon Sep 23 14:27:23 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.1 2011/01/02 09:40:52 tsutsui Exp $
+#	$NetBSD: Makefile.inc,v 1.1.22.1 2013/09/23 14:27:23 riz Exp $
 
 S!= cd ${SA_EXTRADIR}/../../../..; pwd
 
@@ -7,7 +7,7 @@ S!= cd ${SA_EXTRADIR}/../../../..; pwd
 
 SRC_sa= dev_net.c
 
-SRC_here= srt0.S bugsyscalls.S exec_mvme.c parse_args.c getchar.c putchar.c
+SRC_here= bugsyscalls.S exec_mvme.c parse_args.c getchar.c putchar.c
 SRC_here+= if_bug.c clock.c
 
 SRCS+= ${SRC_sa} ${SRC_here}



CVS commit: [netbsd-6-0] src/sys/arch/mvme68k/mvme68k

2013-09-22 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Sep 22 17:34:48 UTC 2013

Modified Files:
src/sys/arch/mvme68k/mvme68k [netbsd-6-0]: pmap_bootstrap.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #953):
sys/arch/mvme68k/mvme68k/pmap_bootstrap.c: revision 1.52
Move physmem calculations before nptpage initialization.
Fixes mvme68k specific part of PR port-m68k/45915
(panic: pmap_enter_ptpage: can't get KPT page).
Reported and confirmed by Andrew Gillham on his MVME177:
http://mail-index.NetBSD.org/port-mvme68k/2013/09/17/msg82.html
Should be pulled up to all netbsd-6 branches.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.51.8.1 src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.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/mvme68k/mvme68k/pmap_bootstrap.c
diff -u src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c:1.51 src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c:1.51.8.1
--- src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c:1.51	Fri Feb 10 06:28:39 2012
+++ src/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c	Sun Sep 22 17:34:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_bootstrap.c,v 1.51 2012/02/10 06:28:39 mhitch Exp $	*/
+/*	$NetBSD: pmap_bootstrap.c,v 1.51.8.1 2013/09/22 17:34:48 riz Exp $	*/
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.51 2012/02/10 06:28:39 mhitch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.51.8.1 2013/09/22 17:34:48 riz Exp $");
 
 #include "opt_m68k_arch.h"
 
@@ -100,6 +100,42 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 #endif
 
 	/*
+	 * Initialize the mem_clusters[] array for the crash dump
+	 * code.  While we're at it, compute the total amount of
+	 * physical memory in the system.
+	 */
+	for (i = 0; i < VM_PHYSSEG_MAX; i++) {
+		if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
+		RELOC(phys_seg_list[i].ps_end, paddr_t)) {
+			/*
+			 * No more memory.
+			 */
+			break;
+		}
+
+		/*
+		 * Make sure these are properly rounded.
+		 */
+		RELOC(phys_seg_list[i].ps_start, paddr_t) =
+		m68k_round_page(RELOC(phys_seg_list[i].ps_start,
+	  paddr_t));
+		RELOC(phys_seg_list[i].ps_end, paddr_t) =
+		m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
+	  paddr_t));
+
+		size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
+		RELOC(phys_seg_list[i].ps_start, paddr_t);
+
+		RELOC(mem_clusters[i].start, u_quad_t) =
+		RELOC(phys_seg_list[i].ps_start, paddr_t);
+		RELOC(mem_clusters[i].size, u_quad_t) = size;
+
+		RELOC(physmem, int) += size >> PGSHIFT;
+
+		RELOC(mem_cluster_cnt, int) += 1;
+	}
+
+	/*
 	 * Calculate important physical addresses:
 	 *
 	 *	lwp0upa		lwp0 u-area		UPAGES pages
@@ -409,42 +445,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
 	RELOC(lwp0uarea, vaddr_t) = lwp0upa - firstpa;
 
 	/*
-	 * Initialize the mem_clusters[] array for the crash dump
-	 * code.  While we're at it, compute the total amount of
-	 * physical memory in the system.
-	 */
-	for (i = 0; i < VM_PHYSSEG_MAX; i++) {
-		if (RELOC(phys_seg_list[i].ps_start, paddr_t) ==
-		RELOC(phys_seg_list[i].ps_end, paddr_t)) {
-			/*
-			 * No more memory.
-			 */
-			break;
-		}
-
-		/*
-		 * Make sure these are properly rounded.
-		 */
-		RELOC(phys_seg_list[i].ps_start, paddr_t) =
-		m68k_round_page(RELOC(phys_seg_list[i].ps_start,
-	  paddr_t));
-		RELOC(phys_seg_list[i].ps_end, paddr_t) =
-		m68k_trunc_page(RELOC(phys_seg_list[i].ps_end,
-	  paddr_t));
-
-		size = RELOC(phys_seg_list[i].ps_end, paddr_t) -
-		RELOC(phys_seg_list[i].ps_start, paddr_t);
-
-		RELOC(mem_clusters[i].start, u_quad_t) =
-		RELOC(phys_seg_list[i].ps_start, paddr_t);
-		RELOC(mem_clusters[i].size, u_quad_t) = size;
-
-		RELOC(physmem, int) += size >> PGSHIFT;
-
-		RELOC(mem_cluster_cnt, int) += 1;
-	}
-
-	/*
 	 * Scoot the start of available on-board RAM forward to
 	 * account for:
 	 *



CVS commit: [netbsd-6-0] src/sys/arch/amiga/dev

2013-06-05 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Jun  6 02:58:12 UTC 2013

Modified Files:
src/sys/arch/amiga/dev [netbsd-6-0]: if_ne_zbus.c

Log Message:
Pull up following revision(s) (requested by rkujawa in ticket #892):
sys/arch/amiga/dev/if_ne_zbus.c: revision 1.15
Workaround for the fake X-Surf autoconfig entry, created by the Deneb =
firmware v11.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.12.1 src/sys/arch/amiga/dev/if_ne_zbus.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/amiga/dev/if_ne_zbus.c
diff -u src/sys/arch/amiga/dev/if_ne_zbus.c:1.14 src/sys/arch/amiga/dev/if_ne_zbus.c:1.14.12.1
--- src/sys/arch/amiga/dev/if_ne_zbus.c:1.14	Tue Jul 19 15:55:27 2011
+++ src/sys/arch/amiga/dev/if_ne_zbus.c	Thu Jun  6 02:58:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ne_zbus.c,v 1.14 2011/07/19 15:55:27 dyoung Exp $ */
+/*	$NetBSD: if_ne_zbus.c,v 1.14.12.1 2013/06/06 02:58:12 riz Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ne_zbus.c,v 1.14 2011/07/19 15:55:27 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ne_zbus.c,v 1.14.12.1 2013/06/06 02:58:12 riz Exp $");
 
 /*
  * Thanks to Village Tronic for giving me a card.
@@ -86,6 +86,13 @@ CFATTACH_DECL_NEW(ne_zbus, sizeof(struct
 #define	NE_ARIADNE_II_ASICBASE	0x0310	/* 0x0620 */
 #define	NE_ARIADNE_II_ASICSIZE	0x10
 
+/*
+ * E3B Deneb firmware v11 creates fake X-Surf autoconfig entry.
+ * Do not attach ne driver to this fake card, otherwise kernel panic
+ * may occur.
+ */
+#define DENEB_XSURF_SERNO	0xC0FFEE01	/* Serial of the fake card */
+
 int
 ne_zbus_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -96,8 +103,10 @@ ne_zbus_match(device_t parent, cfdata_t 
 		return (1);
 
 	/* X-surf ethernet card */
-	if (zap->manid == 4626 && zap->prodid == 23)
-		return (1);
+	if (zap->manid == 4626 && zap->prodid == 23) {
+		if (zap->serno != DENEB_XSURF_SERNO)
+			return (1);
+	}
 
 	return (0);
 }



CVS commit: [netbsd-6-0] src/sys/arch/x68k/dev

2013-04-28 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Apr 29 03:29:08 UTC 2013

Modified Files:
src/sys/arch/x68k/dev [netbsd-6-0]: ite_tv.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #881):
sys/arch/x68k/dev/ite_tv.c: revision 1.16
Fix a kernel panic by printf(1).
The 2nd byte of ISO-2022-JP must be 0x21-0x7e.  Especially,
the character code less than 0x2121 causes SEGV, because a
font address points outside of the CGROM.
Reported by tsutsui@.  Should be pulled up to netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.88.1 src/sys/arch/x68k/dev/ite_tv.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/x68k/dev/ite_tv.c
diff -u src/sys/arch/x68k/dev/ite_tv.c:1.15 src/sys/arch/x68k/dev/ite_tv.c:1.15.88.1
--- src/sys/arch/x68k/dev/ite_tv.c:1.15	Sun Mar 11 06:01:05 2007
+++ src/sys/arch/x68k/dev/ite_tv.c	Mon Apr 29 03:29:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite_tv.c,v 1.15 2007/03/11 06:01:05 isaki Exp $	*/
+/*	$NetBSD: ite_tv.c,v 1.15.88.1 2013/04/29 03:29:08 riz Exp $	*/
 
 /*
  * Copyright (c) 1997 Masaru Oki.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ite_tv.c,v 1.15 2007/03/11 06:01:05 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ite_tv.c,v 1.15.88.1 2013/04/29 03:29:08 riz Exp $");
 
 #include 
 #include 
@@ -283,10 +283,10 @@ tv_putc_nm(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
 			*(u_short *)p = *kf++;
@@ -312,10 +312,10 @@ tv_putc_in(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES)
 			*(u_short *)p = ~*kf++;
@@ -341,10 +341,10 @@ tv_putc_bd(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -388,10 +388,10 @@ tv_putc_ul(struct ite_softc *ip, int ch,
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
 			*(u_short *)p = *kf++;
@@ -425,10 +425,10 @@ tv_putc_bd_in(struct ite_softc *ip, int 
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < FONTHEIGHT; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -458,10 +458,10 @@ tv_putc_ul_in(struct ite_softc *ip, int 
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES)
 			*(u_short *)p = ~*kf++;
@@ -495,10 +495,10 @@ tv_putc_bd_ul(struct ite_softc *ip, int 
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -542,10 +542,10 @@ tv_putc_bd_ul_in(struct ite_softc *ip, i
 
 	hi = ip->save_char & 0x7f;
 
-	if (hi >= 0x21 && hi <= 0x7e) {
+	if (hi >= 0x21 && hi <= 0x7e && ch >= 0x21 && ch <= 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch & 0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh < UNDERLINE; fh++, p += ROWBYTES) {
 			ch = *kf++;



CVS commit: [netbsd-6-0] src/sys/arch/amd64/amd64

2013-04-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Apr 20 10:00:58 UTC 2013

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-6-0]: machdep.c

Log Message:
Pull up following revision(s) (requested by taca in ticket #866):
sys/arch/amd64/amd64/machdep.c: revision 1.193
Use printf_nolog() as i386 when print remaing bytes at crash dump to
prevent message buffer with cound down.


To generate a diff of this commit:
cvs rdiff -u -r1.175.2.7 -r1.175.2.7.2.1 src/sys/arch/amd64/amd64/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/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.175.2.7 src/sys/arch/amd64/amd64/machdep.c:1.175.2.7.2.1
--- src/sys/arch/amd64/amd64/machdep.c:1.175.2.7	Mon Sep  3 19:22:45 2012
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Apr 20 10:00:58 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.175.2.7 2012/09/03 19:22:45 riz Exp $	*/
+/*	$NetBSD: machdep.c,v 1.175.2.7.2.1 2013/04/20 10:00:58 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.7 2012/09/03 19:22:45 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.175.2.7.2.1 2013/04/20 10:00:58 bouyer Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1230,7 +1230,7 @@ dumpsys_seg(paddr_t maddr, paddr_t bytes
 	for (i = 0; i < bytes; i += n, dump_totalbytesleft -= n) {
 		/* Print out how many MBs we have left to go. */
 		if ((dump_totalbytesleft % (1024*1024)) == 0)
-			printf("%lu ", (unsigned long)
+			printf_nolog("%lu ", (unsigned long)
 			(dump_totalbytesleft / (1024 * 1024)));
 
 		/* Limit size for next transfer. */



CVS commit: [netbsd-6-0] src/sys/arch/i386/i386

2012-12-16 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Dec 16 19:12:53 UTC 2012

Modified Files:
src/sys/arch/i386/i386 [netbsd-6-0]: multiboot.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #749):
sys/arch/i386/i386/multiboot.c: revision 1.22
Fix off by one.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.21.20.1 src/sys/arch/i386/i386/multiboot.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/i386/i386/multiboot.c
diff -u src/sys/arch/i386/i386/multiboot.c:1.21 src/sys/arch/i386/i386/multiboot.c:1.21.20.1
--- src/sys/arch/i386/i386/multiboot.c:1.21	Tue Jan 11 12:24:37 2011
+++ src/sys/arch/i386/i386/multiboot.c	Sun Dec 16 19:12:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot.c,v 1.21 2011/01/11 12:24:37 gsutre Exp $	*/
+/*	$NetBSD: multiboot.c,v 1.21.20.1 2012/12/16 19:12:53 riz Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.21 2011/01/11 12:24:37 gsutre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.21.20.1 2012/12/16 19:12:53 riz Exp $");
 
 #include "opt_multiboot.h"
 
@@ -506,7 +506,7 @@ setup_bootpath(struct multiboot_info *mi
 		*cl2 = '\0';
 		memcpy(bi.bootpath, cl, MIN(sizeof(bi.bootpath), len));
 		*cl2 = old;
-		bi.bootpath[MIN(sizeof(bi.bootpath), len)] = '\0';
+		bi.bootpath[MIN(sizeof(bi.bootpath) - 1, len)] = '\0';
 
 		bootinfo_add((struct btinfo_common *)&bi, BTINFO_BOOTPATH,
 		sizeof(struct btinfo_bootpath));



CVS commit: [netbsd-6-0] src/sys/arch/x86/acpi

2012-12-13 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Dec 13 23:42:16 UTC 2012

Modified Files:
src/sys/arch/x86/acpi [netbsd-6-0]: acpi_cpu_md.c

Log Message:
Pull up following revision(s) (requested by jruoho in ticket #741):
sys/arch/x86/acpi/acpi_cpu_md.c: revision 1.72
Disable C1E also on K8, if present. From Imre Vadasz 
in PR install/47224.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.8.1 src/sys/arch/x86/acpi/acpi_cpu_md.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/x86/acpi/acpi_cpu_md.c
diff -u src/sys/arch/x86/acpi/acpi_cpu_md.c:1.71 src/sys/arch/x86/acpi/acpi_cpu_md.c:1.71.8.1
--- src/sys/arch/x86/acpi/acpi_cpu_md.c:1.71	Sat Feb 11 22:09:47 2012
+++ src/sys/arch/x86/acpi/acpi_cpu_md.c	Thu Dec 13 23:42:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_md.c,v 1.71 2012/02/11 22:09:47 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_md.c,v 1.71.8.1 2012/12/13 23:42:16 riz Exp $ */
 
 /*-
  * Copyright (c) 2010, 2011 Jukka Ruohonen 
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.71 2012/02/11 22:09:47 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_md.c,v 1.71.8.1 2012/12/13 23:42:16 riz Exp $");
 
 #include 
 #include 
@@ -253,6 +253,12 @@ acpicpu_md_flags(void)
 		case 0x0f:
 
 			/*
+			 * Disable C1E if present.
+			 */
+			if (rdmsr_safe(MSR_CMPHALT, &msr) != EFAULT)
+val |= ACPICPU_FLAG_C_C1E;
+
+			/*
 			 * Evaluate support for the "FID/VID
 			 * algorithm" also used by powernow(4).
 			 */
@@ -268,6 +274,9 @@ acpicpu_md_flags(void)
 		case 0x10:
 		case 0x11:
 
+			/*
+			 * Disable C1E if present.
+			 */
 			if (rdmsr_safe(MSR_CMPHALT, &msr) != EFAULT)
 val |= ACPICPU_FLAG_C_C1E;
 



CVS commit: [netbsd-6-0] src/sys/arch/xen/xenbus

2012-11-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 30 06:30:39 UTC 2012

Modified Files:
src/sys/arch/xen/xenbus [netbsd-6-0]: xenbus_xs.c

Log Message:
Pull up following revision(s) (requested by royger in ticket #728):
sys/arch/xen/xenbus/xenbus_xs.c: revision 1.23
xen: prevent adding duplicate xenwatches
When a xenstore watch triggers, the event is processed on process_msg
and if a valid handle it's found the handler is queued for execution
on the pending xen watches queue (watch_events).
This may present a problem if we trigger a xenwatch several times and
then disconnect the device. If several xenwatch events are added to
the watch_events queue and the device is disconnected afterwards, the
first processed xenwatch event will disconnect the device, remove the
watch and free all resources. This triggers a panic if there are
pending xenwatch events for that device already queued in the local
queue of the function xenwatch_thread, since when the next watch that
has the same handler tries to execute we get a panic due to the fact
that the device is already disconnected and all resources had been
freed:
xenbus_watch: 0xab7cd1d0
xbw_callback: 0x80755dd4
otherend_changed: backend/vif/1/0
backend/vif/1/0/state 6
backend/vif/1/0 -> Closed
backend/vif/1/0 -> backend_device, b_detach: 0x8075a2bf
xenbus_watch: 0xab7cd1d0
xbw_callback: 0xfc5ec02183e547a8
fatal protection fault in supervisor mode
trap type 4 code 0 rip 80756596 cs e030 rflags 10246 cr2
7f7ff7b4c020 ilevel 0 rsp a000e6d82c50
curlwp 0xaa72d580 pid 0 lid 36 lowest kstack
0xa000e6d7f000
kernel: protection fault trap, code=0
Stopped in pid 0.36 (system) at netbsd:xenwatch_thread+0xc7:call
*10(%rax
)
xenwatch_thread() at netbsd:xenwatch_thread+0xc7
ds  f
es  5987
fs  2c40
gs  1460
rdi ab7cd1d0
rsi aa5477f0
rbp a000e6d82c70
rbx ab7c14c0
rdx 2
rcx f
rax ab7cd1d0
r8  78
r9  ffef
r10 deadbeef
r11 1
r12 a000e6d82c50
r13 aa72d580
r14 aa72d580
r15 0
rip 80756596xenwatch_thread+0xc7
cs  e030
rflags  10246
rsp a000e6d82c50
ss  e02b
netbsd:xenwatch_thread+0xc7:call*10(%rax)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.22.14.1 src/sys/arch/xen/xenbus/xenbus_xs.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/xen/xenbus/xenbus_xs.c
diff -u src/sys/arch/xen/xenbus/xenbus_xs.c:1.22 src/sys/arch/xen/xenbus/xenbus_xs.c:1.22.14.1
--- src/sys/arch/xen/xenbus/xenbus_xs.c:1.22	Wed Jul 27 23:11:23 2011
+++ src/sys/arch/xen/xenbus/xenbus_xs.c	Fri Nov 30 06:30:38 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_xs.c,v 1.22 2011/07/27 23:11:23 matt Exp $ */
+/* $NetBSD: xenbus_xs.c,v 1.22.14.1 2012/11/30 06:30:38 msaitoh Exp $ */
 /**
  * xenbus_xs.c
  *
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.22 2011/07/27 23:11:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenbus_xs.c,v 1.22.14.1 2012/11/30 06:30:38 msaitoh Exp $");
 
 #if 0
 #define DPRINTK(fmt, args...) \
@@ -751,7 +751,7 @@ xenwatch_thread(void *unused)
 static int
 process_msg(void)
 {
-	struct xs_stored_msg *msg;
+	struct xs_stored_msg *msg, *s_msg;
 	char *body;
 	int err;
 
@@ -782,7 +782,7 @@ process_msg(void)
 	body[msg->hdr.len] = '\0';
 
 	if (msg->hdr.type == XS_WATCH_EVENT) {
-		bool found;
+		bool found, repeated;
 
 		DPRINTK("process_msg: XS_WATCH_EVENT");
 		msg->u.watch.vec = split(body, msg->hdr.len,
@@ -796,14 +796,24 @@ process_msg(void)
 		msg->u.watch.handle = find_watch(
 		msg->u.watch.vec[XS_WATCH_TOKEN]);
 		found = (msg->u.watch.handle != NULL);
+		repeated = false;
 		if (found) {
 			mutex_enter(&watch_events_lock);
-			SIMPLEQ_INSERT_TAIL(&watch_events, msg, msg_next);
-			cv_broadcast(&watch_cv);
+			/* Don't add duplicate events to the queue of pending watches */
+			SIMPLEQ_FOREACH(s_msg, &watch_events, msg_next) {
+if (s_msg->u.watch.handle == msg->u.watch.handle) {
+	repeated = true;
+	break;
+}
+			}
+			if (!repeated) {
+SIMPLEQ_INSERT_TAIL(&watch_events, msg, msg_next);
+cv_broadcast(&watch_cv);
+			}
 			mutex_exit(&watch_events_lock);
 		}
 		mutex_exit(&watches_lock);
-		if (!found) {
+		if (!found || repeated) {
 			free(msg->u.watch.vec, M_DEVBUF);
 			free(msg, M_DEVBUF);
 		}



CVS commit: [netbsd-6-0] src/sys/arch/xen/xen

2012-10-31 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Oct 31 16:15:28 UTC 2012

Modified Files:
src/sys/arch/xen/xen [netbsd-6-0]: xengnt.c

Log Message:
Pull up following revision(s) (requested by royger in ticket #640):
sys/arch/xen/xen/xengnt.c: revision 1.25
xen: don't use grants 0-8
Not all grants from the first frame can be used, grants from 0 to 8
(both included) are reserved for external tools. Using this grants
caused system crashes and fs corruption.
Closes PR port-xen/47057 and port-xen/47056
Reviewed by bouyer@


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.1 -r1.22.2.1.4.1 src/sys/arch/xen/xen/xengnt.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/xen/xen/xengnt.c
diff -u src/sys/arch/xen/xen/xengnt.c:1.22.2.1 src/sys/arch/xen/xen/xengnt.c:1.22.2.1.4.1
--- src/sys/arch/xen/xen/xengnt.c:1.22.2.1	Thu Feb 23 21:19:55 2012
+++ src/sys/arch/xen/xen/xengnt.c	Wed Oct 31 16:15:28 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: xengnt.c,v 1.22.2.1 2012/02/23 21:19:55 riz Exp $  */
+/*  $NetBSD: xengnt.c,v 1.22.2.1.4.1 2012/10/31 16:15:28 riz Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.22.2.1 2012/02/23 21:19:55 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.22.2.1.4.1 2012/10/31 16:15:28 riz Exp $");
 
 #include 
 #include 
@@ -51,6 +51,9 @@ __KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1
 
 #define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_t))
 
+/* External tools reserve first few grant table entries. */
+#define NR_RESERVED_ENTRIES 8
+
 /* Current number of frames making up the grant table */
 int gnt_nr_grant_frames;
 /* Maximum number of frames that can make up the grant table */
@@ -161,7 +164,7 @@ xengnt_more_entries(void)
 	gnttab_setup_table_t setup;
 	u_long *pages;
 	int nframes_new = gnt_nr_grant_frames + 1;
-	int i;
+	int i, start_gnt;
 	KASSERT(mutex_owned(&grant_lock));
 
 	if (gnt_nr_grant_frames == gnt_max_grant_frames)
@@ -204,9 +207,14 @@ xengnt_more_entries(void)
 
 	/*
 	 * add the grant entries associated to the last grant table frame
-	 * and mark them as free
+	 * and mark them as free. Prevent using the first grants (from 0 to 8)
+	 * since they are used by the tools.
 	 */
-	for (i = gnt_nr_grant_frames * NR_GRANT_ENTRIES_PER_PAGE;
+	start_gnt = (gnt_nr_grant_frames * NR_GRANT_ENTRIES_PER_PAGE) <
+	(NR_RESERVED_ENTRIES + 1) ?
+	(NR_RESERVED_ENTRIES + 1) :
+	(gnt_nr_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
+	for (i = start_gnt;
 	i < nframes_new * NR_GRANT_ENTRIES_PER_PAGE;
 	i++) {
 		KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY);
@@ -240,7 +248,7 @@ xengnt_get_entry(void)
 	last_gnt_entry--;
 	entry = gnt_entries[last_gnt_entry];
 	gnt_entries[last_gnt_entry] = XENGNT_NO_ENTRY;
-	KASSERT(entry != XENGNT_NO_ENTRY);
+	KASSERT(entry != XENGNT_NO_ENTRY && entry > NR_RESERVED_ENTRIES);
 	KASSERT(last_gnt_entry >= 0);
 	KASSERT(last_gnt_entry <= gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
 	return entry;
@@ -253,6 +261,7 @@ static void
 xengnt_free_entry(grant_ref_t entry)
 {
 	mutex_enter(&grant_lock);
+	KASSERT(entry > NR_RESERVED_ENTRIES);
 	KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY);
 	KASSERT(last_gnt_entry >= 0);
 	KASSERT(last_gnt_entry <= gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);



CVS commit: [netbsd-6-0] src/sys/arch/x86/include

2012-10-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Oct 19 17:33:37 UTC 2012

Modified Files:
src/sys/arch/x86/include [netbsd-6-0]: lock.h

Log Message:
Pull up following revision(s) (requested by apb in ticket #606):
sys/arch/x86/include/lock.h: revision 1.26
Change "=r" to "=qQ" in a register constraint in an asm statement
for a register that is used with the "xchgb" instruction in the
definition of __cpu_simple_lock_try().  This fixes PR 45673, or at
least works around the gcc bug that might be behind PR 45673.
The output from "objdump -d" before and after this change is
identical, for the amd64 GENERIC kernel, the i386 GENERIC kernel,
and the i386 MONOLITHIC kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.25.26.1 src/sys/arch/x86/include/lock.h

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

Modified files:

Index: src/sys/arch/x86/include/lock.h
diff -u src/sys/arch/x86/include/lock.h:1.25 src/sys/arch/x86/include/lock.h:1.25.26.1
--- src/sys/arch/x86/include/lock.h:1.25	Thu Jan 15 01:20:31 2009
+++ src/sys/arch/x86/include/lock.h	Fri Oct 19 17:33:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.25 2009/01/15 01:20:31 pooka Exp $	*/
+/*	$NetBSD: lock.h,v 1.25.26.1 2012/10/19 17:33:37 riz Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2006 The NetBSD Foundation, Inc.
@@ -106,7 +106,7 @@ __cpu_simple_lock_try(__cpu_simple_lock_
 
 	val = __SIMPLELOCK_LOCKED;
 	__asm volatile ("xchgb %0,(%2)" : 
-	"=r" (val)
+	"=qQ" (val)
 	:"0" (val), "r" (lockp));
 	__insn_barrier();
 	return val == __SIMPLELOCK_UNLOCKED;