Page 1 of 1

Getting double fault !

Posted: Sat Nov 21, 2015 6:30 am
by matan
I have installed an IDT and got handlers working for all 256 interrupts, but i keep getting Double fault all the time.
What are some possible causes for this ?

Re: Getting double fault !

Posted: Sat Nov 21, 2015 6:37 am
by Octocontrabass
Are you sure it's really a double fault and not IRQ0?

This might also help.

Re: Getting double fault !

Posted: Sat Nov 21, 2015 7:30 am
by matan
you are absoulotly right ! forgot to remap IRQ's

but now im facing a different problem:
getting an IRQ0 im sending end of interrupt like:
if (r->int_no >= 40) // sending end of interrupt to slave PIC
{
out(0xA0, 0x20);
}
out(0x20, 0x20); // sending end of interrupt to master PIC

but it immediately crashes with qemu:
Trying to execute code outside RAM or ROM at 0x2badb002

im getting suspicious because it is grub's magic number.
how the hell can this happen if in my kernel_init(unsigned int magic , unsigned int adrr)
im popping it off the stack ?

Re: Getting double fault !

Posted: Sat Nov 21, 2015 9:51 am
by Roman
Could you provide the code, that pushes the arguments? What compiler options do you use?

Re: Getting double fault !

Posted: Sat Nov 21, 2015 4:14 pm
by Combuster
Considering tutorials push the signature and boot info onto the stack before calling the kernel main, you could see it reappear when the stack gets smashed.

For the actual stack smash, this could very likely be because the interrupt handler does not treat SP properly (like mismatched numbers of pops and pushes) which in the end uses some random part of the stack for the interrupt return instead of the actual interrupted address.

Re: Getting double fault !

Posted: Tue Nov 24, 2015 1:45 am
by iansjack
Run your code in a debugger. Watch the stack during an interrupt. The problem should be fairly self-evident.