Module Name:    src
Committed By:   martin
Date:           Fri Nov  6 15:30:59 UTC 2015

Modified Files:
        src/sys/arch/sparc64/sparc64: locore.s vm_machdep.c

Log Message:
Basically revert r1.246 of locore.s and r1.73 of vm_machdep.c:

        Remove special case handling for userland lwps from cpu_lwp_fork,
        instead do it in lwp_trampoline when we first return to userland.

which was a stupid idea - since we did now set all fork child's %tstate
(and thus %pstate when back in userland) to the current kernel's userland
default. This meant we lost the address mask bit for 32bit processes and
all memory model details for 64bit ones.

Move it back to cpu_lwp_fork and fix the condition to only do it once when
forking init.


To generate a diff of this commit:
cvs rdiff -u -r1.385 -r1.386 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/sparc64/sparc64/vm_machdep.c

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

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.385 src/sys/arch/sparc64/sparc64/locore.s:1.386
--- src/sys/arch/sparc64/sparc64/locore.s:1.385	Thu Nov  5 10:11:51 2015
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Nov  6 15:30:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.385 2015/11/05 10:11:51 martin Exp $	*/
+/*	$NetBSD: locore.s,v 1.386 2015/11/06 15:30:59 martin Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5958,12 +5958,6 @@ ENTRY(lwp_trampoline)
 	 mov	%l1, %o0
 
 	/*
-	 * Going to userland - set proper tstate in trap frame
-	 */
-	set	(ASI_PRIMARY_NO_FAULT<<TSTATE_ASI_SHIFT)|((PSTATE_USER)<<TSTATE_PSTATE_SHIFT), %g1
-	stx	%g1, [%sp + CC64FSZ + STKB + TF_TSTATE]
-
-	/*
 	 * Here we finish up as in syscall, but simplified.
 	 */
 	b	return_from_trap

Index: src/sys/arch/sparc64/sparc64/vm_machdep.c
diff -u src/sys/arch/sparc64/sparc64/vm_machdep.c:1.100 src/sys/arch/sparc64/sparc64/vm_machdep.c:1.101
--- src/sys/arch/sparc64/sparc64/vm_machdep.c:1.100	Sun Sep 15 16:04:16 2013
+++ src/sys/arch/sparc64/sparc64/vm_machdep.c	Fri Nov  6 15:30:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.100 2013/09/15 16:04:16 martin Exp $ */
+/*	$NetBSD: vm_machdep.c,v 1.101 2015/11/06 15:30:59 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.100 2013/09/15 16:04:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.101 2015/11/06 15:30:59 martin Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -247,6 +247,14 @@ cpu_lwp_fork(register struct lwp *l1, re
 		tf2->tf_out[6] = (uint64_t)(u_long)stack + stacksize;
 
 	/*
+	 * Need to create a %tstate if we are forking our first userland
+	 * process - in all other cases we inherit from the parent.
+	 */
+	if (l2->l_proc->p_pid == 1)
+		tf2->tf_tstate = (ASI_PRIMARY_NO_FAULT<<TSTATE_ASI_SHIFT) |
+		    ((PSTATE_USER)<<TSTATE_PSTATE_SHIFT);
+
+	/*
 	 * Set return values in child mode and clear condition code,
 	 * in case we end up running a signal handler before returning
 	 * to userland.

Reply via email to