From owner-freebsd-mips@FreeBSD.ORG Wed Aug 19 12:38:55 2009 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE1551065672; Wed, 19 Aug 2009 12:38:55 +0000 (UTC) (envelope-from tinderbox@freebsd.org) Received: from freebsd-current2.sentex.ca (freebsd-current2.sentex.ca [64.7.128.100]) by mx1.freebsd.org (Postfix) with ESMTP id 9B6628FC43; Wed, 19 Aug 2009 12:38:55 +0000 (UTC) Received: from freebsd-current2.sentex.ca (localhost [127.0.0.1]) by freebsd-current2.sentex.ca (8.14.3/8.14.3) with ESMTP id n7JCcNot001148; Wed, 19 Aug 2009 08:38:23 -0400 (EDT) (envelope-from tinderbox@freebsd.org) Received: (from tinderbox@localhost) by freebsd-current2.sentex.ca (8.14.3/8.14.3/Submit) id n7JCcNjC001147; Wed, 19 Aug 2009 12:38:23 GMT (envelope-from tinderbox@freebsd.org) Date: Wed, 19 Aug 2009 12:38:23 GMT Message-Id: <200908191238.n7JCcNjC001147@freebsd-current2.sentex.ca> X-Authentication-Warning: freebsd-current2.sentex.ca: tinderbox set sender to FreeBSD Tinderbox using -f Sender: FreeBSD Tinderbox From: FreeBSD Tinderbox To: FreeBSD Tinderbox , , Precedence: bulk Cc: Subject: [head tinderbox] failure on mips/mips X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Aug 2009 12:38:55 -0000 TB --- 2009-08-19 12:30:01 - tinderbox 2.6 running on freebsd-current2.sentex.ca TB --- 2009-08-19 12:30:01 - starting HEAD tinderbox run for mips/mips TB --- 2009-08-19 12:30:01 - mkdir /tinderbox/HEAD/mips TB --- 2009-08-19 12:30:01 - mkdir /tinderbox/HEAD/mips/mips TB --- 2009-08-19 12:30:01 - cleaning the object tree TB --- 2009-08-19 12:30:01 - checking out /src from http://svn.freebsd.org/base/ TB --- 2009-08-19 12:30:01 - cd /tinderbox/HEAD/mips/mips TB --- 2009-08-19 12:30:01 - /usr/local/bin/svn checkout http://svn.freebsd.org/base//head /src TB --- 2009-08-19 12:38:20 - WARNING: /usr/local/bin/svn caught signal 10 TB --- 2009-08-19 12:38:20 - ERROR: unable to check out the source tree TB --- 2009-08-19 12:38:20 - 14.77 user 30.47 system 499.02 real http://tinderbox.des.no/tinderbox-head-HEAD-mips-mips.full From owner-freebsd-mips@FreeBSD.ORG Wed Aug 19 14:05:36 2009 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32A901065690; Wed, 19 Aug 2009 14:05:36 +0000 (UTC) (envelope-from tinderbox@freebsd.org) Received: from freebsd-current2.sentex.ca (freebsd-current2.sentex.ca [64.7.128.100]) by mx1.freebsd.org (Postfix) with ESMTP id F3B258FC52; Wed, 19 Aug 2009 14:05:35 +0000 (UTC) Received: from freebsd-current2.sentex.ca (localhost [127.0.0.1]) by freebsd-current2.sentex.ca (8.14.3/8.14.3) with ESMTP id n7JE51q6001162; Wed, 19 Aug 2009 10:05:01 -0400 (EDT) (envelope-from tinderbox@freebsd.org) Received: (from tinderbox@localhost) by freebsd-current2.sentex.ca (8.14.3/8.14.3/Submit) id n7JE51hq001160; Wed, 19 Aug 2009 14:05:01 GMT (envelope-from tinderbox@freebsd.org) Date: Wed, 19 Aug 2009 14:05:01 GMT Message-Id: <200908191405.n7JE51hq001160@freebsd-current2.sentex.ca> X-Authentication-Warning: freebsd-current2.sentex.ca: tinderbox set sender to FreeBSD Tinderbox using -f Sender: FreeBSD Tinderbox From: FreeBSD Tinderbox To: FreeBSD Tinderbox , , Precedence: bulk Cc: Subject: [head tinderbox] failure on mips/mips X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Aug 2009 14:05:36 -0000 TB --- 2009-08-19 14:05:01 - tinderbox 2.6 running on freebsd-current2.sentex.ca TB --- 2009-08-19 14:05:01 - starting HEAD tinderbox run for mips/mips TB --- 2009-08-19 14:05:01 - cleaning the object tree TB --- 2009-08-19 14:05:01 - checking out /src from http://svn.freebsd.org/base/ TB --- 2009-08-19 14:05:01 - cd /tinderbox/HEAD/mips/mips TB --- 2009-08-19 14:05:01 - /usr/local/bin/svn update /src TB --- 2009-08-19 14:05:01 - WARNING: /usr/local/bin/svn returned exit code 1 TB --- 2009-08-19 14:05:01 - ERROR: unable to check out the source tree TB --- 2009-08-19 14:05:01 - 0.03 user 0.01 system 0.03 real http://tinderbox.des.no/tinderbox-head-HEAD-mips-mips.full From owner-freebsd-mips@FreeBSD.ORG Thu Aug 20 06:16:11 2009 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0940F1065696 for ; Thu, 20 Aug 2009 06:16:11 +0000 (UTC) (envelope-from neelnatu@yahoo.com) Received: from web34407.mail.mud.yahoo.com (web34407.mail.mud.yahoo.com [66.163.178.156]) by mx1.freebsd.org (Postfix) with SMTP id C03CC8FC60 for ; Thu, 20 Aug 2009 06:16:10 +0000 (UTC) Received: (qmail 86946 invoked by uid 60001); 20 Aug 2009 06:16:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1250748970; bh=vwNLrvHuvyDdVQw6gjbWTCo7TvEVGJliLwjL7QPXlhE=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=YmqzQhQ+ajc2XduRL2AdxcVf/a5YrQPAZdCknCnUlNDrMPTO608dwoZUXWwAMGmrEkbjpScIhlW0ZgiifroA6EyOmrLIMlRLj6rwuUaggRoLOl0H7ThSo2VDyJsbrnRphQXnx+qDG3/HVb6j06KCvndi8MNA4vmYOgAZdZlzHQY= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=pwzocdfBx8ZOtd789/Rf/vNYzjgcsKGxmqnB4w3tNCq/PpEwxj/iCcdPBeehoNIkHXyhHWuKk4EDcWWj8yREc9p63v9MMFvMXZ2nd8Hnhn8rloqDH4kQBD2EmKx2ZCIoTmzYdnRRTvg7AlGo1uWs73SlDozyh5vsVocTlM1mTso=; Message-ID: <82309.86773.qm@web34407.mail.mud.yahoo.com> X-YMail-OSG: ZW2c3ZsVM1kyjxb0D3qKdorUuny9qXKibaw_16rx_vj01iYPBQAbu.9y3JMXvESd0Nh74d2Mphx74kX0Dgqm7q9EIZlcxNloZv0r7RKDMa.baGnenNS5sA.WxkvcWreCQQffxNQk7M15TvhSPMda8_F1meIjaQiB2EBQwTFs8g2eMopJh43ollnP1dMVtxGvrire0y6EqSHLccnuhb21EcYQCJhCRvo.EVUg2p9VNIR3zQKMBcNL4kVjb32J8Y_5cLWc2RYHyrBkNwxgblU44Ju3eYQ02chPQ_hMdnAGMCEpgeGZ2l6kfpBcN8Lyhd1ZcDbNzQ-- Received: from [198.95.226.230] by web34407.mail.mud.yahoo.com via HTTP; Wed, 19 Aug 2009 23:16:10 PDT X-Mailer: YahooMailClassic/6.1.2 YahooMailWebService/0.7.338.2 Date: Wed, 19 Aug 2009 23:16:10 -0700 (PDT) From: Neelkanth Natu To: freebsd-mips@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: PATCH: fork_trampoline returning to an incorrect address X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Aug 2009 06:16:11 -0000 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 means 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); } Affected files ... ... //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/include/cpuregs.h#2 edit ... //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/mips/swtch.S#2 edit Differences ... ==== //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/include/cpuregs.h#2 (text) ==== @@ -106,7 +106,7 @@ #elif defined(CPU_SB1) #define COP0_SYNC ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop; ssnop #else -#define COP0_SYNC /* nothing */ +#define COP0_SYNC nop; nop; nop; nop; nop #endif #define COP0_HAZARD_FPUENABLE nop; nop; nop; nop; ==== //depot/user/neelnatu/projects_mips_sibyte/src/sys/mips/mips/swtch.S#2 (text) ==== @@ -161,25 +161,37 @@ DO_AST -/* - * Since interrupts are enabled at this point, we use a1 instead of - * k0 or k1 to store the PCB pointer. This is because k0 and k1 - * are not preserved across interrupts. - */ - GET_CPU_PCPU(a1) - lw a1, PC_CURPCB(a1) -1: + /* + * Clear the SR_INT_ENAB bit before setting the SR_EXL bit. + * + * The problem with doing them together is if an interrupt happens + * while the change makes its way through the pipeline. + * + * According to the MIPS32 Architecture for Programmers Vol2: + * "an exception or interrupt also clears both execution and + * instruction hazards" + * + * This implies that the exception will see the status register + * with the IE bit clear and EXL bit set. Since the EXL bit is set + * the COP_0_EXC_PC will not be updated and the return from exception + * will be to an incorrect address. + */ + mfc0 v0, COP_0_STATUS_REG + and v0, ~(SR_INT_ENAB) # disable interrupts + mtc0 v0, COP_0_STATUS_REG + COP0_SYNC + + or v0, SR_EXL # set exception level bit + mtc0 v0, COP_0_STATUS_REG + COP0_SYNC - 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 + /* + * Since 'k1' is trashed during exception processing its use is safe + * only after the point where we are sure not to be interrupted. + */ .set noat - move k1, a1 + GET_CPU_PCPU(k1) + lw k1, PC_CURPCB(k1) RESTORE_U_PCB_REG(t0, MULLO, k1) RESTORE_U_PCB_REG(t1, MULHI, k1) mtlo t0