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

2019-10-17 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Oct 18 01:19:00 UTC 2019

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

Log Message:
Fix multiboot1 kernel symbol load

ELF_Shdr's sh_type field is a value, not a flag field


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/arch/i386/i386/multiboot.c:1.25
--- src/sys/arch/i386/i386/multiboot.c:1.24	Thu Nov  8 06:23:48 2018
+++ src/sys/arch/i386/i386/multiboot.c	Fri Oct 18 01:19:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot.c,v 1.24 2018/11/08 06:23:48 msaitoh Exp $	*/
+/*	$NetBSD: multiboot.c,v 1.25 2019/10/18 01:19:00 manu Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.24 2018/11/08 06:23:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.25 2019/10/18 01:19:00 manu Exp $");
 
 #include "opt_multiboot.h"
 
@@ -302,14 +302,14 @@ copy_syms(struct multiboot_info *mi)
 
 		shdrp = &((Elf32_Shdr *)mi->mi_elfshdr_addr)[i];
 
-		if ((shdrp->sh_type & SHT_SYMTAB) &&
+		if ((shdrp->sh_type == SHT_SYMTAB) &&
 		shdrp->sh_link != SHN_UNDEF) {
 			Elf32_Shdr *shdrp2;
 
 			shdrp2 = &((Elf32_Shdr *)mi->mi_elfshdr_addr)
 			[shdrp->sh_link];
 
-			if (shdrp2->sh_type & SHT_STRTAB) {
+			if (shdrp2->sh_type == SHT_STRTAB) {
 symtabp = shdrp;
 strtabp = shdrp2;
 			}



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

2019-10-17 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Fri Oct 18 01:19:00 UTC 2019

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

Log Message:
Fix multiboot1 kernel symbol load

ELF_Shdr's sh_type field is a value, not a flag field


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



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

2019-10-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Oct  4 15:28:00 UTC 2019

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

Log Message:
Misc reordering, to clarify and reduce the diff against amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.47 -r1.48 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.



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

2019-10-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Oct  4 15:28:00 UTC 2019

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

Log Message:
Misc reordering, to clarify and reduce the diff against amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/i386/i386_trap.S
cvs rdiff -u -r1.170 -r1.171 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.47 -r1.48 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/i386_trap.S
diff -u src/sys/arch/i386/i386/i386_trap.S:1.18 src/sys/arch/i386/i386/i386_trap.S:1.19
--- src/sys/arch/i386/i386/i386_trap.S:1.18	Mon Feb 11 17:28:52 2019
+++ src/sys/arch/i386/i386/i386_trap.S	Fri Oct  4 15:28:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $	*/
+/*	$NetBSD: i386_trap.S,v 1.19 2019/10/04 15:28:00 maxv Exp $	*/
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.18 2019/02/11 17:28:52 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.19 2019/10/04 15:28:00 maxv Exp $");
 #endif
 
 /*
@@ -220,7 +220,7 @@ IDTVEC(trap07)
 	pushl	%esp
 	call	_C_LABEL(fpudna)
 	addl	$4,%esp
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap07)
 
 IDTVEC(trap08)
@@ -282,7 +282,7 @@ IDTVEC(trap0f)
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
 #endif
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap0f)
 IDTVEC_END(intrspurious)
 
@@ -302,7 +302,7 @@ IDTVEC(trap10)
 	adcl	$0,CPUVAR(NTRAP)+4
 	call	_C_LABEL(fputrap)
 	addl	$4,%esp
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 IDTVEC_END(trap10)
 
 IDTVEC(trap11)
@@ -394,13 +394,14 @@ IDTVEC_END(tss_trap08)
 	.type	_C_LABEL(trap_return_fault_return),@function
 LABEL(trap_return_fault_return)
 	mov	4(%esp),%esp	/* frame for user return */
-	jmp	_C_LABEL(trapreturn)
+	jmp	.Lalltraps_checkusr
 END(trap_return_fault_return)
 
 /* LINTSTUB: Ignore */
 ENTRY(alltraps)
 	INTRENTRY
 	STI(%eax)
+
 calltrap:
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
@@ -410,16 +411,18 @@ calltrap:
 	pushl	%esp
 	call	_C_LABEL(trap)
 	addl	$4,%esp
-_C_LABEL(trapreturn):	.globl	trapreturn
+
+.Lalltraps_checkusr:
 	testb	$CHK_UPL,TF_CS(%esp)
 	jnz	.Lalltraps_checkast
 	jmp	6f
+
 .Lalltraps_checkast:
 	/* Check for ASTs on exit to user mode. */
 	CLI(%eax)
 	CHECK_ASTPENDING(%eax)
 	jz	3f
