CVS commit: src/sys/arch/i386/i386

2012-07-12 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Thu Jul 12 18:13:08 UTC 2012

Modified Files:
src/sys/arch/i386/i386: freebsd_syscall.c ibcs2_syscall.c
svr4_syscall.c

Log Message:
Fix previous - syscall_fancy() didn't contain the check for p_trace_anabled.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/i386/i386/freebsd_syscall.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/i386/i386/ibcs2_syscall.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/i386/i386/svr4_syscall.c

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

Modified files:

Index: src/sys/arch/i386/i386/freebsd_syscall.c
diff -u src/sys/arch/i386/i386/freebsd_syscall.c:1.38 src/sys/arch/i386/i386/freebsd_syscall.c:1.39
--- src/sys/arch/i386/i386/freebsd_syscall.c:1.38	Thu Jul 12 17:26:42 2012
+++ src/sys/arch/i386/i386/freebsd_syscall.c	Thu Jul 12 18:13:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: freebsd_syscall.c,v 1.38 2012/07/12 17:26:42 dsl Exp $	*/
+/*	$NetBSD: freebsd_syscall.c,v 1.39 2012/07/12 18:13:08 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: freebsd_syscall.c,v 1.38 2012/07/12 17:26:42 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: freebsd_syscall.c,v 1.39 2012/07/12 18:13:08 dsl Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -112,7 +112,8 @@ freebsd_syscall(struct trapframe *frame)
 			goto bad;
 	}
 
-	if ((error = trace_enter(code, args, callp-sy_narg)) == 0) {
+	if (!__predict_false(p-p_trace_enabled)
+	|| (error = trace_enter(code, args, callp-sy_narg)) == 0) {
 		rval[0] = 0;
 		rval[1] = frame-tf_edx; /* need to keep edx for shared FreeBSD bins */
 		error = sy_call(callp, l, args, rval);
@@ -142,7 +143,8 @@ freebsd_syscall(struct trapframe *frame)
 		break;
 	}
 
-	trace_exit(code, rval, error);
+	if (__predict_false(p-p_trace_enabled))
+		trace_exit(code, rval, error);
 
 	userret(l);
 }

Index: src/sys/arch/i386/i386/ibcs2_syscall.c
diff -u src/sys/arch/i386/i386/ibcs2_syscall.c:1.47 src/sys/arch/i386/i386/ibcs2_syscall.c:1.48
--- src/sys/arch/i386/i386/ibcs2_syscall.c:1.47	Thu Jul 12 17:26:42 2012
+++ src/sys/arch/i386/i386/ibcs2_syscall.c	Thu Jul 12 18:13:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibcs2_syscall.c,v 1.47 2012/07/12 17:26:42 dsl Exp $	*/
+/*	$NetBSD: ibcs2_syscall.c,v 1.48 2012/07/12 18:13:08 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ibcs2_syscall.c,v 1.47 2012/07/12 17:26:42 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: ibcs2_syscall.c,v 1.48 2012/07/12 18:13:08 dsl Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_vm86.h
@@ -75,12 +75,14 @@ ibcs2_syscall(struct trapframe *frame)
 	char * params;
 	const struct sysent *callp;
 	struct lwp *l;
+	struct proc *p;
 	int error;
 	size_t argsize;
 	register_t code, args[8], rval[2];
 
 	l = curlwp;
-	LWP_CACHE_CREDS(l, l-l_proc);
+	p = l-l_proc;
+	LWP_CACHE_CREDS(l, p);
 
 	code = frame-tf_eax;
 	if (IBCS2_HIGH_SYSCALL(code))
@@ -109,7 +111,8 @@ ibcs2_syscall(struct trapframe *frame)
 			goto bad;
 	}
 
-	if ((error = trace_enter(code, args, callp-sy_narg)) == 0) {
+	if (!__predict_false(p-p_trace_enabled)
+	|| (error = trace_enter(code, args, callp-sy_narg)) == 0) {
 		rval[0] = 0;
 		rval[1] = 0;
 		error = sy_call(callp, l, args, rval);
@@ -140,7 +143,8 @@ ibcs2_syscall(struct trapframe *frame)
 		break;
 	}
 
-	trace_exit(code, rval, error);
+	if (__predict_false(p-p_trace_enabled))
+		trace_exit(code, rval, error);
 
 	userret(l);
 }

Index: src/sys/arch/i386/i386/svr4_syscall.c
diff -u src/sys/arch/i386/i386/svr4_syscall.c:1.46 src/sys/arch/i386/i386/svr4_syscall.c:1.47
--- src/sys/arch/i386/i386/svr4_syscall.c:1.46	Thu Jul 12 17:26:42 2012
+++ src/sys/arch/i386/i386/svr4_syscall.c	Thu Jul 12 18:13:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_syscall.c,v 1.46 2012/07/12 17:26:42 dsl Exp $	*/
+/*	$NetBSD: svr4_syscall.c,v 1.47 2012/07/12 18:13:08 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: svr4_syscall.c,v 1.46 2012/07/12 17:26:42 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: svr4_syscall.c,v 1.47 2012/07/12 18:13:08 dsl Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_vm86.h
@@ -74,12 +74,14 @@ svr4_syscall(struct trapframe *frame)
 	char *params;
 	const struct sysent *callp;
 	struct lwp *l;
+	struct proc *p;
 	int error;
 	size_t argsize;
 	register_t code, args[8], rval[2];
 
 	l = curlwp;
-	LWP_CACHE_CREDS(l, l-l_proc);
+	p = l-l_proc;
+	LWP_CACHE_CREDS(l, p);
 
 	code = frame-tf_eax;
 	callp = svr4_sysent;
@@ -106,7 +108,8 @@ svr4_syscall(struct trapframe *frame)
 			goto bad;
 	}
 
-	if ((error = trace_enter(code, args, callp-sy_narg)) == 0) {
+	if (!__predict_false(p-p_trace_enabled)
+	|| (error = trace_enter(code, args, 

CVS commit: src/sys/arch/i386/i386

2012-06-15 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Fri Jun 15 14:09:26 UTC 2012

Modified Files:
src/sys/arch/i386/i386: spl.S

Log Message:
update a comment


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/i386/i386/spl.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/spl.S
diff -u src/sys/arch/i386/i386/spl.S:1.36 src/sys/arch/i386/i386/spl.S:1.37
--- src/sys/arch/i386/i386/spl.S:1.36	Fri Mar 18 15:18:16 2011
+++ src/sys/arch/i386/i386/spl.S	Fri Jun 15 14:09:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: spl.S,v 1.36 2011/03/18 15:18:16 joerg Exp $	*/
+/*	$NetBSD: spl.S,v 1.37 2012/06/15 14:09:26 yamt Exp $	*/
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: spl.S,v 1.36 2011/03/18 15:18:16 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: spl.S,v 1.37 2012/06/15 14:09:26 yamt Exp $);
 
 #include opt_vm86.h
 #include opt_ddb.h
@@ -73,7 +73,7 @@ END(splraise)
  * void spllower(int s);
  *
  * spllower() for i486 and Pentium.  Must be the same size as
- * i686_spllower().  This must use pushf/cli/popf as it is used
+ * cx8_spllower().  This must use pushf/cli/popf as it is used
  * early in boot where interrupts are disabled via eflags/IE.
  */
 ENTRY(spllower)



CVS commit: src/sys/arch/i386/i386

2012-06-15 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Fri Jun 15 14:23:46 UTC 2012

Modified Files:
src/sys/arch/i386/i386: vector.S

Log Message:
whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/i386/i386/vector.S

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

Modified files:

Index: src/sys/arch/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.59 src/sys/arch/i386/i386/vector.S:1.60
--- src/sys/arch/i386/i386/vector.S:1.59	Sun Jun 12 03:35:42 2011
+++ src/sys/arch/i386/i386/vector.S	Fri Jun 15 14:23:46 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.59 2011/06/12 03:35:42 rmind Exp $	*/
+/*	$NetBSD: vector.S,v 1.60 2012/06/15 14:23:46 yamt Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.59 2011/06/12 03:35:42 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.60 2012/06/15 14:23:46 yamt Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -282,7 +282,7 @@ IDTVEC(intr_ ## name ## num)		;\
 	pushl	$T_ASTFLT		/* trap # for doing ASTs */	;\
 	INTRENTRY			;\
 	movl	CPUVAR(ISOURCES) + (num) * 4, %ebp			;\
-	mask(num)		/* mask it in hardware */		;\
+	mask(num)			/* mask it in hardware */	;\
 	early_ack(num)			/* and allow other intrs */	;\
 	testl	%ebp,%ebp		;\
 	jz	9f			/* stray */			;\



CVS commit: src/sys/arch/i386/i386

2012-06-15 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jun 15 23:01:16 UTC 2012

Modified Files:
src/sys/arch/i386/i386: bios32.c

Log Message:
Don't use an empty body on the same line for the for loop.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/i386/bios32.c

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

Modified files:

Index: src/sys/arch/i386/i386/bios32.c
diff -u src/sys/arch/i386/i386/bios32.c:1.28 src/sys/arch/i386/i386/bios32.c:1.29
--- src/sys/arch/i386/i386/bios32.c:1.28	Tue Nov 17 23:45:39 2009
+++ src/sys/arch/i386/i386/bios32.c	Fri Jun 15 23:01:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios32.c,v 1.28 2009/11/17 23:45:39 dyoung Exp $	*/
+/*	$NetBSD: bios32.c,v 1.29 2012/06/15 23:01:16 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bios32.c,v 1.28 2009/11/17 23:45:39 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: bios32.c,v 1.29 2012/06/15 23:01:16 joerg Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -175,8 +175,8 @@ bios32_init(void)
 		if (p[0] != '_'  p[1] != 'D'  p[2] != 'M' 
 		p[3] != 'I'  p[4] != '_')
 			continue;
-		for (chksum = 0, i = 0xf; i--; chksum += p[i]);
-			;
+		for (chksum = 0, i = 0xf; i--;)
+			chksum += p[i];
 		if (chksum != 0)
 			continue;
 



CVS commit: src/sys/arch/i386/i386

2012-05-07 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 12:23:05 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
For correctness: do not forget VA_SIGN_NEG().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.29 src/sys/arch/i386/i386/db_memrw.c:1.30
--- src/sys/arch/i386/i386/db_memrw.c:1.29	Mon May  7 12:12:03 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 12:23:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.29 2012/05/07 12:12:03 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.30 2012/05/07 12:23:05 jym 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.29 2012/05/07 12:12:03 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.30 2012/05/07 12:23:05 jym Exp $);
 
 #include opt_xen.h
 
@@ -123,7 +123,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * Get the VA for the page.
 		 */
 		if (pte  PG_PS)
-			pgva = (vaddr_t)dst  PG_LGFRAME;
+			pgva = VA_SIGN_NEG((vaddr_t)dst  PG_LGFRAME);
 		else
 			pgva = x86_trunc_page((vaddr_t)dst);
 



CVS commit: src/sys/arch/i386/i386

2012-05-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 02:12:35 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
I am not quite sure that __data_start (set through location counter) is
a char... declare it as int, like amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 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/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.25 src/sys/arch/i386/i386/db_memrw.c:1.26
--- src/sys/arch/i386/i386/db_memrw.c:1.25	Tue Mar 10 20:05:30 2009
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 02:12:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.25 2009/03/10 20:05:30 bouyer Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym 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.25 2009/03/10 20:05:30 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym Exp $);
 
 #include opt_xen.h
 
@@ -186,7 +186,7 @@ db_write_text(vaddr_t addr, size_t size,
 void
 db_write_bytes(vaddr_t addr, size_t size, const char *data)
 {
-	extern char __data_start;
+	extern int __data_start;
 	char *dst;
 
 	dst = (char *)addr;



CVS commit: src/sys/arch/i386/i386

2012-05-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 02:15:34 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
Remove XXXSMP comment and explain why no TLB shootdown is required here.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 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/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.26 src/sys/arch/i386/i386/db_memrw.c:1.27
--- src/sys/arch/i386/i386/db_memrw.c:1.26	Mon May  7 02:12:35 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 02:15:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.26 2012/05/07 02:12:35 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym 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.26 2012/05/07 02:12:35 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym Exp $);
 
 #include opt_xen.h
 
@@ -161,22 +161,13 @@ db_write_text(vaddr_t addr, size_t size,
 		 */
 		pmap_pte_set(pte, oldpte);
 		pmap_pte_flush();
-#if 0 
+		pmap_update_pg(pgva);
 		/*
-		 * XXXSMP Not clear if this is needed for 100% correctness.
+		 * MULTIPROCESSOR: no shootdown required as all other CPUs
+		 * should be in CPUF_PAUSE state and will not cache the PTE
+		 * with the write access set.
 		 */
-		{
-			int cpumask = 0;
-			/*
-			 * shoot down in case other CPU mistakenly caches page.
-			 */
-			pmap_tlb_shootdown(pmap_kernel(), pgva, 0, PG_G);
-			pmap_tlb_shootwait();
-		}
-#else
-		pmap_update_pg(pgva);
-#endif
-		
+
 	} while (size != 0);
 }
 



CVS commit: src/sys/arch/i386/i386

2012-05-06 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon May  7 02:32:09 UTC 2012

Modified Files:
src/sys/arch/i386/i386: db_memrw.c

Log Message:
Use pmap_pte_*bits macros to set/clear bits in a PTE. Remove pmap_pte_flush
calls as these operations are synchronously flushed under Xen; they should
not be cached.

XXX the code can be shared between i386 and amd64, but I will merge
them once I figure out why db_write_text() can cause page faults for
certain CPUs in long mode (code looks correct, but single stepping or
adding debug printf's makes the bug magically disappear... sigh)

Bug reported by David Laight on port-amd64@ when attempting to set
breakpoints through ddb(4).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.27 src/sys/arch/i386/i386/db_memrw.c:1.28
--- src/sys/arch/i386/i386/db_memrw.c:1.27	Mon May  7 02:15:34 2012
+++ src/sys/arch/i386/i386/db_memrw.c	Mon May  7 02:32:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.27 2012/05/07 02:15:34 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.28 2012/05/07 02:32:09 jym 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.27 2012/05/07 02:15:34 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_memrw.c,v 1.28 2012/05/07 02:32:09 jym Exp $);
 
 #include opt_xen.h
 
