VOGONS


First post, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

So I have this situation in Protected Mode (286) when SS=0 and the BIOS executes "PUSH 8". The descriptor in GDT at entry 0 is all 0s so I am generating a Stack-Segment Fault (or a GPF but I think the stack segment fault is more correct).

However when I deal with the fault I also try to push on the stack the error code (and the return address) and that also faults because well, the SS is still 0.

Now what do I do, is that a double fault or yet another Stack-segment fault?

Even in the case of double fault, I will still need to push something on the stack (0) so that will also fault. So now I am tripple faulting.

I have a good GDT and IDT setup. Yet it seems a tripple fault can happen simply because SS is pointing to a bad descriptor. Does that make sense?

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 3 of 5, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie
SarahWalker wrote:

Loading SS with 0 should cause a stack fault - SS must always be valid.

Thank you. That makes sense, I was thinking the same.

crazyc wrote:

Has a new value been loaded into SS after the switch to pmode? If not the real mode stack is still valid.

Can you elaborate? The BIOS loaded (only time it touched) SS with the real mode value 0 and SP with 800h since it wants the real mode stack to be located at 0000:0800 then it switched to PM and did a "push 8". Now do I treat 0 in SS as segment 0 or descriptor 0? If I treat it as segment 0 and push the value at 0x0800 then all is good.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 4 of 5, by crazyc

User metadata
Rank Member
Rank
Member

The descriptor cache isn't reloaded until a new selector is loaded into the segment register. So if SS was 0 in real mode the descriptor cache will contain Base: 0x000000 Limit:0xffff Flags: 0x93 and it will stay that, even after a switch to pmode, until a new selector is loaded when the descriptor cache will contain the values from the GDT or LDT.

Reply 5 of 5, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie

Thank you!

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/