[SOLVED] [Long mode] IRET causing page fault
Posted: Sat Sep 17, 2011 9:54 am
Do you have any idea of why the iret instruction causes a page fault with CR2 = 0xFFF8?
This is the handler code:
This is the stack reported by bochs when iret gets executed:
At the moment of IRET, RSP is containing a good value (0xffffffff8010ef58), so I can't imagine why it should throw a Page Fault... Any idea?
Thanks
This is the handler code:
Code: Select all
cld
; Save the registers
push rax
push rcx
push rdx
push rbx
push rbp
push rsi
push rdi
; Switch to the kernel data segment
mov ax, 0x10
mov ds, ax
mov es, ax
mov ss, ax
; Push the pointer to the InterruptState object
mov rdi, rsp
; Call the C++ Code (Lymph::Hal::Idt::Manager::InterruptGlobalHandler)
call _ZN5Astro3Hal3Idt7Manager22InterruptGlobalHandlerEP14InterruptStack
mov rsp, rax
pop rdi
pop rsi
pop rbp
pop rbx
pop rdx
pop rcx
pop rax
; Remove the errorcode and the interrupt number from the stack
add rsp, 0x10
iret
Code: Select all
Stack address size 8
| STACK 0xffffffff8010ef58 [0xffffffff:0x80208121] <-- RIP
| STACK 0xffffffff8010ef60 [0x00000000:0x00000008] <-- CS
| STACK 0xffffffff8010ef68 [0x00000000:0x00000286] <-- RFLAGS
| STACK 0xffffffff8010ef70 [0xffffffff:0x8010ef88] <-- RSP
| STACK 0xffffffff8010ef78 [0x00000000:0x00000010] <-- SS
| STACK 0xffffffff8010ef80 [0xffffffff:0x8020811c] <-- some other rubbish
| STACK 0xffffffff8010ef88 [0xffffffff:0x8010efb8]
| STACK 0xffffffff8010ef90 [0xffffffff:0xc00011a0]
Thanks