From owner-svn-src-head@FreeBSD.ORG Tue Jan 26 02:26:05 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2CCF1065672; Tue, 26 Jan 2010 02:26:04 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A81058FC16; Tue, 26 Jan 2010 02:26:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0Q2Q4BG049457; Tue, 26 Jan 2010 02:26:04 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0Q2Q4W5049453; Tue, 26 Jan 2010 02:26:04 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201001260226.o0Q2Q4W5049453@svn.freebsd.org> From: Neel Natu Date: Tue, 26 Jan 2010 02:26:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202996 - in head/sys/mips: include mips X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2010 02:26:05 -0000 Author: neel Date: Tue Jan 26 02:26:04 2010 New Revision: 202996 URL: http://svn.freebsd.org/changeset/base/202996 Log: Fix a problem seen when a new process was returning to userland through fork_trampoline. This was caused because we were clearing the SR_INT_IE and setting SR_EXL bits of the status register at the same time. This meant that if an interrupt happened while this MTC0 was making its way through the pipeline the exception processing would see the status register with SR_EXL bit set. This in turn would mean that the COP_0_EXC_PC would not be updated so the return from exception would be to an incorrect address. It is easy to verify this fix by a program that forks in a loop and the child just exits: while (1) { pid_t pid = vfork(); if (pid == 0) _exit(0); if (pid != -1) waitpid(pid, NULL, 0); } Also remove two instances where we set SR_EXL bit gratuitously in exception.S. Approved by: imp (mentor) Modified: head/sys/mips/include/cpuregs.h head/sys/mips/mips/exception.S head/sys/mips/mips/swtch.S Modified: head/sys/mips/include/cpuregs.h ============================================================================== --- head/sys/mips/include/cpuregs.h Tue Jan 26 00:38:56 2010 (r202995) +++ head/sys/mips/include/cpuregs.h Tue Jan 26 02:26:04 2010 (r202996) @@ -106,7 +106,11 @@ #elif defined(CPU_SB1) #define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop #else -#define COP0_SYNC /* nothing */ +/* + * Pick a reasonable default based on the "typical" spacing described in the + * "CP0 Hazards" chapter of MIPS Architecture Book Vol III. + */ +#define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop #endif #define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; Modified: head/sys/mips/mips/exception.S ============================================================================== --- head/sys/mips/mips/exception.S Tue Jan 26 00:38:56 2010 (r202995) +++ head/sys/mips/mips/exception.S Tue Jan 26 02:26:04 2010 (r202996) @@ -519,9 +519,6 @@ NNON_LEAF(MipsUserGenException, STAND_FR and t0, t0, ~(MIPS_SR_INT_IE) mtc0 t0, COP_0_STATUS_REG ITLBNOPFIX - or t0, t0, SR_EXL - mtc0 t0, COP_0_STATUS_REG # set exeption level - ITLBNOPFIX /* * The use of k1 for storing the PCB pointer must be done only @@ -751,9 +748,6 @@ NNON_LEAF(MipsUserIntr, STAND_FRAME_SIZE and t0, t0, ~(MIPS_SR_INT_IE) mtc0 t0, COP_0_STATUS_REG ITLBNOPFIX - or t0, t0, SR_EXL - mtc0 t0, COP_0_STATUS_REG # set exeption level - ITLBNOPFIX GET_CPU_PCPU(k1) lw k1, PC_CURPCB(k1) Modified: head/sys/mips/mips/swtch.S ============================================================================== --- head/sys/mips/mips/swtch.S Tue Jan 26 00:38:56 2010 (r202995) +++ head/sys/mips/mips/swtch.S Tue Jan 26 02:26:04 2010 (r202996) @@ -171,13 +171,9 @@ LEAF(fork_trampoline) 1: mfc0 v0, COP_0_STATUS_REG # set exeption level bit. - or v0, SR_EXL and v0, ~(SR_INT_ENAB) mtc0 v0, COP_0_STATUS_REG # set exeption level bit. - nop - nop - nop - nop + COP0_SYNC .set noat move k1, a1 RESTORE_U_PCB_REG(t0, MULLO, k1)