-5:	CLEAR_ASTPENDING(%eax)
+	CLEAR_ASTPENDING(%eax)
 	STI(%eax)
 	movl	$T_ASTFLT,TF_TRAPNO(%esp)
 	addl	$1,CPUVAR(NTRAP)	/* statistical info */
@@ -430,6 +433,7 @@ _C_LABEL(trapreturn):	.globl	trapreturn
 	jmp	.Lalltraps_checkast	/* re-check ASTs */
 3:	CHECK_DEFERRED_SWITCH
 	jnz	9f
+
 #ifdef XEN
 	STIC(%eax)
 	jz	6f
@@ -450,15 +454,23 @@ _C_LABEL(trapreturn):	.globl	trapreturn
 	movl	CPUVAR(XSOURCES)(,%eax,4),%eax
 	jmp	*IS_RESUME(%eax)
 7:	movl	%ebx,CPUVAR(ILEVEL)	/* restore cpl */
-	jmp	_C_LABEL(trapreturn)
-#endif /* XEN */
-#ifndef DIAGNOSTIC
-6:	INTRFASTEXIT
-#else
-6:	cmpl	CPUVAR(ILEVEL),%ebx
-	jne	3f
+	jmp	.Lalltraps_checkusr
+#endif
+
+6:
+#ifdef DIAGNOSTIC
+	cmpl	CPUVAR(ILEVEL),%ebx
+	jne	.Lspl_error
+#endif
 	INTRFASTEXIT
-3:	STI(%eax)
+
+9:	STI(%eax)
+	call	_C_LABEL(pmap_load)
+	jmp	.Lalltraps_checkast	/* re-check ASTs */
+
+#ifdef DIAGNOSTIC
+.Lspl_error:
+	STI(%eax)
 	pushl	$4f
 	call	_C_LABEL(panic)
 	addl	$4,%esp
@@ -467,8 +479,5 @@ _C_LABEL(trapreturn):	.globl	trapreturn
 	addl	$4,%esp
 	jmp	.Lalltraps_checkast	/* re-check ASTs */
 4:	.asciz	"SPL NOT LOWERED ON TRAP EXIT\n"
-#endif /* DIAGNOSTIC */
-9:	STI(%eax)
-	call	_C_LABEL(pmap_load)
-	jmp	.Lalltraps_checkast	/* re-check ASTs */
+#endif
 END(alltraps)

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.170 src/sys/arch/i386/i386/locore.S:1.171
--- src/sys/arch/i386/i386/locore.S:1.170	Fri Oct  4 11:47:07 2019
+++ src/sys/arch/i386/i386/locore.S	Fri Oct  4 15:28:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.171 2019/10/04 15:28:00 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.170 2019/10/04 11:47:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.171 2019/10/04 15:28:00 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1264,6 +1264,7 @@ IDTVEC(syscall)
 	pushl	$T_ASTFLT	/* trap # for doing ASTs */
 	INTRENTRY
 	STI(%eax)
+
 #ifdef DIAGNOSTIC
 	movl	CPUVAR(ILEVEL),%ebx
 	testl	%ebx,%ebx
@@ -1276,6 +1277,7 @@ IDTVEC(syscall)
 #endif
 1:
 #endif /* DIAGNOSTIC */
+
 	addl	$1,CPUVAR(NSYSCALL)	/* count it atomically */
 	adcl	$0,CPUVAR(NSYSCALL)+4	/* count it atomically */
 	movl	CPUVAR(CURLWP),%edi
@@ -1290,6 +1292,7 @@ IDTVEC(syscall)
 	movl	L_MD_ASTPENDING(%edi), %eax
 	orl	CPUVAR(WANT_PMAPLOAD), %eax
 	jnz	9f
+
 #ifdef XEN
 	STIC(%eax)
 	jz	14f

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

2019-08-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Aug  6 02:04:43 UTC 2019

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

Log Message:
Do not dereference user pointer in ptrace_machdep_dorequest()/i386

Always use copyin(9) for reading user memory.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/i386/i386/process_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/process_machdep.c
diff -u src/sys/arch/i386/i386/process_machdep.c:1.93 src/sys/arch/i386/i386/process_machdep.c:1.94
--- src/sys/arch/i386/i386/process_machdep.c:1.93	Wed Jun 26 12:30:12 2019
+++ src/sys/arch/i386/i386/process_machdep.c	Tue Aug  6 02:04:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.93 2019/06/26 12:30:12 mgorny Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.93 2019/06/26 12:30:12 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $");
 
 #include "opt_ptrace.h"
 
