]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] i386: fix incorrect FP signal code
authorChuck Ebbert <76306.1226@compuserve.com>
Wed, 24 Aug 2005 01:36:40 +0000 (21:36 -0400)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 24 Aug 2005 02:52:37 +0000 (19:52 -0700)
i386 floating-point exception handling has a bug that can cause error
code 0 to be sent instead of the proper code during signal delivery.

This is caused by unconditionally checking the IS and c1 bits from the
FPU status word when they are not always relevant.  The IS bit tells
whether an exception is a stack fault and is only relevant when the
exception is IE (invalid operation.) The C1 bit determines whether a
stack fault is overflow or underflow and is only relevant when IS and IE
are set.

Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/kernel/traps.c

index a61f33d06ea34313b9a36a271d9fd69f2b2034db..cd2d5d5514fe0ffcdf78cadfbabdf5863ede040c 100644 (file)
@@ -803,15 +803,17 @@ void math_error(void __user *eip)
         */
        cwd = get_fpu_cwd(task);
        swd = get_fpu_swd(task);
-       switch (((~cwd) & swd & 0x3f) | (swd & 0x240)) {
+       switch (swd & ~cwd & 0x3f) {
                case 0x000:
                default:
                        break;
                case 0x001: /* Invalid Op */
-               case 0x041: /* Stack Fault */
-               case 0x241: /* Stack Fault | Direction */
+                       /*
+                        * swd & 0x240 == 0x040: Stack Underflow
+                        * swd & 0x240 == 0x240: Stack Overflow
+                        * User must clear the SF bit (0x40) if set
+                        */
                        info.si_code = FPE_FLTINV;
-                       /* Should we clear the SF or let user space do it ???? */
                        break;
                case 0x002: /* Denormalize */
                case 0x010: /* Underflow */