@@ -97,7 +97,7 @@ db_read_bytes(vaddr_t addr, size_t size,
 static void
 db_write_text(vaddr_t addr, size_t size, const char *data)
 {
-	pt_entry_t *pte, oldpte, tmppte;
+	pt_entry_t *ppte, pte;
 	vaddr_t pgva;
 	size_t limit;
 	char *dst;
@@ -111,10 +111,10 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
-		oldpte = *pte;
+		ppte = kvtopte(addr);
+		pte = *ppte;
 
-		if ((oldpte  PG_V) == 0) {
+		if ((pte  PG_V) == 0) {
 			printf( address %p not a valid page\n, dst);
 			return;
 		}
@@ -122,7 +122,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the VA for the page.
 		 */
-		if (oldpte  PG_PS)
+		if (pte  PG_PS)
 			pgva = (vaddr_t)dst  PG_LGFRAME;
 		else
 			pgva = x86_trunc_page((vaddr_t)dst);
@@ -132,7 +132,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * with this mapping and subtract it from the
 		 * total size.
 		 */
-		if (oldpte  PG_PS)
+		if (pte  PG_PS)
 			limit = NBPD_L2 - ((vaddr_t)dst  (NBPD_L2 - 1));
 		else
 			limit = PAGE_SIZE - ((vaddr_t)dst  PGOFSET);
@@ -140,9 +140,11 @@ db_write_text(vaddr_t addr, size_t size,
 			limit = size;
 		size -= limit;
 
-		tmppte = (oldpte  ~PG_KR) | PG_KW;
-		pmap_pte_set(pte, tmppte);
-		pmap_pte_flush();
+		/*
+		 * Make the kernel text page writable.
+		 */
+		pmap_pte_clearbits(ppte, PG_KR);
+		pmap_pte_setbits(ppte, PG_KW);
 		pmap_update_pg(pgva);
 		/*
 		 * MULTIPROCESSOR: no shootdown required as the PTE continues to
@@ -157,10 +159,10 @@ db_write_text(vaddr_t addr, size_t size,
 			*dst++ = *data++;
 
 		/*
-		 * Restore the old PTE.
+		 * Turn the page back to read-only.
 		 */
-		pmap_pte_set(pte, oldpte);
-		pmap_pte_flush();
+		pmap_pte_clearbits(ppte, PG_KW);
+		pmap_pte_setbits(ppte, PG_KR);
 		pmap_update_pg(pgva);
 		/*
 		 * MULTIPROCESSOR: no shootdown required as all other CPUs



CVS commit: src/sys/arch/i386/i386

2012-04-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 22 20:36:52 UTC 2012

Modified Files:
src/sys/arch/i386/i386: compat_16_machdep.c

Log Message:
From Bob Lee [glee at force10networks dot com], Preserve the have fpu context
bit for compat_16 signals, because the old 1.6 context does not deal with the
fpu.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/compat_16_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/i386/i386/compat_16_machdep.c
diff -u src/sys/arch/i386/i386/compat_16_machdep.c:1.21 src/sys/arch/i386/i386/compat_16_machdep.c:1.22
--- src/sys/arch/i386/i386/compat_16_machdep.c:1.21	Sat Nov  6 07:40:24 2010
+++ src/sys/arch/i386/i386/compat_16_machdep.c	Sun Apr 22 16:36:52 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.21 2010/11/06 11:40:24 uebayasi Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.22 2012/04/22 20:36:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: compat_16_machdep.c,v 1.21 2010/11/06 11:40:24 uebayasi Exp $);
+__KERNEL_RCSID(0, $NetBSD: compat_16_machdep.c,v 1.22 2012/04/22 20:36:52 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_vm86.h
@@ -260,7 +260,9 @@ sendsig_sigcontext(const ksiginfo_t *ksi
 		/* NOTREACHED */
 	}
 
+	int svufpu = l-l_md.md_flags  MDL_USEDFPU;
 	buildcontext(l, sel, catcher, fp);
+	l-l_md.md_flags |= svufpu;
 
 	/* Remember that we're now on the signal stack. */
 	if (onstack)



CVS commit: src/sys/arch/i386/i386

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Apr 19 18:07:05 UTC 2012

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
Mirror what is done for amd64 boot and ACPI wakeup code by setting
CR0_WP (write protection bit) early on boot. Although it is set later via
cpu_init(), this can help tracking down invalid writes to pages mapped
as read only from ring 0.

No regression observed when booting under anita (QEMU) or a P4 host.

Depending on your hardware or setup, you may trigger code paths I have
overlooked. So if your machine does not start properly, or you get
page faults early during boot, please report them to me.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 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.98 src/sys/arch/i386/i386/locore.S:1.99
--- src/sys/arch/i386/i386/locore.S:1.98	Thu Apr 19 18:00:35 2012
+++ src/sys/arch/i386/i386/locore.S	Thu Apr 19 18:07:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $	*/
+/*	$NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.98 2012/04/19 18:00:35 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.99 2012/04/19 18:07:05 jym Exp $);
 
 #include opt_compat_oldboot.h
 #include opt_ddb.h
@@ -682,7 +682,7 @@ try586:	/* Use the `cpuid' instruction. 
  	 */
 	movl	%cr0,%eax		# get control word
 	# enable paging  NPX emulation
-	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_AM),%eax
+	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax
 	movl	%eax,%cr0		# and page NOW!
 
 	pushl	$begin			# jump to high mem



CVS commit: src/sys/arch/i386/i386

2012-03-04 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar  4 15:56:09 UTC 2012

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
cast xen_start_info.nr_pages to paddr_t, so that ctob() won't truncate
the addresses to 32bits. Fix avail memory when allocating more than 4GB
to a XEN3PAE domU.


To generate a diff of this commit:
cvs rdiff -u -r1.724 -r1.725 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.724 src/sys/arch/i386/i386/machdep.c:1.725
--- src/sys/arch/i386/i386/machdep.c:1.724	Sat Mar  3 23:43:17 2012
+++ src/sys/arch/i386/i386/machdep.c	Sun Mar  4 15:56:09 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.724 2012/03/03 23:43:17 mrg Exp $	*/
+/*	$NetBSD: machdep.c,v 1.725 2012/03/04 15:56:09 bouyer 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.724 2012/03/03 23:43:17 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.725 2012/03/04 15:56:09 bouyer Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1364,9 +1364,9 @@ init386(paddr_t first_avail)
 	/* Make sure the end of the space used by the kernel is rounded. */
 	first_avail = round_page(first_avail);
 	avail_start = first_avail;
-	avail_end = ctob(xen_start_info.nr_pages) + XPMAP_OFFSET;
+	avail_end = ctob((paddr_t)xen_start_info.nr_pages) + XPMAP_OFFSET;
 	pmap_pa_start = (KERNTEXTOFF - KERNBASE);
-	pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
+	pmap_pa_end = pmap_pa_start + ctob((paddr_t)xen_start_info.nr_pages);
 	mem_clusters[0].start = avail_start;
 	mem_clusters[0].size = avail_end - avail_start;
 	mem_cluster_cnt++;
@@ -1419,9 +1419,10 @@ init386(paddr_t first_avail)
 	initx86_load_memmap(first_avail);
 
 #else /* !XEN */
-	XENPRINTK((load the memory cluster %p(%d) - %p(%ld)\n,
-	(void *)(long)avail_start, (int)atop(avail_start),
-	(void *)(long)avail_end, (int)atop(avail_end)));
+	XENPRINTK((load the memory cluster 0x% PRIx64  (% PRId64 ) - 
+	0x% PRIx64  (% PRId64 )\n,
+	(uint64_t)avail_start, (uint64_t)atop(avail_start),
+	(uint64_t)avail_end, (uint64_t)atop(avail_end)));
 	uvm_page_physload(atop(avail_start), atop(avail_end),
 	atop(avail_start), atop(avail_end),
 	VM_FREELIST_DEFAULT);



CVS commit: src/sys/arch/i386/i386

2012-03-04 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar  4 20:44:17 UTC 2012

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Don't try to uvm_page_physload() the tmpgdt page: this always fails because
only one physical segment is configured for Xen, and it's probably not
worth it to create a second physseg with a single page (uvm has optimisations
for the VM_PHYSSEG_MAX == 1 case)


To generate a diff of this commit:
cvs rdiff -u -r1.725 -r1.726 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.725 src/sys/arch/i386/i386/machdep.c:1.726
--- src/sys/arch/i386/i386/machdep.c:1.725	Sun Mar  4 15:56:09 2012
+++ src/sys/arch/i386/i386/machdep.c	Sun Mar  4 20:44:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.725 2012/03/04 15:56:09 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.726 2012/03/04 20:44:17 bouyer 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.725 2012/03/04 15:56:09 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.726 2012/03/04 20:44:17 bouyer Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1440,10 +1440,6 @@ init386(paddr_t first_avail)
 		}
 	}
 
-	uvm_page_physload(atop((vaddr_t)tmpgdt), atop((vaddr_t)tmpgdt + PAGE_SIZE),
-	atop((vaddr_t)tmpgdt), atop((vaddr_t)tmpgdt + PAGE_SIZE),
-	VM_FREELIST_DEFAULT);
-
 #endif /* !XEN */
 
 	init386_msgbuf();



CVS commit: src/sys/arch/i386/i386

2012-02-27 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Feb 27 19:52:59 UTC 2012

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
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.721 -r1.722 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.721 src/sys/arch/i386/i386/machdep.c:1.722
--- src/sys/arch/i386/i386/machdep.c:1.721	Fri Feb 24 08:06:07 2012
+++ src/sys/arch/i386/i386/machdep.c	Mon Feb 27 19:52:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.721 2012/02/24 08:06:07 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.722 2012/02/27 19:52:59 bouyer 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.721 2012/02/24 08:06:07 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.722 2012/02/27 19:52:59 bouyer Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -723,13 +723,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;
@@ -970,13 +965,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;



CVS commit: src/sys/arch/i386/i386

2012-02-22 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Feb 22 18:35:26 UTC 2012

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
i386_switch_context(): mimic code in cpu_switchto() and compare pcb-pcb_fpcpu
against ci to decide if we need to turn off FPU. Fix FPU corruption, e.g.
paranoia occasionally reporting flaws on Xen/MP systems.

XXX is ci_fpused still needed at all ?


To generate a diff of this commit:
cvs rdiff -u -r1.718 -r1.719 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.718 src/sys/arch/i386/i386/machdep.c:1.719
--- src/sys/arch/i386/i386/machdep.c:1.718	Sun Feb 19 21:06:08 2012
+++ src/sys/arch/i386/i386/machdep.c	Wed Feb 22 18:35:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.718 2012/02/19 21:06:08 rmind Exp $	*/
+/*	$NetBSD: machdep.c,v 1.719 2012/02/22 18:35:26 bouyer 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.718 2012/02/19 21:06:08 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.719 2012/02/22 18:35:26 bouyer Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -542,9 +542,8 @@ i386_switch_context(lwp_t *l)
 
 	pcb = lwp_getpcb(l);
 	ci = curcpu();
-	if (ci-ci_fpused) {
+	if (pcb-pcb_fpcpu != ci) {
 		HYPERVISOR_fpu_taskswitch(1);
-		ci-ci_fpused = 0;
 	}
 
 	HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb-pcb_esp0);



CVS commit: src/sys/arch/i386/i386

2012-02-07 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Feb  7 16:34:44 UTC 2012

Modified Files:
src/sys/arch/i386/i386: mainbus.c

Log Message:
Initialize pcibus_attach_args.pba_sub to 255.  Note in a comment that
this needs some improvement for machines with 1 Host-PCI bridge, but
that it doesn't cause any practical problems at this time.

Ok releng@.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/i386/i386/mainbus.c

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

Modified files:

Index: src/sys/arch/i386/i386/mainbus.c
diff -u src/sys/arch/i386/i386/mainbus.c:1.93 src/sys/arch/i386/i386/mainbus.c:1.94
--- src/sys/arch/i386/i386/mainbus.c:1.93	Wed Jan 18 21:34:38 2012
+++ src/sys/arch/i386/i386/mainbus.c	Tue Feb  7 16:34:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.93 2012/01/18 21:34:38 drochner Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.94 2012/02/07 16:34:44 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.93 2012/01/18 21:34:38 drochner Exp $);
+__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.94 2012/02/07 16:34:44 dyoung Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -406,6 +406,13 @@ mainbus_rescan(device_t self, const char
 		mba.mba_pba.pba_pc = NULL;
 		mba.mba_pba.pba_flags = pci_bus_flags();
 		mba.mba_pba.pba_bus = 0;
+		/* XXX On those machines with 1 Host-PCI bridge,
+		 * XXX not every bus  pba_bus is subordinate to pba_bus,
+		 * XXX but this works on many machines, and pba_sub is
+		 * XXX not used today by any critical code, so it is safe
+		 * XXX to be so inclusive at this time.
+		 */
+		mba.mba_pba.pba_sub = 255;
 		mba.mba_pba.pba_bridgetag = NULL;
 #if NACPICA  0  defined(ACPI_SCANPCI)
 		if (npcibus == 0  sc-sc_mpacpi_active)



CVS commit: src/sys/arch/i386/i386

2012-01-30 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Mon Jan 30 21:35:22 UTC 2012

Modified Files:
src/sys/arch/i386/i386: pmc.c

Log Message:
pmc_init: check ncpu instead of cpus_attached.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/i386/pmc.c

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

Modified files:

Index: src/sys/arch/i386/i386/pmc.c
diff -u src/sys/arch/i386/i386/pmc.c:1.19 src/sys/arch/i386/i386/pmc.c:1.20
--- src/sys/arch/i386/i386/pmc.c:1.19	Tue Apr 27 18:41:52 2010
+++ src/sys/arch/i386/i386/pmc.c	Mon Jan 30 21:35:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmc.c,v 1.19 2010/04/27 18:41:52 dyoung Exp $	*/
+/*	$NetBSD: pmc.c,v 1.20 2012/01/30 21:35:22 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2000 Zembu Labs, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmc.c,v 1.19 2010/04/27 18:41:52 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmc.c,v 1.20 2012/01/30 21:35:22 rmind Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -79,7 +79,7 @@ pmc_init(void)
 
 #ifdef MULTIPROCESSOR
 	/* XXX */
-	if (cpus_attached  1)
+	if (ncpu  1)
 		goto done;
 #endif
 



CVS commit: src/sys/arch/i386/i386

2012-01-18 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Wed Jan 18 21:34:38 UTC 2012

Modified Files:
src/sys/arch/i386/i386: mainbus.c

Log Message:
revert previous, the assumption all buses 1 and up must be subordinate
to pci0 doesn't even hold on i386 -- there are server-class chipsets
with multiple primary PCI buses, see arch/x86/pci/pchb.c for examples


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/i386/i386/mainbus.c

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

Modified files:

Index: src/sys/arch/i386/i386/mainbus.c
diff -u src/sys/arch/i386/i386/mainbus.c:1.92 src/sys/arch/i386/i386/mainbus.c:1.93
--- src/sys/arch/i386/i386/mainbus.c:1.92	Fri Oct 21 21:35:28 2011
+++ src/sys/arch/i386/i386/mainbus.c	Wed Jan 18 21:34:38 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.92 2011/10/21 21:35:28 dyoung Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.93 2012/01/18 21:34:38 drochner Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.92 2011/10/21 21:35:28 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.93 2012/01/18 21:34:38 drochner Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -406,7 +406,6 @@ mainbus_rescan(device_t self, const char
 		mba.mba_pba.pba_pc = NULL;
 		mba.mba_pba.pba_flags = pci_bus_flags();
 		mba.mba_pba.pba_bus = 0;
-		mba.mba_pba.pba_sub = 255;
 		mba.mba_pba.pba_bridgetag = NULL;
 #if NACPICA  0  defined(ACPI_SCANPCI)
 		if (npcibus == 0  sc-sc_mpacpi_active)



CVS commit: src/sys/arch/i386/i386

2012-01-12 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Jan 12 19:37:46 UTC 2012

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
re-order call to x86_bus_space_init() until after %fs is initialised via 
initgdt().

x86_bus_space_init() uses mutex(9) since it uses extent(9), which requires %fs 
to be setup before use.


To generate a diff of this commit:
cvs rdiff -u -r1.715 -r1.716 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.715 src/sys/arch/i386/i386/machdep.c:1.716
--- src/sys/arch/i386/i386/machdep.c:1.715	Fri Dec 30 17:57:49 2011
+++ src/sys/arch/i386/i386/machdep.c	Thu Jan 12 19:37:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.715 2011/12/30 17:57:49 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.716 2012/01/12 19:37:45 cherry 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.715 2011/12/30 17:57:49 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.716 2012/01/12 19:37:45 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1354,9 +1354,6 @@ init386(paddr_t first_avail)
 	cpu_info_primary.ci_pae_l3_pdir = (pd_entry_t *)(rcr3() + KERNBASE);
 #endif /* PAE  !XEN */
 
-#if NISA  0 || NPCI  0
-	x86_bus_space_init();
-#endif
 #ifdef XEN
 	xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL);
 #endif
@@ -1412,6 +1409,11 @@ init386(paddr_t first_avail)
 	 */
 	initgdt(NULL);
 #endif /* XEN */
+
+#if NISA  0 || NPCI  0
+	x86_bus_space_init();
+#endif /* NISA  0 || NPCI  0 */
+	
 	consinit();	/* XXX SHOULD NOT BE DONE HERE */
 
 #ifdef DEBUG_MEMLOAD



CVS commit: src/sys/arch/i386/i386

2011-11-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 29 11:12:27 UTC 2011

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Explicitly cast the result of ptoa() to unsigned long for printf,
to fix build failure on xen.


