x86_64: Entering user mode
Posted: Wed Feb 22, 2012 10:21 am
HEEEEEeeellloooooooooOOoOoo
can someone post me how to enter in usermode (ring3) in x86-64!?!?! I've tried using the classic IRET method but i cant figure out why it doesn't work...
This is my GDT
And this is how, for now using the iret way, i'm trying to get into ring3
The stack pointer is a user mode writeable page....Maybe im wrong with the SS=0!?!?! But if i put in the CS 0x8 (the ring0 selector in the gdt) it works, clearly i'l end up in the ring0 again but this is just for testing.
I'm interested in how to enter in user mode using the SYSRET instruction as well (STAR;LSTAR etch).
I can't find any documentation about this topic for x86_64 so if someone know where is the problem...
Thanks a lot
D
can someone post me how to enter in usermode (ring3) in x86-64!?!?! I've tried using the classic IRET method but i cant figure out why it doesn't work...
This is my GDT
Code: Select all
align 0x10
global gdt64
gdt64:
; null descriptor
dw 0,0,0,0
; ring 0 code segment descriptor
dw 0x0 ; limit 15:0 = 0
dw 0x0 ; base low = 0
db 0x0 ; base middle = 0
db 10011000b ; access
db 00100000b ; flags + limit 19:16
db 0x0 ; base high
; ring 0 data segment descriptor
dw 0x0 ; limit 15:0 = 0
dw 0x0 ; base address = 0
db 0x0 ; base middle = 0
db 10010000b ; access
db 00000000b ; flags + limit 19:16
db 0x0 ; base high
; ring 3 code segment descriptor
dw 0x0
dw 0x0
db 0x0
db 11111000b
db 00100000b
db 0x0
; ring 3 data segment descriptor
dw 0x0
dw 0x0
db 0x0
db 10010000b
db 00000000b
db 0x0
Code: Select all
global enter_usermode
enter_usermode:
push 0x0 ; ss
mov rax, qword 0x7f7ffffffff0 ; rsp
push rax
pushfq ; rflags
push 0x1b ; cs
mov rax, qword um ; rip
push rax
iretq
um:
I'm interested in how to enter in user mode using the SYSRET instruction as well (STAR;LSTAR etch).
I can't find any documentation about this topic for x86_64 so if someone know where is the problem...
Thanks a lot
D