Privilege level switching in x86
Posted: Tue Jan 23, 2007 1:03 am
Hi all,
I am developing a OS with two privilege levels ring0 and ring3.After doing kernel init I am trying to switch to ring 3 code segment.Its giving GP fault for me.
Inside kernel I am doing this:
.............
..........
push USER_SS
push UESP
pushf
push USER_CS
push UEIP
iret
Inside User code I am doing this:
mov ax,USER_DS
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,USER_SS
mov ss,ax
mov esp,UESP
..............
................
Please correct my mistakes in implementation or understanding.
Thanks in advance....
Sampath S
I am developing a OS with two privilege levels ring0 and ring3.After doing kernel init I am trying to switch to ring 3 code segment.Its giving GP fault for me.
Inside kernel I am doing this:
.............
..........
push USER_SS
push UESP
pushf
push USER_CS
push UEIP
iret
Inside User code I am doing this:
mov ax,USER_DS
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ax,USER_SS
mov ss,ax
mov esp,UESP
..............
................
Please correct my mistakes in implementation or understanding.
Thanks in advance....
Sampath S