Strange double fault after "sti"

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
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Strange double fault after "sti"

Post by torshie »

My kernel works in 64-bit mode, after loading the interrupt descriptor table, I set the interrupt flag with "sti". A few (the number varies) instructions after the "sti" instruction, the CPU would fire a double fault. If I simply "iretq" return from the double fault, everything works just fine. Tested on qemu, bochs and physical machine.
Anyone knows the possible cause of the double fault ?

Thanks
-torshie
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Re: Strange double fault after "sti"

Post by torshie »

I know the cause of the double fault. But how can I find out the first interrupt the CPU trying to handle ?

EDIT: I'm confused because the double fault isn't fired from a fixed location.
Last edited by torshie on Mon Aug 29, 2011 3:03 am, edited 1 time in total.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Strange double fault after "sti"

Post by Nessphoro »

I think it's in the error code? (Not sure)
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Strange double fault after "sti"

Post by xenos »

Since this happens right after enabling interrupts, it is very likely a hardware interrupt. It you run your code in Bochs, the log file should tell you what's going on.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Re: Strange double fault after "sti"

Post by torshie »

XenOS wrote:Since this happens right after enabling interrupts, it is very likely a hardware interrupt. It you run your code in Bochs, the log file should tell you what's going on.
got only one line from bochs log, not much help, :(

CPU 0: Interrupt 0x08 occured (error_code=0x0000)
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Strange double fault after "sti"

Post by xenos »

You could try to increase the CPU debug level. When Bochs is running, hit the "config" button, "log options for individual devices", "CPU0", "debug", "report". This should give you a lot more output.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Strange double fault after "sti"

Post by jal »

torshie wrote:got only one line from bochs log, not much help, :(
CPU 0: Interrupt 0x08 occured (error_code=0x0000)
And why exactly do you consider this of not much help?


JAL
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: Strange double fault after "sti"

Post by Combuster »

Given the symptoms, I'm pretty sure the OP missed the FAQ
"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 ]
Post Reply