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

2015-06-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun  4 08:55:24 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: intel_busclock.c

Log Message:
Pull up the following revisions, requested by sborrill in #1963:

sys/arch/x86/x86/intel_busclock.c   1.10, 1.13-23

Update p[34]_get_bus_clock() to avoid panic in est(4).
Return correct bus clock on some CPUs. Use rdmsr_safe()
to access MSRs safely.


To generate a diff of this commit:
cvs rdiff -u -r1.5.10.5 -r1.5.10.6 src/sys/arch/x86/x86/intel_busclock.c

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



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

2015-06-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jun  4 08:55:24 UTC 2015

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: intel_busclock.c

Log Message:
Pull up the following revisions, requested by sborrill in #1963:

sys/arch/x86/x86/intel_busclock.c   1.10, 1.13-23

Update p[34]_get_bus_clock() to avoid panic in est(4).
Return correct bus clock on some CPUs. Use rdmsr_safe()
to access MSRs safely.


To generate a diff of this commit:
cvs rdiff -u -r1.5.10.5 -r1.5.10.6 src/sys/arch/x86/x86/intel_busclock.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/intel_busclock.c
diff -u src/sys/arch/x86/x86/intel_busclock.c:1.5.10.5 src/sys/arch/x86/x86/intel_busclock.c:1.5.10.6
--- src/sys/arch/x86/x86/intel_busclock.c:1.5.10.5	Wed Aug 22 21:18:19 2012
+++ src/sys/arch/x86/x86/intel_busclock.c	Thu Jun  4 08:55:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_busclock.c,v 1.5.10.5 2012/08/22 21:18:19 bouyer Exp $	*/
+/*	$NetBSD: intel_busclock.c,v 1.5.10.6 2015/06/04 08:55:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.5.10.5 2012/08/22 21:18:19 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.5.10.6 2015/06/04 08:55:24 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -91,25 +91,24 @@ p3_get_bus_clock(struct cpu_info *ci)
 {
 	uint64_t msr;
 	int bus, bus_clock = 0;
+	uint32_t model;
 
-	switch (CPUID2MODEL(ci-ci_signature)) {
+	model = CPUID_TO_MODEL(ci-ci_signature);
+		
+	switch (model) {
 	case 0x9: /* Pentium M (130 nm, Banias) */
 		bus_clock = 1;
 		break;
 	case 0xc: /* Core i7, Atom, model 1 */
 		/*
-		 * XXX (See also case 0xe and 0xd)
-		 * Some core i7 CPUs can report model 0xc.
 		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
 		 * In the long-term, use ACPI instead of all this.
 		 */
-		switch (CPUID2EXTMODEL(ci-ci_signature)) {
-		case 0x2:
-			aprint_debug(%s: unable to determine bus speed,
-			device_xname(ci-ci_dev));
+		if (rdmsr_safe(MSR_FSB_FREQ, msr) == EFAULT) {
+			aprint_debug_dev(ci-ci_dev,
+			unable to determine bus speed);
 			goto print_msr;
 		}
-		msr = rdmsr(MSR_FSB_FREQ);
 		bus = (msr  0)  0x7;
 		switch (bus) {
 		case 1:
@@ -121,20 +120,12 @@ p3_get_bus_clock(struct cpu_info *ci)
 			goto print_msr;
 		}
 		break;
-	case 0xd: /* Pentium M (90 nm, Dothan), some Xeons */
-		/*
-		 * XXX (See also case 0xc and 0xd)
-		 * Some Xeons can report model 0xd, e.g. E5-2630
-		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
-		 * In the long-term, use ACPI instead of all this.
-		 */
-		switch (CPUID2EXTMODEL(ci-ci_signature)) {
-		case 0x2:
-			aprint_debug(%s: unable to determine bus speed,
-			device_xname(ci-ci_dev));
+	case 0xd: /* Pentium M (90 nm, Dothan) */
+		if (rdmsr_safe(MSR_FSB_FREQ, msr) == EFAULT) {
+			aprint_debug_dev(ci-ci_dev,
+			unable to determine bus speed);
 			goto print_msr;
 		}
-		msr = rdmsr(MSR_FSB_FREQ);
 		bus = (msr  0)  0x7;
 		switch (bus) {
 		case 0:
@@ -150,20 +141,13 @@ p3_get_bus_clock(struct cpu_info *ci)
 		}
 		break;
 	case 0xe: /* Core Duo/Solo */
-		/*
-		 * XXX (See also case 0xc)
-		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
-		 * In the long-term, use ACPI instead of all this.
-		 */
-		switch (CPUID2EXTMODEL(ci-ci_signature)) {
-		case 0x1:
-			aprint_debug(%s: unable to determine bus speed,
-			device_xname(ci-ci_dev));
+	case 0xf: /* Core Xeon */
+	case 0x17: /* Xeon [35]000, Core 2 Quad [89]00 */
+		if (rdmsr_safe(MSR_FSB_FREQ, msr) == EFAULT) {
+			aprint_debug_dev(ci-ci_dev,
+			unable to determine bus speed);
 			goto print_msr;
 		}
-		/* FALLTHROUGH */
-	case 0xf: /* Core Xeon */
-		msr = rdmsr(MSR_FSB_FREQ);
 		bus = (msr  0)  0x7;
 		switch (bus) {
 		case 5:
@@ -184,6 +168,9 @@ p3_get_bus_clock(struct cpu_info *ci)
 		case 4:
 			bus_clock = 3;
 			break;
+		case 6:
+			bus_clock = 4;
+			break;
 		default:
 			aprint_debug(%s: unknown Core FSB_FREQ value %d,
 			device_xname(ci-ci_dev), bus);
@@ -210,16 +197,135 @@ p3_get_bus_clock(struct cpu_info *ci)
 		case 2:
 			bus_clock = 1;
 			break;
+		case 3:
+			bus_clock = 10666;
+			break;
 		default:
 			aprint_debug(%s: unknown i686 EBL_CR_POWERON 
 			value %d , device_xname(ci-ci_dev), bus);
 			goto print_msr;
 		}
 		break;
+	case 0x1c: /* Atom */
+	case 0x26:
+	case 0x27:
+	case 0x35:
+	case 0x36:
+		if (rdmsr_safe(MSR_FSB_FREQ, msr) == EFAULT) {
+			aprint_debug_dev(ci-ci_dev,
+			unable to determine bus speed);
+			goto print_msr;
+		}
+		bus = (msr  0)  0x7;
+		switch (bus) {
+		case 7:
+			bus_clock =  8333;
+			break;
+		case 5:
+			bus_clock = 1;
+			break;
+		case 1:
+			bus_clock = 1;
+			break;
+		case 3:
+			bus_clock = 16667;
+			break;
+		

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

2015-06-01 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Jun  1 15:45:46 UTC 2015

Modified Files:
src/sys/arch/x86/include [netbsd-5]: specialreg.h

Log Message:
Pull up the following revisions(s) (requested by msaitoh in ticket #1968):
sys/arch/x86/include/specialreg.h: revision 1.72 via patch

Backport CPUID_TO_*() macros. Old macros are kept for compatibility.


To generate a diff of this commit:
cvs rdiff -u -r1.31.4.3 -r1.31.4.4 src/sys/arch/x86/include/specialreg.h

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



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

2015-06-01 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Jun  1 15:45:46 UTC 2015

Modified Files:
src/sys/arch/x86/include [netbsd-5]: specialreg.h

Log Message:
Pull up the following revisions(s) (requested by msaitoh in ticket #1968):
sys/arch/x86/include/specialreg.h: revision 1.72 via patch

Backport CPUID_TO_*() macros. Old macros are kept for compatibility.


To generate a diff of this commit:
cvs rdiff -u -r1.31.4.3 -r1.31.4.4 src/sys/arch/x86/include/specialreg.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/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.31.4.3 src/sys/arch/x86/include/specialreg.h:1.31.4.4
--- src/sys/arch/x86/include/specialreg.h:1.31.4.3	Wed Jun 19 07:44:42 2013
+++ src/sys/arch/x86/include/specialreg.h	Mon Jun  1 15:45:46 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.31.4.3 2013/06/19 07:44:42 bouyer Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.31.4.4 2015/06/01 15:45:46 sborrill Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -240,13 +240,39 @@
 			\11TM2\12SSSE3\13CID\16CX16\17xTPR\20PDCM\23DCA \
 			\24SSE41\25SSE42\26X2APIC\30POPCNT
 
-#define CPUID2FAMILY(cpuid)	(((cpuid)  8)  0xf)
-#define CPUID2MODEL(cpuid)	(((cpuid)  4)  0xf)
-#define CPUID2STEPPING(cpuid)	((cpuid)  0xf)
-
-/* Extended family and model are defined on amd64 processors */
-#define CPUID2EXTFAMILY(cpuid)	(((cpuid)  20)  0xff)
-#define CPUID2EXTMODEL(cpuid)	(((cpuid)  16)  0xf)
+/* CPUID Fn0001 %eax */
+
+#define CPUID_TO_BASEFAMILY(cpuid)	(((cpuid)  8)  0xf)
+#define CPUID_TO_BASEMODEL(cpuid)	(((cpuid)  4)  0xf)
+#define CPUID_TO_STEPPING(cpuid)	((cpuid)  0xf)
+
+/* Old macros for compatibility */
+#define CPUID2FAMILY(cpuid)	CPUID_TO_BASEFAMILY(cpuid)
+#define CPUID2MODEL(cpuid)	CPUID_TO_BASEMODEL(cpuid)
+#define CPUID2STEPPING(cpuid)	CPUID_TO_STEPPING(cpuid)
+
+/*
+ * The Extended family bits should only be inspected when CPUID_TO_BASEFAMILY()
+ * returns 15. They are use to encode family value 16 to 270 (add 15).
+ * The Extended model bits are the high 4 bits of the model.
+ * They are only valid for family = 15 or family 6 (intel, but all amd
+ * family 6 are documented to return zero bits for them).
+ */
+#define CPUID_TO_EXTFAMILY(cpuid)	(((cpuid)  20)  0xff)
+#define CPUID_TO_EXTMODEL(cpuid)	(((cpuid)  16)  0xf)
+
+/* Old macros for compatibility */
+#define CPUID2EXTFAMILY(cpuid)	CPUID_TO_EXTFAMILY(cpuid)
+#define CPUID2EXTMODEL(cpuid)	CPUID_TO_EXTMODEL(cpuid)
+
+/* The macros for the Display Family and the Display Model */
+#define CPUID_TO_FAMILY(cpuid)	(CPUID_TO_BASEFAMILY(cpuid)	\
+	+ ((CPUID_TO_BASEFAMILY(cpuid) != 0x0f)		\
+		? 0 : CPUID_TO_EXTFAMILY(cpuid)))
+#define CPUID_TO_MODEL(cpuid)	(CPUID_TO_BASEMODEL(cpuid)	\
+	| ((CPUID_TO_BASEFAMILY(cpuid) != 0x0f)		\
+		 (CPUID_TO_BASEFAMILY(cpuid) != 0x06)		\
+		? 0 : (CPUID_TO_EXTMODEL(cpuid)  4)))
 
 /*
  * Model-specific registers for the i386 family



CVS commit: [netbsd-5] src/sys/arch

2015-06-01 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Jun  1 14:38:32 UTC 2015

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: cpufunc.S
src/sys/arch/i386/i386 [netbsd-5]: cpufunc.S
src/sys/arch/x86/include [netbsd-5]: cpufunc.h

Log Message:
Pull up the following revisions(s) (requested by msaitoh in ticket #1969):
sys/arch/x86/include/cpufunc.h: revision 1.13
sys/arch/amd64/amd64/cpufunc.S: revision 1.20-1.21 via patch
sys/arch/i386/i386/cpufunc.S:   revision 1.16-1.17, 1.21 via 
patch

Backport rdmsr_safe() to access MSR safely.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.6.1 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.13 -r1.13.4.1 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.8.10.3 -r1.8.10.4 src/sys/arch/x86/include/cpufunc.h

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



CVS commit: [netbsd-5] src/sys/arch

2015-06-01 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Jun  1 14:38:32 UTC 2015

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: cpufunc.S
src/sys/arch/i386/i386 [netbsd-5]: cpufunc.S
src/sys/arch/x86/include [netbsd-5]: cpufunc.h

Log Message:
Pull up the following revisions(s) (requested by msaitoh in ticket #1969):
sys/arch/x86/include/cpufunc.h: revision 1.13
sys/arch/amd64/amd64/cpufunc.S: revision 1.20-1.21 via patch
sys/arch/i386/i386/cpufunc.S:   revision 1.16-1.17, 1.21 via 
patch

Backport rdmsr_safe() to access MSR safely.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.6.1 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.13 -r1.13.4.1 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.8.10.3 -r1.8.10.4 src/sys/arch/x86/include/cpufunc.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/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.15 src/sys/arch/amd64/amd64/cpufunc.S:1.15.6.1
--- src/sys/arch/amd64/amd64/cpufunc.S:1.15	Tue Jun 24 16:32:53 2008
+++ src/sys/arch/amd64/amd64/cpufunc.S	Mon Jun  1 14:38:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.15 2008/06/24 16:32:53 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.15.6.1 2015/06/01 14:38:31 sborrill Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -33,6 +33,8 @@
  * Functions to provide access to i386-specific instructions.
  */
 
+#include sys/errno.h
+
 #include machine/asm.h
 #include machine/specialreg.h
 #include machine/segments.h
@@ -215,6 +217,37 @@ ENTRY(wrmsr_locked)
 	wrmsr
 	ret
 
+/*
+ * Support for reading MSRs in the safe manner (returns EFAULT on fault)
+ */
+/* int rdmsr_safe(u_int msr, uint64_t *data) */
+ENTRY(rdmsr_safe)
+	movq	CPUVAR(CURLWP), %r8
+	movq	L_ADDR(%r8), %r8
+	movq	$_C_LABEL(msr_onfault), PCB_ONFAULT(%r8)
+
+	movl	%edi, %ecx /* u_int msr */
+	rdmsr			/* Read MSR pointed by %ecx. Returns
+   hi byte in edx, lo in %eax */
+	salq	$32, %rdx	/* sign-shift %rdx left */
+	movl	%eax, %eax	/* zero-extend %eax - %rax */
+	orq	%rdx, %rax
+	movq	%rax, (%rsi)  /* *data */
+	xorq	%rax, %rax/* no error */
+
+	movq	%rax, PCB_ONFAULT(%r8)
+	ret
+
+/*
+ * MSR operations fault handler
+ */
+NENTRY(msr_onfault)
+	movq	CPUVAR(CURLWP), %r8
+	movq	L_ADDR(%r8), %r8
+	movq	$0, PCB_ONFAULT(%r8)
+	movl	$EFAULT, %eax
+	ret
+
 #ifndef XEN
 ENTRY(wbinvd)
 	wbinvd

Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.13 src/sys/arch/i386/i386/cpufunc.S:1.13.4.1
--- src/sys/arch/i386/i386/cpufunc.S:1.13	Tue Sep 23 08:50:11 2008
+++ src/sys/arch/i386/i386/cpufunc.S	Mon Jun  1 14:38:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.13 2008/09/23 08:50:11 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.13.4.1 2015/06/01 14:38:31 sborrill Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -35,8 +35,10 @@
  * These are shared with NetBSD/xen.
  */
 
+#include sys/errno.h
+
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: cpufunc.S,v 1.13 2008/09/23 08:50:11 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpufunc.S,v 1.13.4.1 2015/06/01 14:38:31 sborrill Exp $);
 
 #include opt_xen.h
 
@@ -141,6 +143,39 @@ ENTRY(wrmsr_locked)
 	ret
 END(wrmsr_locked)
 
+/*
+ * Support for reading MSRs in the safe manner (returns EFAULT on fault)
+ */
+/* int rdmsr_safe(u_int msr, uint64_t *data) */
+ENTRY(rdmsr_safe)
+	movl	CPUVAR(CURLWP), %ecx
+	movl	L_ADDR(%ecx), %ecx
+	movl	$_C_LABEL(msr_onfault), PCB_ONFAULT(%ecx)
+
+	movl	4(%esp), %ecx /* u_int msr */
+	rdmsr
+	movl	8(%esp), %ecx /* *data */
+	movl	%eax, (%ecx)  /* low-order bits */
+	movl	%edx, 4(%ecx) /* high-order bits */
+	xorl	%eax, %eax/* no error */
+
+	movl	CPUVAR(CURLWP), %ecx
+	movl	L_ADDR(%ecx), %ecx
+	movl	%eax, PCB_ONFAULT(%ecx)
+
+	ret
+
+/*
+ * MSR operations fault handler
+ */
+NENTRY(msr_onfault)
+	movl	CPUVAR(CURLWP), %ecx
+	movl	L_ADDR(%ecx), %ecx
+	movl	$0, PCB_ONFAULT(%ecx)
+	movl	$EFAULT, %eax
+	ret
+END(msr_onfault)
+
 ENTRY(cpu_counter)
 	rdtsc
 	addl	CPUVAR(CC_SKEW), %eax

Index: src/sys/arch/x86/include/cpufunc.h
diff -u src/sys/arch/x86/include/cpufunc.h:1.8.10.3 src/sys/arch/x86/include/cpufunc.h:1.8.10.4
--- src/sys/arch/x86/include/cpufunc.h:1.8.10.3	Mon Feb  2 21:38:50 2009
+++ src/sys/arch/x86/include/cpufunc.h	Mon Jun  1 14:38:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.8.10.3 2009/02/02 21:38:50 snj Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.8.10.4 2015/06/01 14:38:31 sborrill Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -118,6 +118,7 @@ void	x86_reset(void);
 
 uint64_t	rdmsr(u_int);
 uint64_t	rdmsr_locked(u_int, u_int);
+int		rdmsr_safe(u_int, uint64_t *);
 uint64_t	rdtsc(void);
 uint64_t	rdpmc(u_int);
 void		wrmsr(u_int, uint64_t);



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

2015-05-22 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri May 22 11:04:28 UTC 2015

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

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1965):
sys/arch/xen/xen/xenevt.c:  revision 1.42

Fix off by one error, addresses port-xen/49919.


To generate a diff of this commit:
cvs rdiff -u -r1.29.4.2 -r1.29.4.3 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.29.4.2 src/sys/arch/xen/xen/xenevt.c:1.29.4.3
--- src/sys/arch/xen/xen/xenevt.c:1.29.4.2	Wed Sep 30 00:08:03 2009
+++ src/sys/arch/xen/xen/xenevt.c	Fri May 22 11:04:28 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: xenevt.c,v 1.29.4.2 2009/09/30 00:08:03 snj Exp $  */
+/*  $NetBSD: xenevt.c,v 1.29.4.3 2015/05/22 11:04:28 sborrill Exp $  */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xenevt.c,v 1.29.4.2 2009/09/30 00:08:03 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: xenevt.c,v 1.29.4.3 2015/05/22 11:04:28 sborrill Exp $);
 
 #include opt_xen.h
 #include sys/param.h
@@ -496,7 +496,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)
@@ -580,7 +580,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;
 		if (devevent[unbind-port] != d)
 			return ENOTCONN;
@@ -596,7 +596,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;
 		if (devevent[notify-port] != d)
 			return ENOTCONN;



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

2015-05-22 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri May 22 11:04:28 UTC 2015

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

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1965):
sys/arch/xen/xen/xenevt.c:  revision 1.42

Fix off by one error, addresses port-xen/49919.


To generate a diff of this commit:
cvs rdiff -u -r1.29.4.2 -r1.29.4.3 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.



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

2015-04-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Apr 19 06:11:17 UTC 2015

Modified Files:
src/sys/arch/sparc/include [netbsd-5]: openfirm.h
src/sys/arch/sparc/stand/ofwboot [netbsd-5]: Locore.c
loadfile_machdep.c openfirm.h

Log Message:
Pullup another commit for ticket #1958 requested by martin:

sys/arch/sparc/include/openfirm.h   1.7
sys/arch/sparc/stand/ofwboot/Locore.c   1.11
sys/arch/sparc/stand/ofwboot/loadfile_machdep.c 1.7
sys/arch/sparc/stand/ofwboot/openfirm.h 1.4

Make ofwboot can handle over 4GB physical memory by using OpenFirmware
calls properly, and some cosmetic changes.  Idea from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.82.1 src/sys/arch/sparc/include/openfirm.h
cvs rdiff -u -r1.10.30.1 -r1.10.30.2 \
src/sys/arch/sparc/stand/ofwboot/Locore.c
cvs rdiff -u -r1.6 -r1.6.4.1 \
src/sys/arch/sparc/stand/ofwboot/loadfile_machdep.c
cvs rdiff -u -r1.3 -r1.3.72.1 src/sys/arch/sparc/stand/ofwboot/openfirm.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/include/openfirm.h
diff -u src/sys/arch/sparc/include/openfirm.h:1.6 src/sys/arch/sparc/include/openfirm.h:1.6.82.1
--- src/sys/arch/sparc/include/openfirm.h:1.6	Sat Mar  4 02:56:21 2006
+++ src/sys/arch/sparc/include/openfirm.h	Sun Apr 19 06:11:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.h,v 1.6 2006/03/04 02:56:21 uwe Exp $	*/
+/*	$NetBSD: openfirm.h,v 1.6.82.1 2015/04/19 06:11:17 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -49,6 +49,9 @@ typedef uint64_t cell_t;
 #define HDL2CELL(x)	(cell_t)(u_int)(int)(x)
 #define ADR2CELL(x)	(cell_t)(u_int)(int)(x)
 #endif
+#define HDQ2CELL_HI(x)	(cell_t)(0)
+#define HDQ2CELL_LO(x)	(cell_t)(x)
+#define CELL2HDQ(hi,lo)	(lo)
 #else /* SUN4U */
 /* All cells are 4 byte slots */
 typedef uint32_t cell_t;

