I have undertaken the journey of starting to develop an operating system (or kernel rather) and am at the point at which I have set up interrupts and enabled the pic. However, as I'm executing sti to enable hardware-triggered interrupts I am receiving a double fault. Actually it depends; if i declare the interrupt on vector 8 in such a way that it pushes the error code itself (which I am aware it should not), then it triggers a double fault. If i don't and expect the error code, then i first get a double fault, followed by self-repeating Page Faults, which I think are due to the fact that the error code hasn'Ät been pushed and therefore the stack becomes unbalanced as things are cleared up that even though the should have been present weren't.
I should mention that my interrupt-routine in general works fine, at least for software triggered interrupts (executed with the int n instruction), but as soon as I execute sti my program breaks at one point or another with a double fault (or at least the exception is received on interrupt vector , but once again no error code is pushed.
I don't know if this might be an IRQ but as far as I'm concerned 8 is not a standard IRQ vector.
I have written above that i initialized the pic but whether or not the pic is initialized beforehand does not impact the observed behaviour. A such the issue doesn't seem PIC-related.
Has anyone a clue what this might be about?
Thanks already.
PS:
Here's the Github repo: https://github.com/draconware-dev/DraconOS/tree/dev
The dev branch contains the problematic code.
Uncomment sti in 'src/arch/x86/shared/kernel_start.asm' to see the issue in action.
Here's an example log from a test run in which I had registered interrupt vector 8 as a routine that expects an error code.
Code: Select all
// SMM: enter / SMM: after RSM a couple of times (these happen regardless of sti)i
0: v=08 e=0000 i=0 cpl=0 IP=0008:c01012c0 pc=c01012c0 SP=0010:c0007afc env->regs[R_EAX]=00000000
EAX=00000000 EBX=00023000 ECX=000000a1 EDX=00000000
ESI=0000be00 EDI=00102e00 EBP=c0007b00 ESP=c0007afc
EIP=c01012c0 EFL=00000286 [--S--P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= c000069c 00000017
IDT= c0100030 000007ff
CR0=80000011 CR2=00000000 CR3=00023000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000010 CCD=c0007af0 CCO=ADDL
EFER=0000000000000000
check_exception old: 0xffffffff new 0xe
1: v=0e e=0000 i=0 cpl=0 IP=0008:c0100028 pc=c0100028 SP=0010:c0007af4 CR2=00000280
EAX=00000001 EBX=00023000 ECX=000003d5 EDX=000003d4
ESI=0000be00 EDI=00102e00 EBP=c0007b00 ESP=c0007af4
EIP=c0100028 EFL=00000292 [--S-A--] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9a00 DPL=0 CS32 [-R-]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= c000069c 00000017
IDT= c0100030 000007ff
CR0=80000011 CR2=00000280 CR3=00023000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
CCS=00000008 CCD=c0007af4 CCO=ADDL
EFER=0000000000000000
check_exception old: 0xffffffff new 0xe
[many further and equivalent repetitions of Page fault]
So effectively I'm trying to figure out why that first interrupt without error code on vector 8 occurs after executing sti.
Thanks a lot and appreciate any help