Re: FPU-intensive programs crashing with floating point exceptionon Cyrix MII

From: Linus Torvalds
Date: Sun Aug 21 2005 - 16:36:35 EST




On Sun, 21 Aug 2005, Chuck Ebbert wrote:
>
> > MATH ERROR: cwd = 0x37f, swd = 0x2800 <===========
>
> The error I marked has no exception flags set. The rest are all (masked)
> denormal exceptions. Why your Cyrix MII would cause an FPU exception in these
> cases is beyond me. Could you try the statically-linked mprime program?

Also, please try this one, to see where it happens.

Linus

---
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -357,11 +357,11 @@ void init_8259A(int auto_eoi)

static irqreturn_t math_error_irq(int cpl, void *dev_id, struct pt_regs *regs)
{
- extern void math_error(void __user *);
+ extern void math_error(struct pt_regs *);
outb(0,0xF0);
if (ignore_fpu_irq || !boot_cpu_data.hard_math)
return IRQ_NONE;
- math_error((void __user *)regs->eip);
+ math_error(regs);
return IRQ_HANDLED;
}

diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -774,8 +774,9 @@ clear_TF_reenable:
* the correct behaviour even in the presence of the asynchronous
* IRQ13 behaviour
*/
-void math_error(void __user *eip)
+void math_error(struct pt_regs *regs)
{
+ void __user *eip = (void __user *)regs->eip;
struct task_struct * task;
siginfo_t info;
unsigned short cwd, swd;
@@ -805,6 +806,7 @@ void math_error(void __user *eip)
swd = get_fpu_swd(task);
switch (((~cwd) & swd & 0x3f) | (swd & 0x240)) {
case 0x000:
+ show_regs(regs);
default:
break;
case 0x001: /* Invalid Op */
@@ -833,7 +835,7 @@ void math_error(void __user *eip)
fastcall void do_coprocessor_error(struct pt_regs * regs, long error_code)
{
ignore_fpu_irq = 1;
- math_error((void __user *)regs->eip);
+ math_error(regs);
}

static void simd_math_error(void __user *eip)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/