Index: src/sys/arch/sparc/stand/ofwboot/Locore.c
diff -u src/sys/arch/sparc/stand/ofwboot/Locore.c:1.10.30.1 src/sys/arch/sparc/stand/ofwboot/Locore.c:1.10.30.2
--- src/sys/arch/sparc/stand/ofwboot/Locore.c:1.10.30.1	Fri Apr 17 10:49:16 2015
+++ src/sys/arch/sparc/stand/ofwboot/Locore.c	Sun Apr 19 06:11:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: Locore.c,v 1.10.30.1 2015/04/17 10:49:16 msaitoh Exp $	*/
+/*	$NetBSD: Locore.c,v 1.10.30.2 2015/04/19 06:11:17 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -36,15 +36,6 @@
 
 #include machine/cpu.h
 
-vaddr_t	OF_claim_virt(vaddr_t, int);
-vaddr_t	OF_alloc_virt(int, int);
-int	OF_free_virt(vaddr_t, int);
-int	OF_unmap_virt(vaddr_t, int);
-vaddr_t	OF_map_phys(paddr_t, off_t, vaddr_t, int);
-paddr_t	OF_alloc_phys(int, int);
-paddr_t	OF_claim_phys(paddr_t, int);
-int	OF_free_phys(paddr_t, int);
-
 extern int openfirmware(void *);
 
 
@@ -450,9 +441,9 @@ OF_claim_virt(vaddr_t vaddr, int len)
 	args.align = 0;
 	args.len = len;
 	args.vaddr = ADR2CELL(vaddr);
-	if(openfirmware(args) != 0)
+	if (openfirmware(args) != 0)
 		return -1LL;
-	return args.retaddr; /* Kluge till we go 64-bit */
+	return (vaddr_t)args.retaddr;
 }
 
 /* 
@@ -486,13 +477,13 @@ OF_alloc_virt(int len, int align)
 	args.nargs = 4;
 	args.nreturns = 2;
 	args.method = ADR2CELL(claim);
-	args.ihandle = mmuh;
+	args.ihandle = HDL2CELL(mmuh);
 	args.align = align;
 	args.len = len;
 	args.retaddr = ADR2CELL(retaddr);
-	if(openfirmware(args) != 0)
+	if (openfirmware(args) != 0)
 		return -1LL;
-	return (vaddr_t)args.retaddr; /* Kluge till we go 64-bit */
+	return (vaddr_t)args.retaddr;
 }
 
 /* 
@@ -601,8 +592,8 @@ OF_map_phys(paddr_t paddr, off_t size, v
 	args.mode = mode;
 	args.size = size;
 	args.vaddr = ADR2CELL(vaddr);
-	args.paddr_hi = ADR2CELL(paddr32);
-	args.paddr_lo = ADR2CELL(paddr);
+	args.paddr_hi = HDQ2CELL_HI(paddr);
+	args.paddr_lo = HDQ2CELL_LO(paddr);
 
 	if (openfirmware(args) == -1)
 		return -1;
@@ -620,7 +611,6 @@ OF_map_phys(paddr_t paddr, off_t size, v
 paddr_t
 OF_alloc_phys(int len, int align)
 {
-	paddr_t paddr;
 	struct {
 		cell_t name;
 		cell_t nargs;
@@ -647,10 +637,9 @@ OF_alloc_phys(int len, int align)
 	args.ihandle = HDL2CELL(memh);
 	args.align = align;
 	args.len = len;
-	if(openfirmware(args) != 0)
+	if (openfirmware(args) != 0)
 		return -1LL;
-	paddr = (paddr_t)(args.phys_hi32)|((unsigned int)(args.phys_lo));
-	return paddr; /* Kluge till we go 64-bit */
+	return (paddr_t)CELL2HDQ(args.phys_hi, args.phys_lo);
 }
 
 /* 
@@ -661,7 +650,6 @@ OF_alloc_phys(int len, int align)
 paddr_t
 OF_claim_phys(paddr_t phys, int len)
 {
-	paddr_t paddr;
 	struct {
 		cell_t name;
 		cell_t nargs;
@@ -691,12 +679,11 @@ OF_claim_phys(paddr_t phys, int len)
 	args.ihandle = HDL2CELL(memh);
 	args.align = 0;
 	args.len = len;
-	args.phys_hi = HDL2CELL(phys32);
-	args.phys_lo = HDL2CELL(phys);
-	if(openfirmware(args) != 0)
+	args.phys_hi = HDQ2CELL_HI(phys);
+	args.phys_lo = HDQ2CELL_LO(phys);
+	if 

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

2015-04-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Apr 19 06:11:17 UTC 2015

Modified Files:
src/sys/arch/sparc/include [netbsd-5]: openfirm.h
src/sys/arch/sparc/stand/ofwboot [netbsd-5]: Locore.c
loadfile_machdep.c openfirm.h

Log Message:
Pullup another commit for ticket #1958 requested by martin:

sys/arch/sparc/include/openfirm.h   1.7
sys/arch/sparc/stand/ofwboot/Locore.c   1.11
sys/arch/sparc/stand/ofwboot/loadfile_machdep.c 1.7
sys/arch/sparc/stand/ofwboot/openfirm.h 1.4

Make ofwboot can handle over 4GB physical memory by using OpenFirmware
calls properly, and some cosmetic changes.  Idea from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.82.1 src/sys/arch/sparc/include/openfirm.h
cvs rdiff -u -r1.10.30.1 -r1.10.30.2 \
src/sys/arch/sparc/stand/ofwboot/Locore.c
cvs rdiff -u -r1.6 -r1.6.4.1 \
src/sys/arch/sparc/stand/ofwboot/loadfile_machdep.c
cvs rdiff -u -r1.3 -r1.3.72.1 src/sys/arch/sparc/stand/ofwboot/openfirm.h

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



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

2015-04-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Apr 17 10:49:16 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1958):
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.10 -r1.10.30.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.10 src/sys/arch/sparc/stand/ofwboot/Locore.c:1.10.30.1
--- src/sys/arch/sparc/stand/ofwboot/Locore.c:1.10	Wed Oct 17 19:57:16 2007
+++ src/sys/arch/sparc/stand/ofwboot/Locore.c	Fri Apr 17 10:49:16 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: Locore.c,v 1.10 2007/10/17 19:57:16 garbled Exp $	*/
+/*	$NetBSD: Locore.c,v 1.10.30.1 2015/04/17 10:49:16 msaitoh Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -311,8 +311,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-5] src/sys/arch/sparc/stand/ofwboot

2015-04-17 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Apr 17 10:49:16 UTC 2015

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

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1958):
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.10 -r1.10.30.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.



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

2015-01-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 26 13:34:03 UTC 2015

Modified Files:
src/sys/arch/x86/pci [netbsd-5]: ichlpcib.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1944):
sys/arch/x86/pci/ichlpcib.c: revision 1.46

The PMBASE and GPIOBASE registers are not compltible with the PCI spec
and the map sizes are fixed to 128bytes. The pci_mapreg_submap()
function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some
machines. It makes impossible to use pci_mapreg_submap(). Use
pci_conf_read() and bus_space_map() directly.


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.3 -r1.14.4.4 src/sys/arch/x86/pci/ichlpcib.c

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



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

2015-01-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 26 13:34:03 UTC 2015

Modified Files:
src/sys/arch/x86/pci [netbsd-5]: ichlpcib.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1944):
sys/arch/x86/pci/ichlpcib.c: revision 1.46

The PMBASE and GPIOBASE registers are not compltible with the PCI spec
and the map sizes are fixed to 128bytes. The pci_mapreg_submap()
function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some
machines. It makes impossible to use pci_mapreg_submap(). Use
pci_conf_read() and bus_space_map() directly.


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.3 -r1.14.4.4 src/sys/arch/x86/pci/ichlpcib.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/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.14.4.3 src/sys/arch/x86/pci/ichlpcib.c:1.14.4.4
--- src/sys/arch/x86/pci/ichlpcib.c:1.14.4.3	Fri Jan 23 16:24:55 2015
+++ src/sys/arch/x86/pci/ichlpcib.c	Mon Jan 26 13:34:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.14.4.3 2015/01/23 16:24:55 martin Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.14.4.4 2015/01/26 13:34:03 martin Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.14.4.3 2015/01/23 16:24:55 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.14.4.4 2015/01/26 13:34:03 martin Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -184,6 +184,7 @@ lpcibattach(device_t parent, device_t se
 	struct pci_attach_args *pa = aux;
 	struct lpcib_softc *sc = device_private(self);
 	struct lpcib_device *lpcib_dev;
+	pcireg_t pmbase;
 
 	sc-sc_pa = *pa;
 
@@ -205,11 +206,16 @@ lpcibattach(device_t parent, device_t se
 	 *
 	 * The PMBASE register is alike PCI BAR but not completely compatible
 	 * with it. The PMBASE define the base address and the type but
-	 * not describe the size.
+	 * not describe the size. The value of the register may be lower
+	 * than LPCIB_PCI_PM_SIZE. It makes impossible to use
+	 * pci_mapreg_submap() because the function does range check.
 	 */
-	if (pci_mapreg_submap(pa, LPCIB_PCI_PMBASE, PCI_MAPREG_TYPE_IO, 0,
-		LPCIB_PCI_PM_SIZE, 0, sc-sc_iot, sc-sc_ioh, NULL, NULL)) {
-		aprint_error_dev(self, can't map power management i/o space\n);
+	sc-sc_iot = pa-pa_iot;
+	pmbase = pci_conf_read(pa-pa_pc, pa-pa_tag, LPCIB_PCI_PMBASE);
+	if (bus_space_map(sc-sc_iot, PCI_MAPREG_IO_ADDR(pmbase),
+	LPCIB_PCI_PM_SIZE, 0, sc-sc_ioh) != 0) {
+		aprint_error_dev(self,
+		can't map power management i/o space\n);
 		return;
 	}
 



CVS commit: [netbsd-5] src/sys/arch/arm/arm

2015-01-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jan  7 13:03:42 UTC 2015

Modified Files:
src/sys/arch/arm/arm [netbsd-5]: disassem.c

Log Message:
Pull up following revision(s) (requested by hick in ticket #1939):
sys/arch/arm/arm/disassem.c: revision 1.26
The mode synonyms are different for stm and ldm - handle this.
PR/49520: arm/disassem.c doesn't use proper address mode name for loads


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.10.1 src/sys/arch/arm/arm/disassem.c

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



CVS commit: [netbsd-5] src/sys/arch/arm/arm

2015-01-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jan  7 13:03:42 UTC 2015

Modified Files:
src/sys/arch/arm/arm [netbsd-5]: disassem.c

Log Message:
Pull up following revision(s) (requested by hick in ticket #1939):
sys/arch/arm/arm/disassem.c: revision 1.26
The mode synonyms are different for stm and ldm - handle this.
PR/49520: arm/disassem.c doesn't use proper address mode name for loads


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.10.1 src/sys/arch/arm/arm/disassem.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/arm/disassem.c
diff -u src/sys/arch/arm/arm/disassem.c:1.18 src/sys/arch/arm/arm/disassem.c:1.18.10.1
--- src/sys/arch/arm/arm/disassem.c:1.18	Sun Apr 27 18:58:43 2008
+++ src/sys/arch/arm/arm/disassem.c	Wed Jan  7 13:03:42 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: disassem.c,v 1.18 2008/04/27 18:58:43 matt Exp $	*/
+/*	$NetBSD: disassem.c,v 1.18.10.1 2015/01/07 13:03:42 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1996 Mark Brinicombe.
@@ -49,7 +49,7 @@
 
 #include sys/param.h
 
-__KERNEL_RCSID(0, $NetBSD: disassem.c,v 1.18 2008/04/27 18:58:43 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: disassem.c,v 1.18.10.1 2015/01/07 13:03:42 msaitoh Exp $);
 
 #include sys/systm.h
 #include arch/arm/arm/disassem.h
@@ -233,7 +233,8 @@ static char const insn_block_transfers[]
 };
 
 static char const insn_stack_block_transfers[][4] = {
-	ed, ea, fd, fa
+	ed, ea, fd, fa,	/* stm */
+	fa, fd, ea, ed,	/* ldm */
 };
 
 static char const op_shifts[][4] = {
@@ -255,7 +256,7 @@ static char const insn_fpaconstants[][8]
 
 #define insn_condition(x)	arm32_insn_conditions[(x  28)  0x0f]
 #define insn_blktrans(x)	insn_block_transfers[(x  23)  3]
-#define insn_stkblktrans(x)	insn_stack_block_transfers[(x  23)  3]
+#define insn_stkblktrans(x)	insn_stack_block_transfers[((x  (20 - 2))  4)|((x  23)  3)]
 #define op2_shift(x)		op_shifts[(x  5)  3]
 #define insn_fparnd(x)		insn_fpa_rounding[(x  5)  0x03]
 #define insn_fpaprec(x)		insn_fpa_precision[(((x  18)  2)|(x  7))  1]



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

2014-05-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed May 21 22:05:40 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1903):
sys/arch/x86/pci/pci_machdep.c: revision 1.61 via patch
sys/arch/x86/pci/pci_machdep.c: revision 1.66 via patch
Force pci_mode 1 when running as Xen HVM domU to allow cd* to be
detected correctly. Fixes kern/48770. Thanks to cube@
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.34.10.1 -r1.34.10.2 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.34.10.1 src/sys/arch/x86/pci/pci_machdep.c:1.34.10.2
--- src/sys/arch/x86/pci/pci_machdep.c:1.34.10.1	Sat May 19 16:39:24 2012
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed May 21 22:05:40 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.34.10.1 2012/05/19 16:39:24 riz Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.34.10.2 2014/05/21 22:05:40 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.34.10.1 2012/05/19 16:39:24 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.34.10.2 2014/05/21 22:05:40 bouyer Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -483,6 +483,8 @@ pci_mode_detect(void)
 	uint32_t sav, val;
 	int i;
 	pcireg_t idreg;
+	extern char cpu_brand_string[];
+	const char *system_vendor, *system_product;
 
 	if (pci_mode != -1)
 		return pci_mode;
@@ -513,6 +515,19 @@ pci_mode_detect(void)
 		}
 	}
 
+	system_vendor = pmf_get_platform(system-manufacturer);
+	system_product = pmf_get_platform(system-product-name);
+if (memcmp(cpu_brand_string, QEMU, 4) == 0 ||
+	(system_vendor != NULL  system_product != NULL 
+	 !strcmp(system_vendor, Xen) 
+	 !strcmp(system_product, HVM domU))) {
+		/* 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:
 	 * 1. bit 31 (enable) can be set



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

2014-05-21 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed May 21 22:05:40 UTC 2014

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

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1903):
sys/arch/x86/pci/pci_machdep.c: revision 1.61 via patch
sys/arch/x86/pci/pci_machdep.c: revision 1.66 via patch
Force pci_mode 1 when running as Xen HVM domU to allow cd* to be
detected correctly. Fixes kern/48770. Thanks to cube@
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.34.10.1 -r1.34.10.2 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.



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

2013-12-11 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Wed Dec 11 16:00:46 UTC 2013

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

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1890):
sys/arch/xen/xen/evtchn.c:  revision 1.70

Remove the evtchn_do_event: handler %p didn't lower ipl %d %d\n printf
as analysis shows it actually isn't a bug in the handler, but related to
spin mutexes. Fixes port-xen/46313


To generate a diff of this commit:
cvs rdiff -u -r1.39.4.2 -r1.39.4.3 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.39.4.2 src/sys/arch/xen/xen/evtchn.c:1.39.4.3
--- src/sys/arch/xen/xen/evtchn.c:1.39.4.2	Fri Nov 14 02:59:39 2008
+++ src/sys/arch/xen/xen/evtchn.c	Wed Dec 11 16:00:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: evtchn.c,v 1.39.4.2 2008/11/14 02:59:39 snj Exp $	*/
+/*	$NetBSD: evtchn.c,v 1.39.4.3 2013/12/11 16:00:46 sborrill Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -64,7 +64,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: evtchn.c,v 1.39.4.2 2008/11/14 02:59:39 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: evtchn.c,v 1.39.4.3 2013/12/11 16:00:46 sborrill Exp $);
 
 #include opt_xen.h
 #include isa.h
@@ -301,13 +301,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-5] src/sys/arch/hp700/hp700

2013-10-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Oct 20 14:05:36 UTC 2013

Modified Files:
src/sys/arch/hp700/hp700 [netbsd-5]: autoconf.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1886):
sys/arch/hp700/hp700/autoconf.c: revision 1.51
Remember to unmap pagezero once we've finished with it. Found by gcc 4.8.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.14.1 src/sys/arch/hp700/hp700/autoconf.c

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

Modified files:

Index: src/sys/arch/hp700/hp700/autoconf.c
diff -u src/sys/arch/hp700/hp700/autoconf.c:1.26 src/sys/arch/hp700/hp700/autoconf.c:1.26.14.1
--- src/sys/arch/hp700/hp700/autoconf.c:1.26	Sun Mar 30 12:39:32 2008
+++ src/sys/arch/hp700/hp700/autoconf.c	Sun Oct 20 14:05:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.26 2008/03/30 12:39:32 skrll Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.26.14.1 2013/10/20 14:05:36 bouyer Exp $	*/
 
 /*	$OpenBSD: autoconf.c,v 1.15 2001/06/25 00:43:10 mickey Exp $	*/
 
@@ -86,7 +86,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.26 2008/03/30 12:39:32 skrll Exp $);
+__KERNEL_RCSID(0, $NetBSD: autoconf.c,v 1.26.14.1 2013/10/20 14:05:36 bouyer Exp $);
 
 #include opt_kgdb.h
 #include opt_useleds.h
@@ -446,6 +446,8 @@ cpu_rootconf(void)
 	}
 	printf(dp_flags 0x%x pz_class 0x%x\n, PAGE0-mem_boot.pz_dp.dp_flags,
 	PAGE0-mem_boot.pz_class);
+
+	hp700_pagezero_unmap(pagezero_cookie);
 #endif /* DEBUG */
 
 	if (boot_device != NULL)



CVS commit: [netbsd-5] src/sys/arch/hp700/hp700

2013-10-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Oct 20 14:05:36 UTC 2013

Modified Files:
src/sys/arch/hp700/hp700 [netbsd-5]: autoconf.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1886):
sys/arch/hp700/hp700/autoconf.c: revision 1.51
Remember to unmap pagezero once we've finished with it. Found by gcc 4.8.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.14.1 src/sys/arch/hp700/hp700/autoconf.c

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



CVS commit: [netbsd-5] src/sys/arch/i386/stand/boot

2013-09-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep  7 17:23:39 UTC 2013

Modified Files:
src/sys/arch/i386/stand/boot [netbsd-5]: boot2.c

Log Message:
Pull up following revision(s) (requested by he in ticket #1872):
sys/arch/i386/stand/lib/bootmenu.c: revision 1.11 via patch
sys/arch/i386/stand/lib/bootmenu.h: revision 1.3 via patch
sys/arch/i386/stand/boot/boot2.c: revision 1.59 via patch
Two changes for the i386 boot loader related to the boot menu which
can be defined in boot.cfg:
 * Add a menu command which re-displays the menu and initiates
   the timed countdown
 * Use any default command defined in boot.cfg as default args
   if the user runs boot with no arguments
This is useful in circumstances where you e.g. need to interrupt
the normal boot process to switch to serial console, and where
simply boot netbsd is no longer sufficient (e.g. as with install
media which needs the miniroot kernel module loaded).


To generate a diff of this commit:
cvs rdiff -u -r1.38.4.2 -r1.38.4.3 src/sys/arch/i386/stand/boot/boot2.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/stand/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.38.4.2 src/sys/arch/i386/stand/boot/boot2.c:1.38.4.3
--- src/sys/arch/i386/stand/boot/boot2.c:1.38.4.2	Sun Feb 14 14:01:08 2010
+++ src/sys/arch/i386/stand/boot/boot2.c	Sat Sep  7 17:23:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.38.4.2 2010/02/14 14:01:08 bouyer Exp $	*/
+/*	$NetBSD: boot2.c,v 1.38.4.3 2013/09/07 17:23:39 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -131,9 +131,16 @@ void	command_quit(char *);
 void	command_boot(char *);
 void	command_dev(char *);
 void	command_consdev(char *);
+#ifndef SMALL
+void	command_menu(char *);
+#endif
 void	command_modules(char *);
 void	command_load(char *);
 void	command_multiboot(char *);
+#ifndef SMALL
+void	bootdefault(void);
+void	docommandchoice(int);
+#endif
 
 const struct bootblk_command commands[] = {
 	{ help,	command_help },
@@ -143,6 +150,9 @@ const struct bootblk_command commands[] 
 	{ boot,	command_boot },
 	{ dev,	command_dev },
 	{ consdev,	command_consdev },
+#ifndef SMALL
+	{ menu,	command_menu },
+#endif
 	{ modules,	command_modules },
 	{ load,	command_load },
 	{ multiboot,	command_multiboot },
@@ -508,10 +518,58 @@ static int getchoicefrominput(char *inpu
 }
 
 void
+docommandchoice(int choice)
+{
+	char input[80], *ic, *oc;
+ 
+	ic = bootconf.command[choice];
+	/* Split command string at ; into separate commands */
+	do {
+		oc = input;
+		/* Look for ; separator */
+		for (; *ic  *ic != COMMAND_SEPARATOR; ic++)
+			*oc++ = *ic;
+		if (*input == '\0')
+			continue;
+		/* Strip out any trailing spaces */
+		oc--;
+		for (; *oc == ' '  oc  input; oc--);
+		*++oc = '\0';
+		if (*ic == COMMAND_SEPARATOR)
+			ic++;
+		/* Stop silly command strings like ;;; */
+		if (*input != '\0')
+			docommand(input);
+		/* Skip leading spaces */
+		for (; *ic == ' '; ic++);
+	} while (*ic);
+}
+
+void
+bootdefault(void)
+{
+int choice;
+static int entered;
+ 
+if (bootconf.nummenu  0) {
+if (entered) {
+printf(default boot twice, skipping...\n);
+return;
+}
+entered = 1;
+choice = bootconf.def;
+printf(command(s): %s\n, bootconf.command[choice]);
+docommandchoice(choice);
+}
+}
+
+
+
+void
 doboottypemenu(void)
 {
 	int choice;
-	char input[80], *ic, *oc;
+	char input[80];
 		
 	printf(\n);
 	/* Display menu */
@@ -567,27 +625,7 @@ doboottypemenu(void)
 			printf(type \?\ or \help\ for help.\n);
 			bootmenu(); /* does not return */
 		} else {
-			ic = bootconf.command[choice];
-			/* Split command string at ; into separate commands */
-			do {
-oc = input;
-/* Look for ; separator */
-for (; *ic  *ic != COMMAND_SEPARATOR; ic++)
-	*oc++ = *ic;
-if (*input == '\0')
-	continue;
-/* Strip out any trailing spaces */
-oc--;
-for (; *oc ==' '  oc  input; oc--);
-*++oc = '\0';
-if (*ic == COMMAND_SEPARATOR)
-	ic++;
-/* Stop silly command strings like ;;; */
-if (*input != '\0')
-	docommand(input);
-/* Skip leading spaces */
-for (; *ic == ' '; ic++);
-			} while (*ic);
+			docommandchoice(choice);
 		}
 			
 	}
@@ -707,6 +745,9 @@ command_help(char *arg)
 	   dev xd[N[x]]:\n
 	   consdev {pc|com[0123]|com[0123]kbd|auto}\n
 	   modules {enabled|disabled}\n
+#ifndef SMALL
+	   menu (reenters boot menu, if defined in boot.cfg)\n
+#endif
 	   load {path_to_module}\n
 	   multiboot [xdNx:][filename] [args]\n
 	   help|?\n
