Hi,
AR wrote:
You are using paging? The only explanation that currently comes to mind is that you are writing in physical memory and there is a memory mapped device that doesn't support reading that register so it faults causing a stack fault exception.
On most/modern computers, the BIOS itself (i.e. the full BIOS rather than just the part mapped below 1 MB) is at the top of the physical address space, so the stack would be in ROM if paging wasn't enabled. In this case I'd expect a general protection fault during the IRET, caused by CS.
A stack fault is typically caused by exceeding the stack segment limit.
I have a feeling that it'd be possible to pop dwords off the stack, let it wrap from 0xFFFFFFFC to 0x00000000 and then keep popping more from the stack, but instructions that cause more than 4 bytes to be taken from the stack would cause problems (e.g. doing "POPAD" or "IRETD" when ESP = 0xFFFFFFFC). I'm not sure though (I'd need to test it).
Despite all of this, the fact that the same problem occurs when ESP starts at 0xFFFFFFFC and no wrapping is meant to be involved, makes me think the problem is something to do with broken task switching code, messed up SS base or limit, or something along those lines. To be honest broken task switching code would be my first assumption...
Cheers,
Brendan