@@ -281,7 +281,7 @@ ptrace_machdep_dorequest(
 {
 	struct uio uio;
 	struct iovec iov;
-	struct iovec *user_iov = (struct iovec*)addr;
+	struct iovec user_iov;
 	struct vmspace *vm;
 	int error;
 	int write = 0;
@@ -319,12 +319,14 @@ ptrace_machdep_dorequest(
 		/* write = 0 done above. */
 		if (!process_machdep_validxstate(lt->l_proc))
 			return EINVAL;
+		if ((error = copyin(addr, _iov, sizeof(user_iov))) != 0)
+			return error;
 		error = proc_vmspace_getref(l->l_proc, );
 		if (error) {
 			return error;
 		}
-		iov.iov_base = user_iov->iov_base;
-		iov.iov_len = user_iov->iov_len;
+		iov.iov_base = user_iov.iov_base;
+		iov.iov_len = user_iov.iov_len;
 		if (iov.iov_len > sizeof(struct xstate))
 			iov.iov_len = sizeof(struct xstate);
 		uio.uio_iov = 



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

2019-08-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Aug  6 02:04:43 UTC 2019

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

Log Message:
Do not dereference user pointer in ptrace_machdep_dorequest()/i386

Always use copyin(9) for reading user memory.


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

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



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

2019-07-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul 13 17:04:21 UTC 2019

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

Log Message:
Use common code for SMEP/SMAP panic to print more information and
allow debugging.


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



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

2019-07-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jul 13 17:04:21 UTC 2019

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

Log Message:
Use common code for SMEP/SMAP panic to print more information and
allow debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 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.301 src/sys/arch/i386/i386/trap.c:1.302
--- src/sys/arch/i386/i386/trap.c:1.301	Wed May 29 14:28:37 2019
+++ src/sys/arch/i386/i386/trap.c	Sat Jul 13 17:04:21 2019
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $	*/
+/*	$NetBSD: trap.c,v 1.302 2019/07/13 17:04:21 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.302 2019/07/13 17:04:21 mlelstv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -582,17 +582,20 @@ kernelfault:
 
 		if (frame->tf_err & PGEX_X) {
 			/* SMEP might have brought us here */
-			if (cr2 > VM_MIN_ADDRESS && cr2 <= VM_MAXUSER_ADDRESS)
-panic("prevented execution of %p (SMEP)",
+			if (cr2 > VM_MIN_ADDRESS && cr2 <= VM_MAXUSER_ADDRESS) {
+printf("prevented execution of %p (SMEP)\n",
 (void *)cr2);
+goto we_re_toast;
+			}
 		}
 
 		if ((frame->tf_err & PGEX_P) &&
 		cr2 < VM_MAXUSER_ADDRESS) {
 			/* SMAP might have brought us here */
 			if (onfault_handler(pcb, frame) == NULL) {
-panic("prevented access to %p (SMAP)",
+printf("prevented access to %p (SMAP)\n",
 (void *)cr2);
+goto we_re_toast;
 			}
 		}
 



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

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 14:28:37 UTC 2019

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

Log Message:
 Use PRIxREGISTER suggested by Kamil.


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



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

2019-05-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed May 29 14:28:37 UTC 2019

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

Log Message:
 Use PRIxREGISTER suggested by Kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 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.300 src/sys/arch/i386/i386/trap.c:1.301
--- src/sys/arch/i386/i386/trap.c:1.300	Sat Apr  6 03:06:25 2019
+++ src/sys/arch/i386/i386/trap.c	Wed May 29 14:28:37 2019
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: trap.c,v 1.300 2019/04/06 03:06:25 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.300 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.301 2019/05/29 14:28:37 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -467,8 +467,9 @@ kernelfault:
 	case T_STKFLT|T_USER:
 	case T_ALIGNFLT|T_USER:
 #ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): BUS/SEGV (%#x) at eip %#x addr %#lx\n",
-		p->p_pid, l->l_lid, p->p_comm, type, frame->tf_eip, rcr2());
+		printf("pid %d.%d (%s): BUS/SEGV (%#x) at eip %#x addr %#"
+		PRIxREGISTER "\n", p->p_pid, l->l_lid, p->p_comm,
+		type, frame->tf_eip, rcr2());
 		frame_dump(frame, pcb);
 #endif
 		KSI_INIT_TRAP();
@@ -508,8 +509,9 @@ kernelfault:
 	case T_PRIVINFLT|T_USER:	/* privileged instruction fault */
 	case T_FPOPFLT|T_USER:		/* coprocessor operand fault */
 #ifdef TRAP_SIGDEBUG
-		printf("pid %d.%d (%s): ILL at eip %#x addr %#lx\n",
-		p->p_pid, l->l_lid, p->p_comm, frame->tf_eip, rcr2());
+		printf("pid %d.%d (%s): ILL at eip %#x addr %#"
+		PRIxREGISTER "\n", p->p_pid, l->l_lid, p->p_comm,
+		frame->tf_eip, rcr2());
 		frame_dump(frame, pcb);
 #endif
 		KSI_INIT_TRAP();



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

2019-05-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 19 08:49:08 UTC 2019

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

Log Message:
Remove useless call to fpu_sigreset(), buildcontext() already calls it.


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



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

2019-05-19 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun May 19 08:49:08 UTC 2019

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

Log Message:
Remove useless call to fpu_sigreset(), buildcontext() already calls it.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/sys/arch/i386/i386/compat_16_machdep.c:1.32
--- src/sys/arch/i386/i386/compat_16_machdep.c:1.31	Sun May 19 08:46:15 2019
+++ src/sys/arch/i386/i386/compat_16_machdep.c	Sun May 19 08:49:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.31 2019/05/19 08:46:15 maxv Exp $	*/
+/*	$NetBSD: compat_16_machdep.c,v 1.32 2019/05/19 08:49:08 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.31 2019/05/19 08:46:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.32 2019/05/19 08:49:08 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -232,7 +232,6 @@ sendsig_sigcontext(const ksiginfo_t *ksi
 		/* NOTREACHED */
 	}
 
-	fpu_sigreset(l);
 	buildcontext(l, sel, catcher, fp);
 
 	/* Remember that we're now on the signal stack. */



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

2016-05-31 Thread Joerg Sonnenberger
On Tue, May 31, 2016 at 11:39:08AM +0200, Joerg Sonnenberger wrote:
> On Mon, May 30, 2016 at 06:58:52PM -0400, Christos Zoulas wrote:
> > Module Name:src
> > Committed By:   christos
> > Date:   Mon May 30 22:58:52 UTC 2016
> > 
> > Modified Files:
> > src/sys/arch/i386/i386: cpu_in_cksum.S
> > 
> > Log Message:
> > Handle PIC linking for tests
> 
> Except this doesn't work because %ebx is not used as GOT pointer in this
> function?

Scratch that. Been too long since I wrote i386 assembler...

Joerg


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

2016-05-31 Thread Joerg Sonnenberger
On Mon, May 30, 2016 at 06:58:52PM -0400, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Mon May 30 22:58:52 UTC 2016
> 
> Modified Files:
>   src/sys/arch/i386/i386: cpu_in_cksum.S
> 
> Log Message:
> Handle PIC linking for tests

Except this doesn't work because %ebx is not used as GOT pointer in this
function?

Joerg


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

2014-03-06 Thread David Laight
On Thu, Mar 06, 2014 at 12:30:25PM +, NONAKA Kimihiro wrote:
 Module Name:  src
 Committed By: nonaka
 Date: Thu Mar  6 12:30:25 UTC 2014
 
 Modified Files:
   src/sys/arch/i386/i386: cpufunc.S
 
 Log Message:
 fix to pass collect memory address to xrstor.

Gah ... :-(

FWIW I managed to get gcc 4.8 to optimise some fp loops to use the ymm
registers - the xsave/xrstor code seemed to worn an amd64.
But I don't have an i386 install on a new enough system.

David

-- 
David Laight: da...@l8s.co.uk


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

2012-03-05 Thread Manuel Bouyer
On Mon, Mar 05, 2012 at 08:01:09AM +0530, Cherry G. Mathew wrote:
 On 5 March 2012 02:14, Manuel Bouyer bou...@netbsd.org wrote:
  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)
 
 
 
 
 ic, so we're potentially leaking 2 pages at boot now

We were already leaking 2 pages; as this uvm_page_physload() has never
worked ...

-- 
Manuel Bouyer bou...@antioche.eu.org
 NetBSD: 26 ans d'experience feront toujours la difference
--


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

2012-03-04 Thread Cherry G. Mathew
On 5 March 2012 02:14, Manuel Bouyer bou...@netbsd.org wrote:
 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)




ic, so we're potentially leaking 2 pages at boot now


-- 
~Cherry


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

2012-01-21 Thread David Laight
On Fri, Jan 20, 2012 at 12:39:44PM +0100, Matthias Drochner wrote:
 
 m...@eterna.com.au said:
  alloc/free here for whatever is using a lot of memory would be much
  better than increasing the minimum each LWP requires.
 
 Agreed. In the ppbattach case, it should be sufficient
 to put the devinfo printf into a separate function, so
 that it doesn't stack up when called recursively. (One
 just needs to make sure that the compiler doesn't
 inline it again.)

