Rings 1 and 2
Rings 1 and 2
Hi everybody,
Does anybody actually use privilege levels 1 and 2? On the web I found that they are hardly ever used, but I'd like to see some examples of where they are.
Roel
Does anybody actually use privilege levels 1 and 2? On the web I found that they are hardly ever used, but I'd like to see some examples of where they are.
Roel
Re: Rings 1 and 2
I seriously doubt anyone has ever used them. Theoretically, one could run the kernel in 0, drivers in 1, daemons/services in 2 and user processes in 3.Hobbes wrote:Hi everybody,
Does anybody actually use privilege levels 1 and 2? On the web I found that they are hardly ever used, but I'd like to see some examples of where they are.
JAL
Re: Rings 1 and 2
True. It seems however that drivers and services are always also running in ring 0 or 3. This made me wonder whether there is any use for rings 1 and 2 at all.jal wrote:Theoretically, one could run the kernel in 0, drivers in 1, daemons/services in 2 and user processes in 3.
Roel
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Rings 1 and 2
Are there any advantages in using them? I'm aware of the disadvantages (kernel becomes less portable), but why were they introduced in the first place?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Rings 1 and 2
intel thought it would be a good idea but in practice they didnt turn out to be any more useful than 2 privledge levels.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Rings 1 and 2
What I mean... Why would it be good practice? Does anyone actually have an example where more than 2 rings would come in handy?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Rings 1 and 2
Perhaps this is why page table entries have a single U/S-bit, instead of a privilege level bitfield like descriptors do.yemista wrote:intel thought it would be a good idea but in practice they didnt turn out to be any more useful than 2 privledge levels.
Roel
Re: Rings 1 and 2
I think if page table entries had two bits for all four privilege levels, then all four levels would be used, not just ring zero and three. This way monolithic kernels (or any kernel where drivers run in ring zero) would be much safer from a security viewpoint - you couldn't inject a malicious driver and have it take over the kernel.Hobbes wrote:Perhaps this is why page table entries have a single U/S-bit, instead of a privilege level bitfield like descriptors do.
Roel
As far as I know, IA64 can specify all four privilege levels for its page tables. Unfortunately IA64 has other issues, and is not widespread.
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re: Rings 1 and 2
MS Virtual PC runs the "kernel mode" of guest OSes in ring 1 on 32-bit CPUs that don't support the VT extensions. This is called "ring compression".
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Rings 1 and 2
How's that possible? Virtual PC runs at ring 3, how can it run someting at ring 1?Colonel Kernel wrote:MS Virtual PC runs the "kernel mode" of guest OSes in ring 1 on 32-bit CPUs that don't support the VT extensions. This is called "ring compression".
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Re: Rings 1 and 2
The VPC GUI runs at ring 3. It installs a kernel-mode driver that forces the guest OS to run in ring 1 whenever it tries to enter ring 0. It also traps all interrupts and exceptions and handles them appropriately.
The details are all here.
The details are all here.
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Rings 1 and 2
I see. And if the guest code is supposed to run at ring 1 on such a system, will that also mean ring 1 on the host?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Rings 1 and 2
The guest OS is running in ring 1. And I suppose the guest code is still running in ring 3, supposing also that the guest OS uses only ring 0 (now 1) and 3.Love4Boobies wrote:I see. And if the guest code is supposed to run at ring 1 on such a system, will that also mean ring 1 on the host?
JAL
Re: Rings 1 and 2
I have thought many times about trying to use Ring 1 for my OS.
Wishful thinking:
I'd like my Kernel and trusted drivers and mangers/executives to be running in Ring 0 -- where Ring 0 runs in physical memory only, with all paging turned off. I want to be able to transition to Ring 0 (physical mem mode) without trashing the TLB. All of these programs would be written to be position-independent. (However, the TLB part of that doesn't work, and you can't even turn off paging in Long mode -- which is why this is wishful thinking.)
Then, untrusted drivers (or drivers that need VMEM paging) would run in Ring 1. So the differences between Ring 0 and 1 would be paging, address space limitations, plus being able to use Task structures to limit IO ports. And I wouldn't need to handle any of that crap for Ring 0 apps.
Then Ring 3 as normal, of course.
Wishful thinking:
I'd like my Kernel and trusted drivers and mangers/executives to be running in Ring 0 -- where Ring 0 runs in physical memory only, with all paging turned off. I want to be able to transition to Ring 0 (physical mem mode) without trashing the TLB. All of these programs would be written to be position-independent. (However, the TLB part of that doesn't work, and you can't even turn off paging in Long mode -- which is why this is wishful thinking.)
Then, untrusted drivers (or drivers that need VMEM paging) would run in Ring 1. So the differences between Ring 0 and 1 would be paging, address space limitations, plus being able to use Task structures to limit IO ports. And I wouldn't need to handle any of that crap for Ring 0 apps.
Then Ring 3 as normal, of course.
Re: Rings 1 and 2
Sounds like a sensible use of ring 1 to me.Colonel Kernel wrote:MS Virtual PC runs the "kernel mode" of guest OSes in ring 1 on 32-bit CPUs that don't support the VT extensions. This is called "ring compression".
Sounds sensible too, but can't that be done in ring 3 just as well?bewing wrote:Then, untrusted drivers (or drivers that need VMEM paging) would run in Ring 1. So the differences between Ring 0 and 1 would be paging, address space limitations, plus being able to use Task structures to limit IO ports.
Roel
(Typo corrected)
Last edited by qw on Mon Feb 09, 2009 1:06 pm, edited 2 times in total.