how do i Detect the POPAD Bug?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jcout_bsi

how do i Detect the POPAD Bug?

Post by jcout_bsi »

[glow=red,2,300]How would i detect the popad bug and activate a work-around and What processors have the POPAD?[/glow]
Tim

Re:how do i Detect the POPAD Bug?

Post by Tim »

Extra question: what is the POPAD bug?
Curufir

Re:how do i Detect the POPAD Bug?

Post by Curufir »

POPAD bug is present in 386DX and some 386SX.

Basically the bug has to do with effective addressing in the instruction immediately following POPAD/POPA. This explains it quite succinctly http://tamerlan.it.nsc.ru/~michael/x86/86bugs/bugs045.htm.

As for dealing with it...just remember never to have such an effective address type instruction that doesn't use EAX following a POPAD.

**
For Tim:
POPAD/POPA bug is the one where a POPAD/POPA that is immediately followed by an instruction that uses effective addressing via any register but EAX causes the value of EAX not to be restored properly from the stack. I'm sure there should be some more punctuation in there somewhre :).

**
Forgot to answer the detection question (Doh :-[). Load EAX and some other register with the same value, and another with the value to use in effective addressing, pushad, change EAX to another value, popad, perform a memory access using effective addressing and check EAX against the register that you previously set to have the same value. Repeat this a few times to be sure (It's supposed to be deterministic but it never hurts to be sure). If they're the same the bug isn't present, if they're different it is and you know you're dealing with a 386DX/SX processor.

Curufir
Post Reply