Ring1/Ring2?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
onejade34
Posts: 1
Joined: Fri Dec 23, 2005 12:00 am

Ring1/Ring2?

Post by onejade34 »

I've noticed that no one uses ring1 and ring2 in their OSs. People seem to always talk about kernel mode and user mode. What's the use of rings 1 and 2?
robert macabre
Member
Member
Posts: 26
Joined: Fri Nov 18, 2005 12:00 am
Location: a perfect view out of the novotel

Re: Ring1/Ring2?

Post by robert macabre »

i think that it's just those are two categories everything could fit under. i don't think that there's any actual requirement (except that the lower rings are allowed by the cpu to do more) to how you use the rings, though. i once read an example where 0 was the kernel, 1 was drivers, 2 was.. something, and 3 was user processes. the os i'm working on right now uses the rings like you describe it, though. i think that it's just simpler.
laika, come home.
Legend
Member
Member
Posts: 195
Joined: Tue Nov 02, 2004 12:00 am
Contact:

Re: Ring1/Ring2?

Post by Legend »

Paging only got only user and kernel mode.
I think this even means that you can't use Ring 1 & 2 in any meaningful way when combined with paging.
*post*
Zaibot
Posts: 4
Joined: Thu Jan 05, 2006 12:00 am
Location: The Netherlands
Contact:

Re: Ring1/Ring2?

Post by Zaibot »

What about those rings ????? only heared about ring0.... does someone know's a nice tutorial, source or something about there rings? Really like to know.
Blackbird OS :-) lol, hope it works out before I graduate (including the GUI) :-) (am 17 years old :-)
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Ring1/Ring2?

Post by Da_Maestro »

Check out the intel docs. They explain everything very well.

The only difference between the rings is that lowered numbered rings have more privelage than the higher numbered rings. Within the CPU there is a few parameters that you can set that indicate which rings can be used to do what. For example, you can set the IOPL (Input/Output Privelage Level) register to indicate which ring can do IO. Any program running in that ring and below can do IO.

The intel docs are somewhat confusing because of the way they word their statments. Instead of referring to programs with "higher privelage", they refer to progams with "a lower CPL" (Current Privelage Level). Once you get your head around that the intel docs are pretty easy to understand.
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
User avatar
deadmutex
Member
Member
Posts: 85
Joined: Wed Sep 28, 2005 11:00 pm

Re: Ring1/Ring2?

Post by deadmutex »

It seems that the only real use for rings 1/2 and the extra privilege levels is for segmentation. I don't think that there's any other use for them other than complicating a design.

It is possible, however, to emulate privilege levels inside the kernel. Drivers/apps/services run in ring3, but may have different emulated privilege levels. On a fault, the processor could trap into the exception handler, do a privilege check, perform the privileged operation if the check was ok or complain if the check failed. This way, a driver will be able to do I/O and write to certain areas of memory while an app can't, although they are both running in user mode on the processor.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Ring1/Ring2?

Post by JAAman »

no, it is posible to use ring1&2 with just paging (no segmentation), but you don't have page restrictions (they both are considered USER for paging purposes), but you can have calling restrictions: under windows, user processes are not allowed to make syscalls, however this is not enforced, it could be by making syscalls only callable from ring1 or 2, and only the (user mode) library is callable from ring3 (but it is in ring1 or 2, and can make syscalls as necessary)

windows tries to do this, but they don't enforce it, alowing anyone who knows the syscall interface (not publicly documented) to make syscalls from ring3, and cannot change this since the winAPI is located in ring3, and is called directly, instead of through a gate
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: Ring1/Ring2?

Post by earlz »

The intel docs barely even mention ring 1 and 2, it just says there uses like everything else does
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: Ring1/Ring2?

Post by Da_Maestro »

The intel docs use a terminology called "Current Privelage Level", rather than "ring 1,2..etc".

Privelage levels can be used for page level protection as well as segment level protection. For each entry in the page tables, you can set whether the page is a kernel page or a user page. Only programs in CPL0 (ring 0) can use kernel pages, and anything can use user pages.

However segmentation and privelage level are directly linked. The idea is that the kernel sits in a seperate memory space to the user programs (for extra protection), but the system is flexible enough to allow any configuration of memory space.
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
Post Reply