kemoba wrote:
I had the same issue i think, it's not a bug in QEMU, if you are following bran's tutorial, when you do idt_flush and gdt_flush, as a parameter specify &gp and &idtp.
I have my kernel source on GitHub, and this is the commit that fixed that for me:
https://github.com/Enverbalalic/OSDev_K ... c3581918f0Thanks, but I don't think that's the issue. I've dumped the IDT entry and it seems perfectly valid.
Here's the triple fault log from a keyboard interrupt:
6: v=21 e=0000 i=0 cpl=0 IP=0008:ffffffff8010e5e0 pc=ffffffff8010e5e0 SP=0010:ffffffff8010bfb0 env->regs[R_EAX]=00000000000000a0
RAX=00000000000000a0 RBX=0000000000000000 RCX=00000000001bfeb0 RDX=00000000001bff40
RSI=0000000000000018 RDI=ffffffff80168000 RBP=ffffffff8010bff0 RSP=ffffffff8010bfb0
R8 =0000000000000001 R9 =0000000000000000 R10=0000000000000000 R11=
00000000ffffffffR12=
80108e000008e5f0 R13=0000000000000000 R14=0000000000000000 R15=ffffffff80168000
RIP=ffffffff8010e5e0 RFL=00200246 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000000 00609a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
FS =0018 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0018 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= ffffffff801001b0 00000017
IDT= ffffffff80168000 00000fff
CR0=80000011 CR2=0000000000000000 CR3=0000000000101000 CR4=00000020
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000044 CCD=0000000000000000 CCO=EFLAGS
EFER=0000000000000500
check_exception old: 0xffffffff new 0xd
7: v=0d e=0008 i=0 cpl=0 IP=0008:ffffffff8010e5e0 pc=ffffffff8010e5e0 SP=0010:ffffffff8010bfb0 env->regs[R_EAX]=00000000000000a0
RAX=00000000000000a0 RBX=0000000000000000 RCX=00000000001bfeb0 RDX=00000000001bff40
RSI=0000000000000018 RDI=ffffffff80168000 RBP=ffffffff8010bff0 RSP=ffffffff8010bfb0
R8 =0000000000000001 R9 =0000000000000000 R10=0000000000000000 R11=00000000ffffffff
R12=80108e000008e5f0 R13=0000000000000000 R14=0000000000000000 R15=ffffffff80168000
RIP=ffffffff8010e5e0 RFL=00200246 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000000 00609a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
FS =0018 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0018 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= ffffffff801001b0 00000017
IDT= ffffffff80168000 00000fff
CR0=80000011 CR2=0000000000000000 CR3=0000000000101000 CR4=00000020
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000044 CCD=0000000000000000 CCO=EFLAGS
EFER=0000000000000500
check_exception old: 0xd new 0xd
8: v=08 e=0000 i=0 cpl=0 IP=0008:ffffffff8010e5e0 pc=ffffffff8010e5e0 SP=0010:ffffffff8010bfb0 env->regs[R_EAX]=00000000000000a0
RAX=00000000000000a0 RBX=0000000000000000 RCX=00000000001bfeb0 RDX=00000000001bff40
RSI=0000000000000018 RDI=ffffffff80168000 RBP=ffffffff8010bff0 RSP=ffffffff8010bfb0
R8 =0000000000000001 R9 =0000000000000000 R10=0000000000000000 R11=00000000ffffffff
R12=80108e000008e5f0 R13=0000000000000000 R14=0000000000000000 R15=ffffffff80168000
RIP=ffffffff8010e5e0 RFL=00200246 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000000 00609a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000000 00609300 DPL=0 DS [-WA]
FS =0018 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0018 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= ffffffff801001b0 00000017
IDT= ffffffff80168000 00000fff
CR0=80000011 CR2=0000000000000000 CR3=0000000000101000 CR4=00000020
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000044 CCD=0000000000000000 CCO=EFLAGS
EFER=0000000000000500
check_exception old: 0x8 new 0xd
I've dumped IDT[33] (keyboard interrupt) to R11 and R12, which reads
0x00000000ffffffff80108e000008e5f0Parsing it, we get the address for the ISR handler as 0xffffffff8010e5f0, which is correct according to my objdump.
The selector is 0x08, which also seems right
The flag is 0x8e, which is also correct.
Once again the ISR wasn't invoked at all, as the GPF was triggered upon calling it. The value for PC corresponds to essentially a "jmp $1" I put at the end of the kernel's main function.
Also, do I need to fiddle with GDT in long mode? I also tried that before loading IDT, but again got GPF when I tried moving "0x08" into ss (stack selector). I checked the GDT entry and it also seemed perfectly valid.
Pretty confused now...