flat assembler
Message board for the users of flat assembler.

Index > OS Construction > [solved] Error occured when jumping into ring3

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 670
l4m2 04 Sep 2015, 13:42
I set GDT
Code:
dq 0
dw 0ffffh,0                     ;   4Gbytes, start at linear 0
db 0,10011010b,11001111b,0      ;   granularity = 64Kbytes, code segment, ring 0, read only,etc...
dw 0ffffh,0                     ;   4Gbytes, start at linear 0
db 0,10010010b,11001111b,0      ;   granularity = 64Kbytes, data segment, ring 0, read/write,etc...
dw 0ffffh,0                     ;   4Gbytes, start at linear 0
db 0,11111010b,11001111b,0      ;   granularity = 64Kbytes, code segment, ring 3, read only,etc...
dw 0ffffh,0                     ;   4Gbytes, start at linear 0
db 0,11110010b,11001111b,0      ;   granularity = 64Kbytes, data segment, ring 3, read/write,etc...
dw 8*5    
and LDT(all be dq 0x****8e00********).When
Code:
cli
push 32
push 0x1000000
push 24
push @f
retf
@@:
jmp $    
bochs says
Code:
00006403462e[CPU0  ] check_cs(0x0018): non-conforming code seg descriptor dpl != cpl, dpl=3, cpl=0
00006403468e[CPU0  ] iret: SS.rpl != CS.rpl
00006403469e[CPU0  ] fetch_raw_descriptor: GDT: index (3e7) 7c > limit (28)
00006403470e[CPU0  ] fetch_raw_descriptor: GDT: index (3e7) 7c > limit (28)
00006403471e[CPU0  ] fetch_raw_descriptor: GDT: index (3e7) 7c > limit (28)    

but if
Code:
sti
jmp $    
nothing happens
Post 04 Sep 2015, 13:42
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 670
l4m2 05 Sep 2015, 01:35
Solved. jump into 32+3 and 24+3 and it is OK.
Now having trouble jumping back ...
Post 05 Sep 2015, 01:35
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 515
Location: Czech republic, Slovak republic
Feryno 07 Sep 2015, 08:52
from ring3 to ring0 you can execute int (you must set up IDT and allow some interrupt for ring3, or you may wait for timer interrupt which is external interrupt)
don't forget to set TSS so CPU will know how to switch stacks from ring3 stack to ring0 stack
under x64 there is syscall to go from ring3 to ring0
Post 07 Sep 2015, 08:52
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 670
l4m2 07 Sep 2015, 11:51
Feryno wrote:
from ring3 to ring0 you can execute int (you must set up IDT and allow some interrupt for ring3, or you may wait for timer interrupt which is external interrupt)
don't forget to set TSS so CPU will know how to switch stacks from ring3 stack to ring0 stack
under x64 there is syscall to go from ring3 to ring0
Just having the wrong IDT ... solved
Post 07 Sep 2015, 11:51
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.