Hello,
I would like some advice on my code about implementing IDT in long mode. It keeps triggering General Protection Fault when execute iretq. I know it triggers GPF because I have messed up with the stack, but I don't know where did I go wrong. Can anyone help me?
Here is my code https://github.com/NeonLightions/susOS.
The asm file when running QEMU with -d in_asm is in qemu.log. I only show the code after I execute 'sti' in there because all of the file would be very long. Need some helps.
General Fault when handling interrupt in long mode
-
- Member
- Posts: 5562
- Joined: Mon Mar 25, 2013 7:01 pm
Re: General Fault when handling interrupt in long mode
The log from "-d int" is typically more useful for diagnosing this kind of problem.passerby wrote:The asm file when running QEMU with -d in_asm is in qemu.log.
My crystal ball says you didn't load your new code segment selector into CS after setting up your GDT, so the interrupt pushes the wrong CS selector on the stack. The fault occurs when IRETQ pops that bad selector.
Re: General Fault when handling interrupt in long mode
Thank you so much, it solved my problem! This is so awkwardOctocontrabass wrote:The log from "-d int" is typically more useful for diagnosing this kind of problem.passerby wrote:The asm file when running QEMU with -d in_asm is in qemu.log.
My crystal ball says you didn't load your new code segment selector into CS after setting up your GDT, so the interrupt pushes the wrong CS selector on the stack. The fault occurs when IRETQ pops that bad selector.