Recursion in the kernel?
Isn't that really frowned upon itself?

David

-- 
David Laight: da...@l8s.co.uk


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

2012-01-20 Thread Matthias Drochner

m...@eterna.com.au said:
 alloc/free here for whatever is using a lot of memory would be much
 better than increasing the minimum each LWP requires.

Agreed. In the ppbattach case, it should be sufficient
to put the devinfo printf into a separate function, so
that it doesn't stack up when called recursively. (One
just needs to make sure that the compiler doesn't
inline it again.)

best regards
Matthias





Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt



Kennen Sie schon unsere app? http://www.fz-juelich.de/app


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

2012-01-20 Thread Matthias Drochner

chris...@astron.com said:
 /.*sub.*,%[er]sp/

very nice

 18648 80494b55:stbi_gif_load_from_memory+0xd

So this can never have worked on x86, with only 12k stack.

best regards
Matthias





Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt



Kennen Sie schon unsere app? http://www.fz-juelich.de/app


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

2012-01-19 Thread Matthias Drochner

dyo...@pobox.com said:
  increased stack use lead to stack overflow on amd64
  with a deep PCI hierarchy
 Tell me more about this.

It was sys/dev/pci/pci.c rev.1.141 which triggered it.
Stack use must already have been tight, and the additional
device number array was the last straw.
The question is now whether it is sufficient in the long run
to trim down stack usage (eg devinfo in ppbattach()),
or whether the kernel stack needs to be increased.

 Please revert the reversion.  I will add a big, fat comment.