@@ -740,10 +781,25 @@ void
 command_boot(char *arg)
 {
 	char *filename;
-	int howto;
+	int howto, tell;
 
-	if (parseboot(arg, filename, howto))
-		

CVS commit: [netbsd-5] src/sys/arch/i386/stand/boot

2013-09-07 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Sep  7 17:23:39 UTC 2013

Modified Files:
src/sys/arch/i386/stand/boot [netbsd-5]: boot2.c

Log Message:
Pull up following revision(s) (requested by he in ticket #1872):
sys/arch/i386/stand/lib/bootmenu.c: revision 1.11 via patch
sys/arch/i386/stand/lib/bootmenu.h: revision 1.3 via patch
sys/arch/i386/stand/boot/boot2.c: revision 1.59 via patch
Two changes for the i386 boot loader related to the boot menu which
can be defined in boot.cfg:
 * Add a menu command which re-displays the menu and initiates
   the timed countdown
 * Use any default command defined in boot.cfg as default args
   if the user runs boot with no arguments
This is useful in circumstances where you e.g. need to interrupt
the normal boot process to switch to serial console, and where
simply boot netbsd is no longer sufficient (e.g. as with install
media which needs the miniroot kernel module loaded).


To generate a diff of this commit:
cvs rdiff -u -r1.38.4.2 -r1.38.4.3 src/sys/arch/i386/stand/boot/boot2.c

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



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

2013-06-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Jun 19 07:44:42 UTC 2013

Modified Files:
src/sys/arch/x86/include [netbsd-5]: mtrr.h specialreg.h
src/sys/arch/x86/x86 [netbsd-5]: mtrr_i686.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1847):
sys/arch/x86/include/mtrr.h: revision 1.5
sys/arch/x86/x86/mtrr_i686.c: revision 1.25
sys/arch/x86/include/specialreg.h: revision 1.55
Increase MTRR_I686_NVAR_MAX from 8 to 16. Avoids
FIXME: more than 8 MTRRs (10) message on booting Thinkpad W520 and
similar. While here replace a magic number with MTRR_I686_NVAR_MAX * 2


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.6.1 src/sys/arch/x86/include/mtrr.h
cvs rdiff -u -r1.31.4.2 -r1.31.4.3 src/sys/arch/x86/include/specialreg.h
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 src/sys/arch/x86/x86/mtrr_i686.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/mtrr.h
diff -u src/sys/arch/x86/include/mtrr.h:1.4 src/sys/arch/x86/include/mtrr.h:1.4.6.1
--- src/sys/arch/x86/include/mtrr.h:1.4	Tue Jul  1 15:27:34 2008
+++ src/sys/arch/x86/include/mtrr.h	Wed Jun 19 07:44:42 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: mtrr.h,v 1.4 2008/07/01 15:27:34 mrg Exp $ */
+/* $NetBSD: mtrr.h,v 1.4.6.1 2013/06/19 07:44:42 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #define MTRR_I686_FIXED_IDX16K	1
 #define MTRR_I686_FIXED_IDX4K	3
 
-#define MTRR_I686_NVAR_MAX	8	/* could be upto 255? */
+#define MTRR_I686_NVAR_MAX	16	/* could be upto 255? */
 
 #define MTRR_I686_64K_START		0x0
 #define MTRR_I686_16K_START		0x8

Index: src/sys/arch/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.31.4.2 src/sys/arch/x86/include/specialreg.h:1.31.4.3
--- src/sys/arch/x86/include/specialreg.h:1.31.4.2	Wed Nov 28 04:39:03 2012
+++ src/sys/arch/x86/include/specialreg.h	Wed Jun 19 07:44:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.31.4.2 2012/11/28 04:39:03 riz Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.31.4.3 2013/06/19 07:44:42 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -314,6 +314,22 @@
 #define	MSR_MTRRphysMask6	0x20d
 #define	MSR_MTRRphysBase7	0x20e
 #define	MSR_MTRRphysMask7	0x20f
+#define	MSR_MTRRphysBase8	0x210
+#define	MSR_MTRRphysMask8	0x211
+#define	MSR_MTRRphysBase9	0x212
+#define	MSR_MTRRphysMask9	0x213
+#define	MSR_MTRRphysBase10	0x214
+#define	MSR_MTRRphysMask10	0x215
+#define	MSR_MTRRphysBase11	0x216
+#define	MSR_MTRRphysMask11	0x217
+#define	MSR_MTRRphysBase12	0x218
+#define	MSR_MTRRphysMask12	0x219
+#define	MSR_MTRRphysBase13	0x21a
+#define	MSR_MTRRphysMask13	0x21b
+#define	MSR_MTRRphysBase14	0x21c
+#define	MSR_MTRRphysMask14	0x21d
+#define	MSR_MTRRphysBase15	0x21e
+#define	MSR_MTRRphysMask15	0x21f
 #define	MSR_MTRRfix64K_0	0x250
 #define	MSR_MTRRfix16K_8	0x258
 #define	MSR_MTRRfix16K_A	0x259

Index: src/sys/arch/x86/x86/mtrr_i686.c
diff -u src/sys/arch/x86/x86/mtrr_i686.c:1.19.4.1 src/sys/arch/x86/x86/mtrr_i686.c:1.19.4.2
--- src/sys/arch/x86/x86/mtrr_i686.c:1.19.4.1	Wed Feb 16 20:54:13 2011
+++ src/sys/arch/x86/x86/mtrr_i686.c	Wed Jun 19 07:44:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mtrr_i686.c,v 1.19.4.1 2011/02/16 20:54:13 bouyer Exp $ */
+/*	$NetBSD: mtrr_i686.c,v 1.19.4.2 2013/06/19 07:44:42 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mtrr_i686.c,v 1.19.4.1 2011/02/16 20:54:13 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: mtrr_i686.c,v 1.19.4.2 2013/06/19 07:44:42 bouyer Exp $);
 
 #include opt_multiprocessor.h
 
@@ -84,6 +84,22 @@ mtrr_raw[] = {
 	{ MSR_MTRRphysMask6, 0 },
 	{ MSR_MTRRphysBase7, 0 },
 	{ MSR_MTRRphysMask7, 0 },
+	{ MSR_MTRRphysBase8, 0 },
+	{ MSR_MTRRphysMask8, 0 },
+	{ MSR_MTRRphysBase9, 0 },
+	{ MSR_MTRRphysMask9, 0 },
+	{ MSR_MTRRphysBase10, 0 },
+	{ MSR_MTRRphysMask10, 0 },
+	{ MSR_MTRRphysBase11, 0 },
+	{ MSR_MTRRphysMask11, 0 },
+	{ MSR_MTRRphysBase12, 0 },
+	{ MSR_MTRRphysMask12, 0 },
+	{ MSR_MTRRphysBase13, 0 },
+	{ MSR_MTRRphysMask13, 0 },
+	{ MSR_MTRRphysBase14, 0 },
+	{ MSR_MTRRphysMask14, 0 },
+	{ MSR_MTRRphysBase15, 0 },
+	{ MSR_MTRRphysMask15, 0 },
 	{ MSR_MTRRfix64K_0, 0 },
 	{ MSR_MTRRfix16K_8, 0 },
 	{ MSR_MTRRfix16K_A, 0 },
@@ -306,8 +322,8 @@ i686_mtrr_init_first(void)
 		MTRR_I686_NVAR_MAX);
 	else if (i686_mtrr_vcnt  MTRR_I686_NVAR_MAX) {
 		for (i = MTRR_I686_NVAR_MAX - i686_mtrr_vcnt; i; i--) {
-			mtrr_raw[16 - (i*2)].msraddr = 0;
-			mtrr_raw[17 - (i*2)].msraddr = 0;
+			mtrr_raw[(MTRR_I686_NVAR_MAX - i) * 2].msraddr = 0;
+			mtrr_raw[(MTRR_I686_NVAR_MAX - i) * 2 + 1].msraddr = 0;
 		}
 	}
 



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

2013-06-19 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Jun 19 07:44:42 UTC 2013

Modified Files:
src/sys/arch/x86/include [netbsd-5]: mtrr.h specialreg.h
src/sys/arch/x86/x86 [netbsd-5]: mtrr_i686.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1847):
sys/arch/x86/include/mtrr.h: revision 1.5
sys/arch/x86/x86/mtrr_i686.c: revision 1.25
sys/arch/x86/include/specialreg.h: revision 1.55
Increase MTRR_I686_NVAR_MAX from 8 to 16. Avoids
FIXME: more than 8 MTRRs (10) message on booting Thinkpad W520 and
similar. While here replace a magic number with MTRR_I686_NVAR_MAX * 2


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.6.1 src/sys/arch/x86/include/mtrr.h
cvs rdiff -u -r1.31.4.2 -r1.31.4.3 src/sys/arch/x86/include/specialreg.h
cvs rdiff -u -r1.19.4.1 -r1.19.4.2 src/sys/arch/x86/x86/mtrr_i686.c

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



CVS commit: [netbsd-5] src/sys/arch

2013-06-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jun  9 11:44:04 UTC 2013

Modified Files:
src/sys/arch/amd64/conf [netbsd-5]: XEN3_DOMU
src/sys/arch/i386/conf [netbsd-5]: XEN2_DOMU

Log Message:
Apply patch (requested by sborrill in ticket #1858):
sys/arch/amd64/conf/XEN3_DOMU
sys/arch/i386/conf/Attic/XEN2_DOMU
Add wedge support in DOMU kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.13.4.3 -r1.13.4.4 src/sys/arch/amd64/conf/XEN3_DOMU
cvs rdiff -u -r1.19.4.3 -r1.19.4.4 src/sys/arch/i386/conf/XEN2_DOMU

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/conf/XEN3_DOMU
diff -u src/sys/arch/amd64/conf/XEN3_DOMU:1.13.4.3 src/sys/arch/amd64/conf/XEN3_DOMU:1.13.4.4
--- src/sys/arch/amd64/conf/XEN3_DOMU:1.13.4.3	Sun Jan 13 16:46:22 2013
+++ src/sys/arch/amd64/conf/XEN3_DOMU	Sun Jun  9 11:44:04 2013
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOMU,v 1.13.4.3 2013/01/13 16:46:22 bouyer Exp $
+# $NetBSD: XEN3_DOMU,v 1.13.4.4 2013/06/09 11:44:04 msaitoh Exp $
 
 include 	arch/amd64/conf/std.xen
 
@@ -68,6 +68,13 @@ options 	COMPAT_LINUX32	# req. COMPAT_LI
 options 	EXEC_ELF32
 options 	COMPAT_BSDPTY	# /dev/[pt]ty?? ptys.
 
+# Wedge support
+options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
+options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges
+# The following two options can break /etc/fstab, so handle with care
+#options 	DKWEDGE_METHOD_BSDLABEL	# Support disklabel entries as wedges
+#options 	DKWEDGE_METHOD_MBR	# Support MBR partitions as wedges
+
 # File systems
 file-system 	FFS		# UFS
 file-system 	EXT2FS		# second extended file system (linux)

Index: src/sys/arch/i386/conf/XEN2_DOMU
diff -u src/sys/arch/i386/conf/XEN2_DOMU:1.19.4.3 src/sys/arch/i386/conf/XEN2_DOMU:1.19.4.4
--- src/sys/arch/i386/conf/XEN2_DOMU:1.19.4.3	Sun Jan 13 16:46:22 2013
+++ src/sys/arch/i386/conf/XEN2_DOMU	Sun Jun  9 11:44:04 2013
@@ -1,4 +1,4 @@
-# $NetBSD: XEN2_DOMU,v 1.19.4.3 2013/01/13 16:46:22 bouyer Exp $
+# $NetBSD: XEN2_DOMU,v 1.19.4.4 2013/06/09 11:44:04 msaitoh Exp $
 
 include 	arch/xen/conf/std.xen
 
@@ -86,6 +86,13 @@ options 	COMPAT_FREEBSD	# binary compati
 #options 	COMPAT_PECOFF	# kernel support to run Win32 apps
 options 	COMPAT_BSDPTY	# /dev/[pt]ty?? ptys.
 
+# Wedge support
+options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
+options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges
+# The following two options can break /etc/fstab, so handle with care
+#options 	DKWEDGE_METHOD_BSDLABEL	# Support disklabel entries as wedges
+#options 	DKWEDGE_METHOD_MBR	# Support MBR partitions as wedges
+
 # File systems
 file-system 	FFS		# UFS
 file-system 	EXT2FS		# second extended file system (linux)



CVS commit: [netbsd-5] src/sys/arch

2013-06-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Jun  9 11:44:04 UTC 2013

Modified Files:
src/sys/arch/amd64/conf [netbsd-5]: XEN3_DOMU
src/sys/arch/i386/conf [netbsd-5]: XEN2_DOMU

Log Message:
Apply patch (requested by sborrill in ticket #1858):
sys/arch/amd64/conf/XEN3_DOMU
sys/arch/i386/conf/Attic/XEN2_DOMU
Add wedge support in DOMU kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.13.4.3 -r1.13.4.4 src/sys/arch/amd64/conf/XEN3_DOMU
cvs rdiff -u -r1.19.4.3 -r1.19.4.4 src/sys/arch/i386/conf/XEN2_DOMU

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



CVS commit: [netbsd-5] src/sys/arch/arm/arm32

2013-01-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 20 12:13:28 UTC 2013

Modified Files:
src/sys/arch/arm/arm32 [netbsd-5]: cpu.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1841):
sys/arch/arm/arm32/cpu.c: revision 1.89
S/,/;/


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.4.1 src/sys/arch/arm/arm32/cpu.c

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

Modified files:

Index: src/sys/arch/arm/arm32/cpu.c
diff -u src/sys/arch/arm/arm32/cpu.c:1.71 src/sys/arch/arm/arm32/cpu.c:1.71.4.1
--- src/sys/arch/arm/arm32/cpu.c:1.71	Sat Oct 25 18:15:19 2008
+++ src/sys/arch/arm/arm32/cpu.c	Sun Jan 20 12:13:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.71 2008/10/25 18:15:19 matt Exp $	*/
+/*	$NetBSD: cpu.c,v 1.71.4.1 2013/01/20 12:13:28 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
 
 #include sys/param.h
 
-__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.71 2008/10/25 18:15:19 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpu.c,v 1.71.4.1 2013/01/20 12:13:28 bouyer Exp $);
 
 #include sys/systm.h
 #include sys/malloc.h
@@ -486,7 +486,7 @@ identify_arm_cpu(struct device *dv, stru
 		if (cpuids[i].cpuid == (cpuid  CPU_ID_CPU_MASK)) {
 			cpu_class = cpuids[i].cpu_class;
 			steppingstr = cpuids[i].cpu_steppings[cpuid 
-			CPU_ID_REVISION_MASK],
+			CPU_ID_REVISION_MASK];
 			sprintf(cpu_model, %s%s%s (%s core),
 			cpuids[i].cpu_name,
 			steppingstr[0] == '*' ?  :  ,



CVS commit: [netbsd-5] src/sys/arch/arm/arm32

2013-01-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 20 12:13:28 UTC 2013

Modified Files:
src/sys/arch/arm/arm32 [netbsd-5]: cpu.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1841):
sys/arch/arm/arm32/cpu.c: revision 1.89
S/,/;/


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.71.4.1 src/sys/arch/arm/arm32/cpu.c

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



CVS commit: [netbsd-5] src/sys/arch

2013-01-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 13 16:46:23 UTC 2013

Modified Files:
src/sys/arch/amd64/conf [netbsd-5]: XEN3_DOMU
src/sys/arch/i386/conf [netbsd-5]: XEN2_DOMU

Log Message:
apply patch(s) (requested by sborrill in ticket #1834):
sys/arch/i386/conf/XEN2_DOMU: patch
sys/arch/amd64/conf/XEN3_DOMU: patch
Add drvctl to Xen DOMU kernels


To generate a diff of this commit:
cvs rdiff -u -r1.13.4.2 -r1.13.4.3 src/sys/arch/amd64/conf/XEN3_DOMU
cvs rdiff -u -r1.19.4.2 -r1.19.4.3 src/sys/arch/i386/conf/XEN2_DOMU

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/conf/XEN3_DOMU
diff -u src/sys/arch/amd64/conf/XEN3_DOMU:1.13.4.2 src/sys/arch/amd64/conf/XEN3_DOMU:1.13.4.3
--- src/sys/arch/amd64/conf/XEN3_DOMU:1.13.4.2	Mon Feb 15 18:04:11 2010
+++ src/sys/arch/amd64/conf/XEN3_DOMU	Sun Jan 13 16:46:22 2013
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOMU,v 1.13.4.2 2010/02/15 18:04:11 sborrill Exp $
+# $NetBSD: XEN3_DOMU,v 1.13.4.3 2013/01/13 16:46:22 bouyer Exp $
 
 include 	arch/amd64/conf/std.xen
 
@@ -223,3 +223,6 @@ pseudo-device	vcoda		4	# coda minicache 
 
 # a pseudo device needed for SMBFS
 pseudo-device	nsmb			# experimental - SMB requester
+
+# userland interface to drivers, including autoconf and properties retrieval
+pseudo-device   drvctl

Index: src/sys/arch/i386/conf/XEN2_DOMU
diff -u src/sys/arch/i386/conf/XEN2_DOMU:1.19.4.2 src/sys/arch/i386/conf/XEN2_DOMU:1.19.4.3
--- src/sys/arch/i386/conf/XEN2_DOMU:1.19.4.2	Mon Feb 15 18:04:11 2010
+++ src/sys/arch/i386/conf/XEN2_DOMU	Sun Jan 13 16:46:22 2013
@@ -1,4 +1,4 @@
-# $NetBSD: XEN2_DOMU,v 1.19.4.2 2010/02/15 18:04:11 sborrill Exp $
+# $NetBSD: XEN2_DOMU,v 1.19.4.3 2013/01/13 16:46:22 bouyer Exp $
 
 include 	arch/xen/conf/std.xen
 
@@ -237,3 +237,6 @@ pseudo-device	vcoda		4	# coda minicache 
 
 # a pseudo device needed for SMBFS
 pseudo-device	nsmb			# experimental - SMB requester
+
+# userland interface to drivers, including autoconf and properties retrieval
+pseudo-device   drvctl



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

2012-11-27 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Nov 28 04:39:03 UTC 2012

Modified Files:
src/sys/arch/x86/include [netbsd-5]: specialreg.h

Log Message:
Pull up following revision(s) (requested by christos in ticket #1819):
sys/arch/x86/include/specialreg.h: revision 1.58
Add VIA Eden FCR MSR.


To generate a diff of this commit:
cvs rdiff -u -r1.31.4.1 -r1.31.4.2 src/sys/arch/x86/include/specialreg.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/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.31.4.1 src/sys/arch/x86/include/specialreg.h:1.31.4.2
--- src/sys/arch/x86/include/specialreg.h:1.31.4.1	Tue Jun 16 02:23:31 2009
+++ src/sys/arch/x86/include/specialreg.h	Wed Nov 28 04:39:03 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.31.4.1 2009/06/16 02:23:31 snj Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.31.4.2 2012/11/28 04:39:03 riz Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -360,6 +360,11 @@
 #define MSR_VIA_ACE_ENABLE	0x1000
 
 /*
+ * VIA Eden MSRs
+ */
+#define MSR_VIA_FCR 		MSR_VIA_ACE
+
+/*
  * AMD K6/K7 MSRs.
  */
 #define	MSR_K6_UWCCR		0xc085



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

2012-11-26 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Nov 26 19:44:27 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: identcpu.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1819):
sys/arch/x86/x86/identcpu.c: revision 1.31
PR/41267: Andrius V: 5.0 RC4 does not detect second CPU in VIA. VIA Eden cpuid
lies about it's ability to do cmpxchg8b. Turn the feature on using the FCR MSR.
Needs pullup to both 5 and 6.


To generate a diff of this commit:
cvs rdiff -u -r1.10.4.6 -r1.10.4.7 src/sys/arch/x86/x86/identcpu.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/identcpu.c
diff -u src/sys/arch/x86/x86/identcpu.c:1.10.4.6 src/sys/arch/x86/x86/identcpu.c:1.10.4.7
--- src/sys/arch/x86/x86/identcpu.c:1.10.4.6	Thu Apr 22 20:02:48 2010
+++ src/sys/arch/x86/x86/identcpu.c	Mon Nov 26 19:44:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: identcpu.c,v 1.10.4.6 2010/04/22 20:02:48 snj Exp $	*/
+/*	$NetBSD: identcpu.c,v 1.10.4.7 2012/11/26 19:44:26 riz Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: identcpu.c,v 1.10.4.6 2010/04/22 20:02:48 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: identcpu.c,v 1.10.4.7 2012/11/26 19:44:26 riz Exp $);
 
 #include opt_enhanced_speedstep.h
 #include opt_intel_odcm.h
@@ -387,13 +387,31 @@ static void
 cpu_probe_winchip(struct cpu_info *ci)
 {
 
-	if (cpu_vendor != CPUVENDOR_IDT ||
-	CPUID2FAMILY(ci-ci_signature) != 5)
+	if (cpu_vendor != CPUVENDOR_IDT)
 		return;
 
-	if (CPUID2MODEL(ci-ci_signature) == 4) {
-		/* WinChip C6 */
-		ci-ci_feature_flags = ~CPUID_TSC;
+	switch (CPUID2FAMILY(ci-ci_signature)) {
+	case 5:
+ 		/* WinChip C6 */
+		if (CPUID2MODEL(ci-ci_signature) == 4)
+			ci-ci_feature_flags = ~CPUID_TSC;
+		break;
+	case 6:
+		/*
+		 * VIA Eden ESP 
+		 *
+		 * Quoting from page 3-4 of: VIA Eden ESP Processor Datasheet
+		 * http://www.via.com.tw/download/mainboards/6/14/Eden20v115.pdf
+		 * 
+		 * 1. The CMPXCHG8B instruction is provided and always enabled,
+		 *however, it appears disabled in the corresponding CPUID
+		 *function bit 0 to avoid a bug in an early version of
+		 *Windows NT. However, this default can be changed via a
+		 *bit in the FCR MSR.
+		 */
+		ci-ci_feature_flags |= CPUID_CX8;
+		wrmsr(MSR_VIA_FCR, rdmsr(MSR_VIA_FCR) | 0x0001);
+		break;
 	}
 }
 



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

2012-11-26 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Mon Nov 26 19:44:27 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: identcpu.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1819):
sys/arch/x86/x86/identcpu.c: revision 1.31
PR/41267: Andrius V: 5.0 RC4 does not detect second CPU in VIA. VIA Eden cpuid
lies about it's ability to do cmpxchg8b. Turn the feature on using the FCR MSR.
Needs pullup to both 5 and 6.


To generate a diff of this commit:
cvs rdiff -u -r1.10.4.6 -r1.10.4.7 src/sys/arch/x86/x86/identcpu.c

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



CVS commit: [netbsd-5] src/sys/arch/macppc/dev

2012-11-06 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Nov  6 20:10:49 UTC 2012

Modified Files:
src/sys/arch/macppc/dev [netbsd-5]: awacs.c

