Getting double fault !

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

Getting double fault !

Post 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 ?
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: Getting double fault !

Post by Octocontrabass »

Are you sure it's really a double fault and not IRQ0?

This might also help.
matan
Posts: 13
Joined: Sat May 02, 2015 4:15 am
Libera.chat IRC: matan

Re: Getting double fault !

Post 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 ?
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Getting double fault !

Post by Roman »

Could you provide the code, that pushes the arguments? What compiler options do you use?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
Combuster
Member
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: Getting double fault !

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Getting double fault !

Post by iansjack »

Run your code in a debugger. Watch the stack during an interrupt. The problem should be fairly self-evident.
Post Reply