All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: linux-mips@linux-mips.org, binutils@sources.redhat.com
Subject: Re: [Patch]  / 0 should send SIGFPE not SIGTRAP...
Date: Fri, 11 Jun 2004 11:20:32 -0700	[thread overview]
Message-ID: <40C9F7F0.50501@avtrex.com> (raw)
In-Reply-To: <40C9F5FE.8030607@avtrex.com>

I guess I didn't fully read the comment above this section of code.

    /*
     * 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 ...
     */

I am using gcc-3.3.1/binutils-2.15.  With this toolchain, I get break 
instructions that comply with the MIPS documentation for break instructions:


00000000 <do_div>:
   0:   3c1c0000        lui     gp,0x0
   4:   279c0000        addiu   gp,gp,0
   8:   0399e021        addu    gp,gp,t9
   c:   0085001a        div     zero,a0,a1
  10:   14a00002        bnez    a1,1c <do_div+0x1c>
  14:   00000000        nop
  18:   000001cd        break   0x7
  1c:   00001012        mflo    v0
  20:   03e00008        jr      ra
  24:   00000000        nop
 

What to do?

David Daney

David Daney wrote:

> It might help if I attached the patch.  Here it is...
>
> David Daney wrote:
>
>> I am getting a SIGTRAP whenever an integer divide by 0 happens.  It 
>> should be sending SIGFPE.
>>
>> It looks like kernel/traps.c is a little messed up.
>>
>> The attached patch fixes it for me.
>>
>> The decoding of the break instruction was selecting the wrong bits.  
>> It looks like the trap instruction decoding was messed up also.  The 
>> patch fixes trap also, but I could not figure out how to get gcc to 
>> generate the trap form of division, so that part is untested.
>>
>> David Daney.
>>
>
>------------------------------------------------------------------------
>
>--- ../linux-avtrex/linux/arch/mips/kernel/traps.c	2004-02-26 11:14:09.000000000 -0800
>+++ arch/mips/kernel/traps.c	2004-06-11 10:13:59.000000000 -0700
>@@ -598,7 +598,7 @@
> 	 * code starts left to bit 16 instead to bit 6 in the opcode.
> 	 * Gas is bug-compatible ...
> 	 */
>-	bcode = ((opcode >> 16) & ((1 << 20) - 1));
>+	bcode = ((opcode >> 6) & ((1 << 20) - 1));
> 
> 	/*
> 	 * (A short test says that IRIX 5.3 sends SIGTRAP for all break
>@@ -633,7 +633,7 @@
> 
> 	/* Immediate versions don't provide a code.  */
> 	if (!(opcode & OPCODE))
>-		tcode = ((opcode >> 6) & ((1 << 20) - 1));
>+		tcode = ((opcode >> 6) & ((1 << 10) - 1));
> 
> 	/*
> 	 * (A short test says that IRIX 5.3 sends SIGTRAP for all trap
>  
>

  reply	other threads:[~2004-06-11 18:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-11 18:10 [Patch] / 0 should send SIGFPE not SIGTRAP David Daney
2004-06-11 18:12 ` David Daney
2004-06-11 18:20   ` David Daney [this message]
2004-06-11 19:12     ` Maciej W. Rozycki
     [not found]       ` <mailpost.1086981251.16853@news-sj1-1>
2004-06-11 19:27         ` cgd
2004-06-11 19:50           ` Maciej W. Rozycki
2004-06-11 20:51             ` David Daney
2004-06-11 21:10               ` [Patch] (revised patch) " David Daney
2004-06-13  8:33                 ` Geert Uytterhoeven
2004-06-14 12:52                   ` Maciej W. Rozycki
2004-06-22 21:30           ` [Patch] " Maciej W. Rozycki
2004-06-23 19:30             ` David Daney
2004-06-23 19:38               ` Maciej W. Rozycki
2004-06-24 10:39             ` Richard Sandiford
2004-06-24 18:34               ` Maciej W. Rozycki
     [not found]                 ` <mailpost.1088102121.25381@news-sj1-1>
2004-06-24 18:46                   ` cgd
2004-06-28 13:46                     ` Maciej W. Rozycki
  -- strict thread matches above, loose matches on Subject: below --
2004-06-28 15:19 cgd
2004-06-28 15:36 ` Maciej W. Rozycki
2004-07-19 14:21 ` Maciej W. Rozycki
     [not found]   ` <mailpost.1090246948.15046@news-sj1-1>
2004-07-19 15:19     ` cgd
2004-07-19 15:42       ` Maciej W. Rozycki
2004-07-19 23:29   ` Thiemo Seufer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40C9F7F0.50501@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=binutils@sources.redhat.com \
    --cc=linux-mips@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.