It makes more sense if you commit the code together with
the comment, and cvs annotate's output would be more
sensible too.

best regards
Matthias





Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt



Kennen Sie schon unsere app? http://www.fz-juelich.de/app


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

2012-01-19 Thread matthew green

 dyo...@pobox.com said:
   increased stack use lead to stack overflow on amd64
   with a deep PCI hierarchy
  Tell me more about this.
 
 It was sys/dev/pci/pci.c rev.1.141 which triggered it.
 Stack use must already have been tight, and the additional
 device number array was the last straw.
 The question is now whether it is sufficient in the long run
 to trim down stack usage (eg devinfo in ppbattach()),
 or whether the kernel stack needs to be increased.

we should try to decrease kernel stack usage *espcially for* rarely
occuring things like autoconfig.  alloc/free here for whatever is
using a lot of memory would be much better than increasing the
minimum each LWP requires.


.mrg.


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

2012-01-18 Thread David Young
On Wed, Jan 18, 2012 at 09:34:39PM +, Matthias Drochner wrote:
 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

Matthias, was setting pba_sub = 255 causing material problems for
someone, or are you concerned that lossage will eventually occur on
certain server-class machines?

I ask because, while setting pba_sub that way is far from ideal, it
has worked well for me on a variety of machines, and if it has caused
anybody any trouble, I don't remember them bringing it up with me.

Dave

-- 
David Young
dyo...@pobox.comUrbana, IL(217) 721-9981


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

2012-01-18 Thread Matthias Drochner

dyo...@pobox.com said:
  was setting pba_sub = 255 causing material problems for someone, or
 are you concerned that lossage will eventually occur on certain
 server-class machines?

No, this wasn't causing damage. I was tracking another problem which
was incidentally triggered by another of your changes -- increased
stack use lead to stack overflow on amd64 with a deep PCI hierarchy
(a MicroTCA system).

Just stumbled over this. But it is obviously wrong. If you think
it should be in the public tree there should be at least a big fat
comment telling that it is for testing purposes and nothing uses
it really and it will be removed before it can cause damage.

best regards
Matthias





Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt



Kennen Sie schon unsere app? http://www.fz-juelich.de/app


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

2012-01-18 Thread David Young
On Wed, Jan 18, 2012 at 11:38:39PM +0100, Matthias Drochner wrote:
 
 dyo...@pobox.com said:
   was setting pba_sub = 255 causing material problems for someone, or
  are you concerned that lossage will eventually occur on certain
  server-class machines?
 
 No, this wasn't causing damage. I was tracking another problem which
 was incidentally triggered by another of your changes -- increased
 stack use lead to stack overflow on amd64 with a deep PCI hierarchy
 (a MicroTCA system).

Tell me more about this.

 Just stumbled over this. But it is obviously wrong. If you think
 it should be in the public tree there should be at least a big fat
 comment telling that it is for testing purposes and nothing uses
 it really and it will be removed before it can cause damage.

It does belong in the public tree.  Please revert the reversion.  I will
add a big, fat comment.

Dave

-- 
David Young
dyo...@pobox.comUrbana, IL(217) 721-9981


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

2011-11-20 Thread YAMAMOTO Takashi
hi,

 On Oct 31, 2011, at 1:42 PM, YAMAMOTO Takashi wrote:
 
 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
 
 With this change in place core dumps from ddb (reboot 104) no longer work
 on MP machines.
 
 Before pmap_tlb_shootnow() always returned on the `tp-tp_count == 0' check.
 
 Now it goes into the `remote' case and hangs hard trying to reach other CPUs.

