Page 1 of 1

User Mode

Posted: Fri Mar 17, 2006 12:00 am
by Jeko
How can I switch to the ring 3 from ring 0?

Re: User Mode

Posted: Fri Mar 17, 2006 12:00 am
by Hery
You must jump to code segment with privellege level 3. You can do it when you set up TSS. How to set up TSS you can find in Intel Manuals

Re: User Mode

Posted: Fri Mar 17, 2006 12:00 am
by earlz
doing iret is also a good method

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by darktemplar
But you first have to have a TSS, before you do any IRET

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by earlz
i dont have a tss and my iret method works
its called software task switching

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by gaf
Even with software task-swicthing you need at least one TSS per CPU on the IA32 architecture. While you can switch to user-mode without having a TSS, the first call of an interrupt will cause a triple-fualt as the kernel stack pointer can't be determined (Intel reference manual, volume 3: chapter 5.12 - Exception and Interrupt handling).

regrads,
gaf

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by darktemplar
hckr83, I have software task switching in my kernel too, and it requires a TSS =)

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by earlz
hmmm maybe thats why im getting invalid opcode error
after i think about it it seems right that it wouldnt know the kernel stack

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by JAAman
yes -- though it shouldn't cause an invalid opcode error -- infact you could never recieve any error at all -- it would just tripple-fault

you can switch into a ring3 task, but not out of it without the information located in the TSS, so if any exception hard-int, or soft-int occures, whos handler is not in ring3, you will triple-fault

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by earlz
i thought it would gpf

but how can i still display the exception message if i can't go back to ring0

Re: User Mode

Posted: Sun Mar 19, 2006 12:00 am
by darktemplar
Conclusion - get this TSS