Ok, 
 I'm a bit bitter, because I just spent a long time chasing down a kernel 
bug that didn't turn out to be a kernel bug at all.

I started seeing that strange SIGSEGV with programs that use dri, and it
happened right after the SIGFPE that tested for XMM support. As it
happens, I've done some signal delivery changes in the kernel lately, so I
blamed myself.

It wasn't my fault.

That frigging Mesa assembly-code is broken. In particular, it undoes the
whole stack frame _before_ it does the divide-by-zero thing, yet it still
has stuff in the local frame. Signal delivery will overwrite the local
frame if the stack is aligned just the right way, and as a result the
LDMXCSR that follows the DIVPS will load crap into MXCSR. And the crap it
loads may well cause a SIGSEGV due to a GP-fault by the CPU.

Grr. Double-grr. That assembly-language is written in some unreadable 
syntax anyway, but here's a totally untested diff that may fix the crap by 
de-allocating the stack only after we're actually _done_ with it.

I was too lazy to check whether the other asm routines were similarly 
broken. Anyway, the rule is: 

 YOU MUST NOT USE LOCATIONS ON THE STACK UNDER THE STACK POINTER

Ok, I feel better now after that rant. Sorry,

                Linus

-----
Index: common_x86_asm.S
===================================================================
RCS file: /cvsroot/dri/xc/xc/extras/Mesa/src/X86/common_x86_asm.S,v
retrieving revision 1.16
diff -u -r1.16 common_x86_asm.S
--- common_x86_asm.S    25 Nov 2002 19:57:08 -0000      1.16
+++ common_x86_asm.S    8 Jan 2003 21:27:57 -0000
@@ -225,13 +225,13 @@
 
        MOVUPS  ( REGIND( ESP ), XMM1 )
 
-       ADD_L   ( CONST( 32 ), ESP )
-
        DIVPS   ( XMM0, XMM1 )
 
        /* Restore the original MXCSR register value.
         */
        LDMXCSR ( REGOFF( -4, EBP ) )
+
+       ADD_L   ( CONST( 32 ), ESP )
 
        LEAVE
        RET



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to