I was developing a 32 bit PM OS. I have set up a working IDT and GDT. My SS value before switching to PM was 0x600. After switching to PM, i have set up CS, DS values. Now if I point SS to a GDT entry for a stack segment and if i execute an INT instruction, triple fault is the result(I have not implemented exception handler). I have set up a TSS containing SS0, ES0 values. I am invoking the interrupt from ring 0 itself. Any hint as to why this happens???
Interestingly, suppose i leave the SS value untouched after switching to PM(ie, SS = 0x600 in PM), the code works fine, no triple fault is generated when executing INT instruction. I can push and pop into the stack. But the SS doesnot point to a valid entry in the GDT (no GDT entry exists in my GDT at offset 0x600 * and still the code works... Any hints??
Strange Behaviour of Stack
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Strange Behaviour of Stack
Experimental results say otherwise.I have set up a working IDT and GDT
Try looking at the segment limit.
Re: Strange Behaviour of Stack
The CPU caches the segment data - so if you set SS to 0x0600 in real mode, it should behave like a 16-bit segment with base 0x6000, limit 0xFFFF - even if you're not in real mode any more. That's why you need to explicitly reload all segment registers once you're in protected mode.appusajeev wrote: Interestingly, suppose i leave the SS value untouched after switching to PM(ie, SS = 0x600 in PM), the code works fine, no triple fault is generated when executing INT instruction. I can push and pop into the stack. But the SS doesnot point to a valid entry in the GDT (no GDT entry exists in my GDT at offset 0x600 * and still the code works... Any hints??
-
- Posts: 3
- Joined: Mon Aug 01, 2011 7:10 am
Re: Strange Behaviour of Stack
Thanks for the replies.
I was in QEMU all this time. Now, lemme try this is real machine and see if its the prob with QEMU
I was in QEMU all this time. Now, lemme try this is real machine and see if its the prob with QEMU
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Strange Behaviour of Stack
You really must be new to programming in general to simply blame your tools.
Real hardware doesn't just crash, it even thinks it's funny not telling you why. Which is why the lot of us tests in qemu and bochs until that works before even considering real hardware
Real hardware doesn't just crash, it even thinks it's funny not telling you why. Which is why the lot of us tests in qemu and bochs until that works before even considering real hardware
Re: Strange Behaviour of Stack
I used to try my os on an eeepc 900... until it died some month ago for the code executed in a "dirty" ram section. It has never worked again... It seems that something inside has been broken.
This is to say that perhaps if it doesn't work on the emulator... it could be a reason
This is to say that perhaps if it doesn't work on the emulator... it could be a reason