"Protection rings" 和 "CPU modes" 是一回事吗?

Are "Protection rings" and "CPU modes" the same thing?

我知道 CPU 有专门的寄存器来跟踪 CPU 操作模式。 我认为 "Protection rings" 和 "CPU modes" 是同一回事,但是 当我在维基百科上阅读关于 "Protection rings" 的文章时, 我对 "Protection rings" 的真正含义感到困惑。 我的困惑点是维基百科文章中的这些行:

Ring protection can be combined with processor modes (master/kernel/privileged/supervisor mode versus slave/unprivileged/user mode) in some systems. Operating systems running on hardware supporting both may use both forms of protection or only one.

那么,"Protection rings" 是 OS 级抽象吗? "Protection rings" 和 "CPU modes" 有什么区别? 任何进一步的解释表示赞赏。

Protection rings

CPU modes

Are “Protection rings” and “CPU modes” the same thing?

这主要取决于 CPU designer/manufacturer 如何定义他们的术语。

对于 80x86;该术语被定义为有多个 CPU 模式(实模式、保护模式、长模式等),并且一些 CPU 模式具有不是 CPU 模式的特权级别。但是,如果英特尔愿意,他们可以将其定义得更像 "protected mode has 4 sub-modes, one for each privilege level"。

对于其他 CPUs,术语可以定义为 "supervisor mode" 和 "user mode"(可能还有其他模式 - "virtualisation mode"、"IRQ mode",等等)。 ARM 像这样定义他们的术语(但如果他们愿意,他们可以更像 "CPU only has 2 modes (normal mode and hypervisor mode) and everything else is something else (privilege level)" 定义他们的术语)。

So, is "Protection rings" an OS level abstraction? What's the difference between "Protection rings" and "CPU modes"?

总的来说,保护环的概念(将 OS 分成层并具有不同 permissions/privileges 的层)比 80x86(至少与 1960 年代的 multics 一样古老,但是可能更早,可能可以追溯到 1950 年代的批处理系统),80x86 保护模式的设计仅仅是一个预先存在的概念的实现。

然而,没有现代 OS(据我所知)使用这个概念(例如 "all user code in a single protection domain");相反,他们使用更多的隔离(例如 "each separate process in its own isolated protection domain"),这使得拥有超过 2 个权限级别(一个用于控制隔离,另一个用于控制彼此隔离的所有内容)变得毫无意义。