GPF about 1 second after sti
Posted: Fri Nov 18, 2022 7:48 pm
I've been working on interrupts for a x86_64 kernel, and it boots from efi, setups a screen, installs a valid gdt, and then waits. When I try and enable interrupts with sti (after a valid idt is loaded), a triple fault occurs. It doesn't happen with any interrupt, it will occur about one second after the sti instruction. I've looked through qemu debug, and it seems similar to this post but the e on the first fault is e=0038, instead of e=0012. Any help would be appreciated, thanks.
Here is some qemu debug info:
check_exception old: 0xffffffff new 0xd
187: v=0d e=0038 i=0 cpl=0 IP=0008:00000000000020f5 pc=00000000000020f5 SP=0010:000000000ff07340 env->regs[R_EAX]=000000000006fde5
RAX=000000000006fde5 RBX=0000000000002090 RCX=000000000e5f1ec0 RDX=0000000000000000
RSI=000000000e5f1ec0 RDI=00000000000020ed RBP=000000000ff07380 RSP=000000000ff07340
R8 =0000000000000000 R9 =0000000000000122 R10=0000000000000001 R11=000000000ff06990
R12=000000000e624f98 R13=000000000e625018 R14=000000000ff073d0 R15=000000000e624c40
RIP=00000000000020f5 RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000fff 00a09a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
FS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
GS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= 0000000000003000 00000fff
IDT= 000000000f585018 00000fff
CR0=80010033 CR2=0000000000000000 CR3=000000000fc01000 CR4=00000668
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=000000000006fde5 CCO=EFLAGS
EFER=0000000000000d00
check_exception old: 0xd new 0xd
188: v=08 e=0000 i=0 cpl=0 IP=0008:00000000000020f5 pc=00000000000020f5 SP=0010:000000000ff07340 env->regs[R_EAX]=000000000006fde5
RAX=000000000006fde5 RBX=0000000000002090 RCX=000000000e5f1ec0 RDX=0000000000000000
RSI=000000000e5f1ec0 RDI=00000000000020ed RBP=000000000ff07380 RSP=000000000ff07340
R8 =0000000000000000 R9 =0000000000000122 R10=0000000000000001 R11=000000000ff06990
R12=000000000e624f98 R13=000000000e625018 R14=000000000ff073d0 R15=000000000e624c40
RIP=00000000000020f5 RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000fff 00a09a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
FS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
GS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= 0000000000003000 00000fff
IDT= 000000000f585018 00000fff
CR0=80010033 CR2=0000000000000000 CR3=000000000fc01000 CR4=00000668
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=000000000006fde5 CCO=EFLAGS
EFER=0000000000000d00
check_exception old: 0x8 new 0xd
Servicing hardware INT=0x68
189: v=68 e=0000 i=0 cpl=0 IP=0038:000000000f58752a pc=000000000f58752a SP=0030:000000000ff07c40 env->regs[R_EAX]=0000000000000000
RAX=0000000000000000 RBX=00000000000186a0 RCX=0000000000000000 RDX=00000000000004d1
RSI=0000000000000000 RDI=000000000000fffe RBP=0000000000000000 RSP=000000000ff07c40
R8 =0000000000000000 R9 =000000000f588b20 R10=0000000000000002 R11=0000000000000010
R12=000000000ff07cb8 R13=0000000000000000 R14=000000000ff2a720 R15=000000000ff07dc0
RIP=000000000f58752a RFL=00000246 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0038 0000000000000000 ffffffff 00af9a00 DPL=0 CS64 [-R-]
SS =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0030 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= 000000000f9ee698 00000047
IDT= 000000000f585018 00000fff
CR0=80010033 CR2=0000000000000000 CR3=000000000fc01000 CR4=00000660
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=0000000000000000 CCO=SARW
EFER=0000000000000d00
Here is some qemu debug info:
check_exception old: 0xffffffff new 0xd
187: v=0d e=0038 i=0 cpl=0 IP=0008:00000000000020f5 pc=00000000000020f5 SP=0010:000000000ff07340 env->regs[R_EAX]=000000000006fde5
RAX=000000000006fde5 RBX=0000000000002090 RCX=000000000e5f1ec0 RDX=0000000000000000
RSI=000000000e5f1ec0 RDI=00000000000020ed RBP=000000000ff07380 RSP=000000000ff07340
R8 =0000000000000000 R9 =0000000000000122 R10=0000000000000001 R11=000000000ff06990
R12=000000000e624f98 R13=000000000e625018 R14=000000000ff073d0 R15=000000000e624c40
RIP=00000000000020f5 RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000fff 00a09a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
FS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
GS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= 0000000000003000 00000fff
IDT= 000000000f585018 00000fff
CR0=80010033 CR2=0000000000000000 CR3=000000000fc01000 CR4=00000668
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=000000000006fde5 CCO=EFLAGS
EFER=0000000000000d00
check_exception old: 0xd new 0xd
188: v=08 e=0000 i=0 cpl=0 IP=0008:00000000000020f5 pc=00000000000020f5 SP=0010:000000000ff07340 env->regs[R_EAX]=000000000006fde5
RAX=000000000006fde5 RBX=0000000000002090 RCX=000000000e5f1ec0 RDX=0000000000000000
RSI=000000000e5f1ec0 RDI=00000000000020ed RBP=000000000ff07380 RSP=000000000ff07340
R8 =0000000000000000 R9 =0000000000000122 R10=0000000000000001 R11=000000000ff06990
R12=000000000e624f98 R13=000000000e625018 R14=000000000ff073d0 R15=000000000e624c40
RIP=00000000000020f5 RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
CS =0008 0000000000000000 00000fff 00a09a00 DPL=0 CS64 [-R-]
SS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
DS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
FS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
GS =0010 0000000000000000 00000fff 00c09300 DPL=0 DS [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT= 0000000000003000 00000fff
IDT= 000000000f585018 00000fff
CR0=80010033 CR2=0000000000000000 CR3=000000000fc01000 CR4=00000668
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=000000000006fde5 CCO=EFLAGS
EFER=0000000000000d00
check_exception old: 0x8 new 0xd
Servicing hardware INT=0x68
189: v=68 e=0000 i=0 cpl=0 IP=0038:000000000f58752a pc=000000000f58752a SP=0030:000000000ff07c40 env->regs[R_EAX]=0000000000000000
RAX=0000000000000000 RBX=00000000000186a0 RCX=0000000000000000 RDX=00000000000004d1
RSI=0000000000000000 RDI=000000000000fffe RBP=0000000000000000 RSP=000000000ff07c40
R8 =0000000000000000 R9 =000000000f588b20 R10=0000000000000002 R11=0000000000000010
R12=000000000ff07cb8 R13=0000000000000000 R14=000000000ff2a720 R15=000000000ff07dc0
RIP=000000000f58752a RFL=00000246 [---Z-P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0038 0000000000000000 ffffffff 00af9a00 DPL=0 CS64 [-R-]
SS =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0030 0000000000000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0030 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= 000000000f9ee698 00000047
IDT= 000000000f585018 00000fff
CR0=80010033 CR2=0000000000000000 CR3=000000000fc01000 CR4=00000660
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000000 CCD=0000000000000000 CCO=SARW
EFER=0000000000000d00