thanks, i've reverted the changes for now.

YAMAMOTO Takashi

 
 --
 Juergen Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)


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

2011-11-20 Thread Mindaugas Rasiukevicius
J. Hannken-Illjes hann...@eis.cs.tu-bs.de wrote:
  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
 
 With this change in place core dumps from ddb (reboot 104) no longer work
 on MP machines.
 
 Before pmap_tlb_shootnow() always returned on the `tp-tp_count == 0'
 check.
 
 Now it goes into the `remote' case and hangs hard trying to reach other
 CPUs.

We could check for panicstr.  Not sure if that is desirable, though.

-- 
Mindaugas


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

2011-11-19 Thread J. Hannken-Illjes

On Oct 31, 2011, at 1:42 PM, YAMAMOTO Takashi wrote:

 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

With this change in place core dumps from ddb (reboot 104) no longer work
on MP machines.

Before pmap_tlb_shootnow() always returned on the `tp-tp_count == 0' check.

Now it goes into the `remote' case and hangs hard trying to reach other CPUs.

--
Juergen Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)



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

2011-01-12 Thread Grégoire Sutre

On 01/12/2011 05:09 AM, enami tsugutomo wrote:

=?UTF-8?B?R3LDqWdvaXJlIFN1dHJl?=gsu...@netbsd.org  writes:


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 |
  ++--+--+


If this ascii art is correct, memmove should be used instead of
memcpy.


Agreed.  I should have mentioned it in the commit message.  Here,
I just wanted to restore previous (working) behavior.

Note that the figure is just an example: afaik, no assumption can
be made regarding the placement of the tables.


Also, if initial order is kernel, string table, symbol table
and a gap between kernel and string table is smaller than symbol
table, copying it may overwrite the string table.

Is there any guarantee that the gap is large enough?


The code (that was already there) takes care of this by examining
all possible cases.  If initial order is kernel, string table,
symbol table, then the order remains the same.

Grégoire


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

2011-01-11 Thread enami tsugutomo
=?UTF-8?B?R3LDqWdvaXJlIFN1dHJl?= gsu...@netbsd.org writes:

 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 |
  ++--+--+

If this ascii art is correct, memmove should be used instead of
memcpy.  Also, if initial order is kernel, string table, symbol table
and a gap between kernel and string table is smaller than symbol
table, copying it may overwrite the string table.

Is there any guarantee that the gap is large enough?

enami.


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

2010-10-31 Thread David Young
On Sun, Oct 31, 2010 at 04:51:19AM +, YAMAMOTO Takashi wrote:
 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.

Good catch!

Dave

-- 
David Young OJC Technologies
dyo...@ojctech.com  Urbana, IL * (217) 278-3933


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

2010-02-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Feb 22 23:52:17 UTC 2010

Modified Files:
src/sys/arch/i386/i386: genassym.cf

Log Message:
Remove a duplicate entry for PTE_BASE.

While here, introduce PDP_SIZE and PDE_SIZE. They will be used by asm code
to make it more generic (PAE related).


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/i386/i386/genassym.cf

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



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

2010-02-22 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Mon Feb 22 23:52:17 UTC 2010

Modified Files:
src/sys/arch/i386/i386: genassym.cf

Log Message:
Remove a duplicate entry for PTE_BASE.

While here, introduce PDP_SIZE and PDE_SIZE. They will be used by asm code
to make it more generic (PAE related).


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/i386/i386/genassym.cf

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/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.84 src/sys/arch/i386/i386/genassym.cf:1.85
--- src/sys/arch/i386/i386/genassym.cf:1.84	Fri Nov 27 03:23:10 2009
+++ src/sys/arch/i386/i386/genassym.cf	Mon Feb 22 23:52:17 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.84 2009/11/27 03:23:10 rmind Exp $
+#	$NetBSD: genassym.cf,v 1.85 2010/02/22 23:52:17 jym Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -150,7 +150,6 @@
 define	LSRUN			LSRUN
 define	LSONPROC		LSONPROC
 
-define	PTE_BASE		PTE_BASE
 define	UPAGES			UPAGES
 define	USPACE			USPACE
 define	KSTACK_SIZE		KSTACK_SIZE
@@ -169,6 +168,9 @@
 define	PDIR_SLOT_PTE		PDIR_SLOT_PTE
 define	PTE_BASE		PTE_BASE
 