To generate a diff of this commit:
cvs rdiff -u -r1.713 -r1.714 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.713 src/sys/arch/i386/i386/machdep.c:1.714
--- src/sys/arch/i386/i386/machdep.c:1.713	Fri Nov 18 22:18:08 2011
+++ src/sys/arch/i386/i386/machdep.c	Tue Nov 29 11:12:26 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.713 2011/11/18 22:18:08 jmcneill Exp $	*/
+/*	$NetBSD: machdep.c,v 1.714 2011/11/29 11:12:26 martin 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.713 2011/11/18 22:18:08 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.714 2011/11/29 11:12:26 martin Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1622,7 +1622,7 @@ init386(paddr_t first_avail)
 		   have %lu bytes, want %lu bytes\n
 		   running in degraded mode\n
 		   press a key to confirm\n\n,
-		   ptoa(physmem), 2*1024*1024UL);
+		   (unsigned long)ptoa(physmem), 2*1024*1024UL);
 		cngetc();
 	}
 



CVS commit: src/sys/arch/i386/i386

2011-11-09 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Thu Nov 10 03:45:40 UTC 2011

Modified Files:
src/sys/arch/i386/i386: dumpsys.c

Log Message:
i386_use_pae is now just use_pae.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/i386/i386/dumpsys.c

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

Modified files:

Index: src/sys/arch/i386/i386/dumpsys.c
diff -u src/sys/arch/i386/i386/dumpsys.c:1.13 src/sys/arch/i386/i386/dumpsys.c:1.14
--- src/sys/arch/i386/i386/dumpsys.c:1.13	Mon Oct 31 12:42:53 2011
+++ src/sys/arch/i386/i386/dumpsys.c	Thu Nov 10 03:45:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumpsys.c,v 1.13 2011/10/31 12:42:53 yamt Exp $	*/
+/*	$NetBSD: dumpsys.c,v 1.14 2011/11/10 03:45:40 riz Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.13 2011/10/31 12:42:53 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.14 2011/11/10 03:45:40 riz Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -627,7 +627,7 @@ cpu_dump(void)
 	 * Add the machine-dependent header info.
 	 */
 	cpuhdr.pdppaddr = PDPpaddr;
-	if (i386_use_pae == 1)
+	if (use_pae == 1)
 		cpuhdr.pdppaddr |= I386_KCORE_PAE;
 	cpuhdr.nmemsegs = dump_nmemsegs;
 	(void)dump_header_addbytes(cpuhdr, ALIGN(sizeof(cpuhdr)));



CVS commit: src/sys/arch/i386/i386

2011-11-06 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Nov  6 15:35:29 UTC 2011

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
DTRT when initialising pmap_pa_end.


To generate a diff of this commit:
cvs rdiff -u -r1.710 -r1.711 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.710 src/sys/arch/i386/i386/machdep.c:1.711
--- src/sys/arch/i386/i386/machdep.c:1.710	Sun Nov  6 11:40:46 2011
+++ src/sys/arch/i386/i386/machdep.c	Sun Nov  6 15:35:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.710 2011/11/06 11:40:46 cherry Exp $	*/
+/*	$NetBSD: machdep.c,v 1.711 2011/11/06 15:35:29 cherry 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.710 2011/11/06 11:40:46 cherry Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.711 2011/11/06 15:35:29 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1440,7 +1440,7 @@ init386(paddr_t first_avail)
 	avail_start = first_avail;
 	avail_end = ctob(xen_start_info.nr_pages) + XPMAP_OFFSET;
 	pmap_pa_start = (KERNTEXTOFF - KERNBASE);
-	pmap_pa_end = avail_end;
+	pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
 	mem_clusters[0].start = avail_start;
 	mem_clusters[0].size = avail_end - avail_start;
 	mem_cluster_cnt++;



CVS commit: src/sys/arch/i386/i386

2011-10-31 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Mon Oct 31 12:42:53 UTC 2011

Modified Files:
src/sys/arch/i386/i386: dumpsys.c

Log Message:
dumpsys_seg: don't overwrite the previous mapping


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/i386/dumpsys.c

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

Modified files:

Index: src/sys/arch/i386/i386/dumpsys.c
diff -u src/sys/arch/i386/i386/dumpsys.c:1.12 src/sys/arch/i386/i386/dumpsys.c:1.13
--- src/sys/arch/i386/i386/dumpsys.c:1.12	Sat Nov  6 11:40:25 2010
+++ src/sys/arch/i386/i386/dumpsys.c	Mon Oct 31 12:42:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumpsys.c,v 1.12 2010/11/06 11:40:25 uebayasi Exp $	*/
+/*	$NetBSD: dumpsys.c,v 1.13 2011/10/31 12:42:53 yamt Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.12 2010/11/06 11:40:25 uebayasi Exp $);
+__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.13 2011/10/31 12:42:53 yamt Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -668,6 +668,7 @@ dumpsys_seg(paddr_t maddr, paddr_t bytes
 		pmap_update(pmap_kernel());
 
 		error = (*dump)(dumpdev, blkno, (void *)dumpspace, n);
+		pmap_kremove(dumpspace, n * PAGE_SIZE);
 		if (error)
 			return error;
 		maddr += n;



CVS commit: src/sys/arch/i386/i386

2011-10-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 23 13:02:32 UTC 2011

Modified Files:
src/sys/arch/i386/i386: longrun.c

Log Message:
PR #32894: protection fault trap in tmx86_get_longrun_mode

Use rdmsr_safe in tmx86_init_longrun to verify that the MSRs are present.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/i386/longrun.c

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

Modified files:

Index: src/sys/arch/i386/i386/longrun.c
diff -u src/sys/arch/i386/i386/longrun.c:1.3 src/sys/arch/i386/i386/longrun.c:1.4
--- src/sys/arch/i386/i386/longrun.c:1.3	Wed Feb 27 20:18:56 2008
+++ src/sys/arch/i386/i386/longrun.c	Sun Oct 23 13:02:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: longrun.c,v 1.3 2008/02/27 20:18:56 xtraeme Exp $	*/
+/*	$NetBSD: longrun.c,v 1.4 2011/10/23 13:02:32 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2001 Tamotsu Hattori.
@@ -35,7 +35,7 @@
  *
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: longrun.c,v 1.3 2008/02/27 20:18:56 xtraeme Exp $);
+__KERNEL_RCSID(0, $NetBSD: longrun.c,v 1.4 2011/10/23 13:02:32 jmcneill Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -92,6 +92,11 @@ void
 tmx86_init_longrun(void)
 {
 	const struct sysctlnode *mnode;
+	uint64_t msr;
+
+	/* PR #32894, make sure the longrun MSR is present */
+	if (rdmsr_safe(MSR_TMx86_LONGRUN, msr) == EFAULT)
+		return;
 
 	/* create the sysctl machdep.tm_longrun_* nodes */
 sysctl_createv(NULL, 0, NULL, mnode, CTLFLAG_PERMANENT,



CVS commit: src/sys/arch/i386/i386

2011-09-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 28 17:27:21 UTC 2011

Modified Files:
src/sys/arch/i386/i386: linux_syscall.c

Log Message:
syscall (setcontext) can alter eax, so don't attempt to get code again from it
in order to avoid register spills.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/i386/i386/linux_syscall.c

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

Modified files:

Index: src/sys/arch/i386/i386/linux_syscall.c
diff -u src/sys/arch/i386/i386/linux_syscall.c:1.50 src/sys/arch/i386/i386/linux_syscall.c:1.51
--- src/sys/arch/i386/i386/linux_syscall.c:1.50	Fri Nov 20 22:11:00 2009
+++ src/sys/arch/i386/i386/linux_syscall.c	Wed Sep 28 13:27:21 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_syscall.c,v 1.50 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: linux_syscall.c,v 1.51 2011/09/28 17:27:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: linux_syscall.c,v 1.50 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: linux_syscall.c,v 1.51 2011/09/28 17:27:21 christos Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_vm86.h
@@ -103,7 +103,6 @@ linux_syscall(struct trapframe *frame)
 		error = trace_enter(code, args, callp-sy_narg);
 		if (__predict_true(error == 0)) {
 			error = sy_call(callp, l, args, rval);
-			code = frame-tf_eax  (LINUX_SYS_NSYSENT - 1);
 			trace_exit(code, rval, error);
 		}
 	} else



CVS commit: src/sys/arch/i386/i386

2011-08-11 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Thu Aug 11 11:01:31 UTC 2011

Modified Files:
src/sys/arch/i386/i386: gdt.c

Log Message:
per-cpu gdt support for xen


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/i386/i386/gdt.c

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

Modified files:

Index: src/sys/arch/i386/i386/gdt.c
diff -u src/sys/arch/i386/i386/gdt.c:1.50 src/sys/arch/i386/i386/gdt.c:1.51
--- src/sys/arch/i386/i386/gdt.c:1.50	Sat Nov 21 03:11:00 2009
+++ src/sys/arch/i386/i386/gdt.c	Thu Aug 11 11:01:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: gdt.c,v 1.50 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: gdt.c,v 1.51 2011/08/11 11:01:30 cherry 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.50 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: gdt.c,v 1.51 2011/08/11 11:01:30 cherry Exp $);
 
 #include opt_multiprocessor.h
 #include opt_xen.h
@@ -207,17 +207,28 @@
 		KASSERT(va = VM_MIN_KERNEL_ADDRESS);
 		ptp = kvtopte(va);
 		frames[f] = *ptp  PAGE_SHIFT;
-		pmap_pte_clearbits(ptp, PG_RW);
+		{ 
+		   /* 
+		* pmap_pte_clearbits(ptp, PG_RW);
+		* but without spl(), since %fs is not setup
+		* properly yet, ie; curcpu() won't work at this
+		* point and spl() will break.
+		*/
+		   xpq_queue_lock();
+		   xpq_queue_pte_update(xpmap_ptetomach(ptp),
+	*ptp  ~PG_RW);
+		   xpq_flush_queue();
+		   xpq_queue_unlock();
+		}
 	}
-	/* printk(loading gdt %x, %d entries, %d pages, */
-	/* frames[0]  PAGE_SHIFT, gdt_size[0], len  PAGE_SHIFT); */
+
 	if (HYPERVISOR_set_gdt(frames, gdt_size[0]))
 		panic(HYPERVISOR_set_gdt failed!\n);
 	lgdt_finish();
 #endif
 }
 
-#ifdef MULTIPROCESSOR
+#if defined(MULTIPROCESSOR)  !defined(XEN)
 
 void
 gdt_reload_cpu(struct cpu_info *ci)
@@ -255,15 +266,17 @@
 			gdt_size[which] = MINGDTSIZ;
 			new_len = gdt_size[which] * sizeof(gdt[0]);
 		}
-		for(va = (vaddr_t)(cpu_info_primary.ci_gdt) + old_len + max_len;
-		va  (vaddr_t)(cpu_info_primary.ci_gdt) + new_len + max_len;
-		va += PAGE_SIZE) {
-			while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO))
-			== NULL) {
-uvm_wait(gdt_grow);
+		for (CPU_INFO_FOREACH(cii, ci)) {
+			for(va = (vaddr_t)(ci-ci_gdt) + old_len + max_len;
+			va  (vaddr_t)(ci-ci_gdt) + new_len + max_len;
+			va += PAGE_SIZE) {
+while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO))
+   == NULL) {
+	uvm_wait(gdt_grow);
+}
+pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
+	   VM_PROT_READ | VM_PROT_WRITE, 0);
 			}
-			pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
-			VM_PROT_READ | VM_PROT_WRITE, 0);
 		}
 		return;
 	}



CVS commit: src/sys/arch/i386/i386

2011-08-10 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Wed Aug 10 06:38:02 UTC 2011

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
tweak the xen specific startup path to not use %fs before it is setup. Minor 
refactoring. Use Xen specific ipi calls.


To generate a diff of this commit:
cvs rdiff -u -r1.706 -r1.707 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.706 src/sys/arch/i386/i386/machdep.c:1.707
--- src/sys/arch/i386/i386/machdep.c:1.706	Fri Jul  1 18:14:15 2011
+++ src/sys/arch/i386/i386/machdep.c	Wed Aug 10 06:38:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.706 2011/07/01 18:14:15 dyoung Exp $	*/
+/*	$NetBSD: machdep.c,v 1.707 2011/08/10 06:38:02 cherry 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.706 2011/07/01 18:14:15 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.707 2011/08/10 06:38:02 cherry Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -560,6 +560,12 @@
 
 	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);
+
 	physop.cmd = PHYSDEVOP_SET_IOPL;
 	physop.u.set_iopl.iopl = pcb-pcb_iopl;
 	HYPERVISOR_physdev_op(physop);
@@ -949,8 +955,12 @@
 	}
 
 #ifdef MULTIPROCESSOR
+#ifdef XEN
+	xen_broadcast_ipi(XEN_IPI_HALT);
+#else /* XEN */
 	x86_broadcast_ipi(X86_IPI_HALT);
-#endif
+#endif /* XEN */
+#endif /* MULTIPROCESSOR */
 
 	if (howto  RB_HALT) {
 #if NACPICA  0
@@ -1123,14 +1133,18 @@
 int xen_idt_idx;
 #endif
 
-#ifndef XEN
 void cpu_init_idt(void)
 {
+#ifndef XEN
 	struct region_descriptor region;
 	setregion(region, pentium_idt, NIDT * sizeof(idt[0]) - 1);
 	lidt(region);
-}
+#else /* XEN */
+	XENPRINTF((HYPERVISOR_set_trap_table %p\n, xen_idt));
+	if (HYPERVISOR_set_trap_table(xen_idt))
+		panic(HYPERVISOR_set_trap_table %p failed\n, xen_idt);
 #endif /* !XEN */
+}
 
 void
 initgdt(union descriptor *tgdt)
@@ -1166,7 +1180,28 @@
 	lgdt(region);
 #else /* !XEN */
 	frames[0] = xpmap_ptom((uint32_t)gdt - KERNBASE)  PAGE_SHIFT;
-	pmap_kenter_pa((vaddr_t)gdt, (uint32_t)gdt - KERNBASE, VM_PROT_READ, 0);
+	{	/*
+		 * Enter the gdt page RO into the kernel map. We can't
+		 * use pmap_kenter_pa() here, because %fs is not
+		 * usable until the gdt is loaded, and %fs is used as
+		 * the base pointer for curcpu() and curlwp(), both of
+		 * which are in the callpath of pmap_kenter_pa().
+		 * So we mash up our own - this is MD code anyway.
+		 *
+		 * XXX: review this once we have finegrained locking
+		 * for xpq.
+		 */
+		pt_entry_t *pte, npte;
+		pt_entry_t pg_nx = (cpu_feature[2]  CPUID_NOX ? PG_NX : 0);
+
+		pte = kvtopte((vaddr_t)gdt);
+		npte = pmap_pa2pte((vaddr_t)gdt - KERNBASE);
+		npte |= PG_RO | pg_nx | PG_V;
+
+		xpq_queue_pte_update(xpmap_ptetomach(pte), npte);
+		xpq_flush_queue();
+	}
+
 	XENPRINTK((loading gdt %lx, %d entries\n, frames[0]  PAGE_SHIFT,
 	NGDT));
 	if (HYPERVISOR_set_gdt(frames, NGDT /* XXX is it right ? */))
@@ -1579,10 +1614,7 @@
 	xen_idt[xen_idt_idx].address = (uint32_t)IDTVEC(svr4_fasttrap);
 	xen_idt_idx++;
 	lldt(GSEL(GLDT_SEL, SEL_KPL));
-
-	XENPRINTF((HYPERVISOR_set_trap_table %p\n, xen_idt));
-	if (HYPERVISOR_set_trap_table(xen_idt))
-		panic(HYPERVISOR_set_trap_table %p failed\n, xen_idt);
+	cpu_init_idt();
 #endif /* XEN */
 
 	init386_ksyms();



CVS commit: src/sys/arch/i386/i386

2011-06-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jun 30 23:28:03 UTC 2011

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Fix sizeof() usage in memcpy, curtesy of the new warning in clang.