Log Message:
Pull up following revision(s) (requested by phx in ticket #1816):
sys/arch/macppc/dev/awacs.c: revision 1.43
My PowerMac3,1 is using gpio4 to detect a connected headphone, and I would bet
that the same is true for PowerMac3,2.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.4.1 src/sys/arch/macppc/dev/awacs.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/macppc/dev/awacs.c
diff -u src/sys/arch/macppc/dev/awacs.c:1.35 src/sys/arch/macppc/dev/awacs.c:1.35.4.1
--- src/sys/arch/macppc/dev/awacs.c:1.35	Wed Aug 27 14:31:46 2008
+++ src/sys/arch/macppc/dev/awacs.c	Tue Nov  6 20:10:49 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: awacs.c,v 1.35 2008/08/27 14:31:46 jmcneill Exp $	*/
+/*	$NetBSD: awacs.c,v 1.35.4.1 2012/11/06 20:10:49 riz Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: awacs.c,v 1.35 2008/08/27 14:31:46 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: awacs.c,v 1.35.4.1 2012/11/06 20:10:49 riz Exp $);
 
 #include sys/param.h
 #include sys/audioio.h
@@ -281,7 +281,9 @@ static const char *detect_reversed[] = {
 	AAPL,3500,
 	NULL};
 
-static const char *use_gpio4[] = {	PowerMac3,3,
+static const char *use_gpio4[] = {	PowerMac3,1,
+	PowerMac3,2,
+	PowerMac3,3,
 	NULL};
 
 /*



CVS commit: [netbsd-5] src/sys/arch/macppc/dev

2012-11-06 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Nov  6 20:10:49 UTC 2012

Modified Files:
src/sys/arch/macppc/dev [netbsd-5]: awacs.c

Log Message:
Pull up following revision(s) (requested by phx in ticket #1816):
sys/arch/macppc/dev/awacs.c: revision 1.43
My PowerMac3,1 is using gpio4 to detect a connected headphone, and I would bet
that the same is true for PowerMac3,2.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.4.1 src/sys/arch/macppc/dev/awacs.c

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



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

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

Modified Files:
src/sys/arch/i386/i386 [netbsd-5]: locore.S

Log Message:
Pull up following revision(s) (requested by chs in ticket #1810):
sys/arch/i386/i386/locore.S: revision 1.103
in osyscall, set the PSL_I bit into the correct field of the trapframe.
it was going into tf_eip instead of tf_eflags, which would sometimes
corrupt %eip and always return to user mode with interrupts disabled.
this was found with a netbsd 1.0 binary, and dsl@ points out that
this should also fix PR 41342.


To generate a diff of this commit:
cvs rdiff -u -r1.78.4.3 -r1.78.4.4 src/sys/arch/i386/i386/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/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.78.4.3 src/sys/arch/i386/i386/locore.S:1.78.4.4
--- src/sys/arch/i386/i386/locore.S:1.78.4.3	Sat Apr  4 17:39:09 2009
+++ src/sys/arch/i386/i386/locore.S	Wed Oct 31 15:34:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.78.4.3 2009/04/04 17:39:09 snj Exp $	*/
+/*	$NetBSD: locore.S,v 1.78.4.4 2012/10/31 15:34:58 riz Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -134,7 +134,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.78.4.3 2009/04/04 17:39:09 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.78.4.4 2012/10/31 15:34:58 riz Exp $);
 
 #include opt_compat_oldboot.h
 #include opt_ddb.h
@@ -1081,7 +1081,7 @@ IDTVEC(osyscall)
 	cli			# must be first instruction
 	pushfl			# set eflags in trap frame
 	popl	8(%esp)
-	orl	$PSL_I,(%esp)	# re-enable ints on return to user
+	orl	$PSL_I,8(%esp)	# re-enable ints on return to user
 	pushl	$7		# size of instruction for restart
 	jmp	syscall1
 IDTVEC_END(osyscall)



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

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

Modified Files:
src/sys/arch/i386/i386 [netbsd-5]: locore.S

Log Message:
Pull up following revision(s) (requested by chs in ticket #1810):
sys/arch/i386/i386/locore.S: revision 1.103
in osyscall, set the PSL_I bit into the correct field of the trapframe.
it was going into tf_eip instead of tf_eflags, which would sometimes
corrupt %eip and always return to user mode with interrupts disabled.
this was found with a netbsd 1.0 binary, and dsl@ points out that
this should also fix PR 41342.


To generate a diff of this commit:
cvs rdiff -u -r1.78.4.3 -r1.78.4.4 src/sys/arch/i386/i386/locore.S

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



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

2012-10-26 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Oct 26 11:31:50 UTC 2012

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

Log Message:
Pull up the following revisions(s) (requested by royger in ticket #1805):
sys/arch/xen/xen/xengnt.c:  revision 1.25 via patch

Prevents a memory corruption issue that freezes a Xen DomU and can also
cause fs corruption. Addresses PR port-xen/47057 and port-xen/47056


To generate a diff of this commit:
cvs rdiff -u -r1.10.4.1 -r1.10.4.2 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.10.4.1 src/sys/arch/xen/xen/xengnt.c:1.10.4.2
--- src/sys/arch/xen/xen/xengnt.c:1.10.4.1	Sat Jan 30 19:14:20 2010
+++ src/sys/arch/xen/xen/xengnt.c	Fri Oct 26 11:31:50 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: xengnt.c,v 1.10.4.1 2010/01/30 19:14:20 snj Exp $  */
+/*  $NetBSD: xengnt.c,v 1.10.4.2 2012/10/26 11:31:50 sborrill Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xengnt.c,v 1.10.4.1 2010/01/30 19:14:20 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: xengnt.c,v 1.10.4.2 2012/10/26 11:31:50 sborrill Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -55,6 +55,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
+
 int gnt_nr_grant_frames;
 int gnt_max_grant_frames;
 
@@ -127,7 +130,7 @@ xengnt_more_entries()
 	gnttab_setup_table_t setup;
 	u_long *pages;
 	int nframes_new = gnt_nr_grant_frames + 1;
-	int i;
+	int i, start_gnt;
 
 	if (gnt_nr_grant_frames == gnt_max_grant_frames)
 		return ENOMEM;
@@ -167,9 +170,14 @@ xengnt_more_entries()
 
 	/*
 	 * 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);
@@ -206,7 +214,7 @@ xengnt_get_entry()
 	entry = gnt_entries[last_gnt_entry];
 	gnt_entries[last_gnt_entry] = XENGNT_NO_ENTRY;
 	splx(s);
-	KASSERT(entry != XENGNT_NO_ENTRY);
+	KASSERT(entry != XENGNT_NO_ENTRY  entry  NR_RESERVED_ENTRIES);
 	KASSERT(last_gnt_entry = 0  last_gnt_entry = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
 	return entry;
 }
@@ -218,6 +226,7 @@ static void
 xengnt_free_entry(grant_ref_t entry)
 {
 	int s = splvm();
+	KASSERT(entry  NR_RESERVED_ENTRIES);
 	KASSERT(gnt_entries[last_gnt_entry] == XENGNT_NO_ENTRY);
 	KASSERT(last_gnt_entry = 0  last_gnt_entry = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE);
 	gnt_entries[last_gnt_entry] = entry;



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

2012-10-26 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Oct 26 11:31:50 UTC 2012

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

Log Message:
Pull up the following revisions(s) (requested by royger in ticket #1805):
sys/arch/xen/xen/xengnt.c:  revision 1.25 via patch

Prevents a memory corruption issue that freezes a Xen DomU and can also
cause fs corruption. Addresses PR port-xen/47057 and port-xen/47056


To generate a diff of this commit:
cvs rdiff -u -r1.10.4.1 -r1.10.4.2 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.



CVS commit: [netbsd-5] src/sys/arch/vax/include

2012-08-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Aug 22 20:59:47 UTC 2012

Modified Files:
src/sys/arch/vax/include [netbsd-5]: cpu.h

Log Message:
Pull up following revision(s) (requested by abs in ticket #1780):
sys/arch/vax/include/cpu.h: revision 1.94 via patch
Change cpu_idle to be an inline which sets IPL to 1 and then back to 0
so simh can recognize the kernel is idle.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.85.14.1 src/sys/arch/vax/include/cpu.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/vax/include/cpu.h
diff -u src/sys/arch/vax/include/cpu.h:1.85 src/sys/arch/vax/include/cpu.h:1.85.14.1
--- src/sys/arch/vax/include/cpu.h:1.85	Tue Mar 11 05:34:02 2008
+++ src/sys/arch/vax/include/cpu.h	Wed Aug 22 20:59:47 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: cpu.h,v 1.85 2008/03/11 05:34:02 matt Exp $  */
+/*  $NetBSD: cpu.h,v 1.85.14.1 2012/08/22 20:59:47 bouyer Exp $  */
 
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden
@@ -165,7 +165,18 @@ extern int cpu_printfataltraps;
 #define	cpu_proc_fork(x, y)	do { } while (/*CONSCOND*/0)
 #define	cpu_lwp_free(l, f)	do { } while (/*CONSCOND*/0)
 #define	cpu_lwp_free2(l)	do { } while (/*CONSCOND*/0)
-#define	cpu_idle()		do { } while (/*CONSCOND*/0)
+
+/*
+ * This allows SIMH to recognize the kernel wants to sleep.
+ */
+static inline void
+cpu_idle(void)
+{
+	int ipl = mfpr(PR_IPL);
+	mtpr(1, PR_IPL);
+	mtpr(ipl, PR_IPL);
+}
+
 static inline bool
 cpu_intr_p(void)
 {



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

2012-08-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Aug 22 21:18:20 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: intel_busclock.c

Log Message:
sys/arch/x86/x86/intel_busclock.c   patch

Add support for Xeon E5
[sborrill, ticket #1787]


To generate a diff of this commit:
cvs rdiff -u -r1.5.10.4 -r1.5.10.5 src/sys/arch/x86/x86/intel_busclock.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/intel_busclock.c
diff -u src/sys/arch/x86/x86/intel_busclock.c:1.5.10.4 src/sys/arch/x86/x86/intel_busclock.c:1.5.10.5
--- src/sys/arch/x86/x86/intel_busclock.c:1.5.10.4	Tue Aug 31 10:50:22 2010
+++ src/sys/arch/x86/x86/intel_busclock.c	Wed Aug 22 21:18:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: intel_busclock.c,v 1.5.10.4 2010/08/31 10:50:22 bouyer Exp $	*/
+/*	$NetBSD: intel_busclock.c,v 1.5.10.5 2012/08/22 21:18:19 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.5.10.4 2010/08/31 10:50:22 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: intel_busclock.c,v 1.5.10.5 2012/08/22 21:18:19 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -98,7 +98,7 @@ p3_get_bus_clock(struct cpu_info *ci)
 		break;
 	case 0xc: /* Core i7, Atom, model 1 */
 		/*
-		 * XXX (See also case 0xe)
+		 * XXX (See also case 0xe and 0xd)
 		 * Some core i7 CPUs can report model 0xc.
 		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
 		 * In the long-term, use ACPI instead of all this.
@@ -121,7 +121,19 @@ p3_get_bus_clock(struct cpu_info *ci)
 			goto print_msr;
 		}
 		break;
-	case 0xd: /* Pentium M (90 nm, Dothan) */
+	case 0xd: /* Pentium M (90 nm, Dothan), some Xeons */
+		/*
+		 * XXX (See also case 0xc and 0xd)
+		 * Some Xeons can report model 0xd, e.g. E5-2630
+		 * Newer CPUs will GP when attemping to access MSR_FSB_FREQ.
+		 * In the long-term, use ACPI instead of all this.
+		 */
+		switch (CPUID2EXTMODEL(ci-ci_signature)) {
+		case 0x2:
+			aprint_debug(%s: unable to determine bus speed,
+			device_xname(ci-ci_dev));
+			goto print_msr;
+		}
 		msr = rdmsr(MSR_FSB_FREQ);
 		bus = (msr  0)  0x7;
 		switch (bus) {



CVS commit: [netbsd-5] src/sys/arch/vax/include

2012-08-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Aug 22 20:59:47 UTC 2012

Modified Files:
src/sys/arch/vax/include [netbsd-5]: cpu.h

Log Message:
Pull up following revision(s) (requested by abs in ticket #1780):
sys/arch/vax/include/cpu.h: revision 1.94 via patch
Change cpu_idle to be an inline which sets IPL to 1 and then back to 0
so simh can recognize the kernel is idle.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.85.14.1 src/sys/arch/vax/include/cpu.h

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



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

2012-08-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Aug 22 21:18:20 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: intel_busclock.c

Log Message:
sys/arch/x86/x86/intel_busclock.c   patch

Add support for Xeon E5
[sborrill, ticket #1787]


To generate a diff of this commit:
cvs rdiff -u -r1.5.10.4 -r1.5.10.5 src/sys/arch/x86/x86/intel_busclock.c

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



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

2012-06-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Jun 15 09:20:00 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: trap.c

Log Message:
Fix build fallout from ticket #1772 for Xen kernels


To generate a diff of this commit:
cvs rdiff -u -r1.52.4.3 -r1.52.4.4 src/sys/arch/amd64/amd64/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.52.4.3 src/sys/arch/amd64/amd64/trap.c:1.52.4.4
--- src/sys/arch/amd64/amd64/trap.c:1.52.4.3	Tue Jun 12 20:43:47 2012
+++ src/sys/arch/amd64/amd64/trap.c	Fri Jun 15 09:20:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.52.4.3 2012/06/12 20:43:47 riz Exp $	*/
+/*	$NetBSD: trap.c,v 1.52.4.4 2012/06/15 09:20:00 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.52.4.3 2012/06/12 20:43:47 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.52.4.4 2012/06/15 09:20:00 bouyer Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -183,7 +183,9 @@ trap(struct trapframe *frame)
 #if defined(COMPAT_10) || defined(COMPAT_IBCS2)
 	extern char IDTVEC(oosyscall)[];
 #endif
+#ifndef XEN
 	struct trapframe *vframe;
+#endif
 	void *onfault;
 	int error;
 	uint64_t cr2;



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

2012-06-15 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Jun 15 09:20:00 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: trap.c

Log Message:
Fix build fallout from ticket #1772 for Xen kernels


To generate a diff of this commit:
cvs rdiff -u -r1.52.4.3 -r1.52.4.4 src/sys/arch/amd64/amd64/trap.c

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



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

2012-06-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Jun 12 20:43:48 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: trap.c vector.S
src/sys/arch/amd64/include [netbsd-5]: frameasm.h

Log Message:
Pull up following revision(s) (requested by spz in ticket #1772):
sys/arch/amd64/amd64/trap.c: revision 1.71 via patch
sys/arch/amd64/amd64/vector.S: revision 1.41 via patch
sys/arch/amd64/include/frameasm.h: patch

Treat traps in kernel mode during the 'return to user' iret sequence
as user faults.
Based heavily in the i386 code with the correct opcode bytes inserted.
iret path tested, arranging for segment register errors is harder.
User %fs and %gs (32bit apps) are loaded much earlier and any errors
will generate kernel panics - there is probably code to try to stop
the invalid values being set.
If we get a fault setting the user %gs, or on a iret that is returning
to userspace, we must do a 'swapgs' to reload the kernel %gs_base.
Also save the %ds, %es, %fs, %gs selector values in the frame so
they can be restored if we finally return to user (probably after
an application SIGSEGV handler has fixed the error).
Without this any such fault leaves the kernel running with the wrong
%gs offset and it will most likely fault again early in trap().
Repeats until the stack tramples on something important.
iret change works, invalid %gs is a little harder to arrange.


To generate a diff of this commit:
cvs rdiff -u -r1.52.4.2 -r1.52.4.3 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.28.6.1 -r1.28.6.2 src/sys/arch/amd64/amd64/vector.S
cvs rdiff -u -r1.12 -r1.12.12.1 src/sys/arch/amd64/include/frameasm.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/amd64/amd64/trap.c
diff -u src/sys/arch/amd64/amd64/trap.c:1.52.4.2 src/sys/arch/amd64/amd64/trap.c:1.52.4.3
--- src/sys/arch/amd64/amd64/trap.c:1.52.4.2	Fri Aug 14 21:25:34 2009
+++ src/sys/arch/amd64/amd64/trap.c	Tue Jun 12 20:43:47 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.52.4.2 2009/08/14 21:25:34 snj Exp $	*/
+/*	$NetBSD: trap.c,v 1.52.4.3 2012/06/12 20:43:47 riz Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.52.4.2 2009/08/14 21:25:34 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.52.4.3 2012/06/12 20:43:47 riz Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -124,6 +124,7 @@ __KERNEL_RCSID(0, $NetBSD: trap.c,v 1.5
 #endif
 
 void trap(struct trapframe *);
+void trap_return_fault_return(struct trapframe *) __dead;
 
 const char *trap_type[] = {
 	privileged instruction fault,		/*  0 T_PRIVINFLT */
@@ -178,16 +179,11 @@ trap(struct trapframe *frame)
 	struct proc *p;
 	int type = (int)frame-tf_trapno;
 	struct pcb *pcb;
-	extern char fusuintrfailure[], kcopy_fault[],
-		resume_iret[];
+	extern char fusuintrfailure[], kcopy_fault[];
 #if defined(COMPAT_10) || defined(COMPAT_IBCS2)
 	extern char IDTVEC(oosyscall)[];
 #endif
-#if 0
-	extern char resume_pop_ds[], resume_pop_es[];
-#endif
 	struct trapframe *vframe;
-	void *resume;
 	void *onfault;
 	int error;
 	uint64_t cr2;
@@ -274,50 +270,78 @@ copyfault:
 
 		/*
 		 * Check for failure during return to user mode.
+		 * This can happen loading invalid values into the segment
+		 * registers, or during the 'iret' itself.
 		 *
-		 * XXXfvdl check for rex prefix?
-		 *
-		 * We do this by looking at the instruction we faulted on.  The
-		 * specific instructions we recognize only happen when
+		 * We do this by looking at the instruction we faulted on.
+		 * The specific instructions we recognize only happen when
 		 * returning from a trap, syscall, or interrupt.
-		 *
-		 * XXX
-		 * The heuristic used here will currently fail for the case of
-		 * one of the 2 pop instructions faulting when returning from a
-		 * a fast interrupt.  This should not be possible.  It can be
-		 * fixed by rearranging the trap frame so that the stack format
-		 * at this point is the same as on exit from a `slow'
-		 * interrupt.
 		 */
-		switch (*(u_char *)frame-tf_rip) {
-		case 0xcf:	/* iret */
-			vframe = (void *)((uint64_t)frame-tf_rsp - 44);
-			resume = resume_iret;
-			break;
-/*
- * XXXfvdl these are illegal in long mode (not in compat mode, though)
- * and we do not take back the descriptors from the signal context anyway,
- * but may do so later for USER_LDT, in which case we need to intercept
- * other instructions (movl %eax, %Xs).
- */
-#if 0
-		case 0x1f:	/* popl %ds */
-			vframe = (void *)((uint64_t)frame-tf_rsp - 4);
-			resume = resume_pop_ds;
-			break;
-		case 0x07:	/* popl %es */
-			vframe = (void *)((uint64_t)frame-tf_rsp - 0);
-			resume = resume_pop_es;
+
+kernelfault:
+#ifdef XEN
+		/*
+		 * XXX: there has to be an equivalent 'problem'
+		 * but I (dsl) don't know exactly what happens!
+		 * For now panic the kernel.
+		

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

2012-06-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Jun 12 20:48:58 UTC 2012

Modified Files:
src/sys/arch/xen/xenbus [netbsd-5]: xenbus_probe.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1768):
sys/arch/xen/xenbus/xenbus_probe.c: revision 1.36
sys/arch/xen/xenbus/xenbus_probe.c: revision 1.37
Sort vif and vbd device IDs numerically so that attach order does not depend
on the order they are passed in through xenstore. While this works for
hand-crafted Xen configuration files, it does not work for XenServer, XCP or
EC2 instances. This means that adding an extra virtual disk can make the
domU unbootable.
ID is actually based on the Linux device major/minor so this approach isn't
entirely correct (for instance, you can specify devices to be non-contiguous
which doesn't fit too well with our autoconf approach), but it works as a
first approximation.
Tested by me on XenServer and riz@ on EC2. OK bouyer@
Fix problem where devices with ID 0 were skipped as invalid as it didn't
distinguish between numerical zero and invalid numeric string.


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.4 -r1.26.2.5 src/sys/arch/xen/xenbus/xenbus_probe.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_probe.c
diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.26.2.4 src/sys/arch/xen/xenbus/xenbus_probe.c:1.26.2.5
--- src/sys/arch/xen/xenbus/xenbus_probe.c:1.26.2.4	Fri Sep 23 12:44:52 2011
+++ src/sys/arch/xen/xenbus/xenbus_probe.c	Tue Jun 12 20:48:58 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_probe.c,v 1.26.2.4 2011/09/23 12:44:52 sborrill Exp $ */
+/* $NetBSD: xenbus_probe.c,v 1.26.2.5 2012/06/12 20:48:58 riz Exp $ */
 /**
  * Talks to Xen Store to figure out what devices we have.
  *
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xenbus_probe.c,v 1.26.2.4 2011/09/23 12:44:52 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: xenbus_probe.c,v 1.26.2.5 2012/06/12 20:48:58 riz Exp $);
 
 #if 0
 #define DPRINTK(fmt, args...) \
@@ -269,7 +269,8 @@ static int
 xenbus_probe_device_type(const char *path, const char *type,
 int (*create)(struct xenbus_device *))
 {
-	int err, i, msize;
+	int err, i, pos, msize;
+	int *lookup = NULL;
 	unsigned long state;
 	char **dir;
 	unsigned int dir_n = 0;
@@ -283,8 +284,62 @@ xenbus_probe_device_type(const char *pat
 	if (err)
 		return err;
 
-	for (i = 0; i  dir_n; i++) {
+	/* Only sort frontend devices i.e. create == NULL*/
+	if (dir_n  1  create == NULL) {
+		int minp;
+		unsigned long minv;
+		unsigned long *id;
+
+		lookup = malloc(sizeof(int) * dir_n, M_DEVBUF,
+		M_WAITOK | M_ZERO);
+		if (lookup == NULL)
+			panic(can't malloc lookup);
+
+		id = malloc(sizeof(unsigned long) * dir_n, M_DEVBUF,
+		M_WAITOK | M_ZERO);
+		if (id == NULL)
+			panic(can't malloc id);
+
+		/* Convert string values to numeric; skip invalid */
+		for (i = 0; i  dir_n; i++) {
+			/*
+			 * Add one to differentiate numerical zero from invalid
+			 * string. Has no effect on sort order.
+			 */
+			id[i] = strtoul(dir[i], ep, 10) + 1;
+			if (dir[i][0] == '\0' || *ep != '\0')
+id[i] = 0;
+		}
+		
+		/* Build lookup table in ascending order */
+		for (pos = 0; pos  dir_n; ) {
+			minv = UINT32_MAX;
+			minp = -1;
+			for (i = 0; i  dir_n; i++) {
+if (id[i]  minv  id[i]  0) {
+	minv = id[i];
+	minp = i;
+}
+			}
+			if (minp = 0) {
+lookup[pos++] = minp;
+id[minp] = 0;
+			}
+			else
+break;
+		}
+		
+		free(id, M_DEVBUF);
+		/* Adjust in case we had to skip non-numeric entries */
+		dir_n = pos;
+	}
+
+	for (pos = 0; pos  dir_n; pos++) {
 		err = 0;
+		if (lookup)
+			i = lookup[pos];
+		else
+			i = pos;
 		/*
 		 * add size of path to size of xenbus_device. xenbus_device
 		 * already has room for one char in xbusd_path.
@@ -361,6 +416,9 @@ xenbus_probe_device_type(const char *pat
 		talk_to_otherend(xbusd);
 	}
 	free(dir, M_DEVBUF);
+	if (lookup)
+		free(lookup, M_DEVBUF);
+	
 	return err;
 }
 



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

2012-06-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Jun 12 23:18:13 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: machdep.c netbsd32_machdep.c

Log Message:
Pull up following revision(s) (requested by spz in ticket #1773):
sys/arch/amd64/amd64/machdep.c: revision 1.184
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.77
If the user process provided a bogus signal handler address, kill it
now instead of trying to jump to the bogus address.


To generate a diff of this commit:
cvs rdiff -u -r1.102.4.13 -r1.102.4.14 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.55.4.3 -r1.55.4.4 \
src/sys/arch/amd64/amd64/netbsd32_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.102.4.13 src/sys/arch/amd64/amd64/machdep.c:1.102.4.14
--- src/sys/arch/amd64/amd64/machdep.c:1.102.4.13	Thu Apr 22 20:02:48 2010
+++ src/sys/arch/amd64/amd64/machdep.c	Tue Jun 12 23:18:13 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.102.4.13 2010/04/22 20:02:48 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.102.4.14 2012/06/12 23:18:13 riz Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008
@@ -112,7 +112,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.102.4.13 2010/04/22 20:02:48 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.102.4.14 2012/06/12 23:18:13 riz Exp $);
 
 /* #define XENDEBUG_LOW  */
 
@@ -634,6 +634,16 @@ sendsig(const ksiginfo_t *ksi, const sig
 	/* Remember that we're now on the signal stack. */
 	if (onstack)
 		l-l_sigstk.ss_flags |= SS_ONSTACK;
+
+	if ((vaddr_t)catcher = VM_MAXUSER_ADDRESS) {
+		/* 
+		 * process has given an invalid address for the
+		 * handler. Stop it, but do not do it before so
+		 * we can return the right info to userland (or in core dump)
+		 */
+		sigexit(l, SIGILL);
+		/* NOTREACHED */
+	}
 }
 
 void 

Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c
diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.55.4.3 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.55.4.4
--- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.55.4.3	Tue Sep  7 19:38:20 2010
+++ src/sys/arch/amd64/amd64/netbsd32_machdep.c	Tue Jun 12 23:18:13 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.55.4.3 2010/09/07 19:38:20 bouyer Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.55.4.4 2012/06/12 23:18:13 riz Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: netbsd32_machdep.c,v 1.55.4.3 2010/09/07 19:38:20 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: netbsd32_machdep.c,v 1.55.4.4 2012/06/12 23:18:13 riz Exp $);
 
 #include opt_compat_netbsd.h
 #include opt_coredump.h
@@ -278,6 +278,16 @@ netbsd32_sendsig_sigcontext(const ksigin
 	/* Remember that we're now on the signal stack. */
 	if (onstack)
 		l-l_sigstk.ss_flags |= SS_ONSTACK;
+
+	if ((vaddr_t)catcher = VM_MAXUSER_ADDRESS32) {
+		/*
+		 * process has given an invalid address for the
+		 * handler. Stop it, but do not do it before so
+		 * we can return the right info to userland (or in core dump)
+		 */
+		sigexit(l, SIGILL);
+		/* NOTREACHED */
+	}
 }
 #endif
 
@@ -366,6 +376,16 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	/* Remember that we're now on the signal stack. */
 	if (onstack)
 		l-l_sigstk.ss_flags |= SS_ONSTACK;
+
+	if ((vaddr_t)catcher = VM_MAXUSER_ADDRESS32) {
+		/*
+		 * process has given an invalid address for the
+		 * handler. Stop it, but do not do it before so
+		 * we can return the right info to userland (or in core dump)
+		 */
+		sigexit(l, SIGILL);
+		/* NOTREACHED */
+	}
 }
 
 void



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

2012-06-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Jun 12 20:43:48 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: trap.c vector.S
src/sys/arch/amd64/include [netbsd-5]: frameasm.h

Log Message:
Pull up following revision(s) (requested by spz in ticket #1772):
sys/arch/amd64/amd64/trap.c: revision 1.71 via patch
sys/arch/amd64/amd64/vector.S: revision 1.41 via patch
sys/arch/amd64/include/frameasm.h: patch

Treat traps in kernel mode during the 'return to user' iret sequence
as user faults.
Based heavily in the i386 code with the correct opcode bytes inserted.
iret path tested, arranging for segment register errors is harder.
User %fs and %gs (32bit apps) are loaded much earlier and any errors
will generate kernel panics - there is probably code to try to stop
the invalid values being set.
If we get a fault setting the user %gs, or on a iret that is returning
to userspace, we must do a 'swapgs' to reload the kernel %gs_base.
Also save the %ds, %es, %fs, %gs selector values in the frame so
they can be restored if we finally return to user (probably after
an application SIGSEGV handler has fixed the error).
Without this any such fault leaves the kernel running with the wrong
%gs offset and it will most likely fault again early in trap().
Repeats until the stack tramples on something important.
iret change works, invalid %gs is a little harder to arrange.


To generate a diff of this commit:
cvs rdiff -u -r1.52.4.2 -r1.52.4.3 src/sys/arch/amd64/amd64/trap.c
cvs rdiff -u -r1.28.6.1 -r1.28.6.2 src/sys/arch/amd64/amd64/vector.S
cvs rdiff -u -r1.12 -r1.12.12.1 src/sys/arch/amd64/include/frameasm.h

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



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

2012-06-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Tue Jun 12 20:48:58 UTC 2012

Modified Files:
src/sys/arch/xen/xenbus [netbsd-5]: xenbus_probe.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1768):
sys/arch/xen/xenbus/xenbus_probe.c: revision 1.36
sys/arch/xen/xenbus/xenbus_probe.c: revision 1.37
Sort vif and vbd device IDs numerically so that attach order does not depend
on the order they are passed in through xenstore. While this works for
hand-crafted Xen configuration files, it does not work for XenServer, XCP or
EC2 instances. This means that adding an extra virtual disk can make the
domU unbootable.
ID is actually based on the Linux device major/minor so this approach isn't
entirely correct (for instance, you can specify devices to be non-contiguous
which doesn't fit too well with our autoconf approach), but it works as a
first approximation.
Tested by me on XenServer and riz@ on EC2. OK bouyer@
Fix problem where devices with ID 0 were skipped as invalid as it didn't
distinguish between numerical zero and invalid numeric string.


To generate a diff of this commit:
cvs rdiff -u -r1.26.2.4 -r1.26.2.5 src/sys/arch/xen/xenbus/xenbus_probe.c

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



CVS commit: [netbsd-5] src/sys/arch/x68k/x68k

2012-06-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jun  3 08:46:36 UTC 2012

Modified Files:
src/sys/arch/x68k/x68k [netbsd-5]: clock.c

Log Message:
Pull up revision 1.34 (requested by isaki in ticket #1765).

With the freerunnnig mode, set 0 (=256count) not 0xff (=255count)
in Timer-D.  It fixes the clock ticked faster when timecounter uses
mfp (as default choice).  It was introduced in rev 1.24 in 2006.
Thanks tsutsui@ for many comments.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.6.1 src/sys/arch/x68k/x68k/clock.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/x68k/clock.c
diff -u src/sys/arch/x68k/x68k/clock.c:1.28 src/sys/arch/x68k/x68k/clock.c:1.28.6.1
--- src/sys/arch/x68k/x68k/clock.c:1.28	Wed Jun 25 08:14:59 2008
+++ src/sys/arch/x68k/x68k/clock.c	Sun Jun  3 08:46:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.28 2008/06/25 08:14:59 isaki Exp $	*/
+/*	$NetBSD: clock.c,v 1.28.6.1 2012/06/03 08:46:36 jdc Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.28 2008/06/25 08:14:59 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: clock.c,v 1.28.6.1 2012/06/03 08:46:36 jdc Exp $);
 
 #include clock.h
 
@@ -182,7 +182,7 @@ cpu_initclocks(void)
 	mfp_set_tcdr(CLOCKS_PER_SEC / hz);
 	mfp_bit_set_ierb(MFP_INTR_TIMER_C);
 
-	mfp_set_tddr(0xff);	/* maximum free run -- only 8 bits wide */
+	mfp_set_tddr(0);	/* maximum free run -- only 8 bits wide */
 	mfp_set_tcdcr(mfp_get_tcdcr() | 0x07);	/* 1/200 prescaler */
 
 	tc_init(tc);



CVS commit: [netbsd-5] src/sys/arch/x68k/x68k

2012-06-03 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Jun  3 08:46:36 UTC 2012

Modified Files:
src/sys/arch/x68k/x68k [netbsd-5]: clock.c

Log Message:
Pull up revision 1.34 (requested by isaki in ticket #1765).

With the freerunnnig mode, set 0 (=256count) not 0xff (=255count)
in Timer-D.  It fixes the clock ticked faster when timecounter uses
mfp (as default choice).  It was introduced in rev 1.24 in 2006.
Thanks tsutsui@ for many comments.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.6.1 src/sys/arch/x68k/x68k/clock.c

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



CVS commit: [netbsd-5] src/sys/arch

2012-05-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat May 19 16:37:14 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: db_memrw.c
src/sys/arch/i386/i386 [netbsd-5]: db_memrw.c

Log Message:
Pull up following revision(s) (requested by jym in ticket #1754):
sys/arch/amd64/amd64/db_memrw.c: revision 1.10
sys/arch/amd64/amd64/db_memrw.c: revision 1.11
sys/arch/i386/i386/db_memrw.c: revision 1.29
Use the current destination address to compute PTE, not the address of
origin.
Harmless, except when db_write_text() passes a page boundary.
 From Bug Hunting.
XXX has to be pulled up to -5 and -6.
invlpg on a non canonical address is a noop, so no chance to invalidate
the TLB and the CPU will not notice the access right change.
This results in write protection faults in supervisor mode when patching
kernel code through ddb(4) (originally mapped as read only).
Bug reported by David Laight on port-amd64@ (thanks!), patch and test by
me.
i386 is unaffected as PG_LGFRAME does not mask the sign bits. For the
sake of correctness, use VA_SIGN_NEG(...) anyway.
XXX this is the patch that will be pulled-up to -5 and -6.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.10.1 src/sys/arch/amd64/amd64/db_memrw.c
cvs rdiff -u -r1.24.10.1 -r1.24.10.2 src/sys/arch/i386/i386/db_memrw.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/db_memrw.c
diff -u src/sys/arch/amd64/amd64/db_memrw.c:1.6 src/sys/arch/amd64/amd64/db_memrw.c:1.6.10.1
--- src/sys/arch/amd64/amd64/db_memrw.c:1.6	Mon Apr 28 20:23:12 2008
+++ src/sys/arch/amd64/amd64/db_memrw.c	Sat May 19 16:37:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.6 2008/04/28 20:23:12 martin Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.6.10.1 2012/05/19 16:37:14 riz Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.6 2008/04/28 20:23:12 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.6.10.1 2012/05/19 16:37:14 riz Exp $);
 
 #include opt_xen.h
 
@@ -115,7 +115,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
+		pte = kvtopte((vaddr_t)dst);
 		oldpte = *pte;
 
 		if ((oldpte  PG_V) == 0) {
@@ -127,7 +127,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * Get the VA for the page.
 		 */
 		if (oldpte  PG_PS)
-			pgva = (vaddr_t)dst  PG_LGFRAME;
+			pgva = VA_SIGN_NEG((vaddr_t)dst  PG_LGFRAME);
 		else
 			pgva = x86_trunc_page(dst);
 

Index: src/sys/arch/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.24.10.1 src/sys/arch/i386/i386/db_memrw.c:1.24.10.2
--- src/sys/arch/i386/i386/db_memrw.c:1.24.10.1	Wed Sep 30 00:08:03 2009
+++ src/sys/arch/i386/i386/db_memrw.c	Sat May 19 16:37:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.24.10.1 2009/09/30 00:08:03 snj Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.24.10.2 2012/05/19 16:37:14 riz Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.24.10.1 2009/09/30 00:08:03 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.24.10.2 2012/05/19 16:37:14 riz Exp $);
 
 #include opt_xen.h
 
@@ -111,7 +111,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
+		pte = kvtopte((vaddr_t)dst);
 		oldpte = *pte;
 
 		if ((oldpte  PG_V) == 0) {



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

2012-05-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat May 19 16:39:24 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by gendalia in ticket #1755):
sys/arch/x86/pci/pci_machdep.c: revision 1.36
add SIS 740 to the list of chipsets known to implement PCI configuration
mode 1 incorrectly, from Jason White
(see thread ACPI issue with old Shuttle system on port-i386)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.10.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.34 src/sys/arch/x86/pci/pci_machdep.c:1.34.10.1
--- src/sys/arch/x86/pci/pci_machdep.c:1.34	Mon Apr 28 20:23:40 2008
+++ src/sys/arch/x86/pci/pci_machdep.c	Sat May 19 16:39:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.34 2008/04/28 20:23:40 martin Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.34.10.1 2012/05/19 16:39:24 riz Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.34 2008/04/28 20:23:40 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.34.10.1 2012/05/19 16:39:24 riz Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -168,6 +168,8 @@ struct {
 	/* Parallels Desktop for Mac */
 	_qe(0, 2, 0, PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_VIDEO),
 	_qe(0, 3, 0, PCI_VENDOR_PARALLELS, PCI_PRODUCT_PARALLELS_TOOLS),
+	/* SIS 740 */
+	_qe(0, 0, 0, PCI_VENDOR_SIS, PCI_PRODUCT_SIS_740),
 	/* SIS 741 */
 	_qe(0, 0, 0, PCI_VENDOR_SIS, PCI_PRODUCT_SIS_741),
 	{0, 0x} /* patchable */



CVS commit: [netbsd-5] src/sys/arch

2012-05-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat May 19 16:37:14 UTC 2012

Modified Files:
src/sys/arch/amd64/amd64 [netbsd-5]: db_memrw.c
src/sys/arch/i386/i386 [netbsd-5]: db_memrw.c

Log Message:
Pull up following revision(s) (requested by jym in ticket #1754):
sys/arch/amd64/amd64/db_memrw.c: revision 1.10
sys/arch/amd64/amd64/db_memrw.c: revision 1.11
sys/arch/i386/i386/db_memrw.c: revision 1.29
Use the current destination address to compute PTE, not the address of
origin.
Harmless, except when db_write_text() passes a page boundary.
 From Bug Hunting.
XXX has to be pulled up to -5 and -6.
invlpg on a non canonical address is a noop, so no chance to invalidate
the TLB and the CPU will not notice the access right change.
This results in write protection faults in supervisor mode when patching
kernel code through ddb(4) (originally mapped as read only).
Bug reported by David Laight on port-amd64@ (thanks!), patch and test by
me.
i386 is unaffected as PG_LGFRAME does not mask the sign bits. For the
sake of correctness, use VA_SIGN_NEG(...) anyway.
XXX this is the patch that will be pulled-up to -5 and -6.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.10.1 src/sys/arch/amd64/amd64/db_memrw.c
cvs rdiff -u -r1.24.10.1 -r1.24.10.2 src/sys/arch/i386/i386/db_memrw.c

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



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

2012-05-19 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat May 19 16:39:24 UTC 2012

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

Log Message:
Pull up following revision(s) (requested by gendalia in ticket #1755):
sys/arch/x86/pci/pci_machdep.c: revision 1.36
add SIS 740 to the list of chipsets known to implement PCI configuration
mode 1 incorrectly, from Jason White
(see thread ACPI issue with old Shuttle system on port-i386)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.10.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.



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

2012-05-08 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue May  8 12:11:46 UTC 2012

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c

Log Message:
Pull up the following revisions(s) (requested by riz in ticket #1748):
sys/arch/xen/xen/hypervisor.c:  revision 1.62 via patch

Retrieve and print the hypervisor extra (teeny) version.


To generate a diff of this commit:
cvs rdiff -u -r1.42.4.5 -r1.42.4.6 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.5 src/sys/arch/xen/xen/hypervisor.c:1.42.4.6
--- src/sys/arch/xen/xen/hypervisor.c:1.42.4.5	Mon Sep 26 09:56:54 2011
+++ src/sys/arch/xen/xen/hypervisor.c	Tue May  8 12:11:45 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $ */
+/* $NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -63,7 +63,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -239,13 +239,17 @@ hypervisor_attach(device_t parent, devic
 
 #endif /* NPCI */
 	union hypervisor_attach_cookie hac;
+	char xen_extra_version[XEN_EXTRAVERSION_LEN];
 
 	xenkernfs_init();
 
 #ifdef XEN3
 	xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
-	aprint_normal(: Xen version %d.%d\n, (xen_version  0x)  16,
-	   xen_version  0x);
+	memset(xen_extra_version, 0, sizeof(xen_extra_version));
+	HYPERVISOR_xen_version(XENVER_extraversion, xen_extra_version);
+	aprint_normal(: Xen version %d.%d%s\n,
+		(xen_version  0x)  16, xen_version  0x,
+		 xen_extra_version);
 
 	xengnt_init();
 



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

2012-05-08 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue May  8 15:51:14 UTC 2012

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c

Log Message:
Fix XEN2 build after last pullup


To generate a diff of this commit:
cvs rdiff -u -r1.42.4.6 -r1.42.4.7 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.6 src/sys/arch/xen/xen/hypervisor.c:1.42.4.7
--- src/sys/arch/xen/xen/hypervisor.c:1.42.4.6	Tue May  8 12:11:45 2012
+++ src/sys/arch/xen/xen/hypervisor.c	Tue May  8 15:51:13 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $ */
+/* $NetBSD: hypervisor.c,v 1.42.4.7 2012/05/08 15:51:13 sborrill Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -63,7 +63,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.6 2012/05/08 12:11:45 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.7 2012/05/08 15:51:13 sborrill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -230,6 +230,7 @@ hypervisor_attach(device_t parent, devic
 {
 #ifdef XEN3
 	int xen_version;
+	char xen_extra_version[XEN_EXTRAVERSION_LEN];
 #endif
 #if NPCI 0
 #ifndef XEN3
@@ -239,7 +240,6 @@ hypervisor_attach(device_t parent, devic
 
 #endif /* NPCI */
 	union hypervisor_attach_cookie hac;
-	char xen_extra_version[XEN_EXTRAVERSION_LEN];
 
 	xenkernfs_init();
 



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

2012-05-08 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue May  8 12:11:46 UTC 2012

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c

Log Message:
Pull up the following revisions(s) (requested by riz in ticket #1748):
sys/arch/xen/xen/hypervisor.c:  revision 1.62 via patch

Retrieve and print the hypervisor extra (teeny) version.


To generate a diff of this commit:
cvs rdiff -u -r1.42.4.5 -r1.42.4.6 src/sys/arch/xen/xen/hypervisor.c

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



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

2012-05-08 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Tue May  8 15:51:14 UTC 2012

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c

Log Message:
Fix XEN2 build after last pullup


To generate a diff of this commit:
cvs rdiff -u -r1.42.4.6 -r1.42.4.7 src/sys/arch/xen/xen/hypervisor.c

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



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

2012-04-21 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Apr 21 16:00:47 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: ioapic.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1747):
sys/arch/x86/x86/ioapic.c: revision 1.46
sys/arch/x86/x86/ioapic.c: revision 1.47
Mask all i8259 interrupts in ioapic_enable().
Should fix PR kern/45160.
Need i8259.h for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.38.6.1 -r1.38.6.2 src/sys/arch/x86/x86/ioapic.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/ioapic.c
diff -u src/sys/arch/x86/x86/ioapic.c:1.38.6.1 src/sys/arch/x86/x86/ioapic.c:1.38.6.2
--- src/sys/arch/x86/x86/ioapic.c:1.38.6.1	Tue Sep 29 23:55:49 2009
+++ src/sys/arch/x86/x86/ioapic.c	Sat Apr 21 16:00:47 2012
@@ -1,4 +1,4 @@
-/* 	$NetBSD: ioapic.c,v 1.38.6.1 2009/09/29 23:55:49 snj Exp $	*/
+/* 	$NetBSD: ioapic.c,v 1.38.6.2 2012/04/21 16:00:47 riz Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ioapic.c,v 1.38.6.1 2009/09/29 23:55:49 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: ioapic.c,v 1.38.6.2 2012/04/21 16:00:47 riz Exp $);
 
 #include opt_ddb.h
 
@@ -83,6 +83,7 @@ __KERNEL_RCSID(0, $NetBSD: ioapic.c,v 1
 #include machine/i82093var.h
 #include machine/i82489reg.h
 #include machine/i82489var.h
+#include machine/i8259.h
 #include machine/mpbiosvar.h
 #include machine/pio.h
 #include machine/pmap.h
@@ -461,6 +462,8 @@ ioapic_enable(void)
 	if (ioapics == NULL)
 		return;
 
+	i8259_setmask(0x);
+
 	if (ioapics-sc_flags  IOAPIC_PICMODE) {
 		aprint_debug_dev(ioapics-sc_dev,
  writing to IMCR to disable pics\n);



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

2012-04-21 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Apr 21 16:00:47 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: ioapic.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1747):
sys/arch/x86/x86/ioapic.c: revision 1.46
sys/arch/x86/x86/ioapic.c: revision 1.47
Mask all i8259 interrupts in ioapic_enable().
Should fix PR kern/45160.
Need i8259.h for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.38.6.1 -r1.38.6.2 src/sys/arch/x86/x86/ioapic.c

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



CVS commit: [netbsd-5] src/sys/arch/hp700/hp700

2012-03-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 30 19:29:24 UTC 2012

Modified Files:
src/sys/arch/hp700/hp700 [netbsd-5]: intr.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1745):
sys/arch/hp700/hp700/intr.c: revision 1.38
Check for HPPA_SID_KERNEL when checking for interrupt in the
mutex_enter critical section.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.10.1 src/sys/arch/hp700/hp700/intr.c

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

Modified files:

Index: src/sys/arch/hp700/hp700/intr.c
diff -u src/sys/arch/hp700/hp700/intr.c:1.15 src/sys/arch/hp700/hp700/intr.c:1.15.10.1
--- src/sys/arch/hp700/hp700/intr.c:1.15	Mon Apr 28 20:23:19 2008
+++ src/sys/arch/hp700/hp700/intr.c	Fri Mar 30 19:29:24 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.15 2008/04/28 20:23:19 martin Exp $	*/
+/*	$NetBSD: intr.c,v 1.15.10.1 2012/03/30 19:29:24 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intr.c,v 1.15 2008/04/28 20:23:19 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: intr.c,v 1.15.10.1 2012/03/30 19:29:24 bouyer Exp $);
 
 #define __MUTEX_PRIVATE
 
@@ -399,7 +399,8 @@ hppa_intr(struct trapframe *frame)
 	 * handlers need to aquire the mutex, they could
 	 * deadlock if the owner value is left unset.
 	 */
-	if (frame-tf_iioq_head = (u_int)mutex_enter_crit_start 
+	if (frame-tf_iisq_head == HPPA_SID_KERNEL 
+	frame-tf_iioq_head = (u_int)mutex_enter_crit_start 
 	frame-tf_iioq_head = (u_int)mutex_enter_crit_end 
 	frame-tf_ret0 != 0)
 		((kmutex_t *)frame-tf_arg0)-mtx_owner = (uintptr_t)curlwp;



CVS commit: [netbsd-5] src/sys/arch/hp700/hp700

2012-03-30 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Mar 30 19:29:24 UTC 2012

Modified Files:
src/sys/arch/hp700/hp700 [netbsd-5]: intr.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #1745):
sys/arch/hp700/hp700/intr.c: revision 1.38
Check for HPPA_SID_KERNEL when checking for interrupt in the
mutex_enter critical section.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.10.1 src/sys/arch/hp700/hp700/intr.c

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



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

2012-03-21 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Mar 21 21:29:32 UTC 2012

Modified Files:
src/sys/arch/i386/i386 [netbsd-5]: gdt.c machdep.c
src/sys/arch/i386/include [netbsd-5]: segments.h

Log Message:
Apply patch (requested by bouyer in ticket #1738).

Do not special-case XEN and always use the proper selectors for %fs and %gs
in buildcontext() and setregs(). The consequence was that signal handlers
would have the wrong %fs/%gs. Found by running atf tests under Xen/i386.


To generate a diff of this commit:
cvs rdiff -u -r1.45.10.1 -r1.45.10.2 src/sys/arch/i386/i386/gdt.c
cvs rdiff -u -r1.644.4.12 -r1.644.4.13 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.50.4.1 -r1.50.4.2 src/sys/arch/i386/include/segments.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/i386/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.45.10.1 src/sys/arch/i386/i386/gdt.c:1.45.10.2
--- src/sys/arch/i386/i386/gdt.c:1.45.10.1	Sat Apr  4 17:39:09 2009
+++ src/sys/arch/i386/i386/gdt.c	Wed Mar 21 21:29:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.45.10.1 2009/04/04 17:39:09 snj Exp $	*/
+/*	$NetBSD: gdt.c,v 1.45.10.2 2012/03/21 21:29:31 jdc Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.45.10.1 2009/04/04 17:39:09 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.45.10.2 2012/03/21 21:29:31 jdc Exp $);
 
 #include opt_multiprocessor.h
 #include opt_xen.h
@@ -66,7 +66,7 @@ void gdt_grow(int);
 int gdt_get_slot1(int);
 void gdt_put_slot1(int, int);
 
-static void
+void
 update_descriptor(union descriptor *table, union descriptor *entry)
 {
 #ifndef XEN

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.644.4.12 src/sys/arch/i386/i386/machdep.c:1.644.4.13
--- src/sys/arch/i386/i386/machdep.c:1.644.4.12	Thu Apr 22 20:02:48 2010
+++ src/sys/arch/i386/i386/machdep.c	Wed Mar 21 21:29:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.644.4.12 2010/04/22 20:02:48 snj Exp $	*/
+/*	$NetBSD: machdep.c,v 1.644.4.13 2012/03/21 21:29:31 jdc Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.644.4.12 2010/04/22 20:02:48 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.644.4.13 2012/03/21 21:29:31 jdc Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -577,6 +577,12 @@ i386_switch_context(lwp_t *l)
 
 	HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb-pcb_esp0);
 
+	/* Update TLS segment pointers */
+	update_descriptor(ci-ci_gdt[GUFS_SEL],
+			  (union descriptor *) pcb-pcb_fsd);
+	update_descriptor(ci-ci_gdt[GUGS_SEL], 
+			  (union descriptor *) pcb-pcb_gsd);
+
 #ifdef XEN3
 	struct physdev_op physop;
 	physop.cmd = PHYSDEVOP_SET_IOPL;
@@ -754,13 +760,8 @@ buildcontext(struct lwp *l, int sel, voi
 {
 	struct trapframe *tf = l-l_md.md_regs;
 
-#ifndef XEN
 	tf-tf_gs = GSEL(GUGS_SEL, SEL_UPL);
 	tf-tf_fs = GSEL(GUFS_SEL, SEL_UPL);
-#else
-	tf-tf_gs = GSEL(GUDATA_SEL, SEL_UPL);
-	tf-tf_fs = GSEL(GUDATA_SEL, SEL_UPL);
-#endif
 	tf-tf_es = GSEL(GUDATA_SEL, SEL_UPL);
 	tf-tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
 	tf-tf_eip = (int)catcher;
@@ -1034,13 +1035,8 @@ setregs(struct lwp *l, struct exec_packa
 	memcpy(pcb-pcb_gsd, gdt[GUDATA_SEL], sizeof(pcb-pcb_gsd));
 
 	tf = l-l_md.md_regs;
-#ifndef XEN
 	tf-tf_gs = GSEL(GUGS_SEL, SEL_UPL);
 	tf-tf_fs = GSEL(GUFS_SEL, SEL_UPL);
-#else
-	tf-tf_gs = LSEL(LUDATA_SEL, SEL_UPL);
-	tf-tf_fs = LSEL(LUDATA_SEL, SEL_UPL);
-#endif
 	tf-tf_es = LSEL(LUDATA_SEL, SEL_UPL);
 	tf-tf_ds = LSEL(LUDATA_SEL, SEL_UPL);
 	tf-tf_edi = 0;

Index: src/sys/arch/i386/include/segments.h
diff -u src/sys/arch/i386/include/segments.h:1.50.4.1 src/sys/arch/i386/include/segments.h:1.50.4.2
--- src/sys/arch/i386/include/segments.h:1.50.4.1	Tue Nov 18 01:56:59 2008
+++ src/sys/arch/i386/include/segments.h	Wed Mar 21 21:29:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: segments.h,v 1.50.4.1 2008/11/18 01:56:59 snj Exp $	*/
+/*	$NetBSD: segments.h,v 1.50.4.2 2012/03/21 21:29:31 jdc Exp $	*/
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -198,6 +198,7 @@ void setsegment(struct segment_descripto
 void setgdt(int, const void *, size_t, int, int, int, int);
 void unsetgate(struct gate_descriptor *);
 void cpu_init_idt(void);
+void update_descriptor(union descriptor *, union descriptor *);
 
 #if !defined(XEN)
 void idt_init(void);



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

2012-03-21 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Mar 21 21:29:32 UTC 2012

Modified Files:
src/sys/arch/i386/i386 [netbsd-5]: gdt.c machdep.c
src/sys/arch/i386/include [netbsd-5]: segments.h

Log Message:
Apply patch (requested by bouyer in ticket #1738).

Do not special-case XEN and always use the proper selectors for %fs and %gs
in buildcontext() and setregs(). The consequence was that signal handlers
would have the wrong %fs/%gs. Found by running atf tests under Xen/i386.


To generate a diff of this commit:
cvs rdiff -u -r1.45.10.1 -r1.45.10.2 src/sys/arch/i386/i386/gdt.c
cvs rdiff -u -r1.644.4.12 -r1.644.4.13 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.50.4.1 -r1.50.4.2 src/sys/arch/i386/include/segments.h

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



CVS commit: [netbsd-5] src/sys/arch/x68k/stand

2012-03-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Mar 17 18:38:57 UTC 2012

Modified Files:
src/sys/arch/x68k/stand [netbsd-5]: Makefile.booters
src/sys/arch/x68k/stand/boot [netbsd-5]: version
src/sys/arch/x68k/stand/boot_ufs [netbsd-5]: Makefile
src/sys/arch/x68k/stand/boot_ustar [netbsd-5]: Makefile
src/sys/arch/x68k/stand/libsa [netbsd-5]: Makefile

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1731):
sys/arch/x68k/stand/boot_ufs/Makefile: revision 1.26 via patch
sys/arch/x68k/stand/boot/version: revision 1.4 via patch
sys/arch/x68k/stand/libsa/Makefile: revision 1.27 via patch
sys/arch/x68k/stand/Makefile.booters: revision 1.7 via patch
sys/arch/x68k/stand/boot_ustar/Makefile: revision 1.19 via patch
Fix Error occurs, please reset boot problem on
X68030 + 060turbo in 060 mode, found on NetBSD booth
at OSC 2011 Hiroshima:
- use -D__daddr_t=int32_t for all bootloader files
  to avoid 64 bit ops in FFS
- explicitly specify -m68020-60 to avoid 64 bit mulsl/mulul
  instructions which need to be handled by 060SP emulation
  but not available in 060turbo IPL ROM
  (LFS still has uint64_t members even with 32bit daddr_t)
The problem was investigated (at least 1.6.2 bootloaders worked)
by Yasushi Oshima at OSC booth, and fixes have been confirmed
by Y.Sugahara on his 060turbo.  Thanks everyone!
Should also be pulled up to netbsd-5.
Bump version to denote 060turbo boot fix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.88.1 src/sys/arch/x68k/stand/Makefile.booters
cvs rdiff -u -r1.2 -r1.2.136.1 src/sys/arch/x68k/stand/boot/version
cvs rdiff -u -r1.23 -r1.23.4.1 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.15 -r1.15.4.1 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.22 -r1.22.28.1 src/sys/arch/x68k/stand/libsa/Makefile

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/stand/Makefile.booters
diff -u src/sys/arch/x68k/stand/Makefile.booters:1.4 src/sys/arch/x68k/stand/Makefile.booters:1.4.88.1
--- src/sys/arch/x68k/stand/Makefile.booters:1.4	Sun Dec 11 12:19:44 2005
+++ src/sys/arch/x68k/stand/Makefile.booters	Sat Mar 17 18:38:57 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.4 2005/12/11 12:19:44 christos Exp $
+#	$NetBSD: Makefile.booters,v 1.4.88.1 2012/03/17 18:38:57 bouyer Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -6,6 +6,8 @@ S?=	${.CURDIR}/../../../..
 
 CFLAGS+= -ffreestanding
 
+CPPFLAGS+=	-D__daddr_t=int32_t
+
 machine-links:
 	-rm -f machine  \
 	ln -s $S/arch/${MACHINE}/include machine

Index: src/sys/arch/x68k/stand/boot/version
diff -u src/sys/arch/x68k/stand/boot/version:1.2 src/sys/arch/x68k/stand/boot/version:1.2.136.1
--- src/sys/arch/x68k/stand/boot/version:1.2	Fri Nov  9 19:53:16 2001
+++ src/sys/arch/x68k/stand/boot/version	Sat Mar 17 18:38:56 2012
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.2 2001/11/09 19:53:16 scw Exp $
+$NetBSD: version,v 1.2.136.1 2012/03/17 18:38:56 bouyer Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -7,3 +7,4 @@ is taken as the current.
 0.3:	xxboot, ancient monolithic bootstrap program.
 1.0:	Initial version of the libsa-based bootstrap loader.
 1.1:	loadfile() update to avoid backwards seeks for ELF Program Headers.
+1.1.1:	Avoid exception on 68060 in UFS ops.

Index: src/sys/arch/x68k/stand/boot_ufs/Makefile
diff -u src/sys/arch/x68k/stand/boot_ufs/Makefile:1.23 src/sys/arch/x68k/stand/boot_ufs/Makefile:1.23.4.1
--- src/sys/arch/x68k/stand/boot_ufs/Makefile:1.23	Sat Oct 25 22:27:38 2008
+++ src/sys/arch/x68k/stand/boot_ufs/Makefile	Sat Mar 17 18:38:56 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2008/10/25 22:27:38 apb Exp $
+#	$NetBSD: Makefile,v 1.23.4.1 2012/03/17 18:38:56 bouyer Exp $
 
 NOMAN=		# defined
 
@@ -37,12 +37,13 @@ vers.c:	${VERSIONFILE}
 	${HOST_SH} ${S}/conf/newvers_stand.sh -DM ${.ALLSRC} ${MACHINE} ${NEWVERSWHAT}
 
 CFLAGS=	-Os -fomit-frame-pointer
+CFLAGS+= -m68020-60
 CFLAGS+= -W -Wall -Wstrict-prototypes -Wmissing-prototypes
 CPPFLAGS+= -DTEXTADDR=0x$(TEXT) -DBOOT_TEXTADDR=0x$(BOOT_TEXT)
 CPPFLAGS+= -DBOOT=\$(BOOT)\ -DBOOT_VERS=\$(VERSION)\
 CPPFLAGS+= -DSCSI_ADHOC_BOOTPART
 #CPPFLAGS+= -DBOOT_DEBUG
-CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS1 -DUSE_UFS2 -D__daddr_t=int32_t
+CPPFLAGS+= -DUSE_FFS -DUSE_LFS -DUSE_UFS1 -DUSE_UFS2
 CPPFLAGS+= -I${COMMONDIR} -I${LIBIOCS} -I${S} -I. -D_STANDALONE
 AFLAGS=	   ${CFLAGS:M-[ID]*}
 .if ${OBJECT_FMT} == ELF

Index: src/sys/arch/x68k/stand/boot_ustar/Makefile
diff -u src/sys/arch/x68k/stand/boot_ustar/Makefile:1.15 src/sys/arch/x68k/stand/boot_ustar/Makefile:1.15.4.1
--- src/sys/arch/x68k/stand/boot_ustar/Makefile:1.15	Sat Oct 25 22:27:38 2008
+++ src/sys/arch/x68k/stand/boot_ustar/Makefile	Sat Mar 17 18:38:57 2012
@@ -1,4 +1,4 

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

2012-03-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Mar 17 18:40:20 UTC 2012

Modified Files:
src/sys/arch/x68k/dev [netbsd-5]: kbd.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1732):
sys/arch/x68k/dev/kbd.c: revision 1.37
Calling psignal(9) (via EV_WAKEUP()) in interrupt handlers
could cause mutex error panic, so defer it via softint(9).
This should fix panic on heavy key strokes during running Xserver.
Should be pulled up to netbsd-5.
XXX: amiga and atari might have the similar problem?


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.6.1 src/sys/arch/x68k/dev/kbd.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/kbd.c
diff -u src/sys/arch/x68k/dev/kbd.c:1.35 src/sys/arch/x68k/dev/kbd.c:1.35.6.1
--- src/sys/arch/x68k/dev/kbd.c:1.35	Wed Jun 25 08:14:59 2008
+++ src/sys/arch/x68k/dev/kbd.c	Sat Mar 17 18:40:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: kbd.c,v 1.35 2008/06/25 08:14:59 isaki Exp $	*/
+/*	$NetBSD: kbd.c,v 1.35.6.1 2012/03/17 18:40:20 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kbd.c,v 1.35 2008/06/25 08:14:59 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: kbd.c,v 1.35.6.1 2012/03/17 18:40:20 bouyer Exp $);
 
 #include ite.h
 #include bell.h
@@ -350,7 +350,7 @@ kbdintr(void *arg)
 	fe-value = KEY_UP(c) ? VKEY_UP : VKEY_DOWN;
 	getmicrotime(fe-time);
 	sc-sc_events.ev_put = put;
-	EV_WAKEUP(sc-sc_events);
+	softint_schedule(sc-sc_softintr_cookie);
 
 	return 0;
 }
@@ -358,10 +358,14 @@ kbdintr(void *arg)
 void
 kbdsoftint(void *arg)			/* what if ite is not configured? */
 {
+	struct kbd_softc *sc = arg;
 	int s;
 
 	s = spltty();
 
+	if (sc-sc_event_mode)
+		EV_WAKEUP(sc-sc_events);
+
 	while(kbdgetoff  kbdputoff)
 		ite_filter(kbdbuf[kbdgetoff++  KBDBUFMASK]);
 	kbdgetoff = kbdputoff = 0;



CVS commit: [netbsd-5] src/sys/arch/x68k/stand

2012-03-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Mar 17 18:38:57 UTC 2012

Modified Files:
src/sys/arch/x68k/stand [netbsd-5]: Makefile.booters
src/sys/arch/x68k/stand/boot [netbsd-5]: version
src/sys/arch/x68k/stand/boot_ufs [netbsd-5]: Makefile
src/sys/arch/x68k/stand/boot_ustar [netbsd-5]: Makefile
src/sys/arch/x68k/stand/libsa [netbsd-5]: Makefile

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1731):
sys/arch/x68k/stand/boot_ufs/Makefile: revision 1.26 via patch
sys/arch/x68k/stand/boot/version: revision 1.4 via patch
sys/arch/x68k/stand/libsa/Makefile: revision 1.27 via patch
sys/arch/x68k/stand/Makefile.booters: revision 1.7 via patch
sys/arch/x68k/stand/boot_ustar/Makefile: revision 1.19 via patch
Fix Error occurs, please reset boot problem on
X68030 + 060turbo in 060 mode, found on NetBSD booth
at OSC 2011 Hiroshima:
- use -D__daddr_t=int32_t for all bootloader files
  to avoid 64 bit ops in FFS
- explicitly specify -m68020-60 to avoid 64 bit mulsl/mulul
  instructions which need to be handled by 060SP emulation
  but not available in 060turbo IPL ROM
  (LFS still has uint64_t members even with 32bit daddr_t)
The problem was investigated (at least 1.6.2 bootloaders worked)
by Yasushi Oshima at OSC booth, and fixes have been confirmed
by Y.Sugahara on his 060turbo.  Thanks everyone!
Should also be pulled up to netbsd-5.
Bump version to denote 060turbo boot fix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.88.1 src/sys/arch/x68k/stand/Makefile.booters
cvs rdiff -u -r1.2 -r1.2.136.1 src/sys/arch/x68k/stand/boot/version
cvs rdiff -u -r1.23 -r1.23.4.1 src/sys/arch/x68k/stand/boot_ufs/Makefile
cvs rdiff -u -r1.15 -r1.15.4.1 src/sys/arch/x68k/stand/boot_ustar/Makefile
cvs rdiff -u -r1.22 -r1.22.28.1 src/sys/arch/x68k/stand/libsa/Makefile

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



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

2012-03-17 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Mar 17 18:40:20 UTC 2012

Modified Files:
src/sys/arch/x68k/dev [netbsd-5]: kbd.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1732):
sys/arch/x68k/dev/kbd.c: revision 1.37
Calling psignal(9) (via EV_WAKEUP()) in interrupt handlers
could cause mutex error panic, so defer it via softint(9).
This should fix panic on heavy key strokes during running Xserver.
Should be pulled up to netbsd-5.
XXX: amiga and atari might have the similar problem?


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.35.6.1 src/sys/arch/x68k/dev/kbd.c

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



CVS commit: [netbsd-5] src/sys/arch

2012-02-24 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Feb 24 17:29:32 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: pmap.c
src/sys/arch/xen/x86 [netbsd-5]: x86_xpmap.c

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1729):
sys/arch/x86/x86/pmap.c:revision 1.170 via patch
sys/arch/xen/x86/x86_xpmap.c:   revision 1.40 via patch

Fix random kernel panic on domains with large memory.
May fix PR port-xen/38699


To generate a diff of this commit:
cvs rdiff -u -r1.74.4.3 -r1.74.4.4 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/arch/xen/x86/x86_xpmap.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.74.4.3 src/sys/arch/x86/x86/pmap.c:1.74.4.4
--- src/sys/arch/x86/x86/pmap.c:1.74.4.3	Thu Apr 22 20:02:48 2010
+++ src/sys/arch/x86/x86/pmap.c	Fri Feb 24 17:29:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.74.4.3 2010/04/22 20:02:48 snj Exp $	*/
+/*	$NetBSD: pmap.c,v 1.74.4.4 2012/02/24 17:29:32 sborrill Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -154,7 +154,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.74.4.3 2010/04/22 20:02:48 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.74.4.4 2012/02/24 17:29:32 sborrill Exp $);
 
 #include opt_user_ldt.h
 #include opt_lockdebug.h
@@ -535,7 +535,12 @@ static struct pool_cache pmap_pv_cache;
  * special VAs and the PTEs that map them
  */
 static pt_entry_t *csrc_pte, *cdst_pte, *zero_pte, *ptp_pte, *early_zero_pte;
-static char *csrcp, *cdstp, *zerop, *ptpp, *early_zerop;
+static char *csrcp, *cdstp, *zerop, *ptpp;
+#ifdef XEN
+char *early_zerop; /* also referenced from xen_pmap_bootstrap() */
+#else
+static char *early_zerop;
+#endif
 
 /*
  * pool and cache that PDPs are allocated from
@@ -1340,8 +1345,11 @@ pmap_bootstrap(vaddr_t kva_start)
 		 * when it's called for the first time.
 		 * XXXfvdl fix this for MULTIPROCESSOR later.
 		 */
-
+#ifdef XEN
+		/* early_zerop initialized in xen_pmap_bootstrap() */
+#else
 		early_zerop = (void *)(KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2);
+#endif
 		early_zero_pte = PTE_BASE + pl1_i((unsigned long)early_zerop);
 	}
 

Index: src/sys/arch/xen/x86/x86_xpmap.c
diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.11 src/sys/arch/xen/x86/x86_xpmap.c:1.11.4.1
--- src/sys/arch/xen/x86/x86_xpmap.c:1.11	Fri Oct 24 21:09:24 2008
+++ src/sys/arch/xen/x86/x86_xpmap.c	Fri Feb 24 17:29:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_xpmap.c,v 1.11 2008/10/24 21:09:24 jym Exp $	*/
+/*	$NetBSD: x86_xpmap.c,v 1.11.4.1 2012/02/24 17:29:32 sborrill Exp $	*/
 
 /*
  * Copyright (c) 2006 Mathieu Ropert m...@adviseo.fr
@@ -79,7 +79,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.11 2008/10/24 21:09:24 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: x86_xpmap.c,v 1.11.4.1 2012/02/24 17:29:32 sborrill Exp $);
 
 #include opt_xen.h
 #include opt_ddb.h
@@ -545,6 +545,7 @@ xen_pmap_bootstrap(void)
 	 *  - UAREA
 	 *  - dummy user PGD (x86_64)
 	 *  - HYPERVISOR_shared_info
+	 *  - early_zerop
 	 *  - ISA I/O mem (if needed)
 	 */
 	mapsize += UPAGES * NBPG;
@@ -552,6 +553,7 @@ xen_pmap_bootstrap(void)
 	mapsize += NBPG;
 #endif
 	mapsize += NBPG;
+	mapsize += NBPG;
 
 #ifdef DOM0OPS
 	if (xendomain_is_dom0()) {
@@ -639,6 +641,7 @@ xen_bootstrap_tables (vaddr_t old_pgd, v
 	vaddr_t page, avail, text_end, map_end;
 	int i;
 	extern char __data_start;
+	extern char *early_zerop; /* from pmap.c */
 
 	__PRINTK((xen_bootstrap_tables(0x%lx, 0x%lx, %d, %d)\n,
 	old_pgd, new_pgd, old_count, new_count));
@@ -652,6 +655,7 @@ xen_bootstrap_tables (vaddr_t old_pgd, v
 	 *  UAREA
 	 *  dummy user PGD (x86_64 only)/gdt page (i386 only)
 	 *  HYPERVISOR_shared_info
+	 *  early_zerop
 	 *  ISA I/O mem (if needed)
 	 */
 	map_end = new_pgd + ((new_count + l2_4_count) * NBPG);
@@ -659,6 +663,8 @@ xen_bootstrap_tables (vaddr_t old_pgd, v
 		map_end += (UPAGES + 1) * NBPG;
 		HYPERVISOR_shared_info = (shared_info_t *)map_end;
 		map_end += NBPG;
+		early_zerop = (char *)map_end;
+		map_end += NBPG;
 	}
 	/*
 	 * we always set atdevbase, as it's used by init386 to find the first



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

2012-02-24 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Feb 24 17:45:29 UTC 2012

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1730):
sys/arch/xen/xen/if_xennet_xenbus.c:revision 1.59 via patch

Fix receive stall on the domU side when buffers stay a long time in the
network stack or socket buffers.


To generate a diff of this commit:
cvs rdiff -u -r1.29.2.6 -r1.29.2.7 src/sys/arch/xen/xen/if_xennet_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/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.6 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.7
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.6	Thu May 19 21:13:07 2011
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Fri Feb 24 17:45:29 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.29.2.6 2011/05/19 21:13:07 bouyer Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.29.2.7 2012/02/24 17:45:29 sborrill Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -61,7 +61,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_xennet_xenbus.c,v 1.29.2.6 2011/05/19 21:13:07 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_xennet_xenbus.c,v 1.29.2.7 2012/02/24 17:45:29 sborrill Exp $);
 
 #include opt_xen.h
 #include opt_nfs_boot.h
@@ -130,7 +130,6 @@ int xennet_debug = 0xff;
 #endif
 
 #define GRANT_INVALID_REF -1 /* entry is free */
-#define GRANT_STACK_REF   -2 /* entry owned by the network stack */
 
 #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
 #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
@@ -192,6 +191,9 @@ struct xennet_xenbus_softc {
 static multicall_entry_t rx_mcl[NET_RX_RING_SIZE+1];
 static u_long xennet_pages[NET_RX_RING_SIZE];
 
+static pool_cache_t if_xennetrxbuf_cache;
+static int if_xennetrxbuf_cache_inited=0;
+
 static int  xennet_xenbus_match(device_t, cfdata_t, void *);
 static void xennet_xenbus_attach(device_t, device_t, void *);
 static int  xennet_xenbus_detach(device_t, int);
@@ -202,6 +204,7 @@ static void xennet_alloc_rx_buffer(struc
 static void xennet_free_rx_buffer(struct xennet_xenbus_softc *);
 static void xennet_tx_complete(struct xennet_xenbus_softc *);
 static void xennet_rx_mbuf_free(struct mbuf *, void *, size_t, void *);
+static void xennet_rx_free_req(struct xennet_rxreq *);
 static int  xennet_handler(void *);
 static int  xennet_talk_to_backend(struct xennet_xenbus_softc *);
 #ifdef XENNET_DEBUG_DUMP
@@ -278,6 +281,14 @@ xennet_xenbus_attach(device_t parent, de
 	sc-sc_xbusd = xa-xa_xbusd;
 	sc-sc_xbusd-xbusd_otherend_changed = xennet_backend_changed;
 
+	/* xenbus ensure 2 devices can't be probed at the same time */
+	if (if_xennetrxbuf_cache_inited == 0) {
+		if_xennetrxbuf_cache = pool_cache_init(PAGE_SIZE, 0, 0, 0,
+		xnfrx, NULL, IPL_VM, NULL, NULL, NULL);
+		if_xennetrxbuf_cache_inited = 1;
+	}
+		
+
 	/* initialize free RX and RX request lists */
 	SLIST_INIT(sc-sc_txreq_head);
 	for (i = 0; i  NET_TX_RING_SIZE; i++) {
@@ -291,13 +302,10 @@ xennet_xenbus_attach(device_t parent, de
 		struct xennet_rxreq *rxreq = sc-sc_rxreqs[i];
 		rxreq-rxreq_id = i;
 		rxreq-rxreq_sc = sc;
-		rxreq-rxreq_va = uvm_km_alloc(kernel_map,
-		PAGE_SIZE, PAGE_SIZE, UVM_KMF_WIRED | UVM_KMF_ZERO);
+		rxreq-rxreq_va = (vaddr_t)pool_cache_get_paddr(
+		if_xennetrxbuf_cache, PR_WAITOK, rxreq-rxreq_pa);
 		if (rxreq-rxreq_va == 0)
 			break;
-		if (!pmap_extract(pmap_kernel(), rxreq-rxreq_va,
-		rxreq-rxreq_pa))
-			panic(%s: no pa for mapped va ?, device_xname(self));
 		rxreq-rxreq_gntref = GRANT_INVALID_REF;
 		SLIST_INSERT_HEAD(sc-sc_rxreq_head, rxreq, rxreq_next);
 	}
@@ -560,7 +568,7 @@ xennet_alloc_rx_buffer(struct xennet_xen
 	RING_IDX i;
 	struct xennet_rxreq *req;
 	struct xen_memory_reservation reservation;
-	int s1, s2, otherend_id;
+	int s1, s2, otherend_id, notify;
 	paddr_t pfn;
 
 	otherend_id = sc-sc_xbusd-xbusd_otherend_id;
@@ -647,9 +655,10 @@ out_loop:
 	}
 
 	sc-sc_rx_ring.req_prod_pvt = req_prod + i;
-	RING_PUSH_REQUESTS(sc-sc_rx_ring);
-
+	RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(sc-sc_rx_ring, notify);
 	splx(s1);
+	if (notify)
+		hypervisor_notify_via_evtchn(sc-sc_evtchn);
 	return;
 }
 
@@ -669,14 +678,6 @@ xennet_free_rx_buffer(struct xennet_xenb
 	for (i = 0; i  NET_RX_RING_SIZE; i++) {
 		struct xennet_rxreq *rxreq = sc-sc_rxreqs[i];
 
-		/*
-		 * if the buffer is in transit in the network stack, wait for
-		 * the network stack to free it.
-		 */
-		while ((volatile grant_ref_t)rxreq-rxreq_gntref ==
-		GRANT_STACK_REF)
-			tsleep(xennet_xenbus_detach, PRIBIO, xnet_free, hz/2);
-
 		if (rxreq-rxreq_gntref != GRANT_INVALID_REF) {
 			/*
 			 * this req is still granted. Get back the page or
@@ -746,7 +747,20 @@ xennet_free_rx_buffer(struct xennet_xenb

CVS commit: [netbsd-5] src/sys/arch

2012-02-24 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Feb 24 17:29:32 UTC 2012

Modified Files:
src/sys/arch/x86/x86 [netbsd-5]: pmap.c
src/sys/arch/xen/x86 [netbsd-5]: x86_xpmap.c

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1729):
sys/arch/x86/x86/pmap.c:revision 1.170 via patch
sys/arch/xen/x86/x86_xpmap.c:   revision 1.40 via patch

Fix random kernel panic on domains with large memory.
May fix PR port-xen/38699


To generate a diff of this commit:
cvs rdiff -u -r1.74.4.3 -r1.74.4.4 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/arch/xen/x86/x86_xpmap.c

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



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

2012-02-04 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Feb  4 17:04:09 UTC 2012

Modified Files:
src/sys/arch/i386/conf [netbsd-5]: INSTALL_FLOPPY

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1719):
sys/arch/i386/conf/INSTALL_FLOPPY: revision 1.15
Add virtio driver to INSTALL_FLOPPY.
Requested by Matthias Scheler t...@netbsd.org for particular cases like
http://mail-index.netbsd.org/netbsd-users/2011/09/13/msg009128.html


To generate a diff of this commit:
cvs rdiff -u -r1.1.16.2 -r1.1.16.3 src/sys/arch/i386/conf/INSTALL_FLOPPY

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/INSTALL_FLOPPY
diff -u src/sys/arch/i386/conf/INSTALL_FLOPPY:1.1.16.2 src/sys/arch/i386/conf/INSTALL_FLOPPY:1.1.16.3
--- src/sys/arch/i386/conf/INSTALL_FLOPPY:1.1.16.2	Tue Nov 18 01:56:58 2008
+++ src/sys/arch/i386/conf/INSTALL_FLOPPY	Sat Feb  4 17:04:09 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: INSTALL_FLOPPY,v 1.1.16.2 2008/11/18 01:56:58 snj Exp $
+#	$NetBSD: INSTALL_FLOPPY,v 1.1.16.3 2012/02/04 17:04:09 bouyer Exp $
 #
 #	INSTALL - Installation kernel.
 #
@@ -742,6 +742,11 @@ url*	at uhub? port ?		# Realtek RTL8150L
 # Planetconnect Satellite receiver driver.
 #satlink0 at isa? port 0x300 drq 1
 
+# Virtio devices
+virtio*	at pci? dev ? function ?	# Virtio PCI device
+viomb*	at virtio?			# Virtio memory balloon device
+ld*	at virtio?			# Virtio disk device
+vioif*	at virtio?			# Virtio network device
 
 # Pull in optional local configuration
 cinclude arch/i386/conf/INSTALL.local



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

2012-02-04 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Feb  4 17:04:09 UTC 2012

Modified Files:
src/sys/arch/i386/conf [netbsd-5]: INSTALL_FLOPPY

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1719):
sys/arch/i386/conf/INSTALL_FLOPPY: revision 1.15
Add virtio driver to INSTALL_FLOPPY.
Requested by Matthias Scheler t...@netbsd.org for particular cases like
http://mail-index.netbsd.org/netbsd-users/2011/09/13/msg009128.html


To generate a diff of this commit:
cvs rdiff -u -r1.1.16.2 -r1.1.16.3 src/sys/arch/i386/conf/INSTALL_FLOPPY

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



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

2011-11-18 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Nov 18 21:09:24 UTC 2011

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

Log Message:
Pull up the following revisions(s) (requested by dholland in ticket #1687):
sys/arch/i386/i386/vector.S:revision 1.54

Keep interrupts disabled in NMI handler. Addresses PR/43007.


To generate a diff of this commit:
cvs rdiff -u -r1.42.6.3 -r1.42.6.4 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.42.6.3 src/sys/arch/i386/i386/vector.S:1.42.6.4
--- src/sys/arch/i386/i386/vector.S:1.42.6.3	Thu May 20 05:51:59 2010
+++ src/sys/arch/i386/i386/vector.S	Fri Nov 18 21:09:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.42.6.3 2010/05/20 05:51:59 snj Exp $	*/
+/*	$NetBSD: vector.S,v 1.42.6.4 2011/11/18 21:09:24 sborrill Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.42.6.3 2010/05/20 05:51:59 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.42.6.4 2011/11/18 21:09:24 sborrill Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -841,7 +841,10 @@ IDTVEC(trap00)
 IDTVEC(trap01)
 	BPTTRAP(T_TRCTRAP)
 IDTVEC(trap02)
-	ZTRAP(T_NMI)
+	pushl $0
+	pushl $(T_NMI)
+	INTRENTRY
+	jmp _C_LABEL(calltrap)
 IDTVEC(trap03)
 	BPTTRAP(T_BPTFLT)
 IDTVEC(trap04)



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

2011-11-02 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Nov  2 20:30:41 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1682):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.45
Guard against spurious xbdback_backend_changed() calls which would result
in the block device being opened twice. Fixes port-xen/45158,
although the underlying cause (multiple open of the same device not
properly handled any more) is not fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.20.4.6 -r1.20.4.7 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.20.4.6 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.7
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.6	Fri Aug 12 20:48:47 2011
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Wed Nov  2 20:30:41 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.20.4.7 2011/11/02 20:30:41 riz Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $);
+__KERNEL_RCSID(0, $NetBSD: xbdback_xenbus.c,v 1.20.4.7 2011/11/02 20:30:41 riz Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -674,10 +674,16 @@ xbdback_backend_changed(struct xenbus_wa
 	 */
 	if (err)
 		return;
-	if (xbdi-xbdi_status == CONNECTED  xbdi-xbdi_dev != dev) {
-		printf(xbdback %s: changing physical device from 0x%x to 
-		0x%lx not supported\n, xbusd-xbusd_path, xbdi-xbdi_dev,
-		dev);
+	/*
+	 * we can also fire up after having opened the device, don't try
+	 * to do it twice.
+	 */
+	if (xbdi-xbdi_vp != NULL) {
+		if (xbdi-xbdi_status == CONNECTED  xbdi-xbdi_dev != dev) {
+			printf(xbdback %s: changing physical device from 
+			0x%x to 0x%lx not supported\n,
+			xbusd-xbusd_path, xbdi-xbdi_dev, dev);
+		}
 		return;
 	}
 	xbdi-xbdi_dev = dev;



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

2011-11-02 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Nov  2 20:30:41 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1682):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.45
Guard against spurious xbdback_backend_changed() calls which would result
in the block device being opened twice. Fixes port-xen/45158,
although the underlying cause (multiple open of the same device not
properly handled any more) is not fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.20.4.6 -r1.20.4.7 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.



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

2011-11-02 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Nov  2 20:34:52 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1685):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.48
Fix bogus KASSERT: if there is a xbdi_io, xbdi_pendingreqs must *NOT* be 0.
Not sure why it has stayed unoticed for so long ...


To generate a diff of this commit:
cvs rdiff -u -r1.20.4.7 -r1.20.4.8 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.



CVS commit: [netbsd-5] src/sys/arch/i386/stand/lib

2011-10-16 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Oct 16 23:38:52 UTC 2011

Modified Files:
src/sys/arch/i386/stand/lib [netbsd-5]: gatea20.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #923):
sys/arch/i386/stand/lib/gatea20.c: revision 1.12
PR# kern/39726: Soekris 5501-60 boot/bootxx 120 second delay
PR# port-i386/41162: A20 gate legacy hook cause long pxeboot delay on Soekris
net5501
Remove calls to delay() before polling KBD registers in gateA20().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/arch/i386/stand/lib/gatea20.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/stand/lib/gatea20.c
diff -u src/sys/arch/i386/stand/lib/gatea20.c:1.11 src/sys/arch/i386/stand/lib/gatea20.c:1.11.4.1
--- src/sys/arch/i386/stand/lib/gatea20.c:1.11	Tue Oct 14 14:18:11 2008
+++ src/sys/arch/i386/stand/lib/gatea20.c	Sun Oct 16 23:38:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: gatea20.c,v 1.11 2008/10/14 14:18:11 ad Exp $	*/
+/*	$NetBSD: gatea20.c,v 1.11.4.1 2011/10/16 23:38:52 riz Exp $	*/
 
 /* extracted from freebsd:sys/i386/boot/biosboot/io.c */
 
@@ -67,12 +67,10 @@ gateA20(void)
 
 		outb(K_CMD, KC_CMD_WOUT);
 
-		delay(100);
 		while (inb(K_STATUS)  K_IBUF_FUL);
 
 		outb(K_RDWR, x_20);
 
-		delay(100);
 		while (inb(K_STATUS)  K_IBUF_FUL);
 
 		while (inb(K_STATUS)  K_OBUF_FUL)



CVS commit: [netbsd-5] src/sys/arch/i386/stand/lib

2011-10-16 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Oct 16 23:38:52 UTC 2011

Modified Files:
src/sys/arch/i386/stand/lib [netbsd-5]: gatea20.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #923):
sys/arch/i386/stand/lib/gatea20.c: revision 1.12
PR# kern/39726: Soekris 5501-60 boot/bootxx 120 second delay
PR# port-i386/41162: A20 gate legacy hook cause long pxeboot delay on Soekris
net5501
Remove calls to delay() before polling KBD registers in gateA20().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.4.1 src/sys/arch/i386/stand/lib/gatea20.c

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



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

2011-09-26 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Sep 26 09:56:55 UTC 2011

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c

Log Message:
Patch to fix build on Xen 2 (fallout from pullup #1672)


To generate a diff of this commit:
cvs rdiff -u -r1.42.4.4 -r1.42.4.5 src/sys/arch/xen/xen/hypervisor.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/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.4 src/sys/arch/xen/xen/hypervisor.c:1.42.4.5
--- src/sys/arch/xen/xen/hypervisor.c:1.42.4.4	Fri Sep 23 12:44:51 2011
+++ src/sys/arch/xen/xen/hypervisor.c	Mon Sep 26 09:56:54 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.42.4.4 2011/09/23 12:44:51 sborrill Exp $ */
+/* $NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -63,7 +63,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.4 2011/09/23 12:44:51 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.5 2011/09/26 09:56:54 sborrill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -100,7 +100,6 @@ __KERNEL_RCSID(0, $NetBSD: hypervisor.c
 #include xen/xen3-public/version.h
 #endif
 
-#if defined(DOM0OPS) || defined(XEN3)
 #include sys/dirent.h
 #include sys/stat.h
 #include sys/tree.h
@@ -108,6 +107,7 @@ __KERNEL_RCSID(0, $NetBSD: hypervisor.c
 #include miscfs/specfs/specdev.h
 #include miscfs/kernfs/kernfs.h
 #include xen/kernfs_machdep.h
+#if defined(DOM0OPS) || defined(XEN3)
 #include dev/isa/isavar.h
 #endif /* DOM0OPS || XEN3 */
 #ifdef XEN3



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

2011-09-26 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Mon Sep 26 09:56:55 UTC 2011

Modified Files:
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c

Log Message:
Patch to fix build on Xen 2 (fallout from pullup #1672)


To generate a diff of this commit:
cvs rdiff -u -r1.42.4.4 -r1.42.4.5 src/sys/arch/xen/xen/hypervisor.c

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



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

2011-09-23 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Sep 23 12:44:52 UTC 2011

Modified Files:
src/sys/arch/xen/conf [netbsd-5]: files.xen
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c
src/sys/arch/xen/xenbus [netbsd-5]: xenbus_dev.c xenbus_probe.c

Log Message:
Pull up the following revisions(s) (requested by jym in ticket #1672):
sys/arch/xen/conf/files.xen:revision 1.123 via patch
sys/arch/xen/xen/hypervisor.c:  revision 1.58 via patch
sys/arch/xen/xenbus/xenbus_dev.c:   revision 1.9
sys/arch/xen/xenbus/xenbus_probe.c: revision 1.35

Expose Xen kernfs entries inside a domU to make it possible to use pkgsrc's
sysutils/xentools inside a domU to query XenStore entries (or even modify
part of it if the domain has enough rights).


To generate a diff of this commit:
cvs rdiff -u -r1.88.4.6 -r1.88.4.7 src/sys/arch/xen/conf/files.xen
cvs rdiff -u -r1.42.4.3 -r1.42.4.4 src/sys/arch/xen/xen/hypervisor.c
cvs rdiff -u -r1.7 -r1.7.28.1 src/sys/arch/xen/xenbus/xenbus_dev.c
cvs rdiff -u -r1.26.2.3 -r1.26.2.4 src/sys/arch/xen/xenbus/xenbus_probe.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/conf/files.xen
diff -u src/sys/arch/xen/conf/files.xen:1.88.4.6 src/sys/arch/xen/conf/files.xen:1.88.4.7
--- src/sys/arch/xen/conf/files.xen:1.88.4.6	Fri Jan  7 01:42:55 2011
+++ src/sys/arch/xen/conf/files.xen	Fri Sep 23 12:44:51 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.xen,v 1.88.4.6 2011/01/07 01:42:55 riz Exp $
+#	$NetBSD: files.xen,v 1.88.4.7 2011/09/23 12:44:51 sborrill Exp $
 #	NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #	NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -181,7 +181,7 @@
 attach xenbus at xendevbus
 file arch/xen/xenbus/xenbus_client.c xenbus  xen3 needs-flag
 file arch/xen/xenbus/xenbus_comms.c xenbus  xen3 needs-flag
-file arch/xen/xenbus/xenbus_dev.c xenbus  xen3  dom0ops needs-flag
+file arch/xen/xenbus/xenbus_dev.c xenbus  xen3 needs-flag
 file arch/xen/xenbus/xenbus_probe.c xenbus  xen3 needs-flag
 file arch/xen/xenbus/xenbus_xs.c xenbus  xen3 needs-flag
 

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.42.4.3 src/sys/arch/xen/xen/hypervisor.c:1.42.4.4
--- src/sys/arch/xen/xen/hypervisor.c:1.42.4.3	Sun Oct  4 00:02:00 2009
+++ src/sys/arch/xen/xen/hypervisor.c	Fri Sep 23 12:44:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.42.4.3 2009/10/04 00:02:00 snj Exp $ */
+/* $NetBSD: hypervisor.c,v 1.42.4.4 2011/09/23 12:44:51 sborrill Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -63,7 +63,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.3 2009/10/04 00:02:00 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: hypervisor.c,v 1.42.4.4 2011/09/23 12:44:51 sborrill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -240,11 +240,8 @@
 #endif /* NPCI */
 	union hypervisor_attach_cookie hac;
 
-#ifdef DOM0OPS
-	if (xendomain_is_privileged()) {
-		xenkernfs_init();
-	}
-#endif
+	xenkernfs_init();
+
 #ifdef XEN3
 	xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
 	aprint_normal(: Xen version %d.%d\n, (xen_version  0x)  16,
@@ -408,8 +405,6 @@
 	return (UNCONF);
 }
 
-#if defined(DOM0OPS)
-
 #define DIR_MODE	(S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
 
 kernfs_parentdir_t *kernxen_pkt;
@@ -424,7 +419,6 @@
 	kernfs_addentry(NULL, dkt);
 	kernxen_pkt = KERNFS_ENTOPARENTDIR(dkt);
 }
-#endif /* DOM0OPS */
 
 #ifndef XEN3
 /* handler for the shutdown messages */

Index: src/sys/arch/xen/xenbus/xenbus_dev.c
diff -u src/sys/arch/xen/xenbus/xenbus_dev.c:1.7 src/sys/arch/xen/xenbus/xenbus_dev.c:1.7.28.1
--- src/sys/arch/xen/xenbus/xenbus_dev.c:1.7	Tue Nov 27 11:37:27 2007
+++ src/sys/arch/xen/xenbus/xenbus_dev.c	Fri Sep 23 12:44:52 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xenbus_dev.c,v 1.7 2007/11/27 11:37:27 pooka Exp $ */
+/* $NetBSD: xenbus_dev.c,v 1.7.28.1 2011/09/23 12:44:52 sborrill Exp $ */
 /*
  * xenbus_dev.c
  * 
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xenbus_dev.c,v 1.7 2007/11/27 11:37:27 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: xenbus_dev.c,v 1.7.28.1 2011/09/23 12:44:52 sborrill Exp $);
 
 #include opt_xen.h
 
@@ -92,10 +92,13 @@
 	PRIVCMD_MODE);
 	kernfs_addentry(kernxen_pkt, dkt);
 
-	kfst = KERNFS_ALLOCTYPE(xsd_port_fileops);
-	KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK);
-	KERNFS_INITENTRY(dkt, DT_REG, xsd_port, NULL, kfst, VREG, XSD_MODE);
-	kernfs_addentry(kernxen_pkt, dkt);
+	if (xendomain_is_dom0()) {
+		kfst = KERNFS_ALLOCTYPE(xsd_port_fileops);
+		KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK);
+		KERNFS_INITENTRY(dkt, DT_REG, xsd_port, NULL,
+		kfst, VREG, XSD_MODE);
+		kernfs_addentry(kernxen_pkt, dkt);
+	}
 }
 
 struct xenbus_dev_data {

Index: src/sys/arch/xen/xenbus/xenbus_probe.c
diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.26.2.3 

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

2011-09-23 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Sep 23 12:44:52 UTC 2011

Modified Files:
src/sys/arch/xen/conf [netbsd-5]: files.xen
src/sys/arch/xen/xen [netbsd-5]: hypervisor.c
src/sys/arch/xen/xenbus [netbsd-5]: xenbus_dev.c xenbus_probe.c

Log Message:
Pull up the following revisions(s) (requested by jym in ticket #1672):
sys/arch/xen/conf/files.xen:revision 1.123 via patch
sys/arch/xen/xen/hypervisor.c:  revision 1.58 via patch
sys/arch/xen/xenbus/xenbus_dev.c:   revision 1.9
sys/arch/xen/xenbus/xenbus_probe.c: revision 1.35

Expose Xen kernfs entries inside a domU to make it possible to use pkgsrc's
sysutils/xentools inside a domU to query XenStore entries (or even modify
part of it if the domain has enough rights).


To generate a diff of this commit:
cvs rdiff -u -r1.88.4.6 -r1.88.4.7 src/sys/arch/xen/conf/files.xen
cvs rdiff -u -r1.42.4.3 -r1.42.4.4 src/sys/arch/xen/xen/hypervisor.c
cvs rdiff -u -r1.7 -r1.7.28.1 src/sys/arch/xen/xenbus/xenbus_dev.c
cvs rdiff -u -r1.26.2.3 -r1.26.2.4 src/sys/arch/xen/xenbus/xenbus_probe.c

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



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

2011-08-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Aug 12 20:48:48 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1654):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.42
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.43
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.44
Make sure to call xbdback_trampoline() at splbio()
Several fixes to the continuation engine:
- make sure to enter the continuation loop at splbio(), and add some
  KASSERT() for this.
- When a flush operation is enqueued to the workqueue, make sure the
  continuation loop can't be restarted by a previous workqueue
  completion or an event. We can't restart it at this point because
  the flush even is still recorded as the current I/O.
  For this add a xbdback_co_cache_doflush_wait() which acts as a noop;
  the workqueue callback will restart the loop once the flush is complete.
Should fix kernel diagnostic assertion xbd_io-xio_mapped == 0 panics
reported by Jeff Rizzo on port-xen@.
Add a comment explaing why a flush workqueue is handled differently from
read/write workqueue requests.


To generate a diff of this commit:
cvs rdiff -u -r1.20.4.5 -r1.20.4.6 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.20.4.5 src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.6
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.20.4.5	Sat Jun 18 16:38:26 2011
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Fri Aug 12 20:48:47 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.20.4.5 2011/06/18 16:38:26 bouyer Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: xbdback_xenbus.c,v 1.20.4.5 2011/06/18 16:38:26 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: xbdback_xenbus.c,v 1.20.4.6 2011/08/12 20:48:47 riz Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -283,6 +283,7 @@
 static void *xbdback_co_cache_flush(struct xbdback_instance *, void *);
 static void *xbdback_co_cache_flush2(struct xbdback_instance *, void *);
 static void *xbdback_co_cache_doflush(struct xbdback_instance *, void *);
+static void *xbdback_co_cache_doflush_wait(struct xbdback_instance *, void *);
 
 static void *xbdback_co_io(struct xbdback_instance *, void *);
 static void *xbdback_co_io_gotreq(struct xbdback_instance *, void *);
@@ -941,6 +942,8 @@
 {
 	(void)obj;
 	if (xbdi-xbdi_io != NULL) {
+		KASSERT(xbdi-xbdi_io-xio_operation == BLKIF_OP_READ ||
+		xbdi-xbdi_io-xio_operation == BLKIF_OP_WRITE);
 		xbdi-xbdi_cont = xbdback_co_flush;
 		xbdi-xbdi_cont_aux = xbdback_co_main_done2;
 	} else {
@@ -966,8 +969,13 @@
 xbdback_co_cache_flush(struct xbdback_instance *xbdi, void *obj)
 {
 	(void)obj;
+	KASSERT(curcpu()-ci_ilevel = IPL_BIO);
 	XENPRINTF((xbdback_co_cache_flush %p %p\n, xbdi, obj));
 	if (xbdi-xbdi_io != NULL) {
+		/* Some I/Os are required for this instance. Process them. */
+		KASSERT(xbdi-xbdi_io-xio_operation == BLKIF_OP_READ ||
+		xbdi-xbdi_io-xio_operation == BLKIF_OP_WRITE);
+		KASSERT(xbdi-xbdi_pendingreqs == 0);
 		xbdi-xbdi_cont = xbdback_co_flush;
 		xbdi-xbdi_cont_aux = xbdback_co_cache_flush2;
 	} else {
@@ -982,7 +990,10 @@
 	(void)obj;
 	XENPRINTF((xbdback_co_cache_flush2 %p %p\n, xbdi, obj));
 	if (xbdi-xbdi_pendingreqs  0) {
-		/* event or iodone will restart processing */
+		/*
+		 * There are pending requests.
+		 * Event or iodone() will restart processing
+		 */
 		xbdi-xbdi_cont = NULL;
 		xbdi_put(xbdi);
 		return NULL;
@@ -1002,8 +1013,23 @@
 	xbd_io-xio_operation = xbdi-xbdi_xen_req.operation;
 	xbd_io-xio_flush_id = xbdi-xbdi_xen_req.id;
 	workqueue_enqueue(xbdback_workqueue, xbdi-xbdi_io-xio_work, NULL);
-	/* xbdback_do_io() will advance req pointer and restart processing */
-	xbdi-xbdi_cont = xbdback_co_cache_doflush;
+	/*
+	 * xbdback_do_io() will advance req pointer and restart processing.
+	 * Note that we could probably set xbdi-xbdi_io to NULL and
+	 * let the processing continue, but we really want to wait
+	 * for the flush to complete before doing any more work.
+	 */
+	xbdi-xbdi_cont = xbdback_co_cache_doflush_wait;
+	return NULL;
+}
+
+/* wait for the flush work to complete */
+static void *
+xbdback_co_cache_doflush_wait(struct xbdback_instance *xbdi, void *obj)
+{
+	(void)obj;
+	/* abort the continuation loop; xbdback_do_io() will restart it */
+	xbdi-xbdi_cont = xbdback_co_cache_doflush_wait;
 	return NULL;
 }
 
@@ -1027,7 +1053,9 @@
 		goto end;
 	}
 
-	if (xbdi-xbdi_xen_req.operation == BLKIF_OP_WRITE) {
+	KASSERT(req-operation == BLKIF_OP_READ ||
+	req-operation == BLKIF_OP_WRITE);
+	if (req-operation == 

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

2011-08-12 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Aug 12 20:48:48 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1654):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.42
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.43
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.44
Make sure to call xbdback_trampoline() at splbio()
Several fixes to the continuation engine:
- make sure to enter the continuation loop at splbio(), and add some
  KASSERT() for this.
- When a flush operation is enqueued to the workqueue, make sure the
  continuation loop can't be restarted by a previous workqueue
  completion or an event. We can't restart it at this point because
  the flush even is still recorded as the current I/O.
  For this add a xbdback_co_cache_doflush_wait() which acts as a noop;
  the workqueue callback will restart the loop once the flush is complete.
Should fix kernel diagnostic assertion xbd_io-xio_mapped == 0 panics
reported by Jeff Rizzo on port-xen@.
Add a comment explaing why a flush workqueue is handled differently from
read/write workqueue requests.


To generate a diff of this commit:
cvs rdiff -u -r1.20.4.5 -r1.20.4.6 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.



CVS commit: [netbsd-5] src/sys/arch

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jul 15 22:43:59 UTC 2011

Modified Files:
src/sys/arch/mvme68k/stand/libsa [netbsd-5]: exec_mvme.c
src/sys/arch/sun68k/stand/tapeboot [netbsd-5]: boot.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1639):
sys/arch/sun68k/stand/tapeboot/boot.c: revision 1.7 via patch
sys/arch/mvme68k/stand/libsa/exec_mvme.c: revision 1.16 via patch
Disable LOAD_BACKWARDS on tapeboot which can't seek backwards.
Fixes bootstrap tapeboot installation failure on TME reported from ryoon@.
Should be pulled up to netbsd-5.
(note netbsd-5 uses LOAD_NOTE instead of LOAD_BACKWARDS)
Avoid backward seek on tape boot.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.20.1 src/sys/arch/mvme68k/stand/libsa/exec_mvme.c
cvs rdiff -u -r1.5 -r1.5.88.1 src/sys/arch/sun68k/stand/tapeboot/boot.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/stand/libsa/exec_mvme.c
diff -u src/sys/arch/mvme68k/stand/libsa/exec_mvme.c:1.15 src/sys/arch/mvme68k/stand/libsa/exec_mvme.c:1.15.20.1
--- src/sys/arch/mvme68k/stand/libsa/exec_mvme.c:1.15	Sat Jan 12 09:54:32 2008
+++ src/sys/arch/mvme68k/stand/libsa/exec_mvme.c	Fri Jul 15 22:43:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_mvme.c,v 1.15 2008/01/12 09:54:32 tsutsui Exp $ */
+/*	$NetBSD: exec_mvme.c,v 1.15.20.1 2011/07/15 22:43:59 riz Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -56,7 +56,7 @@
 
 	lflags = LOAD_KERNEL;
 	if ((flag  RB_NOSYM) != 0 )
-		lflags = ~LOAD_SYM;
+		lflags = ~(LOAD_SYM | LOAD_NOTE);
 
 	marks[MARK_START] = KERN_LOADADDR;
 	if ((fd = loadfile(file, marks, lflags)) == -1)

Index: src/sys/arch/sun68k/stand/tapeboot/boot.c
diff -u src/sys/arch/sun68k/stand/tapeboot/boot.c:1.5 src/sys/arch/sun68k/stand/tapeboot/boot.c:1.5.88.1
--- src/sys/arch/sun68k/stand/tapeboot/boot.c:1.5	Sun Dec 11 12:19:29 2005
+++ src/sys/arch/sun68k/stand/tapeboot/boot.c	Fri Jul 15 22:43:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.5 2005/12/11 12:19:29 christos Exp $ */
+/*	$NetBSD: boot.c,v 1.5.88.1 2011/07/15 22:43:59 riz Exp $ */
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -107,7 +107,8 @@
 			printf(tapeboot: loading segment %s\n, file);
 
 		marks[MARK_START] = mark_start;
-		if ((fd = loadfile(file, marks, LOAD_KERNEL)) != -1) {
+		if ((fd = loadfile(file, marks,
+		LOAD_KERNEL  ~LOAD_NOTE)) != -1) {
 			break;
 		}
 		printf(tapeboot: segment %s: %s\n, file, strerror(errno));



CVS commit: [netbsd-5] src/sys/arch/x68k/x68k

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jul 15 22:46:06 UTC 2011

Modified Files:
src/sys/arch/x68k/x68k [netbsd-5]: locore.s

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1640):
sys/arch/x68k/x68k/locore.s: revision 1.102
Defer fpu_probe() call until curlwp and related variables are initialized.
Fixes pre-consinit KASSERT() in trap() caused by fnop instruction in
fpu_probe() on machines without FPU, including XM6i.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.84.6.1 src/sys/arch/x68k/x68k/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/x68k/x68k/locore.s
diff -u src/sys/arch/x68k/x68k/locore.s:1.84 src/sys/arch/x68k/x68k/locore.s:1.84.6.1
--- src/sys/arch/x68k/x68k/locore.s:1.84	Mon Jun 23 08:33:38 2008
+++ src/sys/arch/x68k/x68k/locore.s	Fri Jul 15 22:46:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.84 2008/06/23 08:33:38 isaki Exp $	*/
+/*	$NetBSD: locore.s,v 1.84.6.1 2011/07/15 22:46:06 riz Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -955,9 +955,6 @@
 /* select the software page size now */
 	lea	_ASM_LABEL(tmpstk),%sp	| temporary stack
 	jbsr	_C_LABEL(uvm_setpagesize)  | select software page size
-/* detect FPU type */
-	jbsr	_C_LABEL(fpu_probe)
-	movl	%d0,_C_LABEL(fputype)
 /* set kernel stack, user SP, and initial pcb */
 	movl	_C_LABEL(proc0paddr),%a1 | get lwp0 pcb addr
 	lea	%a1@(USPACE-4),%sp	| set kernel stack to end of area
@@ -968,6 +965,9 @@
 	movl	%a2,%usp		| init user SP
 	movl	%a1,_C_LABEL(curpcb)	| lwp0 is running
 
+/* detect FPU type */
+	jbsr	_C_LABEL(fpu_probe)
+	movl	%d0,_C_LABEL(fputype)
 	tstl	_C_LABEL(fputype)	| Have an FPU?
 	jeq	Lenab2			| No, skip.
 	clrl	%a1@(PCB_FPCTX)		| ensure null FP context



CVS commit: [netbsd-5] src/sys/arch/sparc64/dev

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Jul 16 00:14:57 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev [netbsd-5]: lom.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1641):
sys/arch/sparc64/dev/lom.c: revision 1.8
Limit reading from registers at most once every second with using
ratecheck(9).


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/arch/sparc64/dev/lom.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/dev/lom.c
diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.7 src/sys/arch/sparc64/dev/lom.c:1.1.2.8
--- src/sys/arch/sparc64/dev/lom.c:1.1.2.7	Sun Mar 20 21:23:32 2011
+++ src/sys/arch/sparc64/dev/lom.c	Sat Jul 16 00:14:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $	*/
+/*	$NetBSD: lom.c,v 1.1.2.8 2011/07/16 00:14:57 riz Exp $	*/
 /*	$OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $	*/
 /*
  * Copyright (c) 2009 Mark Kettenis
@@ -17,7 +17,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: lom.c,v 1.1.2.8 2011/07/16 00:14:57 riz Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -171,6 +171,12 @@
 
 	int32_t			sc_sysctl_num[LOM_MAX_ALARM];
 
+	struct timeval		sc_alarm_lastread;
+	uint8_t			sc_alarm_lastval;
+	struct timeval		sc_fan_lastread[LOM_MAX_FAN];
+	struct timeval		sc_psu_lastread[LOM_MAX_PSU];
+	struct timeval		sc_temp_lastread[LOM_MAX_TEMP];
+
 	uint8_t			sc_fan_cal[LOM_MAX_FAN];
 	uint8_t			sc_fan_low[LOM_MAX_FAN];
 
@@ -239,6 +245,7 @@
 static const char *nodedesc[LOM_MAX_ALARM] =
 { Fault LED status, Alarm1 status, Alarm2 status , Alarm3 status };
 #endif
+static const struct timeval refresh_interval = { 1, 0 };
 
 static int
 lom_match(device_t parent, cfdata_t match, void *aux)
@@ -1002,24 +1009,31 @@
 	/* Fault LED or Alarms */
 	KASSERT(i  sc-sc_num_alarm);
 
-	if (lom_read(sc, LOM_IDX_ALARM, val)) {
-		edata-state = ENVSYS_SINVALID;
-	} else {
-		if (i == 0) {
-			/* Fault LED */
-			if ((val  LOM_ALARM_FAULT) == LOM_ALARM_FAULT)
-edata-value_cur = 0;
-			else
-edata-value_cur = 1;
-		} else {
-			/* Alarms */
-			if ((val  (LOM_ALARM_1  (i - 1))) == 0)
-edata-value_cur = 0;
-			else
-edata-value_cur = 1;
+	/* Read new value at most once every second. */
+	if (ratecheck(sc-sc_alarm_lastread, refresh_interval)) {
+		if (lom_read(sc, LOM_IDX_ALARM, val)) {
+			edata-state = ENVSYS_SINVALID;
+			return;
 		}
-		edata-state = ENVSYS_SVALID;
+		sc-sc_alarm_lastval = val;
+	} else {
+		val = sc-sc_alarm_lastval;
+	}
+
+	if (i == 0) {
+		/* Fault LED */
+		if ((val  LOM_ALARM_FAULT) == LOM_ALARM_FAULT)
+			edata-value_cur = 0;
+		else
+			edata-value_cur = 1;
+	} else {
+		/* Alarms */
+		if ((val  (LOM_ALARM_1  (i - 1))) == 0)
+			edata-value_cur = 0;
+		else
+			edata-value_cur = 1;
 	}
+	edata-state = ENVSYS_SVALID;
 }
 
 static void
@@ -1030,6 +1044,10 @@
 	/* Fan speed */
 	KASSERT(i  sc-sc_num_fan);
 
+	/* Read new value at most once every second. */
+	if (!ratecheck(sc-sc_fan_lastread[i], refresh_interval))
+		return;
+
 	if (lom_read(sc, LOM_IDX_FAN1 + i, val)) {
 		edata-state = ENVSYS_SINVALID;
 	} else {
@@ -1049,6 +1067,10 @@
 	/* PSU status */
 	KASSERT(i  sc-sc_num_psu);
 
+	/* Read new value at most once every second. */
+	if (!ratecheck(sc-sc_psu_lastread[i], refresh_interval))
+		return;
+
 	if (lom_read(sc, LOM_IDX_PSU1 + i, val) ||
 	!ISSET(val, LOM_PSU_PRESENT)) {
 		edata-state = ENVSYS_SINVALID;
@@ -1076,6 +1098,10 @@
 	/* Temperature */
 	KASSERT(i  sc-sc_num_temp);
 
+	/* Read new value at most once every second. */
+	if (!ratecheck(sc-sc_temp_lastread[i], refresh_interval))
+		return;
+
 	if (lom_read(sc, LOM_IDX_TEMP1 + i, val)) {
 		edata-state = ENVSYS_SINVALID;
 	} else {



CVS commit: [netbsd-5] src/sys/arch

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jul 15 22:43:59 UTC 2011

Modified Files:
src/sys/arch/mvme68k/stand/libsa [netbsd-5]: exec_mvme.c
src/sys/arch/sun68k/stand/tapeboot [netbsd-5]: boot.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1639):
sys/arch/sun68k/stand/tapeboot/boot.c: revision 1.7 via patch
sys/arch/mvme68k/stand/libsa/exec_mvme.c: revision 1.16 via patch
Disable LOAD_BACKWARDS on tapeboot which can't seek backwards.
Fixes bootstrap tapeboot installation failure on TME reported from ryoon@.
Should be pulled up to netbsd-5.
(note netbsd-5 uses LOAD_NOTE instead of LOAD_BACKWARDS)
Avoid backward seek on tape boot.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.15.20.1 src/sys/arch/mvme68k/stand/libsa/exec_mvme.c
cvs rdiff -u -r1.5 -r1.5.88.1 src/sys/arch/sun68k/stand/tapeboot/boot.c

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



CVS commit: [netbsd-5] src/sys/arch/x68k/x68k

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jul 15 22:46:06 UTC 2011

Modified Files:
src/sys/arch/x68k/x68k [netbsd-5]: locore.s

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1640):
sys/arch/x68k/x68k/locore.s: revision 1.102
Defer fpu_probe() call until curlwp and related variables are initialized.
Fixes pre-consinit KASSERT() in trap() caused by fnop instruction in
fpu_probe() on machines without FPU, including XM6i.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.84.6.1 src/sys/arch/x68k/x68k/locore.s

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



CVS commit: [netbsd-5] src/sys/arch/sparc64/dev

2011-07-15 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sat Jul 16 00:14:57 UTC 2011

Modified Files:
src/sys/arch/sparc64/dev [netbsd-5]: lom.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #1641):
sys/arch/sparc64/dev/lom.c: revision 1.8
Limit reading from registers at most once every second with using
ratecheck(9).


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/arch/sparc64/dev/lom.c

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



CVS commit: [netbsd-5] src/sys/arch/m68k/fpe

2011-06-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jun 18 16:26:58 UTC 2011

Modified Files:
src/sys/arch/m68k/fpe [netbsd-5]: fpu_emulate.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.


To generate a diff of this commit:
cvs rdiff -u -r1.27.54.1 -r1.27.54.2 src/sys/arch/m68k/fpe/fpu_emulate.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/m68k/fpe/fpu_emulate.c
diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.27.54.1 src/sys/arch/m68k/fpe/fpu_emulate.c:1.27.54.2
--- src/sys/arch/m68k/fpe/fpu_emulate.c:1.27.54.1	Mon Jan 26 00:24:55 2009
+++ src/sys/arch/m68k/fpe/fpu_emulate.c	Sat Jun 18 16:26:58 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fpu_emulate.c,v 1.27.54.1 2009/01/26 00:24:55 snj Exp $	*/
+/*	$NetBSD: fpu_emulate.c,v 1.27.54.2 2011/06/18 16:26:58 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross
@@ -37,7 +37,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.27.54.1 2009/01/26 00:24:55 snj Exp $);
+__KERNEL_RCSID(0, $NetBSD: fpu_emulate.c,v 1.27.54.2 2011/06/18 16:26:58 bouyer Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -922,27 +922,34 @@
 if (res == NULL)
 	sig = SIGILL;
 
-if (!discard_result  sig == 0) {
-	fpu_implode(fe, res, FTYPE_EXT, fpregs[regnum * 3]);
+if (sig == 0) {
+	if (!discard_result)
+	fpu_implode(fe, res, FTYPE_EXT, fpregs[regnum * 3]);
 
 	/* update fpsr according to the result of operation */
 	fpu_upd_fpsr(fe, res);
 #if DEBUG_FPE
-	printf(fpu_emul_arith: %08x,%08x,%08x stored in FP%d\n,
-	   fpregs[regnum*3], fpregs[regnum*3+1],
-	   fpregs[regnum*3+2], regnum);
-} else if (sig == 0) {
-	static const char *class_name[] =
-	{ SNAN, QNAN, ZERO, NUM, INF };
-	printf(fpu_emul_arith: result(%s,%c,%d,%08x,%08x,%08x) discarded\n,
-	   class_name[res-fp_class + 2],
-	   res-fp_sign ? '-' : '+', res-fp_exp,
-	   res-fp_mant[0], res-fp_mant[1],
-	   res-fp_mant[2]);
-} else {
-	printf(fpu_emul_arith: received signal %d\n, sig);
+	if (!discard_result) {
+	printf(fpu_emul_arith: %08x,%08x,%08x stored in FP%d\n,
+		fpregs[regnum*3], fpregs[regnum*3+1],
+		fpregs[regnum*3+2], regnum);
+	} else {
+	static const char *class_name[] =
+		{ SNAN, QNAN, ZERO, NUM, INF };
+	printf(fpu_emul_arith: result(%s,%c,%d,%08x,%08x,%08x)
+		 discarded\n,
+		class_name[res-fp_class + 2],
+		res-fp_sign ? '-' : '+', res-fp_exp,
+		res-fp_mant[0], res-fp_mant[1],
+		res-fp_mant[2]);
+	}
 #endif
 }
+#if DEBUG_FPE
+else {
+	printf(fpu_emul_arith: received signal %d\n, sig);
+}
+#endif
 
 #if DEBUG_FPE
 printf(fpu_emul_arith: FPSR = %08x, FPCR = %08x\n,



CVS commit: [netbsd-5] src/sys/arch/m68k/fpe

2011-06-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jun 18 16:26:58 UTC 2011

Modified Files:
src/sys/arch/m68k/fpe [netbsd-5]: fpu_emulate.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.


To generate a diff of this commit:
cvs rdiff -u -r1.27.54.1 -r1.27.54.2 src/sys/arch/m68k/fpe/fpu_emulate.c

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



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

2011-06-18 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sat Jun 18 16:38:27 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by jym in ticket #1630):
sys/arch/xen/xen/xbdback_xenbus.c: revision 1.37
In xbdback(4), move the code that copies segments after the bound checks
of the ``nr_segments'' variable.
In cases where we are running domUs with an architecture different from the
dom0 one (for example: 32 bits domUs on 64 bits dom0), copying segments
with an invalid nr_segments value will lead to the corruption of the
xbdback instance structure and quickly crash the dom0 backend.
Tested under 64 bits dom0 with 32 bits domUs. No regression observed.
ok bouyer@.
Will be pulled up to -4 and -5.


To generate a diff of this commit:
cvs rdiff -u -r1.20.4.4 -r1.20.4.5 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.



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

2011-05-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri May 20 19:28:06 UTC 2011

Modified Files:
src/sys/arch/x68k/dev [netbsd-5]: fd.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1617):
sys/arch/x68k/dev/fd.c: revision 1.94 via patch
Fix hangup on the first floppy access since 2008.
Problem was reported by isaki@.
On X680x0 (and most other machines other than ISA FDC),
the ready line from FDD is connected to FDC and fdc driver can
be notified of the ready state after fd_set_motor() by interrupts.
In this case no need to use callout(9) to wait the FDD motor stabilized,
and the callout(9) method used in ISA fdc(4) driver rather caused
infinite unhandled interrupts since callout(9) was no longer invoked
during interrupt storm after vmlocking2 merge, I guess.
Should be pulled up to netbsd-5.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.85.6.1 src/sys/arch/x68k/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/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.85 src/sys/arch/x68k/dev/fd.c:1.85.6.1
--- src/sys/arch/x68k/dev/fd.c:1.85	Sun Jun 29 09:44:11 2008
+++ src/sys/arch/x68k/dev/fd.c	Fri May 20 19:28:05 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.85 2008/06/29 09:44:11 isaki Exp $	*/
+/*	$NetBSD: fd.c,v 1.85.6.1 2011/05/20 19:28:05 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.85 2008/06/29 09:44:11 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.85.6.1 2011/05/20 19:28:05 bouyer Exp $);
 
 #include rnd.h
 #include opt_ddb.h
@@ -212,7 +212,9 @@
 	struct fd_type *sc_deftype;	/* default type descriptor */
 	struct fd_type *sc_type;	/* current type descriptor */
 
+#if 0	/* see comments in fd_motor_on() */
 	struct callout sc_motoron_ch;
+#endif
 	struct callout sc_motoroff_ch;
 
 	daddr_t	sc_blkno;	/* starting block number */
@@ -278,7 +280,9 @@
 
 void fd_set_motor(struct fdc_softc *, int);
 void fd_motor_off(void *);
+#if 0
 void fd_motor_on(void *);
+#endif
 int fdcresult(struct fdc_softc *);
 int out_fdc(bus_space_tag_t, bus_space_handle_t, u_char);
 void fdcstart(struct fdc_softc *);
@@ -566,7 +570,9 @@
 	struct fd_type *type = fd_types[0];	/* XXX 1.2MB */
 	int drive = fa-fa_drive;
 
+#if 0
 	callout_init(fd-sc_motoron_ch, 0);
+#endif
 	callout_init(fd-sc_motoroff_ch, 0);
 
 	fd-sc_dev = self;
@@ -790,6 +796,7 @@
 	splx(s);
 }
 
+#if 0 /* on x68k motor on triggers interrupts by state change of ready line. */
 void
 fd_motor_on(void *arg)
 {
@@ -805,6 +812,7 @@
 		(void) fdcintr(fdc);
 	splx(s);
 }
+#endif
 
 int
 fdcresult(struct fdc_softc *fdc)
@@ -1078,9 +1086,11 @@
 			fd-sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
 			fd_set_motor(fdc, 0);
 			fdc-sc_state = MOTORWAIT;
+#if 0	/* no need to callout on x68k; motor on will trigger interrupts */
 			/* allow .5s for motor to stabilize */
 			callout_reset(fd-sc_motoron_ch, hz / 2,
 			fd_motor_on, fd);
+#endif
 			return 1;
 		}
 		/* Make sure the right drive is selected. */
@@ -1434,8 +1444,21 @@
 		goto doseek;
 
 	case MOTORWAIT:
+#if 0 /* on x68k motor on triggers interrupts by state change of ready line. */
 		if (fd-sc_flags  FD_MOTOR_WAIT)
 			return 1;		/* time's not up yet */
+#else
+		/* check drive ready by state change interrupt */
+		KASSERT(fd-sc_flags  FD_MOTOR_WAIT);
+		out_fdc(iot, ioh, NE7CMD_SENSEI);
+		tmp = fdcresult(fdc);
+		if (tmp != 2 || (st0  0xc0) != 0xc0 /* ready changed */) {
+			printf(%s: unexpected interrupt during MOTORWAIT\n,
+			device_xname(fd-sc_dev));
+			return 1;
+		}
+		fd-sc_flags = ~FD_MOTOR_WAIT;
+#endif
 		goto doseek;
 
 	default:



CVS commit: [netbsd-5] src/sys/arch/x68k/x68k

2011-05-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri May 20 19:32:44 UTC 2011

Modified Files:
src/sys/arch/x68k/x68k [netbsd-5]: disksubr.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1621):
sys/arch/x68k/x68k/disksubr.c: revision 1.34
Fix buffer overrun in readdisklabel(9) (and writedisklabel(9))
that causes unexpected panic during installation and
DIAGNOSTIC pool assertions.
Also fix bp-b_flags in writedisklabel(9) error path.
The problem was reported from Y.Sugahara during XM6i development,
and this fix is confirmed on both X68030 (by me) and XM6i (by Sugahara).
XXX: broken dkbad support (which makes struct cpu_disklabel larger
XXX: than 512 bytes) should be removed...


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.20.1 src/sys/arch/x68k/x68k/disksubr.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/x68k/disksubr.c
diff -u src/sys/arch/x68k/x68k/disksubr.c:1.33 src/sys/arch/x68k/x68k/disksubr.c:1.33.20.1
--- src/sys/arch/x68k/x68k/disksubr.c:1.33	Wed Jan  2 11:48:32 2008
+++ src/sys/arch/x68k/x68k/disksubr.c	Fri May 20 19:32:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: disksubr.c,v 1.33 2008/01/02 11:48:32 ad Exp $	*/
+/*	$NetBSD: disksubr.c,v 1.33.20.1 2011/05/20 19:32:44 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: disksubr.c,v 1.33 2008/01/02 11:48:32 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: disksubr.c,v 1.33.20.1 2011/05/20 19:32:44 bouyer Exp $);
 
 #include opt_compat_netbsd.h
 
@@ -69,7 +69,7 @@
 	struct buf *bp;
 	struct disklabel *dlp;
 	const char *msg = NULL;
-	int i, labelsz;
+	int i, bsdlabelsz, humanlabelsz;
 
 	if (osdep)
 		dp = osdep-dosparts;
@@ -90,15 +90,19 @@
 	lp-d_partitions[0].p_offset = 0;
 
 	/* get a buffer and initialize it */
-	bp = geteblk((int)lp-d_secsize);
+	bsdlabelsz =
+	howmany(LABELOFFSET + sizeof(struct disklabel), lp-d_secsize)
+	* lp-d_secsize;
+	humanlabelsz =
+	howmany(sizeof(struct cpu_disklabel), lp-d_secsize)
+	* lp-d_secsize;
+	bp = geteblk(MAX(bsdlabelsz, humanlabelsz));
 	bp-b_dev = dev;
 
 	/* read BSD disklabel first */
 	bp-b_blkno = LABELSECTOR;
 	bp-b_cylinder = LABELSECTOR/lp-d_secpercyl;
-	labelsz = howmany(LABELOFFSET+sizeof(struct disklabel), lp-d_secsize)
-		* lp-d_secsize;
-	bp-b_bcount = labelsz;	/* to support  512B/sector disks */
+	bp-b_bcount = bsdlabelsz;	/* to support  512B/sector disks */
 	bp-b_flags |= B_READ;
 	(*strat)(bp);
 
@@ -109,7 +113,7 @@
 	}
 	for (dlp = (struct disklabel *)bp-b_data;
 	 dlp = (struct disklabel *)
-		((char *)bp-b_data + labelsz - sizeof(*dlp));
+		((char *)bp-b_data + bsdlabelsz - sizeof(*dlp));
 	 dlp = (struct disklabel *)((uint8_t *)dlp + sizeof(long))) {
 		if (dlp-d_magic != DISKMAGIC || dlp-d_magic2 != DISKMAGIC) {
 			if (msg == NULL)
@@ -135,9 +139,7 @@
 	bp-b_blkno = DOSPARTOFF * DEF_BSIZE / lp-d_secsize;
 /* DOSPARTOFF in DEV_BSIZE unit */
 	bp-b_cylinder = DOSBBSECTOR / lp-d_secpercyl;
-	labelsz = howmany(sizeof(struct cpu_disklabel),
-			  lp-d_secsize) * lp-d_secsize;
-	bp-b_bcount = labelsz;	/* to support  512B/sector disks */
+	bp-b_bcount = humanlabelsz;	/* to support  512B/sector disks */
 	bp-b_oflags = ~(BO_DONE);
 	(*strat)(bp);
 
@@ -313,7 +315,7 @@
 	struct dos_partition *dp = 0;
 	struct buf *bp;
 	struct disklabel *dlp;
-	int error, labelsz, i;
+	int error, bsdlabelsz, humanlabelsz, i;
 	const char *np;
 
 	if (osdep)
@@ -326,15 +328,19 @@
 		parttbl_consistency_check(lp, dp);
 
 	/* get a buffer and initialize it */
-	bp = geteblk((int)lp-d_secsize);
+	bsdlabelsz =
+	howmany(LABELOFFSET + sizeof(struct disklabel), lp-d_secsize)
+	* lp-d_secsize;
+	humanlabelsz =
+	howmany(sizeof(struct cpu_disklabel), lp-d_secsize)
+	* lp-d_secsize;
+	bp = geteblk(MAX(bsdlabelsz, humanlabelsz));
 	bp-b_dev = dev;
 
 	/* attempt to write BSD disklabel first */
 	bp-b_blkno = LABELSECTOR;
 	bp-b_cylinder = LABELSECTOR / lp-d_secpercyl;
-	labelsz = howmany(LABELOFFSET+sizeof(struct disklabel), lp-d_secsize)
-		* lp-d_secsize;
-	bp-b_bcount = labelsz;	/* to support  512B/sector disks */
+	bp-b_bcount = bsdlabelsz;	/* to support  512B/sector disks */
 	bp-b_flags |= B_READ;
 	(*strat)(bp);
 
@@ -344,7 +350,7 @@
 	error = ESRCH;
 	for (dlp = (struct disklabel *)bp-b_data;
 	 dlp = (struct disklabel *)
-		((char *)bp-b_data + labelsz - sizeof(*dlp));
+		((char *)bp-b_data + bsdlabelsz - sizeof(*dlp));
 	 dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
 		if (dlp-d_magic == DISKMAGIC  dlp-d_magic2 == DISKMAGIC 
 		dkcksum(dlp) == 0) {
@@ -370,6 +376,7 @@
 		bp-b_blkno = DOSBBSECTOR;
 		bp-b_bcount = lp-d_secsize;
 		bp-b_oflags = ~(BO_DONE);
+		bp-b_flags = ~(B_WRITE);
 		bp-b_flags |= B_READ;
 		bp-b_cylinder = DOSBBSECTOR / lp-d_secpercyl;
 		

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

2011-05-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri May 20 19:28:06 UTC 2011

Modified Files:
src/sys/arch/x68k/dev [netbsd-5]: fd.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1617):
sys/arch/x68k/dev/fd.c: revision 1.94 via patch
Fix hangup on the first floppy access since 2008.
Problem was reported by isaki@.
On X680x0 (and most other machines other than ISA FDC),
the ready line from FDD is connected to FDC and fdc driver can
be notified of the ready state after fd_set_motor() by interrupts.
In this case no need to use callout(9) to wait the FDD motor stabilized,
and the callout(9) method used in ISA fdc(4) driver rather caused
infinite unhandled interrupts since callout(9) was no longer invoked
during interrupt storm after vmlocking2 merge, I guess.
Should be pulled up to netbsd-5.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.85.6.1 src/sys/arch/x68k/dev/fd.c

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



CVS commit: [netbsd-5] src/sys/arch/x68k/x68k

2011-05-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri May 20 19:32:44 UTC 2011

Modified Files:
src/sys/arch/x68k/x68k [netbsd-5]: disksubr.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1621):
sys/arch/x68k/x68k/disksubr.c: revision 1.34
Fix buffer overrun in readdisklabel(9) (and writedisklabel(9))
that causes unexpected panic during installation and
DIAGNOSTIC pool assertions.
Also fix bp-b_flags in writedisklabel(9) error path.
The problem was reported from Y.Sugahara during XM6i development,
and this fix is confirmed on both X68030 (by me) and XM6i (by Sugahara).
XXX: broken dkbad support (which makes struct cpu_disklabel larger
XXX: than 512 bytes) should be removed...


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.20.1 src/sys/arch/x68k/x68k/disksubr.c

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



  1   2   3   4   >