+define	PDP_SIZE		PDP_SIZE
+define	PDE_SIZE		sizeof(pd_entry_t)
+
 define	IOMAPSIZE		IOMAPSIZE
 
 define	VM_MAXUSER_ADDRESS	(int)VM_MAXUSER_ADDRESS



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

2010-02-21 Thread Darran Hunt
Module Name:src
Committed By:   darran
Date:   Mon Feb 22 06:42:15 UTC 2010

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

Log Message:
DTrace: missed the opt_dtrace.h include for these.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/sys/arch/i386/i386/trap.c
cvs rdiff -u -r1.52 -r1.53 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.



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

2010-02-16 Thread Matthias Drochner

da...@l8s.co.uk said:
 I presume the panic was in the 'return to user' sequence?

Yes, in the iret.

 Does it now SIGSEGV the program?

Yes, which is a bit strange because this happened before
even the first instruction was fetched, and no user-supplied
data are involved (as opposed to setmcontext).
It was entirely the kernel's fault, so a panic would be
only fair.

 (putting in the kernel %cs might leave you running user code with
 kernel privelege)

This couldn't happen here because the CPL=3 is set together with
the CS descriptor, so one should get a GPF on any attempt to
use a kernel descriptor.

best regards
Matthias





Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt




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.



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.



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.



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.



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.



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.



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

2009-11-26 Thread YAMAMOTO Takashi
hi,

 Hello,
 
 David Laight wrote:
 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.
 
 Thanks for working this around, however it is not a right fix.  With this
 patch, build.sh release passes:
 
 http://www.netbsd.org/~rmind/crash_pcb.diff