To generate a diff of this commit:
cvs rdiff -u -r1.704 -r1.705 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.704 src/sys/arch/i386/i386/machdep.c:1.705
--- src/sys/arch/i386/i386/machdep.c:1.704	Sun Jun 12 03:35:42 2011
+++ src/sys/arch/i386/i386/machdep.c	Thu Jun 30 23:28:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.704 2011/06/12 03:35:42 rmind Exp $	*/
+/*	$NetBSD: machdep.c,v 1.705 2011/06/30 23:28:03 joerg 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.704 2011/06/12 03:35:42 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.705 2011/06/30 23:28:03 joerg Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1861,7 +1861,7 @@
 memcpy(
 	pcb-pcb_savefpu.sv_xmm,
 	mcp-__fpregs.__fp_reg_set.__fp_xmm_state.__fp_xmm,
-	sizeof (pcb-pcb_savefpu.sv_xmm));
+	sizeof (pcb-pcb_savefpu.sv_xmm));
 			} else {
 /* This is a weird corner case */
 process_xmm_to_s87((struct savexmm *)



CVS commit: src/sys/arch/i386/i386

2011-05-20 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 20 13:17:12 UTC 2011

Modified Files:
src/sys/arch/i386/i386: busfunc.S

Log Message:
The %dx argument for in/out is not a memory reference, so don't use the
feature of GNU as to hide it as such.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/i386/busfunc.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/busfunc.S
diff -u src/sys/arch/i386/i386/busfunc.S:1.7 src/sys/arch/i386/i386/busfunc.S:1.8
--- src/sys/arch/i386/i386/busfunc.S:1.7	Wed May  5 17:42:19 2010
+++ src/sys/arch/i386/i386/busfunc.S	Fri May 20 13:17:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: busfunc.S,v 1.7 2010/05/05 17:42:19 dyoung Exp $	*/
+/*	$NetBSD: busfunc.S,v 1.8 2011/05/20 13:17:12 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: busfunc.S,v 1.7 2010/05/05 17:42:19 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: busfunc.S,v 1.8 2011/05/20 13:17:12 joerg Exp $);
 
 #include assym.h
 
@@ -157,7 +157,7 @@
 	movl	24(%esp), %ecx
 	jne	1f
 	rep
-	insb	(%dx), %es:(%edi)
+	insb	%dx, %es:(%edi)
 	popl	%edi
 	ret
 	.align	16
@@ -184,7 +184,7 @@
 	movl	24(%esp), %ecx
 	jne	1f
 	rep
-	insw	(%dx), %es:(%edi)
+	insw	%dx, %es:(%edi)
 	popl	%edi
 	ret
 	.align	16
@@ -211,7 +211,7 @@
 	movl	24(%esp), %ecx
 	jne	1f
 	rep
-	insl	(%dx), %es:(%edi)
+	insl	%dx, %es:(%edi)
 	popl	%edi
 	ret
 	.align	16
@@ -242,7 +242,7 @@
 	movl	24(%esp), %ecx
 	jne	1f
 	rep
-	outsb	%ds:(%esi), (%dx)
+	outsb	%ds:(%esi), %dx
 	popl	%esi
 	ret
 	.align	16
@@ -269,7 +269,7 @@
 	movl	24(%esp), %ecx
 	jne	1f
 	rep
-	outsw	%ds:(%esi),(%dx)
+	outsw	%ds:(%esi), %dx
 	popl	%esi
 	ret
 	.align	16
@@ -296,7 +296,7 @@
 	movl	24(%esp), %ecx
 	jne	1f
 	rep
-	outsl	%ds:(%esi),(%dx)
+	outsl	%ds:(%esi), %dx
 	popl	%esi
 	ret
 	.align	16



CVS commit: src/sys/arch/i386/i386

2011-04-14 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Apr 14 16:04:12 UTC 2011

Modified Files:
src/sys/arch/i386/i386: vector.S

Log Message:
comments


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.57 src/sys/arch/i386/i386/vector.S:1.58
--- src/sys/arch/i386/i386/vector.S:1.57	Fri Mar 18 15:18:16 2011
+++ src/sys/arch/i386/i386/vector.S	Thu Apr 14 16:04:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.57 2011/03/18 15:18:16 joerg Exp $	*/
+/*	$NetBSD: vector.S,v 1.58 2011/04/14 16:04:12 yamt Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.57 2011/03/18 15:18:16 joerg Exp $);
+__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.58 2011/04/14 16:04:12 yamt Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -435,8 +435,9 @@
 	addl	$1,IS_EVCNTLO(%ebp)	/* inc event counter */		;\
 	adcl	$0,IS_EVCNTHI(%ebp)	;\
 1:	\
-	pushl	%esi			;\
+	pushl	%esi			/* if_ppi */			;\
 	movl	%ebx,CPUVAR(ILEVEL)	;\
+	/* switch stack if necessary, and push a ptr to our intrframe */ \
 	IDEPTH_INCR			;\
 	sti;\
 	movl	IS_HANDLERS(%ebp),%ebx	;\



CVS commit: src/sys/arch/i386/i386

2011-04-14 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Apr 14 16:05:59 UTC 2011

Modified Files:
src/sys/arch/i386/i386: db_machdep.c

Log Message:
fix backtrace of interrupt


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/i386/db_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/i386/i386/db_machdep.c
diff -u src/sys/arch/i386/i386/db_machdep.c:1.2 src/sys/arch/i386/i386/db_machdep.c:1.3
--- src/sys/arch/i386/i386/db_machdep.c:1.2	Mon Apr 11 04:22:31 2011
+++ src/sys/arch/i386/i386/db_machdep.c	Thu Apr 14 16:05:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.2 2011/04/11 04:22:31 mrg Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.3 2011/04/14 16:05:59 yamt Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_machdep.c,v 1.2 2011/04/11 04:22:31 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_machdep.c,v 1.3 2011/04/14 16:05:59 yamt Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -217,8 +217,7 @@
 	static struct trapframe tf;
 	static struct i386tss tss;
 	struct i386_frame *fp;
-	struct intrframe *ifp;
-	int traptype, trapno, err, i;
+	int traptype;
 	uintptr_t ptr;
 
 	switch (is_trap) {
@@ -256,24 +255,23 @@
 	case INTERRUPT:
 	default:
 		/* The only argument to trap() or syscall() is the trapframe. */
-		ptr = db_get_value((int)argp, 4, false);
-		db_read_bytes((db_addr_t)ptr, sizeof(tf), (char *)tf);
 		switch (is_trap) {
 		case TRAP:
+			ptr = db_get_value((int)argp, 4, false);
+			db_read_bytes((db_addr_t)ptr, sizeof(tf), (char *)tf);
 			(*pr)(--- trap (number %d) ---\n, tf.tf_trapno);
 			break;
 		case SYSCALL:
+			ptr = db_get_value((int)argp, 4, false);
+			db_read_bytes((db_addr_t)ptr, sizeof(tf), (char *)tf);
 			(*pr)(--- syscall (number %d) ---\n, tf.tf_eax);
 			break;
 		case INTERRUPT:
 			(*pr)(--- interrupt ---\n);
 			/*
-			 * Get intrframe address as saved when switching
-			 * to interrupt stack, and convert to trapframe
-			 * (add 4).  See frame.h.
+			 * see the XXX -1 here is a hack comment below.
 			 */
-			ptr = db_get_value((int)(argp - 1) + 4, 4, false);
-			db_read_bytes((db_addr_t)ptr, sizeof(tf), (char *)tf);
+			db_read_bytes((db_addr_t)argp, sizeof(tf), (char *)tf);
 			break;
 		}
 		*ip = (db_addr_t)tf.tf_eip;
@@ -295,16 +293,32 @@
 	if (db_frame_info(*nextframe, (db_addr_t)*ip, NULL, NULL, traptype,
 	NULL) != (db_sym_t)0
 	 traptype == INTERRUPT) {
-		for (i = 0; i  4; i++) {
-			ifp = (struct intrframe *)(argp + i);
-			err = db_get_value((int)ifp-__if_err, 4, false);
-			trapno = db_get_value((int)ifp-__if_trapno, 4, false);
-			if ((err == 0 || err == IREENT_MAGIC)  trapno == T_ASTFLT) {
-*nextframe = (long *)ifp - 1;
-break;
-			}
-		}
-		if (i == 4) {
+		struct intrframe *ifp;
+		int trapno;
+		int err;
+
+		/*
+		 * 2nd argument of interrupt handlers is a pointer to intrframe.
+		 */
+		ifp = (struct intrframe *)
+		db_get_value((db_addr_t)(argp + 1), sizeof(ifp), false);
+		/*
+		 * check if it's a valid intrframe.
+		 */
+		err = db_get_value((db_addr_t)ifp-__if_err,
+		sizeof(ifp-__if_err), false);
+		trapno = db_get_value((db_addr_t)ifp-__if_trapno,
+		sizeof(ifp-__if_trapno), false);
+		if ((err == 0 || err == IREENT_MAGIC)  trapno == T_ASTFLT) {
+			/*
+			 * found seemingly valid intrframe.
+			 *
+			 * XXX -1 here is a hack.
+			 * for the next frame, we will be called with
+			 * argp = *nextframe + 2.  (long *)if - 1 + 2 = tf.
+			 */
+			*nextframe = (long *)ifp - 1;
+		} else {
 			(*pr)(DDB lost frame for );
 			db_printsym(*ip, DB_STGY_ANY, pr);
 			(*pr)(, trying %p\n,argp);



CVS commit: src/sys/arch/i386/i386

2011-03-18 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Mar 18 15:32:02 UTC 2011

Modified Files:
src/sys/arch/i386/i386: cpufunc.S

Log Message:
Use explicit size with fld.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/i386/cpufunc.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/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.14 src/sys/arch/i386/i386/cpufunc.S:1.15
--- src/sys/arch/i386/i386/cpufunc.S:1.14	Tue Dec  2 17:56:06 2008
+++ src/sys/arch/i386/i386/cpufunc.S	Fri Mar 18 15:32:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.14 2008/12/02 17:56:06 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.15 2011/03/18 15:32:02 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: cpufunc.S,v 1.14 2008/12/02 17:56:06 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: cpufunc.S,v 1.15 2011/03/18 15:32:02 joerg Exp $);
 
 #include opt_xen.h
 
@@ -351,7 +351,7 @@
 ENTRY(fldummy)
 	movl	4(%esp), %eax
 	ffree	%st(7)
-	fld	(%eax)
+	flds	(%eax)
 	ret
 END(fldummy)
 



CVS commit: src/sys/arch/i386/i386

2011-01-11 Thread Grégoire Sutre
Module Name:src
Committed By:   gsutre
Date:   Tue Jan 11 12:24:38 UTC 2011

Modified Files:
src/sys/arch/i386/i386: multiboot.c

Log Message:
As said in the comment (lines 327-336), we must make sure that
we don't overwrite valid data when moving the symbol and string
tables.

Assume for instance that the boot-loader left us with:

  +--+   ++ +--+
  | string table |   | kernel | | symbol table |
  +--+   ++ +--+

The new addresses computed by lines 338-359 (here, it's really
lines 344-345) will move the tables so that they end up as:

 ++--+--+
 | kernel | symbol table | string table |
 ++--+--+

The current version (rev. 1.20) will, however, first copy the
string table and then the symbol table.  But the copy of the
string table will overwrite the symbol table (see the pictures).

The old code (rev. 1.19) uses the right order of table copy to
make sure that we don't overwrite one table when moving the
other.  Here, we simply restore this behavior.  This makes
multibooting from GRUB2 work again (for MONOLITHIC).

ok jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/i386/multiboot.c

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

Modified files:

Index: src/sys/arch/i386/i386/multiboot.c
diff -u src/sys/arch/i386/i386/multiboot.c:1.20 src/sys/arch/i386/i386/multiboot.c:1.21
--- src/sys/arch/i386/i386/multiboot.c:1.20	Sat Jul 24 00:45:55 2010
+++ src/sys/arch/i386/i386/multiboot.c	Tue Jan 11 12:24:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot.c,v 1.20 2010/07/24 00:45:55 jym Exp $	*/
+/*	$NetBSD: multiboot.c,v 1.21 2011/01/11 12:24:37 gsutre Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: multiboot.c,v 1.20 2010/07/24 00:45:55 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: multiboot.c,v 1.21 2011/01/11 12:24:37 gsutre Exp $);
 
 #include opt_multiboot.h
 
@@ -339,28 +339,35 @@
 	(void *)strtabp  RELOC(void *, end)) {
 		symstart = RELOC(Elf32_Addr, end);
 		strstart = symstart + symsize;
+		memcpy((void *)symstart, (void *)symaddr, symsize);
+		memcpy((void *)strstart, (void *)straddr, strsize);
 } else if ((void *)symtabp  RELOC(void *, end) 
 	   (void *)strtabp  RELOC(void *, end)) {
 		symstart = RELOC(Elf32_Addr, end);
 		strstart = symstart + symsize;
+		memcpy((void *)symstart, (void *)symaddr, symsize);
+		memcpy((void *)strstart, (void *)straddr, strsize);
 } else if ((void *)symtabp  RELOC(void *, end) 
 	   (void *)strtabp  RELOC(void *, end)) {
 		strstart = RELOC(Elf32_Addr, end);
 		symstart = strstart + strsize;
+		memcpy((void *)strstart, (void *)straddr, strsize);
+		memcpy((void *)symstart, (void *)symaddr, symsize);
 	} else {
 		/* symtabp and strtabp are both over end */
 		if (symtabp  strtabp) {
 			symstart = RELOC(Elf32_Addr, end);
 			strstart = symstart + symsize;
+			memcpy((void *)symstart, (void *)symaddr, symsize);
+			memcpy((void *)strstart, (void *)straddr, strsize);
 		} else {
 			strstart = RELOC(Elf32_Addr, end);
 			symstart = strstart + strsize;
+			memcpy((void *)strstart, (void *)straddr, strsize);
+			memcpy((void *)symstart, (void *)symaddr, symsize);
 		}
 	}
 
-	memcpy((void *)strstart, (void *)straddr, strsize);
-	memcpy((void *)symstart, (void *)symaddr, symsize);
-
 	*RELOC(int *, esym) =
 	(int)(symstart + symsize + strsize + KERNBASE);
 



CVS commit: src/sys/arch/i386/i386

2010-11-06 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Sat Nov  6 11:40:25 UTC 2010

Modified Files:
src/sys/arch/i386/i386: compat_16_machdep.c dumpsys.c

Log Message:
These don't use UVM physical page API, don't need uvm/uvm_page.h.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/i386/compat_16_machdep.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/i386/dumpsys.c

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

Modified files:

Index: src/sys/arch/i386/i386/compat_16_machdep.c
diff -u src/sys/arch/i386/i386/compat_16_machdep.c:1.20 src/sys/arch/i386/i386/compat_16_machdep.c:1.21
--- src/sys/arch/i386/i386/compat_16_machdep.c:1.20	Sat Nov 21 03:11:00 2009
+++ src/sys/arch/i386/i386/compat_16_machdep.c	Sat Nov  6 11:40:24 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.20 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.21 2010/11/06 11:40:24 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: compat_16_machdep.c,v 1.20 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: compat_16_machdep.c,v 1.21 2010/11/06 11:40:24 uebayasi Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_vm86.h
@@ -52,7 +52,6 @@
 #include machine/vm86.h
 #endif
 #include uvm/uvm_extern.h
-#include uvm/uvm_page.h
 
 #include machine/pmap.h
 #include machine/vmparam.h

Index: src/sys/arch/i386/i386/dumpsys.c
diff -u src/sys/arch/i386/i386/dumpsys.c:1.11 src/sys/arch/i386/i386/dumpsys.c:1.12
--- src/sys/arch/i386/i386/dumpsys.c:1.11	Tue Oct  5 23:48:16 2010
+++ src/sys/arch/i386/i386/dumpsys.c	Sat Nov  6 11:40:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumpsys.c,v 1.11 2010/10/05 23:48:16 jym Exp $	*/
+/*	$NetBSD: dumpsys.c,v 1.12 2010/11/06 11:40:25 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.11 2010/10/05 23:48:16 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.12 2010/11/06 11:40:25 uebayasi Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -83,7 +83,6 @@
 #include machine/kcore.h
 
 #include uvm/uvm_extern.h
-#include uvm/uvm_page.h
 
 /*
  * Exports, needed by savecore, the debugger or elsewhere in the kernel.



CVS commit: src/sys/arch/i386/i386

2010-10-30 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sun Oct 31 04:51:19 UTC 2010

Modified Files:
src/sys/arch/i386/i386: vector.S

Log Message:
keep interrupts disabled in NMI handler.
the patch provided by IRINO yoshiaki in PR/43007.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.53 src/sys/arch/i386/i386/vector.S:1.54
--- src/sys/arch/i386/i386/vector.S:1.53	Mon Feb 22 06:42:14 2010
+++ src/sys/arch/i386/i386/vector.S	Sun Oct 31 04:51:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.53 2010/02/22 06:42:14 darran Exp $	*/
+/*	$NetBSD: vector.S,v 1.54 2010/10/31 04:51:19 yamt Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.53 2010/02/22 06:42:14 darran Exp $);
+__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.54 2010/10/31 04:51:19 yamt Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -896,7 +896,10 @@
 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: src/sys/arch/i386/i386

2010-10-02 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Sat Oct  2 22:54:47 UTC 2010

Modified Files:
src/sys/arch/i386/i386: dumpsys.c

Log Message:
dump is not used here.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/i386/dumpsys.c

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

Modified files:

Index: src/sys/arch/i386/i386/dumpsys.c
diff -u src/sys/arch/i386/i386/dumpsys.c:1.9 src/sys/arch/i386/i386/dumpsys.c:1.10
--- src/sys/arch/i386/i386/dumpsys.c:1.9	Fri Feb 26 19:25:07 2010
+++ src/sys/arch/i386/i386/dumpsys.c	Sat Oct  2 22:54:47 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: dumpsys.c,v 1.9 2010/02/26 19:25:07 jym Exp $	*/
+/*	$NetBSD: dumpsys.c,v 1.10 2010/10/02 22:54:47 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.9 2010/02/26 19:25:07 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: dumpsys.c,v 1.10 2010/10/02 22:54:47 jym Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -609,7 +609,6 @@
 static int
 cpu_dump(void)
 {
-	int (*dump)(dev_t, daddr_t, void *, size_t);
 	kcore_seg_t seg;
 	cpu_kcore_hdr_t cpuhdr;
 	const struct bdevsw *bdev;
@@ -617,7 +616,6 @@
 	bdev = bdevsw_lookup(dumpdev);
 	if (bdev == NULL)
 		return (ENXIO);
-	dump = bdev-d_dump;
 
 	/*
 	 * Generate a segment header.



CVS commit: src/sys/arch/i386/i386

2010-08-17 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Aug 17 22:24:05 UTC 2010

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Use SYSCTL_DESCR()


To generate a diff of this commit:
cvs rdiff -u -r1.693 -r1.694 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.693 src/sys/arch/i386/i386/machdep.c:1.694
--- src/sys/arch/i386/i386/machdep.c:1.693	Mon Aug 16 19:39:06 2010
+++ src/sys/arch/i386/i386/machdep.c	Tue Aug 17 22:24:04 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.693 2010/08/16 19:39:06 jym Exp $	*/
+/*	$NetBSD: machdep.c,v 1.694 2010/08/17 22:24:04 jym 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.693 2010/08/16 19:39:06 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.694 2010/08/17 22:24:04 jym Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -693,7 +693,8 @@
 		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 	sysctl_createv(clog, 0, NULL, NULL,
 		   CTLFLAG_PERMANENT,
-		   CTLTYPE_INT, pae, Whether the kernel uses PAE,
+		   CTLTYPE_INT, pae, 
+		   SYSCTL_DESCR(Whether the kernel uses PAE),
 		   NULL, 0, i386_use_pae, 0,
 		   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
 }



CVS commit: src/sys/arch/i386/i386

2010-07-28 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Jul 28 17:05:51 UTC 2010

Modified Files:
src/sys/arch/i386/i386: mptramp.S

Log Message:
Enable the NX bit feature early in i386 MP trampoline code (do not rely on
cpu_init_msrs() to do it). Having NX bit set on a page will raise a #GP
on fetch if NXE is not enabled, which can happen early when structures
(like idlelwp) are allocated with just rw- rights.

NX is enabled with PAE (if host supports it).

Exact same issue as for amd64, some weeks ago. Same player, shoot again...


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/mptramp.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/mptramp.S
diff -u src/sys/arch/i386/i386/mptramp.S:1.21 src/sys/arch/i386/i386/mptramp.S:1.22
--- src/sys/arch/i386/i386/mptramp.S:1.21	Sat Jul 24 00:45:55 2010
+++ src/sys/arch/i386/i386/mptramp.S	Wed Jul 28 17:05:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: mptramp.S,v 1.21 2010/07/24 00:45:55 jym Exp $	*/
+/*	$NetBSD: mptramp.S,v 1.22 2010/07/28 17:05:51 jym Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: mptramp.S,v 1.21 2010/07/24 00:45:55 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: mptramp.S,v 1.22 2010/07/28 17:05:51 jym Exp $);
 	
 #include opt_mpbios.h		/* for MPDEBUG */
 		
@@ -158,6 +158,7 @@
 	movl	%cr4,%eax
 	orl	$CR4_PSE,%eax
 	movl	%eax,%cr4
+
 1:
 
 #ifdef PAE /* Enable PAE */
@@ -181,6 +182,18 @@
 #endif
 	HALT(0x6)
 
+	/*
+	 * If EFER_NXE is not enabled, fetching a page with a NX bit set
+	 * will raise a #GP. Avoid that by setting the NXE feature now.
+	 */
+	movl	_C_LABEL(cpu_feature)+2*4,%eax	/* cpu_feature[2] */
+	andl	$CPUID_NOX,%eax
+	jz	1f
+	movl	$MSR_EFER,%ecx
+	rdmsr
+	orl	$EFER_NXE,%eax	/* enable No-Execute feature */
+	wrmsr
+
 /*
  * ok, we are now running with paging enabled and sharing page tables
  * with cpu0.  figure out which processor we really are, what stack we



CVS commit: src/sys/arch/i386/i386

2010-07-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 25 19:19:06 UTC 2010

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

Log Message:
PR/43655: Taylor R Campbell: Incorrect siginfo code's for integer zero
divide and overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/sys/arch/i386/i386/trap.c

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

Modified files:

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.257 src/sys/arch/i386/i386/trap.c:1.258
--- src/sys/arch/i386/i386/trap.c:1.257	Tue May  4 19:27:13 2010
+++ src/sys/arch/i386/i386/trap.c	Sun Jul 25 15:19:06 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.257 2010/05/04 23:27:13 jym Exp $	*/
+/*	$NetBSD: trap.c,v 1.258 2010/07/25 19:19:06 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.257 2010/05/04 23:27:13 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.258 2010/07/25 19:19:06 christos Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -603,14 +603,16 @@
 			ksi.ksi_code = xmm_si_code(l);
 			break;
 		case T_BOUND|T_USER:
+			ksi.ksi_code = FPE_FLTSUB;
+			break;
 		case T_OFLOW|T_USER:
-			ksi.ksi_code = FPE_FLTOVF;
+			ksi.ksi_code = FPE_INTOVF;
 			break;
 		case T_DIVIDE|T_USER:
-			ksi.ksi_code = FPE_FLTDIV;
+			ksi.ksi_code = FPE_INTDIV;
 			break;
 		case T_ARITHTRAP|T_USER:
-			ksi.ksi_code = FPE_INTOVF;
+			ksi.ksi_code = npxtrap(l);
 			break;
 		default:
 			ksi.ksi_code = 0;



CVS commit: src/sys/arch/i386/i386

2010-07-15 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Jul 15 18:55:27 UTC 2010

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
In Xen PAE case, fix argument size passed to init386(), by pushing the
upper bits onto stack (we do not expect first_avail to be above 4GiB, so
assume their value is 0).

Remove macros (PROC0PDIR and PROC0STACK) that were never used.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 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.91 src/sys/arch/i386/i386/locore.S:1.92
--- src/sys/arch/i386/i386/locore.S:1.91	Fri Nov 27 03:23:10 2009
+++ src/sys/arch/i386/i386/locore.S	Thu Jul 15 18:55:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.91 2009/11/27 03:23:10 rmind Exp $	*/
+/*	$NetBSD: locore.S,v 1.92 2010/07/15 18:55:27 jym Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -129,7 +129,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.91 2009/11/27 03:23:10 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.92 2010/07/15 18:55:27 jym Exp $);
 
 #include opt_compat_oldboot.h
 #include opt_ddb.h
@@ -746,24 +746,26 @@
 	movl	%eax,RELOC(cpuid_level)
 
 	call	xen_pmap_bootstrap
+
 	/*
 	 * First avail returned by xen_pmap_bootstrap in %eax
 	 */
 	movl	%eax, %esi;
 	movl	%esi, _C_LABEL(lwp0uarea)
 
-#define PROC0PDIR   ((0)  * PAGE_SIZE)
-#define PROC0STACK  ((1)  * PAGE_SIZE)
-
 	/* Set up bootstrap stack. */
 	leal	(KSTACK_SIZE-FRAMESIZE)(%eax),%esp
 	xorl	%ebp,%ebp   # mark end of frames
 
 	addl	$USPACE, %esi
 	subl	$KERNBASE, %esi		#init386 want a physical address
+
+#ifdef PAE
+	pushl	$0	# init386() expects a 64 bits paddr_t with PAE
+#endif
 	pushl	%esi
 	call	_C_LABEL(init386)	# wire 386 chip for unix operation
-	addl	$4,%esp
+	addl	$PDE_SIZE,%esp
 	call 	_C_LABEL(main)
 
 #if defined(XEN)  !defined(XEN_COMPAT_030001)



CVS commit: src/sys/arch/i386/i386

2010-07-15 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Thu Jul 15 22:19:19 UTC 2010

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
pte0 is used to map the page required by bioscall() trampoline code, so
add VM_PROT_EXECUTE protection for it.

Currently, this does not change much, as page execute permission is not
enforced for i386 (except for Xen, where BIOS calls are not used anyway).


To generate a diff of this commit:
cvs rdiff -u -r1.688 -r1.689 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.688 src/sys/arch/i386/i386/machdep.c:1.689
--- src/sys/arch/i386/i386/machdep.c:1.688	Wed Jul 14 14:42:40 2010
+++ src/sys/arch/i386/i386/machdep.c	Thu Jul 15 22:19:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.688 2010/07/14 14:42:40 jym Exp $	*/
+/*	$NetBSD: machdep.c,v 1.689 2010/07/15 22:19:19 jym 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.688 2010/07/14 14:42:40 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.689 2010/07/15 22:19:19 jym Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1236,7 +1236,7 @@
 
 	paddr = 4 * PAGE_SIZE;
 	vaddr = (vaddr_t)vtopte(0);
-	pmap_kenter_pa(vaddr, paddr, VM_PROT_READ | VM_PROT_WRITE, 0);
+	pmap_kenter_pa(vaddr, paddr, VM_PROT_ALL, 0);
 	pmap_update(pmap_kernel());
 	/* make sure it is clean before using */
 	memset((void *)vaddr, 0, PAGE_SIZE);



CVS commit: src/sys/arch/i386/i386

2010-07-14 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Wed Jul 14 14:42:40 UTC 2010

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.687 -r1.688 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.687 src/sys/arch/i386/i386/machdep.c:1.688
--- src/sys/arch/i386/i386/machdep.c:1.687	Tue May  4 23:27:13 2010
+++ src/sys/arch/i386/i386/machdep.c	Wed Jul 14 14:42:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.687 2010/05/04 23:27:13 jym Exp $	*/
+/*	$NetBSD: machdep.c,v 1.688 2010/07/14 14:42:40 jym 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.687 2010/05/04 23:27:13 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.688 2010/07/14 14:42:40 jym Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1346,7 +1346,7 @@
 #endif
 
 	/*
-	 * Initailize PAGE_SIZE-dependent variables.
+	 * Initialize PAGE_SIZE-dependent variables.
 	 */
 	uvm_setpagesize();
 



CVS commit: src/sys/arch/i386/i386

2010-07-06 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Jul  7 01:21:15 UTC 2010

Modified Files:
src/sys/arch/i386/i386: copy.S

Log Message:
return the error from fault handler in ucas_fault
rather than forcing EFAULT.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/i386/copy.S

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

Modified files:

Index: src/sys/arch/i386/i386/copy.S
diff -u src/sys/arch/i386/i386/copy.S:1.21 src/sys/arch/i386/i386/copy.S:1.22
--- src/sys/arch/i386/i386/copy.S:1.21	Fri Nov 27 03:23:10 2009
+++ src/sys/arch/i386/i386/copy.S	Wed Jul  7 01:21:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.21 2009/11/27 03:23:10 rmind Exp $	*/
+/*	$NetBSD: copy.S,v 1.22 2010/07/07 01:21:15 chs Exp $	*/
 /*	NetBSD: locore.S,v 1.34 2005/04/01 11:59:31 yamt Exp $	*/
 
 /*-
@@ -65,7 +65,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: copy.S,v 1.21 2009/11/27 03:23:10 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: copy.S,v 1.22 2010/07/07 01:21:15 chs Exp $);
 
 #include assym.h
 
@@ -98,8 +98,7 @@
  * Label must be before all copy functions.
  */
 	.text
-
-x86_copyfunc_start:	.globl	x86_copyfunc_start
+LABEL(x86_copyfunc_start)
 
 /*
  * Handle deferred pmap switch.  We must re-enable preemption without
@@ -686,7 +685,7 @@
 	movl	12(%esp), %ecx
 	/* Fail if kernel-space */
 	cmpl	$VM_MAXUSER_ADDRESS-4, %edx
-	ja	_C_LABEL(ucas_fault)
+	ja	_C_LABEL(ucas_efault)
 	/* Label for fault handler */
 .Lucas32_start:
 	/* Perform the CAS */
@@ -703,16 +702,14 @@
 	ret
 	DEFERRED_SWITCH_CALL
 
-/*
- * Fault handler for ucas_32().
- * Unset the handler and return the failure.
- */
+NENTRY(ucas_efault)
+	mov	$EFAULT, %eax
 NENTRY(ucas_fault)
-	movl	$EFAULT, %eax
 	ret
 
 /*
  * int	ucas_int(volatile int *uptr, int old, int new, int *ret);
+ * int	ucas_ptr(volatile void **uptr, void *old, void *new, void **ret);
  */
 STRONG_ALIAS(ucas_ptr, ucas_32)
 STRONG_ALIAS(ucas_int, ucas_32)
@@ -782,7 +779,7 @@
 /*
  * Label must be after all copy functions.
  */
-x86_copyfunc_end:	.globl	x86_copyfunc_end
+LABEL(x86_copyfunc_end)
 
 /*
  * Fault table of copy functions for trap().



CVS commit: src/sys/arch/i386/i386

2010-05-05 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Wed May  5 17:42:19 UTC 2010

Modified Files:
src/sys/arch/i386/i386: busfunc.S

Log Message:
Andrew Doran points out that _ALIGN_TEXT is unused, and the processor
may be able to pair or pipeline instructions if I load the
bus_space_tag pointer nearer the top of the functions.  Get rid of the
_ALIGN_TEXT definition, and load the pointer earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/i386/busfunc.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/busfunc.S
diff -u src/sys/arch/i386/i386/busfunc.S:1.6 src/sys/arch/i386/i386/busfunc.S:1.7
--- src/sys/arch/i386/i386/busfunc.S:1.6	Wed Apr 28 19:17:03 2010
+++ src/sys/arch/i386/i386/busfunc.S	Wed May  5 17:42:19 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: busfunc.S,v 1.6 2010/04/28 19:17:03 dyoung Exp $	*/
+/*	$NetBSD: busfunc.S,v 1.7 2010/05/05 17:42:19 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,22 +30,18 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: busfunc.S,v 1.6 2010/04/28 19:17:03 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: busfunc.S,v 1.7 2010/05/05 17:42:19 dyoung Exp $);
 
 #include assym.h
 
-/* XXX */
-#undef	_ALIGN_TEXT
-#define	_ALIGN_TEXT	.align 16
-
 /*
  * uint8_t bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t bsh,
  *bus_size_t offset);
  */
 ENTRY(bus_space_read_1)
+	movl	4(%esp), %eax
 	movl	8(%esp), %edx
 	addl	12(%esp), %edx
-	movl	4(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	je	1f
 	movzbl	(%edx), %eax
@@ -60,9 +56,9 @@
  *bus_size_t offset);
  */
 ENTRY(bus_space_read_2)
+	movl	4(%esp), %eax
 	movl	8(%esp), %edx
 	addl	12(%esp), %edx
-	movl	4(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	je	1f
 	movzwl	(%edx), %eax
@@ -77,9 +73,9 @@
  *bus_size_t offset);
  */
 ENTRY(bus_space_read_4)
+	movl	4(%esp), %eax
 	movl	8(%esp), %edx
 	addl	12(%esp), %edx
-	movl	4(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	je	1f
 	movl	(%edx), %eax
@@ -97,9 +93,9 @@
  *bus_size_t offset, uint8_t value);
  */
 ENTRY(bus_space_write_1)
+	movl	4(%esp), %eax
 	movl	8(%esp), %edx
 	addl	12(%esp), %edx
-	movl	4(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	16(%esp), %eax
 	je	1f
@@ -114,9 +110,9 @@
  *bus_size_t offset, uint16_t value);
  */
 ENTRY(bus_space_write_2)
+	movl	4(%esp), %eax
 	movl	8(%esp), %edx
 	addl	12(%esp), %edx
-	movl	4(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	16(%esp), %eax
 	je	1f
@@ -131,9 +127,9 @@
  * bus_size_t offset, uint32_t value);
  */
 ENTRY(bus_space_write_4)
+	movl	4(%esp), %eax
 	movl	8(%esp), %edx
 	addl	12(%esp), %edx
-	movl	4(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	16(%esp), %eax
 	je	1f
@@ -153,9 +149,9 @@
  */
 ENTRY(bus_space_read_multi_1)
 	pushl	%edi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %edi
 	movl	24(%esp), %ecx
@@ -180,9 +176,9 @@
  */
 ENTRY(bus_space_read_multi_2)
 	pushl	%edi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %edi
 	movl	24(%esp), %ecx
@@ -207,9 +203,9 @@
  */
 ENTRY(bus_space_read_multi_4)
 	pushl	%edi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %edi
 	movl	24(%esp), %ecx
@@ -238,9 +234,9 @@
  */
 ENTRY(bus_space_write_multi_1)
 	pushl	%esi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %esi
 	movl	24(%esp), %ecx
@@ -265,9 +261,9 @@
  */
 ENTRY(bus_space_write_multi_2)
 	pushl	%esi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %esi
 	movl	24(%esp), %ecx
@@ -292,9 +288,9 @@
  */
 ENTRY(bus_space_write_multi_4)
 	pushl	%esi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %esi
 	movl	24(%esp), %ecx
@@ -323,9 +319,9 @@
  */
 ENTRY(bus_space_read_region_1)
 	pushl	%edi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %edi
 	movl	24(%esp), %ecx
@@ -353,9 +349,9 @@
  */
 ENTRY(bus_space_read_region_2)
 	pushl	%edi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, BST_TYPE(%eax)
 	movl	20(%esp), %edi
 	movl	24(%esp), %ecx
@@ -383,9 +379,9 @@
  */
 ENTRY(bus_space_read_region_4)
 	pushl	%edi
+	movl	8(%esp), %eax
 	movl	12(%esp), %edx
 	addl	16(%esp), %edx
-	movl	8(%esp), %eax
 	cmpl	$X86_BUS_SPACE_IO, 

CVS commit: src/sys/arch/i386/i386

2010-04-27 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Apr 27 18:41:52 UTC 2010

Modified Files:
src/sys/arch/i386/i386: pmc.c

Log Message:
#include machine/cpuvar.h for CPU feature definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/pmc.c

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

Modified files:

Index: src/sys/arch/i386/i386/pmc.c
diff -u src/sys/arch/i386/i386/pmc.c:1.18 src/sys/arch/i386/i386/pmc.c:1.19
--- src/sys/arch/i386/i386/pmc.c:1.18	Thu Apr 22 21:02:25 2010
+++ src/sys/arch/i386/i386/pmc.c	Tue Apr 27 18:41:52 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmc.c,v 1.18 2010/04/22 21:02:25 jym Exp $	*/
+/*	$NetBSD: pmc.c,v 1.19 2010/04/27 18:41:52 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2000 Zembu Labs, Inc.
@@ -38,13 +38,14 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pmc.c,v 1.18 2010/04/22 21:02:25 jym Exp $);
+__KERNEL_RCSID(0, $NetBSD: pmc.c,v 1.19 2010/04/27 18:41:52 dyoung Exp $);
 
 #include sys/param.h
 #include sys/systm.h
 #include sys/proc.h
 
 #include machine/cpufunc.h
+#include machine/cpuvar.h
 #include machine/specialreg.h
 #include machine/sysarch.h
 #include machine/pmc.h



CVS commit: src/sys/arch/i386/i386

2010-04-07 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Apr  7 11:16:30 UTC 2010

Modified Files:
src/sys/arch/i386/i386: lock_stubs.S

Log Message:
Fix fmt'ing error in comment from rev 1.22.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/i386/lock_stubs.S

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

Modified files:

Index: src/sys/arch/i386/i386/lock_stubs.S
diff -u src/sys/arch/i386/i386/lock_stubs.S:1.23 src/sys/arch/i386/i386/lock_stubs.S:1.24
--- src/sys/arch/i386/i386/lock_stubs.S:1.23	Fri Apr 24 17:45:40 2009
+++ src/sys/arch/i386/i386/lock_stubs.S	Wed Apr  7 11:16:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.S,v 1.23 2009/04/24 17:45:40 ad Exp $	*/
+/*	$NetBSD: lock_stubs.S,v 1.24 2010/04/07 11:16:30 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 /*
- * Where possible we make * each routine fit into an assumed 64-byte cache
- * line.  Please check * alignment with 'objdump -d' after making changes. 
+ * Where possible we make each routine fit into an assumed 64-byte cache
+ * line.  Please check alignment with 'objdump -d' after making changes. 
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: lock_stubs.S,v 1.23 2009/04/24 17:45:40 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: lock_stubs.S,v 1.24 2010/04/07 11:16:30 pooka Exp $);
 
 #include opt_lockdebug.h
 



CVS commit: src/sys/arch/i386/i386

2010-02-14 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Sun Feb 14 11:09:54 UTC 2010

Modified Files:
src/sys/arch/i386/i386: ibcs2_machdep.c svr4_machdep.c

Log Message:
fix confused CS selector, fixes the panic reported by Mark Davis
per PR port-i386/42787 (the panic happens due to a GPF when a
privileged descriptor is tried to be loaded with the UPL bit set)
The original bug is very old (pre-2.0, i386/svr4_machdep.c rev. 1.69),
but it was relatively harmless until the order of GDT entries was
shuffled (pre-5.0, i386/segments.h rev. 1.42). Before, it caused
a userlevel data selector to be used for CS which broke the emulation
(likely the reason of PR port-i386/32424). The shuffle made that
a privileged selector was used, causing the GPF.
(recent -current doesn't panic on that GPF which seems to be a
side effect of another change)


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/i386/ibcs2_machdep.c
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/i386/i386/svr4_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/i386/i386/ibcs2_machdep.c
diff -u src/sys/arch/i386/i386/ibcs2_machdep.c:1.39 src/sys/arch/i386/i386/ibcs2_machdep.c:1.40
--- src/sys/arch/i386/i386/ibcs2_machdep.c:1.39	Thu Dec 10 14:13:50 2009
+++ src/sys/arch/i386/i386/ibcs2_machdep.c	Sun Feb 14 11:09:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ibcs2_machdep.c,v 1.39 2009/12/10 14:13:50 matt Exp $	*/
+/*	$NetBSD: ibcs2_machdep.c,v 1.40 2010/02/14 11:09:54 drochner Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ibcs2_machdep.c,v 1.39 2009/12/10 14:13:50 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: ibcs2_machdep.c,v 1.40 2010/02/14 11:09:54 drochner Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_vm86.h
@@ -74,7 +74,7 @@
 		pcb-pcb_savefpu.sv_87.sv_env.en_cw = __iBCS2_NPXCW__;
 	tf = l-l_md.md_regs;
 	tf-tf_eax = 0x200;		/* XXX base of heap */
-	tf-tf_cs = GSEL(LUCODEBIG_SEL, SEL_UPL);
+	tf-tf_cs = GSEL(GUCODEBIG_SEL, SEL_UPL);
 }
 
 /*

Index: src/sys/arch/i386/i386/svr4_machdep.c
diff -u src/sys/arch/i386/i386/svr4_machdep.c:1.95 src/sys/arch/i386/i386/svr4_machdep.c:1.96
--- src/sys/arch/i386/i386/svr4_machdep.c:1.95	Thu Dec 10 14:13:50 2009
+++ src/sys/arch/i386/i386/svr4_machdep.c	Sun Feb 14 11:09:54 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_machdep.c,v 1.95 2009/12/10 14:13:50 matt Exp $	 */
+/*	$NetBSD: svr4_machdep.c,v 1.96 2010/02/14 11:09:54 drochner Exp $	 */
 
 /*-
  * Copyright (c) 1994, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: svr4_machdep.c,v 1.95 2009/12/10 14:13:50 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: svr4_machdep.c,v 1.96 2010/02/14 11:09:54 drochner Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_vm86.h
@@ -119,7 +119,7 @@
 		pcb-pcb_savefpu.sv_xmm.sv_env.en_cw = __SVR4_NPXCW__;
 	else
 		pcb-pcb_savefpu.sv_87.sv_env.en_cw = __SVR4_NPXCW__;
-	tf-tf_cs = GSEL(LUCODEBIG_SEL, SEL_UPL);
+	tf-tf_cs = GSEL(GUCODEBIG_SEL, SEL_UPL);
 }
 
 void *



CVS commit: src/sys/arch/i386/i386

2010-02-09 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Tue Feb  9 23:09:47 UTC 2010

Modified Files:
src/sys/arch/i386/i386: mptramp.S

Log Message:
Use CR0_PE (enable protected mode) instead of hardcoding constant.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/i386/mptramp.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/mptramp.S
diff -u src/sys/arch/i386/i386/mptramp.S:1.19 src/sys/arch/i386/i386/mptramp.S:1.20
--- src/sys/arch/i386/i386/mptramp.S:1.19	Fri Nov 27 03:23:10 2009
+++ src/sys/arch/i386/i386/mptramp.S	Tue Feb  9 23:09:47 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: mptramp.S,v 1.19 2009/11/27 03:23:10 rmind Exp $	*/
+/*	$NetBSD: mptramp.S,v 1.20 2010/02/09 23:09:47 jym Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: mptramp.S,v 1.19 2009/11/27 03:23:10 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: mptramp.S,v 1.20 2010/02/09 23:09:47 jym Exp $);
 	
 #include opt_mpbios.h		/* for MPDEBUG */
 		
@@ -125,8 +125,8 @@
 	movw%ax, %es
 	movw%ax, %ss
 	data32 addr32 lgdt(gdt_desc)  # load flat descriptor table
-	movl%cr0, %eax   # get cr0
-	orl $0x1, %eax  # enable protected mode
+	movl%cr0, %eax  # get cr0
+	orl $CR0_PE, %eax   # enable protected mode
 	movl%eax, %cr0  # doit
 	ljmpl$0x8, $mp_startup
 



CVS commit: src/sys/arch/i386/i386

2010-01-17 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jan 17 22:21:18 UTC 2010

Modified Files:
src/sys/arch/i386/i386: trap.c vector.S

Log Message:
Fix 'fault on load of %gs during retirn to userspace' to look for the
  correct instruction bytes.
Take the 'fault on load segment register' through the same path as 'fault
  on iret' so we don't have to fixup the broken stackframe that contains a
  mix of user and kernel registers,
Update comments about how the faults during return to userspace are processed.
Setting an invalid %gs in the saved context of a signal handler causes
  a SIGSEGV handler to be entered with what look like valid registers.


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/sys/arch/i386/i386/trap.c
cvs rdiff -u -r1.50 -r1.51 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/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.252 src/sys/arch/i386/i386/trap.c:1.253
--- src/sys/arch/i386/i386/trap.c:1.252	Sun Jan 10 15:37:36 2010
+++ src/sys/arch/i386/i386/trap.c	Sun Jan 17 22:21:18 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.252 2010/01/10 15:37:36 dsl Exp $	*/
+/*	$NetBSD: trap.c,v 1.253 2010/01/17 22:21:18 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.252 2010/01/10 15:37:36 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.253 2010/01/17 22:21:18 dsl Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -123,7 +123,7 @@
 static inline int xmm_si_code(struct lwp *);
 void trap(struct trapframe *);
 void trap_tss(struct i386tss *, int, int);
-void trap_return_iret(struct trapframe *) __dead;
+void trap_return_fault_return(struct trapframe *) __dead;
 
 #ifdef KVM86
 #include machine/kvm86.h
@@ -300,7 +300,7 @@
 	struct proc *p;
 	struct pcb *pcb;
 	extern char fusubail[], kcopy_fault[], return_address_fault[],
-	trapreturn[], IDTVEC(osyscall)[];
+	IDTVEC(osyscall)[];
 	struct trapframe *vframe;
 	ksiginfo_t ksi;
 	void *onfault;
@@ -398,96 +398,76 @@
 
 		/*
 		 * Check for failure during return to user mode.
+		 * This can happen loading invalid values into the segment
+		 * registers, or during the 'iret' itself.
 		 *
 		 * 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.
-		 *
-		 * At this point, there are (at least) two trap frames on
-		 * the kernel stack; we presume here that we faulted while
-		 * loading our registers out of the outer one.
 		 */
 
 		KSI_INIT_TRAP(ksi);
 		ksi.ksi_signo = SIGSEGV;
-		/* There is no fault address! */
 		ksi.ksi_code = SEGV_ACCERR;
 		ksi.ksi_trap = type;
 
 		switch (*(u_char *)frame-tf_eip) {
 		case 0xcf:	/* iret */
 			/*
-			 * The outer trap frame only contains the user space
-			 * return address and stack pointer.
-			 * The user registers are in the inner frame following
-			 * the kernel address of the iret.
-			 * We must copy the registers next to the userspace
-			 * return address so we have a frame for md_regs.
-			 *
-			 * Also, we might have faulted trying to execute the
-			 * trampoline for a local (nested) signal handler.
-			 * If we change the %cs (eg to include the stack)
-			 * just return the return to user.
+			 * The 'iret' instruction faulted, so we have the
+			 * 'user' registers saved after the kernel %eip:%cs:%fl
+			 * of the 'iret' and below that the user %eip:%cs:%fl
+			 * the 'iret' was processing.
+			 * We must delete the 3 words of kernel return address
+			 * from the stack to generate a normal stack frame
+			 * (eg for sending a SIGSEGV).
 			 */
 			vframe = (void *)((int *)frame + 3);
 			if (KERNELMODE(vframe-tf_cs, vframe-tf_eflags))
 goto we_re_toast;
 			memmove(vframe, frame,
 			offsetof(struct trapframe, tf_eip));
-			l-l_md.md_regs = vframe;
+			/* Set the faulting address to the user %eip */
 			ksi.ksi_addr = (void *)vframe-tf_eip;
-			if (!pmap_exec_fixup(p-p_vmspace-vm_map, vframe,
-			lwp_getpcb(l)))
-(*p-p_emul-e_trapsignal)(l, ksi);
-			trap_return_iret(vframe);
-			/* NOTREACHED */
+			break;
 		case 0x8e:
 			switch (*(uint32_t *)frame-tf_eip) {
-			case 0x0c245c8e:	/* movl 0xc(%esp,1),%ds */
-			case 0x0824448e:	/* movl 0x8(%esp,1),%es */
-			case 0x0424648e:	/* movl 0x4(%esp,1),%fs */
-			case 0x00246c8e:	/* movl 0x0(%esp,1),%gs */
+			case 0x8e242c8e:	/* mov (%esp,%gs), then */
+			case 0x0424648e:	/* mov 0x4(%esp),%fs */
+			case 0x0824448e:	/* mov 0x8(%esp),%es */
+			case 0x0c245c8e:	/* mov 0xc(%esp),%ds */
 break;
 			default:
 goto we_re_toast;
 			}
+			/*
+			 * We faulted loading one if the user segment registers.
+			 * The stack frame containing the user registers is
+			 * still valid and is just below the 

CVS commit: src/sys/arch/i386/i386

2010-01-10 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jan 10 15:21:36 UTC 2010

Modified Files:
src/sys/arch/i386/i386: trap.c vector.S

Log Message:
If we fault on the 'iret' during return to userpace (eg if %eip is outside
the bounds of %cs) then hack the stack to contain a normal fault frame
for the signal setup code (etc).
Previously the code assumed that the original user trap frame was still
present - at it is for faults when loading the segment registers.


To generate a diff of this commit:
cvs rdiff -u -r1.250 -r1.251 src/sys/arch/i386/i386/trap.c
cvs rdiff -u -r1.49 -r1.50 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/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.250 src/sys/arch/i386/i386/trap.c:1.251
--- src/sys/arch/i386/i386/trap.c:1.250	Sat Nov 21 03:11:00 2009
+++ src/sys/arch/i386/i386/trap.c	Sun Jan 10 15:21:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.250 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: trap.c,v 1.251 2010/01/10 15:21:36 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.250 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.251 2010/01/10 15:21:36 dsl Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -123,6 +123,7 @@
 static inline int xmm_si_code(struct lwp *);
 void trap(struct trapframe *);
 void trap_tss(struct i386tss *, int, int);
+void trap_return_iret(struct trapframe *) __dead;
 
 #ifdef KVM86
 #include machine/kvm86.h
@@ -406,11 +407,33 @@
 		 * the kernel stack; we presume here that we faulted while
 		 * loading our registers out of the outer one.
 		 */
+
+		KSI_INIT_TRAP(ksi);
+		ksi.ksi_signo = SIGSEGV;
+		/* There is no fault address! */
+		ksi.ksi_code = SEGV_ACCERR;
+		ksi.ksi_trap = type;
+
 		switch (*(u_char *)frame-tf_eip) {
 		case 0xcf:	/* iret */
-			vframe = (void *)((int)frame-tf_esp -
+			/*
+			 * The outer trap frame only contains the user space
+			 * return address and stack pointer.
+			 * The user registers are in the inner frame following
+			 * the kernel address of the iret.
+			 * We must copy the registers next to the userspace
+			 * return address so we have a frame for md_regs.
+			 */
+			vframe = (void *)((int *)frame + 3);
+			if (KERNELMODE(vframe-tf_cs, vframe-tf_eflags))
+goto we_re_toast;
+			memmove(vframe, frame,
 			offsetof(struct trapframe, tf_eip));
-			break;
+			l-l_md.md_regs = vframe;
+			ksi.ksi_addr = (void *)vframe-tf_eip;
+			(*p-p_emul-e_trapsignal)(l, ksi);
+			trap_return_iret(vframe);
+			/* NOTREACHED */
 		case 0x8e:
 			switch (*(uint32_t *)frame-tf_eip) {
 			case 0x0c245c8e:	/* movl 0xc(%esp,1),%ds */
@@ -421,11 +444,12 @@
 			default:
 goto we_re_toast;
 			}
-			vframe = (void *)(int)frame-tf_esp;
 			break;
 		default:
 			goto we_re_toast;
 		}
+
+		vframe = (void *)(int)frame-tf_esp;
 		if (KERNELMODE(vframe-tf_cs, vframe-tf_eflags))
 			goto we_re_toast;
 
@@ -445,17 +469,16 @@
 		 * continue to generate traps infinitely with
 		 * interrupts disabled.
 		 */
+		/* We don't want to fault unwinding the inner frame */
 		frame-tf_ds = GSEL(GDATA_SEL, SEL_KPL);
 		frame-tf_es = GSEL(GDATA_SEL, SEL_KPL);
 		frame-tf_gs = GSEL(GDATA_SEL, SEL_KPL);
 		frame-tf_fs = GSEL(GCPU_SEL, SEL_KPL);
+		/* Reload the entire outer (user) frame */
 		frame-tf_eip = (uintptr_t)trapreturn;
 		frame-tf_eflags = (frame-tf_eflags  ~PSL_NT) | PSL_I;
-		KSI_INIT_TRAP(ksi);
-		ksi.ksi_signo = SIGSEGV;
-		ksi.ksi_addr = (void *)rcr2();
-		ksi.ksi_code = SEGV_ACCERR;
-		ksi.ksi_trap = type  ~T_USER;
+		/* Save outer frame for any signal return */
+		l-l_md.md_regs = vframe;
 		(*p-p_emul-e_trapsignal)(l, ksi);
 		return;
 

Index: src/sys/arch/i386/i386/vector.S
diff -u src/sys/arch/i386/i386/vector.S:1.49 src/sys/arch/i386/i386/vector.S:1.50
--- src/sys/arch/i386/i386/vector.S:1.49	Wed Nov 25 14:28:50 2009
+++ src/sys/arch/i386/i386/vector.S	Sun Jan 10 15:21:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vector.S,v 1.49 2009/11/25 14:28:50 rmind Exp $	*/
+/*	$NetBSD: vector.S,v 1.50 2010/01/10 15:21:36 dsl Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.49 2009/11/25 14:28:50 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: vector.S,v 1.50 2010/01/10 15:21:36 dsl Exp $);
 
 #include opt_ddb.h
 #include opt_multiprocessor.h
@@ -1036,6 +1036,10 @@
 	iret
 	jmp	1b
 
+_C_LABEL(trap_return_iret):	.globl	trap_return_iret
+	mov	4(%esp),%esp	/* frame for user return */
+	jmp	_C_LABEL(trapreturn)
+
 /* LINTSTUB: Ignore */
 NENTRY(alltraps)
 	INTRENTRY



CVS commit: src/sys/arch/i386/i386

2010-01-10 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Jan 10 15:37:36 UTC 2010

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

Log Message:
If we fault on the iret during return to userspace, see if we need to
do a lazy update of %cs to make the stack executable.
If a change is made, just retry the failing sequence.
Signal handlers as gcc nested local functions now work!


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/arch/i386/i386/trap.c

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

Modified files:

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.251 src/sys/arch/i386/i386/trap.c:1.252
--- src/sys/arch/i386/i386/trap.c:1.251	Sun Jan 10 15:21:36 2010
+++ src/sys/arch/i386/i386/trap.c	Sun Jan 10 15:37:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.251 2010/01/10 15:21:36 dsl Exp $	*/
+/*	$NetBSD: trap.c,v 1.252 2010/01/10 15:37:36 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.251 2010/01/10 15:21:36 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.252 2010/01/10 15:37:36 dsl Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -423,6 +423,11 @@
 			 * the kernel address of the iret.
 			 * We must copy the registers next to the userspace
 			 * return address so we have a frame for md_regs.
+			 *
+			 * Also, we might have faulted trying to execute the
+			 * trampoline for a local (nested) signal handler.
+			 * If we change the %cs (eg to include the stack)
+			 * just return the return to user.
 			 */
 			vframe = (void *)((int *)frame + 3);
 			if (KERNELMODE(vframe-tf_cs, vframe-tf_eflags))
@@ -431,7 +436,9 @@
 			offsetof(struct trapframe, tf_eip));
 			l-l_md.md_regs = vframe;
 			ksi.ksi_addr = (void *)vframe-tf_eip;
-			(*p-p_emul-e_trapsignal)(l, ksi);
+			if (!pmap_exec_fixup(p-p_vmspace-vm_map, vframe,
+			lwp_getpcb(l)))
+(*p-p_emul-e_trapsignal)(l, ksi);
 			trap_return_iret(vframe);
 			/* NOTREACHED */
 		case 0x8e:



CVS commit: src/sys/arch/i386/i386

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 16:04:32 UTC 2009

Modified Files:
src/sys/arch/i386/i386: apmbios.c

Log Message:
Fix compilation issue with time_t


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/i386/apmbios.c

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

Modified files:

Index: src/sys/arch/i386/i386/apmbios.c
diff -u src/sys/arch/i386/i386/apmbios.c:1.15 src/sys/arch/i386/i386/apmbios.c:1.16
--- src/sys/arch/i386/i386/apmbios.c:1.15	Fri Nov 20 22:11:00 2009
+++ src/sys/arch/i386/i386/apmbios.c	Thu Dec 31 11:04:32 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: apmbios.c,v 1.15 2009/11/21 03:11:00 rmind Exp $ */
+/*	$NetBSD: apmbios.c,v 1.16 2009/12/31 16:04:32 christos Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: apmbios.c,v 1.15 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: apmbios.c,v 1.16 2009/12/31 16:04:32 christos Exp $);
 
 #include opt_apm.h
 #include opt_compat_mach.h	/* Needed to get the right segment def */
@@ -221,6 +221,7 @@
 	const char *name;
 	int inf;
 	int outf = 0; /* XXX: gcc */
+	long long milli;
 		
 	if (print) {
 		if (func = sizeof(aci) / sizeof(aci[0])) {
@@ -232,12 +233,13 @@
 			outf = aci[func].outflag;
 		}
 		inittodr(time_second);	/* update timestamp */
+		milli = time_second % 1000;
 		if (name)
-			printf(apmc...@%03ld: %s/%#x (line=%d) , 
-time_second % 1000, name, func, line);
+			printf(apmc...@%03lld: %s/%#x (line=%d) , 
+			milli, name, func, line);
 		else
-			printf(apmc...@%03ld: %#x (line=%d) , 
-time_second % 1000, func, line);
+			printf(apmc...@%03lld: %#x (line=%d) , 
+			milli, func, line);
 		acallpr(inf, in:, regs);
 	}
 	rv = apmcall(func, regs);



CVS commit: src/sys/arch/i386/i386

2009-11-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Nov 23 05:01:12 UTC 2009

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
When converting an if/panic to a KASSERT it's necessary to reverse the
sense of the test. Makes i386 boot again.

HI RMIND


To generate a diff of this commit:
cvs rdiff -u -r1.675 -r1.676 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.675 src/sys/arch/i386/i386/machdep.c:1.676
--- src/sys/arch/i386/i386/machdep.c:1.675	Sat Nov 21 15:38:43 2009
+++ src/sys/arch/i386/i386/machdep.c	Mon Nov 23 05:01:12 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.675 2009/11/21 15:38:43 rmind Exp $	*/
+/*	$NetBSD: machdep.c,v 1.676 2009/11/23 05:01:12 dholland 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.675 2009/11/21 15:38:43 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.676 2009/11/23 05:01:12 dholland Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1371,7 +1371,7 @@
 	 * Saving SSE registers won't work if the save area isn't
 	 * 16-byte aligned.
 	 */
-	KASSERT(offsetof(struct pcb, pcb_savefpu)  0xf);
+	KASSERT((offsetof(struct pcb, pcb_savefpu)  0xf) == 0);
 
 	/*
 	 * Start with 2 color bins -- this is just a guess to get us



CVS commit: src/sys/arch/i386/i386

2009-11-21 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Nov 21 15:38:43 UTC 2009

Modified Files:
src/sys/arch/i386/i386: machdep.c

Log Message:
Missed fix for Xen builds.


To generate a diff of this commit:
cvs rdiff -u -r1.674 -r1.675 src/sys/arch/i386/i386/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/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.674 src/sys/arch/i386/i386/machdep.c:1.675
--- src/sys/arch/i386/i386/machdep.c:1.674	Sat Nov 21 03:11:00 2009
+++ src/sys/arch/i386/i386/machdep.c	Sat Nov 21 15:38:43 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.674 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: machdep.c,v 1.675 2009/11/21 15:38:43 rmind 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.674 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: machdep.c,v 1.675 2009/11/21 15:38:43 rmind Exp $);
 
 #include opt_beep.h
 #include opt_compat_ibcs2.h
@@ -1320,7 +1320,7 @@
 #ifdef XEN
 	/* not on Xen... */
 	cpu_feature = ~(CPUID_PGE|CPUID_PSE|CPUID_MTRR|CPUID_FXSR|CPUID_NOX);
-	pcb-u_pcb.pcb_cr3 = PDPpaddr - KERNBASE;
+	pcb-pcb_cr3 = PDPpaddr - KERNBASE;
 	__PRINTK((pcb_cr3 0x%lx cr3 0x%lx\n,
 	PDPpaddr - KERNBASE, xpmap_ptom(PDPpaddr - KERNBASE)));
 	XENPRINTK((proc0 pcb %p first_avail %p\n,



CVS commit: src/sys/arch/i386/i386

2009-11-21 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Nov 21 19:59:51 UTC 2009

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

Log Message:
Don't call lwp_getpcb() when not KERNEL.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/i386/i386/db_trace.c

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

Modified files:

Index: src/sys/arch/i386/i386/db_trace.c
diff -u src/sys/arch/i386/i386/db_trace.c:1.64 src/sys/arch/i386/i386/db_trace.c:1.65
--- src/sys/arch/i386/i386/db_trace.c:1.64	Sat Nov 21 03:11:00 2009
+++ src/sys/arch/i386/i386/db_trace.c	Sat Nov 21 19:59:51 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.64 2009/11/21 03:11:00 rmind Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.65 2009/11/21 19:59:51 dsl Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_trace.c,v 1.64 2009/11/21 03:11:00 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_trace.c,v 1.65 2009/11/21 19:59:51 dsl Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -452,7 +452,6 @@
 sizeof(l), (char *)l);
 			}
 			(*pr)(lid %d , l.l_lid);
-			pcb = lwp_getpcb(l);
 #ifdef _KERNEL
 			if (l.l_proc == curproc 
 			(lwp_t *)lwpaddr == curlwp) {
@@ -462,6 +461,11 @@
 			} else
 #endif
 			{
+#ifdef _KERNEL
+pcb = lwp_getpcb(l);
+#else
+pcb = l.l_addr-u_pcb;
+#endif
 db_read_bytes((db_addr_t)pcb-pcb_ebp,
 sizeof(frame), (char *)frame);
 db_read_bytes((db_addr_t)(frame + 1),



CVS commit: src/sys/arch/i386/i386

2009-11-17 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Nov 17 23:45:40 UTC 2009

Modified Files:
src/sys/arch/i386/i386: bios32.c

Log Message:
Fix spelling in a comment, s/extentions/extensions/.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/i386/bios32.c

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

Modified files:

Index: src/sys/arch/i386/i386/bios32.c
diff -u src/sys/arch/i386/i386/bios32.c:1.27 src/sys/arch/i386/i386/bios32.c:1.28
--- src/sys/arch/i386/i386/bios32.c:1.27	Sat Nov  7 07:27:44 2009
+++ src/sys/arch/i386/i386/bios32.c	Tue Nov 17 23:45:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios32.c,v 1.27 2009/11/07 07:27:44 cegger Exp $	*/
+/*	$NetBSD: bios32.c,v 1.28 2009/11/17 23:45:39 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bios32.c,v 1.27 2009/11/07 07:27:44 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: bios32.c,v 1.28 2009/11/17 23:45:39 dyoung Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -156,7 +156,7 @@
 		bios32_entry.offset = (void *)ISA_HOLE_VADDR(entry);
 		bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL);
 	}
-	/* see if we have SMBIOS extentions */
+	/* see if we have SMBIOS extensions */
 	for (p = ISA_HOLE_VADDR(SMBIOS_START);
 	p  (char *)ISA_HOLE_VADDR(SMBIOS_END); p+= 16) {
 		struct smbhdr * sh = (struct smbhdr *)p;



CVS commit: src/sys/arch/i386/i386

2009-10-05 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Mon Oct  5 19:04:14 UTC 2009

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

Log Message:
Improve readability of trap() by extracting two subroutines,
trap_print() and check_dr0().


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/sys/arch/i386/i386/trap.c

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

Modified files:

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.247 src/sys/arch/i386/i386/trap.c:1.248
--- src/sys/arch/i386/i386/trap.c:1.247	Wed Jul 29 18:47:15 2009
+++ src/sys/arch/i386/i386/trap.c	Mon Oct  5 19:04:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.247 2009/07/29 18:47:15 rmind Exp $	*/
+/*	$NetBSD: trap.c,v 1.248 2009/10/05 19:04:14 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.247 2009/07/29 18:47:15 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.248 2009/10/05 19:04:14 dyoung Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -252,6 +252,37 @@
 	return NULL;
 }
 
+static void
+trap_print(int type, struct trapframe *frame)
+{
+	if (frame-tf_trapno  trap_types)
+		printf(fatal %s, trap_type[frame-tf_trapno]);
+	else
+		printf(unknown trap %d, frame-tf_trapno);
+	printf( in %s mode\n, (type  T_USER) ? user : supervisor);
+	printf(trap type %d code %x eip %x cs %x eflags %x cr2 %lx ilevel %x\n,
+	type, frame-tf_err, frame-tf_eip, frame-tf_cs,
+	frame-tf_eflags, (long)rcr2(), curcpu()-ci_ilevel);
+}
+
+static void
+check_dr0(void)
+{
+#ifdef KSTACK_CHECK_DR0
+	u_int mask, dr6 = rdr6();
+
+	mask = 1  0; /* dr0 */
+	if (dr6  mask) {
+		panic(trap on DR0: maybe kernel stack overflow\n);
+#if 0
+		dr6 = ~mask;
+		ldr6(dr6);
+		return;
+#endif
+	}
+#endif
+}
+
 /*
  * trap(frame): exception, fault, and trap interface to BSD kernel.
  *
@@ -314,29 +345,10 @@
 
 	default:
 	we_re_toast:
-#ifdef KSTACK_CHECK_DR0
-		if (type == T_TRCTRAP) {
-			u_int mask, dr6 = rdr6();
-
-			mask = 1  0; /* dr0 */
-			if (dr6  mask) {
-panic(trap on DR0: maybe kernel stack overflow\n);
-#if 0
-dr6 = ~mask;
-ldr6(dr6);
-return;
-#endif
-			}
-		}
-#endif
-		if (frame-tf_trapno  trap_types)
-			printf(fatal %s, trap_type[frame-tf_trapno]);
+		if (type == T_TRCTRAP)
+			check_dr0();
 		else
-			printf(unknown trap %d, frame-tf_trapno);
-		printf( in %s mode\n, (type  T_USER) ? user : supervisor);
-		printf(trap type %d code %x eip %x cs %x eflags %x cr2 %lx ilevel %x\n,
-		type, frame-tf_err, frame-tf_eip, frame-tf_cs,
-		frame-tf_eflags, (long)rcr2(), curcpu()-ci_ilevel);
+			trap_print(type, frame);
 #ifdef DDB
 		if (kdb_trap(type, 0, frame))
 			return;



CVS commit: src/sys/arch/i386/i386

2009-09-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Sep 14 11:37:36 UTC 2009

Modified Files:
src/sys/arch/i386/i386: ipkdb_glue.c

Log Message:
Make this compile. From e...@.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/i386/ipkdb_glue.c

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

Modified files:

Index: src/sys/arch/i386/i386/ipkdb_glue.c
diff -u src/sys/arch/i386/i386/ipkdb_glue.c:1.12 src/sys/arch/i386/i386/ipkdb_glue.c:1.13
--- src/sys/arch/i386/i386/ipkdb_glue.c:1.12	Tue Apr 21 14:51:49 2009
+++ src/sys/arch/i386/i386/ipkdb_glue.c	Mon Sep 14 11:37:36 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipkdb_glue.c,v 1.12 2009/04/21 14:51:49 elad Exp $	*/
+/*	$NetBSD: ipkdb_glue.c,v 1.13 2009/09/14 11:37:36 tsutsui Exp $	*/
 
 /*
  * Copyright (C) 2000 Wolfgang Solfrank.
@@ -31,7 +31,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ipkdb_glue.c,v 1.12 2009/04/21 14:51:49 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: ipkdb_glue.c,v 1.13 2009/09/14 11:37:36 tsutsui Exp $);
 
 #include opt_ipkdb.h
 
@@ -42,6 +42,7 @@
 
 #include machine/ipkdb.h
 #include machine/psl.h
+#include machine/cpufunc.h
 
 int ipkdbregs[NREG];
 
@@ -72,7 +73,7 @@
 ipkdb_trap(void)
 {
 	ipkdb_mode = IPKDB_CMD_STEP;
-	x86_write_eflags(x86_read_eflags() | PSL_T);
+	x86_write_flags(x86_read_flags() | PSL_T);
 }
 
 int



CVS commit: src/sys/arch/i386/i386

2009-08-26 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Wed Aug 26 23:17:03 UTC 2009

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

Log Message:
Do not try to get the faulting instruction if eip is 0.
This makes 'trace' work when the kernel paniced because it jumped to
a NULL function pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/i386/i386/db_trace.c

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

Modified files:

Index: src/sys/arch/i386/i386/db_trace.c
diff -u src/sys/arch/i386/i386/db_trace.c:1.61 src/sys/arch/i386/i386/db_trace.c:1.62
--- src/sys/arch/i386/i386/db_trace.c:1.61	Sat Mar  7 22:02:16 2009
+++ src/sys/arch/i386/i386/db_trace.c	Wed Aug 26 23:17:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.61 2009/03/07 22:02:16 ad Exp $	*/
+/*	$NetBSD: db_trace.c,v 1.62 2009/08/26 23:17:03 bouyer Exp $	*/
 
 /* 
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: db_trace.c,v 1.61 2009/03/07 22:02:16 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: db_trace.c,v 1.62 2009/08/26 23:17:03 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -501,7 +501,7 @@
 		sym = db_frame_info(frame, callpc, name, offset, is_trap,
 narg);
 
-		if (lastframe == 0  sym == (db_sym_t)0) {
+		if (lastframe == 0  sym == (db_sym_t)0  callpc != 0) {
 			/* Symbol not found, peek at code */
 			int	instr = db_get_value(callpc, 4, false);
 



CVS commit: src/sys/arch/i386/i386

2009-08-23 Thread Adam Hoka
Module Name:src
Committed By:   ahoka
Date:   Sun Aug 23 15:58:39 UTC 2009

Modified Files:
src/sys/arch/i386/i386: powernow_k7.c

Log Message:
Fix typo: Mhz - MHz

No functional change at all intended.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/i386/i386/powernow_k7.c

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

Modified files:

Index: src/sys/arch/i386/i386/powernow_k7.c
diff -u src/sys/arch/i386/i386/powernow_k7.c:1.32 src/sys/arch/i386/i386/powernow_k7.c:1.33
--- src/sys/arch/i386/i386/powernow_k7.c:1.32	Wed Nov 12 12:36:02 2008
+++ src/sys/arch/i386/i386/powernow_k7.c	Sun Aug 23 15:58:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: powernow_k7.c,v 1.32 2008/11/12 12:36:02 ad Exp $ */
+/*	$NetBSD: powernow_k7.c,v 1.33 2009/08/23 15:58:39 ahoka Exp $ */
 /*	$OpenBSD: powernow-k7.c,v 1.24 2006/06/16 05:58:50 gwk Exp $ */
 
 /*-
@@ -59,7 +59,7 @@
 /* AMD POWERNOW K7 driver */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: powernow_k7.c,v 1.32 2008/11/12 12:36:02 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: powernow_k7.c,v 1.33 2009/08/23 15:58:39 ahoka Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -468,7 +468,7 @@
 
 	aprint_normal(%s: AMD %s Technology %d MHz\n,
 	cpuname, techname, cur_freq);
-	aprint_normal(%s: frequencies available (Mhz): %s\n,
+	aprint_normal(%s: frequencies available (MHz): %s\n,
 	cpuname, freq_names);
 
 	return;



CVS commit: src/sys/arch/i386/i386

2009-08-04 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Tue Aug  4 06:55:27 UTC 2009

Modified Files:
src/sys/arch/i386/i386: mainbus.c

Log Message:
Add #if NPCI  1 around call to mp_pci_childdetached()
Fixes rst of PR/41301


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/arch/i386/i386/mainbus.c

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

Modified files:

Index: src/sys/arch/i386/i386/mainbus.c
diff -u src/sys/arch/i386/i386/mainbus.c:1.85 src/sys/arch/i386/i386/mainbus.c:1.86
--- src/sys/arch/i386/i386/mainbus.c:1.85	Sat Jun 13 13:35:11 2009
+++ src/sys/arch/i386/i386/mainbus.c	Tue Aug  4 06:55:26 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.85 2009/06/13 13:35:11 tsutsui Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.86 2009/08/04 06:55:26 dsl Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.85 2009/06/13 13:35:11 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.86 2009/08/04 06:55:26 dsl Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -190,7 +190,9 @@
 	if (sc-sc_pci == child)
 		sc-sc_pci = NULL;
 
+#if NPCI  0
 	mp_pci_childdetached(self, child);
+#endif
 }
 
 /*



CVS commit: src/sys/arch/i386/i386

2009-07-29 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Wed Jul 29 17:16:56 UTC 2009

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

Log Message:
Fix KASSERT(1);


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

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

Modified files:

Index: src/sys/arch/i386/i386/trap.c
diff -u src/sys/arch/i386/i386/trap.c:1.245 src/sys/arch/i386/i386/trap.c:1.246
--- src/sys/arch/i386/i386/trap.c:1.245	Wed Jul 29 12:02:06 2009
+++ src/sys/arch/i386/i386/trap.c	Wed Jul 29 17:16:56 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.245 2009/07/29 12:02:06 cegger Exp $	*/
+/*	$NetBSD: trap.c,v 1.246 2009/07/29 17:16:56 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.245 2009/07/29 12:02:06 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: trap.c,v 1.246 2009/07/29 17:16:56 rmind Exp $);
 
 #include opt_ddb.h
 #include opt_kgdb.h
@@ -483,7 +483,7 @@
 			ksi.ksi_code = BUS_ADRALN;
 			break;
 		default:
-			KASSERT(1);
+			KASSERT(0);
 			break;
 		}
 		goto trapsignal;



CVS commit: src/sys/arch/i386/i386

2009-05-04 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon May  4 11:47:29 UTC 2009

Modified Files:
src/sys/arch/i386/i386: locore.S

Log Message:
PR kern/41342: BSDi binaries cause panic

XXX Manuel, please have a look as I am not sure what to do for XEN here!


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 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.86 src/sys/arch/i386/i386/locore.S:1.87
--- src/sys/arch/i386/i386/locore.S:1.86	Sat Mar 21 22:55:08 2009
+++ src/sys/arch/i386/i386/locore.S	Mon May  4 11:47:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.86 2009/03/21 22:55:08 ad Exp $	*/
+/*	$NetBSD: locore.S,v 1.87 2009/05/04 11:47:29 ad Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -134,7 +134,7 @@
  */
 
 #include machine/asm.h
-__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.86 2009/03/21 22:55:08 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: locore.S,v 1.87 2009/05/04 11:47:29 ad Exp $);
 
 #include opt_compat_oldboot.h
 #include opt_ddb.h
@@ -1080,7 +1080,10 @@
  * Old call gate entry for syscall
  */
 IDTVEC(osyscall)
+#ifndef XEN
+	/* XXX we are in trouble! interrupts be off here. */
 	cli			# must be first instruction
+#endif
 	pushfl			# set eflags in trap frame
 	popl	8(%esp)
 	orl	$PSL_I,(%esp)	# re-enable ints on return to user



CVS commit: src/sys/arch/i386/i386

2009-04-21 Thread Elad Efrat
Module Name:src
Committed By:   elad
Date:   Tue Apr 21 14:51:49 UTC 2009

Modified Files:
src/sys/arch/i386/i386: ipkdb_glue.c

Log Message:
Remove extra ')'.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/i386/ipkdb_glue.c

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

Modified files:

Index: src/sys/arch/i386/i386/ipkdb_glue.c
diff -u src/sys/arch/i386/i386/ipkdb_glue.c:1.11 src/sys/arch/i386/i386/ipkdb_glue.c:1.12
--- src/sys/arch/i386/i386/ipkdb_glue.c:1.11	Wed Mar 18 10:22:30 2009
+++ src/sys/arch/i386/i386/ipkdb_glue.c	Tue Apr 21 14:51:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipkdb_glue.c,v 1.11 2009/03/18 10:22:30 cegger Exp $	*/
+/*	$NetBSD: ipkdb_glue.c,v 1.12 2009/04/21 14:51:49 elad Exp $	*/
 
 /*
  * Copyright (C) 2000 Wolfgang Solfrank.
@@ -31,7 +31,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ipkdb_glue.c,v 1.11 2009/03/18 10:22:30 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: ipkdb_glue.c,v 1.12 2009/04/21 14:51:49 elad Exp $);
 
 #include opt_ipkdb.h
 
@@ -72,7 +72,7 @@
 ipkdb_trap(void)
 {
 	ipkdb_mode = IPKDB_CMD_STEP;
-	x86_write_eflags(x86_read_eflags() | PSL_T));
+	x86_write_eflags(x86_read_eflags() | PSL_T);
 }
 
 int



CVS commit: src/sys/arch/i386/i386

2009-04-09 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu Apr  9 10:56:41 UTC 2009

Modified Files:
src/sys/arch/i386/i386: kvm86.c

Log Message:
Add missing cpu.h include required by last commit.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/i386/kvm86.c

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

Modified files:

Index: src/sys/arch/i386/i386/kvm86.c
diff -u src/sys/arch/i386/i386/kvm86.c:1.17 src/sys/arch/i386/i386/kvm86.c:1.18
--- src/sys/arch/i386/i386/kvm86.c:1.17	Sat Mar 21 14:41:29 2009
+++ src/sys/arch/i386/i386/kvm86.c	Thu Apr  9 10:56:41 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm86.c,v 1.17 2009/03/21 14:41:29 ad Exp $ */
+/* $NetBSD: kvm86.c,v 1.18 2009/04/09 10:56:41 sborrill Exp $ */
 
 /*
  * Copyright (c) 2002
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kvm86.c,v 1.17 2009/03/21 14:41:29 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: kvm86.c,v 1.18 2009/04/09 10:56:41 sborrill Exp $);
 
 #include opt_multiprocessor.h
 
@@ -37,6 +37,7 @@
 #include sys/user.h
 #include sys/malloc.h
 #include sys/mutex.h
+#include sys/cpu.h
 
 #include uvm/uvm.h
 



CVS commit: src/sys/arch/i386/i386

2009-04-08 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Wed Apr  8 17:08:03 UTC 2009

Modified Files:
src/sys/arch/i386/i386: mainbus.c

Log Message:
Remove redundant declaration of mainbus_attach(), as pointed out by
Thomas Klausner.

Do not compile in the local variable mba in mainbus_rescan unless
NPNPBIOS  0 || NACPI  0 || NIPMI  0 || NMCA  0.  This fixes the
build on systems such as Soekris where none of those options apply.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/i386/i386/mainbus.c

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

Modified files:

Index: src/sys/arch/i386/i386/mainbus.c
diff -u src/sys/arch/i386/i386/mainbus.c:1.82 src/sys/arch/i386/i386/mainbus.c:1.83
--- src/sys/arch/i386/i386/mainbus.c:1.82	Tue Apr  7 22:01:38 2009
+++ src/sys/arch/i386/i386/mainbus.c	Wed Apr  8 17:08:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.82 2009/04/07 22:01:38 dyoung Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.83 2009/04/08 17:08:02 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.82 2009/04/07 22:01:38 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: mainbus.c,v 1.83 2009/04/08 17:08:02 dyoung Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -97,7 +97,6 @@
 void	mainbus_childdetached(device_t, device_t);
 int	mainbus_match(device_t, cfdata_t, void *);
 void	mainbus_attach(device_t, device_t, void *);
-void	mainbus_attach(device_t, device_t, void *);
 
 static int	mainbus_rescan(device_t, const char *, const int *);
 
@@ -362,7 +361,9 @@
 mainbus_rescan(device_t self, const char *ifattr, const int *locators)
 {
 	struct mainbus_softc *sc = device_private(self);
+#if NPNPBIOS  0 || NACPI  0 || NIPMI  0 || NMCA  0
 	union mainbus_attach_args mba;
+#endif
 
 	if (ifattr_match(ifattr, acpibus)  sc-sc_acpi == NULL 
 	sc-sc_acpi_present) {



CVS commit: src/sys/arch/i386/i386

2009-03-30 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Mon Mar 30 17:48:22 UTC 2009

Modified Files:
src/sys/arch/i386/i386: vm_machdep.c

Log Message:
Cosmetic: reduce differences from amd64/amd64/vm_machdep.c by deleting
an empty line.


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/arch/i386/i386/vm_machdep.c

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

Modified files:

Index: src/sys/arch/i386/i386/vm_machdep.c
diff -u src/sys/arch/i386/i386/vm_machdep.c:1.145 src/sys/arch/i386/i386/vm_machdep.c:1.146
--- src/sys/arch/i386/i386/vm_machdep.c:1.145	Sun Mar 29 01:10:28 2009
+++ src/sys/arch/i386/i386/vm_machdep.c	Mon Mar 30 17:48:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.145 2009/03/29 01:10:28 rmind Exp $	*/
+/*	$NetBSD: vm_machdep.c,v 1.146 2009/03/30 17:48:22 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -80,7 +80,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: vm_machdep.c,v 1.145 2009/03/29 01:10:28 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: vm_machdep.c,v 1.146 2009/03/30 17:48:22 dyoung Exp $);
 
 #include opt_mtrr.h
 
@@ -229,7 +229,6 @@
 void
 cpu_lwp_free(struct lwp *l, int proc)
 {
-
 #if NNPX  0
 	/* If we were using the FPU, forget about it. */
 	if (l-l_addr-u_pcb.pcb_fpcpu != NULL)



<    1   2