2 ms·
I'm not talking about the fact that the privilege level is two bits instead of one bit. What I mean is: the privilege level is more or less duplicated in quite
by amluto 9y ago
I'm not talking about the fact that the privilege level is two bits instead of one bit. What I mean is: the privilege level is more or less duplicated in quite a few different pieces of CPU state. There's CPL, CS.RPL, CS.DPL, SS.RPL, and SS.DPL, not to mention CR0.PE. The one that matters is CPL, but CPL itself isn't an architecturally visible register except (I think) on AMD systems with SVM -- it's merely a concept.
CS.RPL, CS.DPL, SS.RPL, and SS.DPL all usually match CPL, but I think that all four equalities have nasty corner case exceptions. This results in a bunch of overhead when you change privilege: the CPU needs to update CPL, CS.RPL, CS.DPL, SS.RPL, and SS.DPL. This means that you need to change two of these nasty large legacy registers, the values of which barely matter for practical purposes, every time you enter or exit user mode.
Saying there's a ring -1 is a red herring here. There's SMM, which is a mode of execution that's more privileged than ring 0, but it doesn't have a number -1 associated with it, nor is it part of CPL. Similarly, ring 0 is split into root and non-root when virtualization is in play, but that's also a bit beside the point.
[1] Check out the Linux commit message for ae9fedc793c4d98aa9bb298585b2b9246096ce65 if you want to see a bit of how nasty this is.