FPU-intensive programs crashing with floating point exception onCyrix MII

From: Ondrej Zary
Date: Wed Aug 17 2005 - 11:14:46 EST


My machine (Cyrix MII PR300 CPU, PCPartner TXB820DS board with i430TX chipset) exhibits a really weird problem:
When I run a program that uses FPU, it sometimes crashes with "flaoting point exception" - for example, when playing MP3 files using any player. Or with Prime95 - http://www.mersenne.org/freesoft.htm - the "torture test" does not crash but shows "fatal error" in less than 10 minutes.
It might be something like this:
http://lists.suse.com/archive/suse-linux-e/2000-Sep/1080.html
or this
http://lists.slug.org.au/archives/slug/2000/11/msg00343.html

The problem appears on 2.4.x kernels and 2.6.x kernels. It works fine in Windows 98 - it can play MP3s and run Prime95 for hours without any problems.
I've tracked it down to math_error() in arch/i386/kernel/traps.c and "fixed" it (I really don't know anything about FPU programming). The patch is attached. It fixes my system - with the patch, I can play MP3s fine and Prime95 runs without any problems too.

Does anyone know why these exceptions happen and/or what's the correct solution?

--
Ondrej Zary

--- linux-2.6.10/arch/i386/kernel/traps.c~ 2004-12-25 12:02:03.000000000 +0100
+++ linux-2.6.10/arch/i386/kernel/traps.c 2004-12-25 12:02:03.000000000 +0100
@@ -790,8 +790,11 @@
*/
cwd = get_fpu_cwd(task);
swd = get_fpu_swd(task);
+ printk("MATH ERROR %d\n",((~cwd) & swd & 0x3f) | (swd & 0x240));
switch (((~cwd) & swd & 0x3f) | (swd & 0x240)) {
- case 0x000:
+ case 0x000: /* Hack for Cyrix problems */
+ case 0x200:
+ return;
default:
break;
case 0x001: /* Invalid Op */