Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [patch] linux: Report the faulting FPU instruction
@ 2001-11-26 15:28 Maciej W. Rozycki
  2001-11-27  1:13 ` Ralf Baechle
  0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2001-11-26 15:28 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, linux-mips

Hello,

 I believe it's desireable to point to the faulting instruction upon an
FPU trap and not the following one.  Why?  First, the FPU restores the
state from before attempting to exectute the instruction.  Second, with
the current approach state is lost -- consider instructions in branch/jump
delay slots.  Third, erroneous execution is possible if SIG_FPE's handler
is set to "ignore" by mistake.

 The following patch implements the described approach.  It should not
affect standard handlers which use setjmp()/longjmp(), but it should
enable a smarter interpreting handler or just better diagnostics.  Both
the hardware and the emulator are handled.  Tested successfully with gdb
on an R3k, an R4k and the emulator. 

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

patch-mips-2.4.14-20011123-fpu-epc-0
diff -up --recursive --new-file linux-mips-2.4.14-20011123.macro/arch/mips/kernel/traps.c linux-mips-2.4.14-20011123/arch/mips/kernel/traps.c
--- linux-mips-2.4.14-20011123.macro/arch/mips/kernel/traps.c	Wed Nov 21 05:26:46 2001
+++ linux-mips-2.4.14-20011123/arch/mips/kernel/traps.c	Sun Nov 25 13:25:06 2001
@@ -497,9 +497,6 @@ asmlinkage void do_fpe(struct pt_regs *r
 		return;
 	}
 
-	if (compute_return_epc(regs))
-		return;
-
 	force_sig(SIGFPE, current);
 	printk(KERN_DEBUG "Sent send SIGFPE to %s\n", current->comm);
 }
diff -up --recursive --new-file linux-mips-2.4.14-20011123.macro/arch/mips/math-emu/cp1emu.c linux-mips-2.4.14-20011123/arch/mips/math-emu/cp1emu.c
--- linux-mips-2.4.14-20011123.macro/arch/mips/math-emu/cp1emu.c	Sun Oct 14 04:26:36 2001
+++ linux-mips-2.4.14-20011123/arch/mips/math-emu/cp1emu.c	Sun Nov 25 13:29:30 2001
@@ -1721,6 +1721,9 @@ int fpu_emulator_cop1Handler(struct pt_r
 		/* but if epc has advanced, then ignore it */
 		sig = 0;
 
+	if (sig)
+		xcp->cp0_epc = prevepc;
+
 	return sig;
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-11-27 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-26 15:28 [patch] linux: Report the faulting FPU instruction Maciej W. Rozycki
2001-11-27  1:13 ` Ralf Baechle
2001-11-27 13:20   ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox