LDT load causing GPF

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mmiikkee12
Member
Member
Posts: 38
Joined: Sat Jun 03, 2006 11:00 pm

LDT load causing GPF

Post by mmiikkee12 »

Whenever I try to switch tasks, I get a GPF with error code 0x18. I set up my LDT in the GDT with type 2, granularity bit 0, base as the start address of my LDT, and limit as size of the ldt - 1.

Code: Select all

extern old_esp
global _irq0
_irq0:
	pusha
	pushf
	mov eax, [old_esp]
	mov [eax], esp
	jmp isr32

Code: Select all

; The old esp is saved by the interrupt handler.
extern current_esp, current_ldt
global do_task_switch
do_task_switch:
	mov esp, [current_esp]
	popf
	popa
	lldt [current_ldt]
	iret
current_esp and current_ldt are definitely getting set correctly.

Also, when I tried 0x03 instead of 0x18 for the LDT selector, it loaded the LDT without a crash, but then GPFed again when I tried to set CS to 0x04. I used the same flags for the LDT's code segment as I did for the GDT's one at 0x08.
Post Reply