Requesting http://www.netbsd.org/~rmind/crash_pcb.diff
ftp: Error retrieving file `404 Not Found'

YAMAMOTO Takashi

 
 It should have been enough to amend the argument of routine exported to
 userland.  Do not you agree?
 
 -- 
 Mindaugas


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

2009-11-22 Thread Mindaugas Rasiukevicius
David Laight da...@l8s.co.uk wrote:
  Thanks for working this around, however it is not a right fix.  With this
  patch, build.sh release passes:
  
  http://www.netbsd.org/~rmind/crash_pcb.diff
  
  It should have been enough to amend the argument of routine exported to
  userland.  Do not you agree?
  

 ...
 
 No - you shouldn't be making any names visible to normal user programs.
 We pollute user namespace far too much as it is.

Can you please elaborate on this?  Normal user application do not and should
not include sys/lwp.h, only KVM grovellers (ps, libkvm) do that.  There are
few utilities which do that via sys/proc.h, but lwp.h already exports stuff
like USER_TO_UAREA/UAREA_TO_USER.  Addition of lwp_getpcb(), which is supposed
to replace them, does not change the status quo.  Do not you agree?

Having said that, it might be useful to abstract them using on _LWP_PRIVATE
definition or similar.  However, it is unrelated to this change.  Moreover,
your revert changed the original definition of lwp_getpcb().

 The 'fix' I did was a pragmatic one to get the build working.
 Programs like crash (and gdb) need to be able to define something
 in order to get these extra structures (etc) visible.

-- 
Mindaugas


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

2009-11-21 Thread Mindaugas Rasiukevicius
Hello,

David Laight wrote:
 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.

Thanks for working this around, however it is not a right fix.  With this
patch, build.sh release passes:

http://www.netbsd.org/~rmind/crash_pcb.diff

It should have been enough to amend the argument of routine exported to
userland.  Do not you agree?

-- 
Mindaugas


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

2009-11-21 Thread Christos Zoulas
In article 20091121223029.1e0d263b...@mail.netbsd.org,
Mindaugas Rasiukevicius  rm...@netbsd.org wrote:
Hello,

David Laight wrote:
 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.

Thanks for working this around, however it is not a right fix.  With this
patch, build.sh release passes:

http://www.netbsd.org/~rmind/crash_pcb.diff

It should have been enough to amend the argument of routine exported to
userland.  Do not you agree?

I do.

christos



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

2009-05-11 Thread Manuel Bouyer
On Sat, May 09, 2009 at 06:58:46AM +, Andrew Doran wrote:
   xen isn't as vulnerable to the LDT/segreg problem as native x86 because
   it's not MP and doesn't do kernel preemption. For the time being I guess
   it would suffice to #ifdef the 'cli'.
  
  That's not enough to make the binary run: even with the cli commented
  out the test binary segfaults.
  There may be something else wrong, I'll try to look further.
  
  Any way to use gdb to see what it's doing ? The NetBSD/i386 doesn't want
  to load this executable ...
 
 Can you ktrace it? At least we then can see if it's hitting the syscall
 path.


here's what I get:
 11703  1 ktrace   EMUL  netbsd
 11703  1 ktrace   RET   ktrace 0
 11703  1 ktrace   CALL  execve(0xbf7ffc27,0xbf7feb68,0xbf7feb70)
 11703  1 ktrace   NAMI  ./architextIndex
 11703  1 architextIndex EMUL  netbsd
 11703  1 architextIndex RET   syscall JUSTRETURN
 11703  1 architextIndex PSIG  SIGSEGV SIG_DFL: code=SEGV_ACCERR, 
addr=0xacb94, trap=4)
 11703  1 architextIndex NAMI  architextIndex.core

-- 
Manuel Bouyer, LIP6, Universite Paris VI.   manuel.bou...@lip6.fr
 NetBSD: 26 ans d'experience feront toujours la difference
--


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

2009-05-05 Thread Manuel Bouyer
On Tue, May 05, 2009 at 09:20:02PM +, Andrew Doran wrote:
  but the test binary from the PR segfaults:
  truc# kdump |less   
 
  34  0 ktrace   EMUL  netbsd
  34  0 ktrace   RET   ktrace 0
  34  0 ktrace   CALL  execve(0xbf7ffc02,0xbf7feb3c,0xbf7feb44)
  34  0 ktrace   NAMI  ./architextIndex
  34  0 architextIndex EMUL  netbsd
  34  0 architextIndex RET   syscall JUSTRETURN
  34  0 architextIndex PSIG  SIGSEGV SIG_DFL: code=SEGV_ACCERR, 
  addr=0xacb 94, trap=4)
  34  0 architextIndex NAMI  architextIndex.core
  
  On Xen CLI(%eax) expands to:
 movlCPUVAR(VCPU),%eax ;
 movb $1,EVTCHN_UPCALL_MASK(%eax)
 
 At this point the segment registers won't be set up. And %eax contains the
 syscall number.
  
  I guess this is a problem. Is there a way to account for this somewhere ?
 
 It is difficult to avoid the LDT/segreg problems without having interrupts
 disabled instantly on entry.
 
 Maybe we could add really ugly logic to compensate for it in trap() since
 oosyscall is the only place where we enter with interupts on (I don't know
 how interrupts/traps are set up on xen currently).
 
 xen isn't as vulnerable to the LDT/segreg problem as native x86 because
 it's not MP and doesn't do kernel preemption. For the time being I guess
 it would suffice to #ifdef the 'cli'.

That's not enough to make the binary run: even with the cli commented
out the test binary segfaults.
There may be something else wrong, I'll try to look further.

Any way to use gdb to see what it's doing ? The NetBSD/i386 doesn't want
to load this executable ...

-- 
Manuel Bouyer bou...@antioche.eu.org
 NetBSD: 26 ans d'experience feront toujours la difference
--


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

2009-05-04 Thread Manuel Bouyer
On Mon, May 04, 2009 at 11:47:29AM +, Andrew Doran wrote:
 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!

I tried the following code instead:
IDTVEC(osyscall)
CLI(%eax)   # must be first instruction
pushfl  # set eflags in trap frame
popl8(%esp)
orl $PSL_I,(%esp)   # re-enable ints on return to user
pushl   $7  # size of instruction for restart
jmp syscall1

but the test binary from the PR segfaults:
truc# kdump |less  
34  0 ktrace   EMUL  netbsd
34  0 ktrace   RET   ktrace 0
34  0 ktrace   CALL  execve(0xbf7ffc02,0xbf7feb3c,0xbf7feb44)
34  0 ktrace   NAMI  ./architextIndex
34  0 architextIndex EMUL  netbsd
34  0 architextIndex RET   syscall JUSTRETURN
34  0 architextIndex PSIG  SIGSEGV SIG_DFL: code=SEGV_ACCERR, addr=0xacb 
94, trap=4)
34  0 architextIndex NAMI  architextIndex.core

On Xen CLI(%eax) expands to:
   movlCPUVAR(VCPU),%eax ;
   movb $1,EVTCHN_UPCALL_MASK(%eax)

I guess this is a problem. Is there a way to account for this somewhere ?

-- 
Manuel Bouyer, LIP6, Universite Paris VI.   manuel.bou...@lip6.fr
 NetBSD: 26 ans d'experience feront toujours la difference
--


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

2009-03-30 Thread Izumi Tsutsui
dyo...@netbsd.org wrote:

 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.

src/share/misc/style says to insert it:

---
static int
dirinfo(const char *p, struct stat *sb, struct dirent *de, struct statfs *sf,
int *rargc, char **rargv[])
{   /* Insert an empty line if the function has no local variables. */

/*
 * In system libraries, catch obviously invalid function arguments
 * using _DIAGASSERT(3).
 */
_DIAGASSERT(p != NULL);

---
Izumi Tsutsui