Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Dec 2006 23:29:58 GMT
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 110841 for review
Message-ID:  <200612012329.kB1NTwPE070566@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=110841

Change 110841 by gonzo@gonzo_jeeves on 2006/12/01 23:29:25

	o Remove SP voodoo magic from exception_save_registers and 
	    exception_restore_registers. It was wrongly assumed that SP was
	    modified by return from exception_restore_registers and therefore
	    exception_save_registers increased SP by TF_SIZE and
	    exception_restore_registers decreased SP by the same value (we use
	    single j command without any stack modifications in these two
	    functions) But this behaviour is unacceptable for exec(2) syscall.
	    Brand new trapframe inititalized by exec_setregs contained actual
	    value of SP for new process and therefore
	    exception_restore_registers tweaked it by TF_SIZE making it wrong.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips/exception.S#16 edit
.. //depot/projects/mips2/src/sys/mips/mips/swtch.S#7 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/mips/exception.S#16 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/mips2/src/sys/mips/mips/exception.S#15 $
+ * $P4: //depot/projects/mips2/src/sys/mips/mips/exception.S#16 $
  */
 
 /*	$NetBSD: mipsX_subr.S,v 1.19 2005/12/11 12:18:09 christos Exp $	*/
@@ -798,14 +798,7 @@
 	lw	a0, TF_REG_A0(k1)
 	lw	v1, TF_REG_V1(k1)
 	lw	v0, TF_REG_V0(k1)
-
-
-
-	/*
-	 * Restore the stack minus TF_SIZE, to account for sp twiddle.
-	 */
 	lw	sp, TF_REG_SP(k1)
-	subu	sp, TF_SIZE
 
 
 	/*
@@ -814,17 +807,13 @@
 	 */
 	.set noat
 	lw	AT, TF_REG_AST(k1)
-#if 1
+
 	/* XXX
 	 * We wait until now so we don't interrupt ourselves.
 	 */
 	lw	k1, TF_REG_SR(k1)
 	jr	k0
 	mtc0	k1, MIPS_COP_0_STATUS
-#else
-	jr	k0
-	nop
-#endif
 
 	.set at
 END(exception_restore_registers)
@@ -890,8 +879,7 @@
 	 * To accomodate this, we add TF_SIZE, which makes up for the
 	 * initial subtraction for the trapframe.
 	 */
-	addu	t0, sp, TF_SIZE
-	sw	t0, TF_REG_SP(k1)
+	sw	sp, TF_REG_SP(k1)
 
 
 

==== //depot/projects/mips2/src/sys/mips/mips/swtch.S#7 (text+ko) ====

@@ -165,6 +165,19 @@
  */
 
 ENTRY(fork_trampoline)
+
+        mtc0    zero, MIPS_COP_0_STATUS         # disable int
+        COP0_SYNC
+        nop                                     # 3 op delay
+        nop
+        nop
+        li      a0, MIPS_SR_EXL                 # set exception level
+        mtc0    a0, MIPS_COP_0_STATUS
+        COP0_SYNC
+        nop
+        nop
+
+
 	move	a0, s0
 	move	a1, s1
 	move	a2, s2
@@ -182,7 +195,6 @@
 	move	k1, t0
 	jal	exception_restore_registers
 	nop
-	addu	sp, sp, TF_SIZE
 	eret
 
 END(fork_trampoline)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612012329.kB1NTwPE070566>