Noob GPF Help [SOLVED]
Posted: Wed Feb 22, 2012 7:30 pm
I'm having a problem tracking down the cause of a GPF in my code.
My GDT and IDT have to be perfect, I've checked them tens of times.
I know only bare rudimentary assembly and I am convinced that is where my problem is.
I install my GDT, IDT, set up ISR handlers from 0-31 and IRQ handlers for 32-47, then execute 'sti' and immediately I get the GPF.
Somehow, I believe a stack problem is being caused by my isr or irq stub handler.
Note that all isrs and irqs push a dummy error code if the cpu doesn't.
If I execute this code
This is my result:
I get gibberish:
Anyone have any ideas?
My GDT and IDT have to be perfect, I've checked them tens of times.
I know only bare rudimentary assembly and I am convinced that is where my problem is.
I install my GDT, IDT, set up ISR handlers from 0-31 and IRQ handlers for 32-47, then execute 'sti' and immediately I get the GPF.
Somehow, I believe a stack problem is being caused by my isr or irq stub handler.
Note that all isrs and irqs push a dummy error code if the cpu doesn't.
If I execute this code
Code: Select all
isr_common_stub:
pusha
push gs
push fs
push es
push ds
mov ax, 0x10 ; Load the kernel data segment descriptor;
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, esp
push eax
mov eax, fault_handler
call eax
pop eax
; Commented out here, enabled in the next example
;call fault_handler
pop ds
pop es
pop fs
pop gs
popa
add esp, 8 ; Cleans up the pushed error code and pushed ISR number
iret
However, whenever I change the way I call my fault handler by just doing a "call fault_handler",General Protection Fault Exception
Error Code: 129
ds: 16
es: 1048592
fs: 16
gs: 16
edi: 128
esi: 179832
ebp: 1073144
esp: 1073096
ebx: 179488
edx: 142
ecs: 753664
eax: 47
int_no: 13
err_code: 129
epi: 1053168
cs: 8
eflags: 66050
esp: 1053395
ss: 1054748
Code: Select all
isr_common_stub:
pusha
push gs
push fs
push es
push ds
mov ax, 0x10 ; Load the kernel data segment descriptor;
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; Commented out here, enabled in the previous example
;mov eax, esp
;push eax
;mov eax, fault_handler
;call eax
;pop eax
call fault_handler
pop ds
pop es
pop fs
pop gs
popa
add esp, 8 ; Cleans up the pushed error code and pushed ISR number
iret
I don't know enough about x86 to figure out what the root cause of this is.Unknown Interrupt!
ds: 40262597203
es: 40262597203
fs: 40262597203
gs: 40262597203
edi: 4026597029
esi: 4026591623
ebp: 40262597203
esp: 40262597203
ebx: 40262597203
edx: 40262597203
ecs: 4026593111
eax: 40262597203
int_no: 3221225779
err_code: 4026597203
eip: 4026595393
cs: 4026590206
eflags: 4026591033
esp: 4026595417
ss: 4026591278
Anyone have any ideas?