From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29619 invoked by alias); 11 Jun 2004 20:52:40 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 29575 invoked from network); 11 Jun 2004 20:52:39 -0000 Received: from unknown (HELO avtrex.com) (216.102.217.178) by sourceware.org with SMTP; 11 Jun 2004 20:52:39 -0000 Received: from avtrex.com ([192.168.0.111] RDNS failed) by avtrex.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 11 Jun 2004 13:50:26 -0700 Message-ID: <40CA1B35.6010603@avtrex.com> Date: Fri, 11 Jun 2004 20:52:00 -0000 From: David Daney User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030 MIME-Version: 1.0 To: "Maciej W. Rozycki" CC: cgd@broadcom.com, Ralf Baechle , linux-mips@linux-mips.org, binutils@sources.redhat.com Subject: Re: [Patch] / 0 should send SIGFPE not SIGTRAP... References: <40C9F5A4.2050606@avtrex.com> <40C9F5FE.8030607@avtrex.com> <40C9F7F0.50501@avtrex.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------050705030308070603060308" X-OriginalArrivalTime: 11 Jun 2004 20:50:26.0155 (UTC) FILETIME=[B8F03BB0:01C44FF5] X-SW-Source: 2004-06/txt/msg00193.txt.bz2 This is a multi-part message in MIME format. --------------050705030308070603060308 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 364 Maciej W. Rozycki wrote: >On Fri, 11 Jun 2004 cgd@broadcom.com wrote: > > >>Unfortunately, at this point, Linux should probably accept the >>divide-by-zero code in both locations. >> >> > > I think that's not a big trouble for Linux -- the path is rare and not >critical for performance. > > > How about the attached (lightly tested) patch? David Daney. --------------050705030308070603060308 Content-Type: text/plain; name="traps.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="traps.diff" Content-length: 2111 *** ../linux-avtrex/linux/arch/mips/kernel/traps.c 2004-02-26 11:14:09.000000000 -0800 --- arch/mips/kernel/traps.c 2004-06-11 13:43:00.000000000 -0700 *************** *** 597,615 **** * There is the ancient bug in the MIPS assemblers that the break * code starts left to bit 16 instead to bit 6 in the opcode. * Gas is bug-compatible ... ! */ ! bcode = ((opcode >> 16) & ((1 << 20) - 1)); ! ! /* * (A short test says that IRIX 5.3 sends SIGTRAP for all break * insns, even for break codes that indicate arithmetic failures. * Weird ...) * But should we continue the brokenness??? --macro */ switch (bcode) { ! case 6: ! case 7: ! if (bcode == 7) info.si_code = FPE_INTDIV; else info.si_code = FPE_INTOVF; --- 597,621 ---- * There is the ancient bug in the MIPS assemblers that the break * code starts left to bit 16 instead to bit 6 in the opcode. * Gas is bug-compatible ... ! * * (A short test says that IRIX 5.3 sends SIGTRAP for all break * insns, even for break codes that indicate arithmetic failures. * Weird ...) * But should we continue the brokenness??? --macro + * + * It seems some assemblers (binutils-2.15 for example) assemble + * break correctly. So we check for the break code in either + * position. + * */ + + bcode = ((opcode >> 6) & ((1 << 20) - 1)); switch (bcode) { ! case 0x0006: ! case 0x0007: ! case 0x1800: /* 6 << 10 */ ! case 0x1c00: /* 7 << 10 */ ! if (bcode == 0x7 || bcode == 0x1c00) info.si_code = FPE_INTDIV; else info.si_code = FPE_INTOVF; *************** *** 633,639 **** /* Immediate versions don't provide a code. */ if (!(opcode & OPCODE)) ! tcode = ((opcode >> 6) & ((1 << 20) - 1)); /* * (A short test says that IRIX 5.3 sends SIGTRAP for all trap --- 639,645 ---- /* Immediate versions don't provide a code. */ if (!(opcode & OPCODE)) ! tcode = ((opcode >> 6) & ((1 << 10) - 1)); /* * (A short test says that IRIX 5.3 sends SIGTRAP for all trap --------------050705030308070603060308--