User: Password:
|
|
Subscribe / Log in / New account

Broken on 386

Broken on 386

Posted Mar 15, 2012 1:53 UTC (Thu) by slashdot (guest, #22014)
Parent article: The x86 NMI iret problem

The linked commit is broken on original 386 CPUs without cmpxchg.

cmpxchg() is emulated by disabling interrupts, but of course NMIs aren't disabled, so there's a race that can read to a loss of the nested NMI on 386 CPUs.

This seems fixable by replacing cmpxchg() with local_dec_and_test() after setting NOT_RUNNING = 0, EXECUTING = 1, LATCHED = 2, which doesn't have a race condition, since the LATCHED -> EXECUTING transition is harmless.


(Log in to post comments)

Broken on 386

Posted Mar 15, 2012 2:00 UTC (Thu) by slashdot (guest, #22014) [Link]

More precisely, the LATCHED -> EXECUTING transition (in addition to the EXECUTING -> NOT_RUNNING one) is what you actually want and is done by the next assignment, so local_dec_and_test allows to remove the assignment and is just conceptually better than the cmpxchg, in addition to working on 386s.

Broken on 386

Posted Mar 16, 2012 15:07 UTC (Fri) by nevets (subscriber, #11875) [Link]

Hmm, I didn't realize that old versions of i386 didn't implement cmpxchg. Not sure there's many of these processors out there that will be using newer kernels that will need these features, but none-the-less, it should be fixed.

I actually like your solution. The assignment is still needed, but only for the first instance of the NMI, but the label could be moved.

It's great that you brought this up on LWN, but it would be much better if you posted a patch :-)


Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds