Page 1 of 1

GPF and int instruction

Posted: Wed Feb 20, 2008 6:35 pm
by jtlb
hello, my kernel is running in ring0(or at least is suppose to!). When a thread returns i make it issue an int instruction and I get a GPF with error code 0x7fa. Is that normal?? what should i do then?

thank you for your help

Posted: Thu Feb 21, 2008 5:19 pm
by Combuster
You're probably loading a bad segment register somewhere. Your IDT may be borked...

Have you tried debugging the code? does Bochs tell you anything special?

Posted: Fri Feb 22, 2008 3:20 am
by jtlb
tanks for your answer.
yes i tried to debug the code. I' m also sure the segment is good and the IDT segment has been setted up the same way as the isr interrupt vector. I think that if the problem were comming from here, i would get another exeption than a GPF. Actually, the GPF occures on the "int" instruction, not while loading the handler.

I finally choose to handle it in my GPF handler near the v86 handler.

Posted: Fri Feb 22, 2008 3:55 am
by Combuster
jtlb wrote:Actually, the GPF occures on the "int" instruction, not while loading the handler.
If your GPF handler points to the INT instruction, then it is indeed that instruction that causes the GPF. Given that you are in protected mode, it will always look at the IDT and try to load the corresponding entry. If if finds something unusual there the result can very easily become that the GPF handler is called because it fails to enter the normal handler.

Posted: Fri Feb 22, 2008 4:05 am
by jtlb
No, I first detect that the app was running in non v86 mode and i then "emulate" the int instruction by calling the "C" handler directly. Of course i add 2 to the ip pointer to make it execute the next instruction