From owner-p4-projects@FreeBSD.ORG Fri Dec 1 23:29:59 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C0D3016A40F; Fri, 1 Dec 2006 23:29:59 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6FFEC16A412 for ; Fri, 1 Dec 2006 23:29:59 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5ECE043CA2 for ; Fri, 1 Dec 2006 23:29:42 +0000 (GMT) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kB1NTxqe070569 for ; Fri, 1 Dec 2006 23:29:59 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kB1NTwPE070566 for perforce@freebsd.org; Fri, 1 Dec 2006 23:29:58 GMT (envelope-from gonzo@FreeBSD.org) Date: Fri, 1 Dec 2006 23:29:58 GMT Message-Id: <200612012329.kB1NTwPE070566@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 110841 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Dec 2006 23:30:00 -0000 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)