Serious bug in save_flags

From: Alan Modra (alan@linuxcare.com.au)
Date: Sat Mar 18 2000 - 09:47:06 EST


Unless I'm very much mistaken, I've hit a bad problem with save_flags and
restore_flags on x86 with --fomit-frame-pointer. I've been fixing a
few more races in 2.2.15-pre/drivers/char, and found the following code
being generated for n_tty.c (my hacked version):

    1ad3: 9c pushf
    1ad4: 8f 44 24 14 popl 0x14(%esp,1) <=== !!!
    1ad8: fa cli
    1ad9: 8b 97 c0 09 00 00 mov 0x9c0(%edi),%edx
    1adf: 89 54 24 18 mov %edx,0x18(%esp,1)
    1ae3: 39 f2 cmp %esi,%edx
    1ae5: 75 94 jne 1a7b <read_chan+0x4d9>
    1ae7: 29 cb sub %ecx,%ebx
    1ae9: 89 d0 mov %edx,%eax
    1aeb: 01 d8 add %ebx,%eax
    1aed: 25 ff 0f 00 00 and $0xfff,%eax
    1af2: 89 87 c0 09 00 00 mov %eax,0x9c0(%edi)
    1af8: ff 74 24 14 pushl 0x14(%esp,1)
    1afc: 9d popf

You can't use the "g" constraint on any asm that messes with the
stack, and will be compiled with --fomit-frame-pointer. If gcc runs out
of hardware regs, it spills to a stack slot, but doesn't know that the asm
has changed %esp. In the above gcc should be using "popl 0x18(%esp)"

Simple fix: Change the "g" to "r".

Regards, Alan Modra

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:24 EST