CPU特权环:为什么不使用环1和2? [英] CPU Privilege Rings: Why rings 1 and 2 aren't used?
问题描述
关于x86 CPU特权环的几个问题:
-
为什么大多数人都不使用环1和2操作系统?仅仅是为了保持与其他体系结构的代码兼容性,还是有更好的理由?
-
是否有任何实际使用这些环的操作系统?还是完全不使用它们?
作为一名业余操作系统作家,我发现,由于分页(现代保护模型的主要部分)仅具有特权(0,1,2环)和非特权的概念,因此对环1和2的好处大大减少了。
Intel的第1环和第2环的意图是使操作系统将设备驱动程序置于该级别,因此它们具有特权,但与内核代码的其余部分有所区别。
第1环和第2环具有大部分特权。他们可以访问主管页面,但是如果尝试使用特权指令,它们仍会像环3一样使用GPF。因此,对于英特尔计划的驱动程序来说,这不是一个坏地方。
话虽如此,但它们确实在某些设计中有用。实际上,并非总是直接由OS。例如, VirtualBox ,虚拟机,将来宾内核代码置于环1中。我还可以确定某些操作系统确实使用了它们,我只是暂时认为它不是一种流行的设计。 p>
A couple of questions regarding the x86 CPU privilege rings:
Why aren't rings 1 and 2 used by most operating systems? Is it just to maintain code compatibility with other architectures, or is there a better reason?
Are there any operating systems which actually use those rings? Or are they completely unused?
As a hobbyist operating system writer, I found that because paging (a major part of the modern protection model) only has a concept of privileged (ring 0,1,2) and unprivileged, the benefit to rings 1 and 2 were diminished greatly.
The intent by Intel in having rings 1 and 2 is for the OS to put device drivers at that level, so they are privileged, but somewhat separated from the rest of the kernel code.
Rings 1 and 2 are in a way, "mostly" privileged. They can access supervisor pages, but if they attempt to use a privileged instruction, they still GPF like ring 3 would. So it is not a bad place for drivers as Intel planned...
That said, they definitely do have use in some designs. In fact, not always directly by the OS. For example, VirtualBox, a Virtual Machine, puts the guest kernel code in ring 1. I am also sure some operating systems do make use of them, I just don't think it is a popular design at the moment.
这篇关于CPU特权环:为什么不使用环1和2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!