OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 10:35 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Ring1/Ring2?
PostPosted: Fri Dec 23, 2005 12:00 am 
Offline

Joined: Fri Dec 23, 2005 12:00 am
Posts: 1
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?


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Sat Dec 24, 2005 12:00 am 
Offline
Member
Member

Joined: Fri Nov 18, 2005 12:00 am
Posts: 26
Location: a perfect view out of the novotel
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.


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Sat Dec 24, 2005 12:00 am 
Offline
Member
Member

Joined: Tue Nov 02, 2004 12:00 am
Posts: 195
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*


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Thu Jan 05, 2006 12:00 am 
Offline

Joined: Thu Jan 05, 2006 12:00 am
Posts: 4
Location: The Netherlands
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 :-)


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Thu Jan 05, 2006 12:00 am 
Offline
Member
Member

Joined: Tue Oct 26, 2004 11:00 pm
Posts: 144
Location: Australia
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


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Sun Jan 08, 2006 12:00 am 
Offline
Member
Member
User avatar

Joined: Wed Sep 28, 2005 11:00 pm
Posts: 85
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.


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Sun Jan 08, 2006 12:00 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 874
Location: WA
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

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Sun Jan 08, 2006 12:00 am 
Offline
Member
Member

Joined: Thu Jul 07, 2005 11:00 pm
Posts: 1546
The intel docs barely even mention ring 1 and 2, it just says there uses like everything else does

_________________
My new NEW blag


Top
 Profile  
 
 Post subject: Re: Ring1/Ring2?
PostPosted: Sun Jan 08, 2006 12:00 am 
Offline
Member
Member

Joined: Tue Oct 26, 2004 11:00 pm
Posts: 144
Location: Australia
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 23 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group