<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
hierarchical	B-Operating_System
protection	I-Operating_System
domains	I-Operating_System
,	O
often	O
called	O
protection	B-Operating_System
rings	I-Operating_System
,	O
are	O
mechanisms	O
to	O
protect	O
data	O
and	O
functionality	O
from	O
faults	O
(	O
by	O
improving	O
fault	B-General_Concept
tolerance	I-General_Concept
)	O
and	O
malicious	O
behavior	O
(	O
by	O
providing	O
computer	O
security	O
)	O
.	O
</s>
<s>
Computer	B-General_Concept
operating	I-General_Concept
systems	I-General_Concept
provide	O
different	O
levels	O
of	O
access	O
to	O
resources	O
.	O
</s>
<s>
A	O
protection	B-Operating_System
ring	I-Operating_System
is	O
one	O
of	O
two	O
or	O
more	O
hierarchical	O
levels	O
or	O
layers	O
of	O
privilege	O
within	O
the	O
architecture	B-General_Concept
of	O
a	O
computer	O
system	O
.	O
</s>
<s>
This	O
is	O
generally	O
hardware-enforced	O
by	O
some	O
CPU	B-General_Concept
architectures	O
that	O
provide	O
different	O
CPU	B-General_Concept
modes	I-General_Concept
at	O
the	O
hardware	O
or	O
microcode	B-Device
level	B-Architecture
.	O
</s>
<s>
Ring	B-Operating_System
0	I-Operating_System
is	O
the	O
level	B-Architecture
with	O
the	O
most	O
privileges	O
and	O
allows	O
direct	O
interaction	O
with	O
the	O
physical	O
hardware	O
such	O
as	O
certain	O
CPU	B-General_Concept
functionality	O
and	O
chips	O
on	O
the	O
motherboard	O
.	O
</s>
<s>
Special	O
call	B-Device
gates	I-Device
between	O
rings	O
are	O
provided	O
to	O
allow	O
an	O
outer	O
ring	O
to	O
access	O
an	O
inner	O
ring	O
's	O
resources	O
in	O
a	O
predefined	O
manner	O
,	O
as	O
opposed	O
to	O
allowing	O
arbitrary	O
usage	O
.	O
</s>
<s>
Correctly	O
gating	O
access	O
between	O
rings	O
can	O
improve	O
security	O
by	O
preventing	O
programs	O
from	O
one	O
ring	O
or	O
privilege	O
level	B-Architecture
from	O
misusing	O
resources	O
intended	O
for	O
programs	O
in	O
another	O
.	O
</s>
<s>
For	O
example	O
,	O
spyware	O
running	O
as	O
a	O
user	O
program	O
in	O
Ring	B-Operating_System
3	I-Operating_System
should	O
be	O
prevented	O
from	O
turning	O
on	O
a	O
web	O
camera	O
without	O
informing	O
the	O
user	O
,	O
since	O
hardware	O
access	O
should	O
be	O
a	O
Ring	B-Operating_System
1	I-Operating_System
function	O
reserved	O
for	O
device	B-Application
drivers	I-Application
.	O
</s>
<s>
Multiple	O
rings	O
of	O
protection	O
were	O
among	O
the	O
most	O
revolutionary	O
concepts	O
introduced	O
by	O
the	O
Multics	B-Application
operating	I-Application
system	I-Application
,	O
a	O
highly	O
secure	O
predecessor	O
of	O
today	O
's	O
Unix	B-Application
family	O
of	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
The	O
GE	B-Device
645	I-Device
mainframe	O
computer	O
did	O
have	O
some	O
hardware	O
access	O
control	O
,	O
but	O
that	O
was	O
not	O
sufficient	O
to	O
provide	O
full	O
support	O
for	O
rings	O
in	O
hardware	O
,	O
so	O
Multics	B-Application
supported	O
them	O
by	O
trapping	O
ring	O
transitions	O
in	O
software	O
;	O
its	O
successor	O
,	O
the	O
Honeywell	B-Device
6180	I-Device
,	O
implemented	O
them	O
in	O
hardware	O
,	O
with	O
support	O
for	O
eight	O
rings	O
.	O
</s>
<s>
However	O
,	O
most	O
general-purpose	O
systems	O
use	O
only	O
two	O
rings	O
,	O
even	O
if	O
the	O
hardware	O
they	O
run	O
on	O
provides	O
more	O
CPU	B-General_Concept
modes	I-General_Concept
than	O
that	O
.	O
</s>
<s>
For	O
example	O
,	O
Windows	B-Application
7	O
and	O
Windows	B-Application
Server	O
2008	O
(	O
and	O
their	O
predecessors	O
)	O
use	O
only	O
two	O
rings	O
,	O
with	O
ring	B-Operating_System
0	I-Operating_System
corresponding	O
to	O
kernel	B-Operating_System
mode	O
and	O
ring	B-Operating_System
3	I-Operating_System
to	O
user	B-Operating_System
mode	I-Operating_System
,	O
because	O
earlier	O
versions	O
of	O
Windows	B-Application
ran	O
on	O
processors	O
that	O
supported	O
only	O
two	O
protection	O
levels	O
.	O
</s>
<s>
Many	O
modern	O
CPU	B-General_Concept
architectures	O
(	O
including	O
the	O
popular	O
Intel	B-Operating_System
x86	I-Operating_System
architecture	B-General_Concept
)	O
include	O
some	O
form	O
of	O
ring	O
protection	O
,	O
although	O
the	O
Windows	B-Device
NT	I-Device
operating	B-General_Concept
system	I-General_Concept
,	O
like	O
Unix	B-Application
,	O
does	O
not	O
fully	O
utilize	O
this	O
feature	O
.	O
</s>
<s>
OS/2	B-Application
does	O
to	O
some	O
extent	O
,	O
using	O
three	O
rings	O
:	O
ring	B-Operating_System
0	I-Operating_System
for	O
kernel	B-Operating_System
code	O
and	O
device	B-Application
drivers	I-Application
,	O
ring	B-Operating_System
2	I-Operating_System
for	O
privileged	O
code	O
(	O
user	O
programs	O
with	O
I/O	O
access	O
permissions	O
)	O
,	O
and	O
ring	B-Operating_System
3	I-Operating_System
for	O
unprivileged	O
code	O
(	O
nearly	O
all	O
user	O
programs	O
)	O
.	O
</s>
<s>
Under	O
DOS	B-Device
,	O
the	O
kernel	B-Operating_System
,	O
drivers	O
and	O
applications	O
typically	O
run	O
on	O
ring	B-Operating_System
3	I-Operating_System
(	O
however	O
,	O
this	O
is	O
exclusive	O
to	O
the	O
case	O
where	O
protected-mode	B-Application
drivers	O
and/or	O
DOS	B-Device
extenders	O
are	O
used	O
;	O
as	O
a	O
real-mode	O
OS	O
,	O
the	O
system	O
runs	O
with	O
effectively	O
no	O
protection	O
)	O
,	O
whereas	O
386	O
memory	O
managers	O
such	O
as	O
EMM386	B-Device
run	O
at	O
ring	B-Operating_System
0	I-Operating_System
.	O
</s>
<s>
In	O
addition	O
to	O
this	O
,	O
DR-DOS	B-Application
'	O
EMM386	B-Device
3.xx	O
can	O
optionally	O
run	O
some	O
modules	B-Application
(	O
such	O
as	O
DPMS	O
)	O
on	O
ring	B-Operating_System
1	I-Operating_System
instead	O
.	O
</s>
<s>
OpenVMS	B-Operating_System
uses	O
four	O
modes	O
called	O
(	O
in	O
order	O
of	O
decreasing	O
privileges	O
)	O
Kernel	B-Operating_System
,	O
Executive	O
,	O
Supervisor	O
and	O
User	O
.	O
</s>
<s>
A	O
renewed	O
interest	O
in	O
this	O
design	O
structure	O
came	O
with	O
the	O
proliferation	O
of	O
the	O
Xen	B-Operating_System
VMM	B-Operating_System
software	O
,	O
ongoing	B-Language
discussion	I-Language
on	O
monolithic	B-Operating_System
vs.	O
micro-kernels	B-Operating_System
(	O
particularly	O
in	O
Usenet	B-Application
newsgroups	O
and	O
Web	B-Application
forums	I-Application
)	O
,	O
Microsoft	O
's	O
Ring-1	O
design	O
structure	O
as	O
part	O
of	O
their	O
NGSCB	O
initiative	O
,	O
and	O
hypervisors	B-Operating_System
based	O
on	O
x86	B-General_Concept
virtualization	I-General_Concept
such	O
as	O
Intel	O
VT-x	O
(	O
formerly	O
Vanderpool	O
)	O
.	O
</s>
<s>
The	O
original	O
Multics	B-Application
system	O
had	O
eight	O
rings	O
,	O
but	O
many	O
modern	O
systems	O
have	O
fewer	O
.	O
</s>
<s>
The	O
hardware	O
remains	O
aware	O
of	O
the	O
current	O
ring	O
of	O
the	O
executing	O
instruction	O
thread	B-Operating_System
at	O
all	O
times	O
,	O
with	O
the	O
help	O
of	O
a	O
special	O
machine	O
register	O
.	O
</s>
<s>
In	O
some	O
systems	O
,	O
areas	O
of	O
virtual	B-Architecture
memory	I-Architecture
are	O
instead	O
assigned	O
ring	O
numbers	O
in	O
hardware	O
.	O
</s>
<s>
One	O
example	O
is	O
the	O
Data	B-Device
General	I-Device
Eclipse	I-Device
MV/8000	I-Device
,	O
in	O
which	O
the	O
top	O
three	O
bits	O
of	O
the	O
program	B-General_Concept
counter	I-General_Concept
(	O
PC	O
)	O
served	O
as	O
the	O
ring	O
register	O
.	O
</s>
<s>
Using	O
x86	B-Operating_System
as	O
an	O
example	O
,	O
there	O
is	O
a	O
special	O
gate	O
structure	O
which	O
is	O
referenced	O
by	O
the	O
call	O
instruction	O
that	O
transfers	O
control	O
in	O
a	O
secure	O
way	O
towards	O
predefined	O
entry	O
points	O
in	O
lower-level	O
(	O
more	O
trusted	O
)	O
rings	O
;	O
this	O
functions	O
as	O
a	O
supervisor	B-Operating_System
call	I-Operating_System
in	O
many	O
operating	B-General_Concept
systems	I-General_Concept
that	O
use	O
the	O
ring	O
architecture	B-General_Concept
.	O
</s>
<s>
In	O
addition	O
,	O
the	O
most	O
privileged	O
ring	O
may	O
be	O
given	O
special	O
capabilities	O
,	O
(	O
such	O
as	O
real	O
memory	O
addressing	O
that	O
bypasses	O
the	O
virtual	B-Architecture
memory	I-Architecture
hardware	O
)	O
.	O
</s>
<s>
ARM	B-Architecture
version	O
7	O
architecture	B-General_Concept
implements	O
three	O
privilege	B-Operating_System
levels	I-Operating_System
:	O
application	O
(	O
PL0	O
)	O
,	O
operating	B-General_Concept
system	I-General_Concept
(	O
PL1	O
)	O
,	O
and	O
hypervisor	B-Operating_System
(	O
PL2	O
)	O
.	O
</s>
<s>
Unusually	O
,	O
level0	O
(	O
PL0	O
)	O
is	O
the	O
least-privileged	O
level	B-Architecture
,	O
while	O
level2	O
is	O
the	O
most-privileged	O
level	B-Architecture
.	O
</s>
<s>
ARM	B-Architecture
version	O
8	O
implements	O
four	O
exception	O
levels	O
:	O
application	O
(	O
EL0	O
)	O
,	O
operating	B-General_Concept
system	I-General_Concept
(	O
EL1	O
)	O
,	O
hypervisor	B-Operating_System
(	O
EL2	O
)	O
,	O
and	O
secure	O
monitor	O
/	O
firmware	O
(	O
EL3	O
)	O
,	O
for	O
AArch64	O
and	O
AArch32	O
.	O
</s>
<s>
Ring	O
protection	O
can	O
be	O
combined	O
with	O
processor	B-General_Concept
modes	I-General_Concept
(	O
master/kernel/privileged/supervisor	O
mode	O
versus	O
slave/unprivileged/user	O
mode	O
)	O
in	O
some	O
systems	O
.	O
</s>
<s>
Operating	B-General_Concept
systems	I-General_Concept
running	O
on	O
hardware	O
supporting	O
both	O
may	O
use	O
both	O
forms	O
of	O
protection	O
or	O
only	O
one	O
.	O
</s>
<s>
Effective	O
use	O
of	O
ring	O
architecture	B-General_Concept
requires	O
close	O
cooperation	O
between	O
hardware	O
and	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Operating	B-General_Concept
systems	I-General_Concept
designed	O
to	O
work	O
on	O
multiple	O
hardware	O
platforms	O
may	O
make	O
only	O
limited	O
use	O
of	O
rings	O
if	O
they	O
are	O
not	O
present	O
on	O
every	O
supported	O
platform	O
.	O
</s>
<s>
Often	O
the	O
security	O
model	O
is	O
simplified	O
to	O
"	O
kernel	B-Operating_System
"	O
and	O
"	O
user	O
"	O
even	O
if	O
hardware	O
provides	O
finer	O
granularity	O
through	O
rings	O
.	O
</s>
<s>
In	O
computer	O
terms	O
,	O
supervisor	O
mode	O
is	O
a	O
hardware-mediated	O
flag	O
that	O
can	O
be	O
changed	O
by	O
code	O
running	O
in	O
system-level	O
software	O
.	O
</s>
<s>
System-level	O
tasks	O
or	O
threads	B-Operating_System
may	O
have	O
this	O
flag	O
set	O
while	O
they	O
are	O
running	O
,	O
whereas	O
user-level	B-Operating_System
applications	O
will	O
not	O
.	O
</s>
<s>
This	O
is	O
the	O
mode	O
in	O
which	O
the	O
operating	B-General_Concept
system	I-General_Concept
usually	O
runs.	O
"	O
</s>
<s>
In	O
a	O
monolithic	B-Operating_System
kernel	I-Operating_System
,	O
the	O
operating	B-General_Concept
system	I-General_Concept
runs	O
in	O
supervisor	O
mode	O
and	O
the	O
applications	O
run	O
in	O
user	B-Operating_System
mode	I-Operating_System
.	O
</s>
<s>
Other	O
types	O
of	O
operating	B-General_Concept
systems	I-General_Concept
,	O
like	O
those	O
with	O
an	O
exokernel	B-Operating_System
or	O
microkernel	B-Operating_System
,	O
do	O
not	O
necessarily	O
share	O
this	O
behavior	O
.	O
</s>
<s>
Linux	B-Application
,	O
macOS	B-Application
and	O
Windows	B-Application
are	O
three	O
operating	B-General_Concept
systems	I-General_Concept
that	O
use	O
supervisor/user	O
mode	O
.	O
</s>
<s>
To	O
perform	O
specialized	O
functions	O
,	O
user	B-Operating_System
mode	I-Operating_System
code	O
must	O
perform	O
a	O
system	B-Operating_System
call	I-Operating_System
into	O
supervisor	O
mode	O
or	O
even	O
to	O
the	O
kernel	B-Operating_System
space	I-Operating_System
where	O
trusted	O
code	O
of	O
the	O
operating	B-General_Concept
system	I-General_Concept
will	O
perform	O
the	O
needed	O
task	O
and	O
return	O
the	O
execution	O
back	O
to	O
the	O
userspace	B-Operating_System
.	O
</s>
<s>
Additional	O
code	O
can	O
be	O
added	O
into	O
kernel	B-Operating_System
space	I-Operating_System
through	O
the	O
use	O
of	O
loadable	B-Application
kernel	I-Application
modules	I-Application
,	O
but	O
only	O
by	O
a	O
user	O
with	O
the	O
requisite	O
permissions	O
,	O
as	O
this	O
code	O
is	O
not	O
subject	O
to	O
the	O
access	O
control	O
and	O
safety	O
limitations	O
of	O
user	B-Operating_System
mode	I-Operating_System
.	O
</s>
<s>
DOS	B-Device
(	O
for	O
as	O
long	O
as	O
no	O
386	O
memory	O
manager	O
such	O
as	O
EMM386	B-Device
is	O
loaded	O
)	O
,	O
as	O
well	O
as	O
other	O
simple	O
operating	B-General_Concept
systems	I-General_Concept
and	O
many	O
embedded	O
devices	O
run	O
in	O
supervisor	O
mode	O
permanently	O
,	O
meaning	O
that	O
drivers	O
can	O
be	O
written	O
directly	O
as	O
user	O
programs	O
.	O
</s>
<s>
The	O
x86-processors	O
have	O
four	O
different	O
modes	O
divided	O
into	O
four	O
different	O
rings	O
.	O
</s>
<s>
Programs	O
that	O
run	O
in	O
Ring	B-Operating_System
0	I-Operating_System
can	O
do	O
anything	O
with	O
the	O
system	O
,	O
and	O
code	O
that	O
runs	O
in	O
Ring	B-Operating_System
3	I-Operating_System
should	O
be	O
able	O
to	O
fail	O
at	O
any	O
time	O
without	O
impact	O
to	O
the	O
rest	O
of	O
the	O
computer	O
system	O
.	O
</s>
<s>
Ring	B-Operating_System
1	I-Operating_System
and	O
Ring	B-Operating_System
2	I-Operating_System
are	O
rarely	O
used	O
,	O
but	O
could	O
be	O
configured	O
with	O
different	O
levels	O
of	O
access	O
.	O
</s>
<s>
In	O
most	O
existing	O
systems	O
,	O
switching	O
from	O
user	B-Operating_System
mode	I-Operating_System
to	O
kernel	B-Operating_System
mode	O
has	O
an	O
associated	O
high	O
cost	O
in	O
performance	O
.	O
</s>
<s>
It	O
has	O
been	O
measured	O
,	O
on	O
the	O
basic	O
request	O
getpid	B-Operating_System
,	O
to	O
cost	O
1000	O
–	O
1500	O
cycles	O
on	O
most	O
machines	O
.	O
</s>
<s>
Of	O
these	O
just	O
around	O
100	O
are	O
for	O
the	O
actual	O
switch	O
(	O
70	O
from	O
user	O
to	O
kernel	B-Operating_System
space	I-Operating_System
,	O
and	O
40	O
back	O
)	O
,	O
the	O
rest	O
is	O
"	O
kernel	B-Operating_System
overhead	O
"	O
.	O
</s>
<s>
In	O
the	O
L3	O
microkernel	B-Operating_System
,	O
the	O
minimization	O
of	O
this	O
overhead	O
reduced	O
the	O
overall	O
cost	O
to	O
around	O
150	O
cycles	O
.	O
</s>
<s>
To	O
gain	O
performance	O
and	O
determinism	O
,	O
some	O
systems	O
place	O
functions	O
that	O
would	O
likely	O
be	O
viewed	O
as	O
application	O
logic	O
,	O
rather	O
than	O
as	O
device	B-Application
drivers	I-Application
,	O
in	O
kernel	B-Operating_System
mode	O
;	O
security	O
applications	O
(	O
access	O
control	O
,	O
firewalls	B-Application
,	O
etc	O
.	O
)	O
</s>
<s>
and	O
operating	B-General_Concept
system	I-General_Concept
monitors	O
are	O
cited	O
as	O
examples	O
.	O
</s>
<s>
At	O
least	O
one	O
embedded	O
database	O
management	O
system	O
,	O
eXtremeDB	O
Kernel	B-Operating_System
Mode	O
,	O
has	O
been	O
developed	O
specifically	O
for	O
kernel	B-Operating_System
mode	O
deployment	O
,	O
to	O
provide	O
a	O
local	O
database	O
for	O
kernel-based	O
application	O
functions	O
,	O
and	O
to	O
eliminate	O
the	O
context	B-Operating_System
switches	I-Operating_System
that	O
would	O
otherwise	O
occur	O
when	O
kernel	B-Operating_System
functions	O
interact	O
with	O
a	O
database	O
system	O
running	O
in	O
user	B-Operating_System
mode	I-Operating_System
.	O
</s>
<s>
The	O
Linux	B-Operating_System
kernel	I-Operating_System
,	O
for	O
instance	O
,	O
injects	O
into	O
processes	O
a	O
vDSO	B-Application
section	O
which	O
contains	O
functions	O
that	O
would	O
normally	O
require	O
a	O
system	B-Operating_System
call	I-Operating_System
,	O
i.e.	O
</s>
<s>
Instead	O
of	O
doing	O
a	O
syscall	B-Operating_System
these	O
functions	O
use	O
static	O
data	O
provided	O
by	O
the	O
kernel	B-Operating_System
.	O
</s>
<s>
This	O
avoids	O
the	O
need	O
for	O
a	O
ring	O
transition	O
and	O
so	O
is	O
more	O
lightweight	O
than	O
a	O
syscall	B-Operating_System
.	O
</s>
<s>
Recent	O
CPUs	O
from	O
Intel	O
and	O
AMD	O
offer	O
x86	B-General_Concept
virtualization	I-General_Concept
instructions	O
for	O
a	O
hypervisor	B-Operating_System
to	O
control	O
Ring0	O
hardware	O
access	O
.	O
</s>
<s>
Although	O
they	O
are	O
mutually	O
incompatible	O
,	O
both	O
Intel	O
VT-x	O
(	O
codenamed	O
"	O
Vanderpool	O
"	O
)	O
and	O
AMD-V	O
(	O
codenamed	O
"	O
Pacifica	O
"	O
)	O
create	O
a	O
new	O
"	O
Ring−1	O
"	O
so	O
that	O
a	O
guest	O
operating	B-General_Concept
system	I-General_Concept
can	O
run	O
Ring0	O
operations	O
natively	O
without	O
affecting	O
other	O
guests	O
or	O
the	O
host	O
OS	O
.	O
</s>
<s>
To	O
assist	O
virtualization	B-General_Concept
,	O
VT-x	O
and	O
SVM	O
insert	O
a	O
new	O
privilege	O
level	B-Architecture
beneath	O
Ring	O
0	O
.	O
</s>
<s>
Both	O
add	O
nine	O
new	O
machine	O
code	O
instructions	O
that	O
only	O
work	O
at	O
"	O
Ring	O
−1	O
"	O
,	O
intended	O
to	O
be	O
used	O
by	O
the	O
hypervisor	B-Operating_System
.	O
</s>
<s>
A	O
privilege	O
level	B-Architecture
in	O
the	O
x86	B-Operating_System
instruction	B-General_Concept
set	I-General_Concept
controls	O
the	O
access	O
of	O
the	O
program	O
currently	O
running	O
on	O
the	O
processor	O
to	O
resources	O
such	O
as	O
memory	O
regions	O
,	O
I/O	B-Architecture
ports	I-Architecture
,	O
and	O
special	O
instructions	O
.	O
</s>
<s>
There	O
are	O
4	O
privilege	B-Operating_System
levels	I-Operating_System
ranging	O
from	O
0	O
which	O
is	O
the	O
most	O
privileged	O
,	O
to	O
3	O
which	O
is	O
least	O
privileged	O
.	O
</s>
<s>
Most	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
use	O
level	B-Architecture
0	O
for	O
the	O
kernel/executive	O
,	O
and	O
use	O
level	B-Architecture
3	O
for	O
application	O
programs	O
.	O
</s>
<s>
Any	O
resource	O
available	O
to	O
level	B-Architecture
n	O
is	O
also	O
available	O
to	O
levels	O
0	O
to	O
n	O
,	O
so	O
the	O
privilege	B-Operating_System
levels	I-Operating_System
are	O
rings	O
.	O
</s>
<s>
When	O
a	O
lesser	O
privileged	O
process	O
tries	O
to	O
access	O
a	O
higher	O
privileged	O
process	O
,	O
a	O
general	B-Operating_System
protection	I-Operating_System
fault	I-Operating_System
exception	O
is	O
reported	O
to	O
the	O
OS	O
.	O
</s>
<s>
It	O
is	O
not	O
necessary	O
to	O
use	O
all	O
four	O
privilege	B-Operating_System
levels	I-Operating_System
.	O
</s>
<s>
Current	O
operating	B-General_Concept
systems	I-General_Concept
with	O
wide	O
market	O
share	O
including	O
Microsoft	B-Application
Windows	I-Application
,	O
macOS	B-Application
,	O
Linux	B-Application
,	O
iOS	B-Application
and	O
Android	B-Application
mostly	O
use	O
a	O
paging	B-Architecture
mechanism	O
with	O
only	O
one	O
bit	O
to	O
specify	O
the	O
privilege	O
level	B-Architecture
as	O
either	O
Supervisor	O
or	O
User	O
(	O
U/S	O
Bit	O
)	O
.	O
</s>
<s>
Windows	B-Device
NT	I-Device
uses	O
the	O
two-level	O
system	O
.	O
</s>
<s>
The	O
real	O
mode	O
programs	O
in	O
8086	O
are	O
executed	O
at	O
level	B-Architecture
0	O
(	O
highest	O
privilege	O
level	B-Architecture
)	O
whereas	O
virtual	O
mode	O
in	O
8086	O
executes	O
all	O
programs	O
at	O
level	B-Architecture
3	O
.	O
</s>
<s>
Potential	O
future	O
uses	O
for	O
the	O
multiple	O
privilege	B-Operating_System
levels	I-Operating_System
supported	O
by	O
the	O
x86	B-Operating_System
ISA	O
family	O
include	O
containerization	B-Application
and	O
virtual	B-Architecture
machines	I-Architecture
.	O
</s>
<s>
A	O
host	O
operating	B-Operating_System
system	I-Operating_System
kernel	I-Operating_System
could	O
use	O
instructions	O
with	O
full	O
privilege	O
access	O
(	O
kernel	B-Operating_System
mode	O
)	O
,	O
whereas	O
applications	O
running	O
on	O
the	O
guest	O
OS	O
in	O
a	O
virtual	B-Architecture
machine	I-Architecture
or	O
container	B-Application
could	O
use	O
the	O
lowest	O
level	B-Architecture
of	O
privileges	O
in	O
user	B-Operating_System
mode	I-Operating_System
.	O
</s>
<s>
The	O
virtual	B-Architecture
machine	I-Architecture
and	O
guest	O
OS	B-Operating_System
kernel	I-Operating_System
could	O
themselves	O
use	O
an	O
intermediate	O
level	B-Architecture
of	O
instruction	O
privilege	O
to	O
invoke	O
and	O
virtualize	B-General_Concept
kernel-mode	B-Operating_System
operations	O
such	O
as	O
system	B-Operating_System
calls	I-Operating_System
from	O
the	O
point	O
of	O
view	O
of	O
the	O
guest	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
The	O
IOPL	B-Device
(	O
I/O	O
Privilege	O
level	B-Architecture
)	O
flag	O
is	O
a	O
flag	O
found	O
on	O
all	O
IA-32	O
compatible	O
x86	B-Operating_System
CPUs	I-Operating_System
.	O
</s>
<s>
It	O
occupies	O
bits	O
12	O
and	O
13	O
in	O
the	O
FLAGS	B-General_Concept
register	I-General_Concept
.	O
</s>
<s>
In	O
protected	B-Application
mode	I-Application
and	O
long	B-Application
mode	I-Application
,	O
it	O
shows	O
the	O
I/O	O
privilege	O
level	B-Architecture
of	O
the	O
current	O
program	O
or	O
task	O
.	O
</s>
<s>
The	O
Current	O
Privilege	O
Level	B-Architecture
(	O
CPL	O
)	O
(	O
CPL0	B-Operating_System
,	O
CPL1	B-Operating_System
,	O
CPL2	B-Operating_System
,	O
CPL3	B-Operating_System
)	O
of	O
the	O
task	O
or	O
program	O
must	O
be	O
less	O
than	O
or	O
equal	O
to	O
the	O
IOPL	B-Device
in	O
order	O
for	O
the	O
task	O
or	O
program	O
to	O
access	O
I/O	B-Architecture
ports	I-Architecture
.	O
</s>
<s>
The	O
IOPL	B-Device
can	O
be	O
changed	O
using	O
POPF(D )	O
and	O
IRET(D )	O
only	O
when	O
the	O
current	O
privilege	O
level	B-Architecture
is	O
Ring	B-Operating_System
0	I-Operating_System
.	O
</s>
<s>
Besides	O
IOPL	B-Device
,	O
the	O
I/O	B-Architecture
Port	I-Architecture
Permissions	O
in	O
the	O
TSS	O
also	O
take	O
part	O
in	O
determining	O
the	O
ability	O
of	O
a	O
task	O
to	O
access	O
an	O
I/O	B-Architecture
port	I-Architecture
.	O
</s>
<s>
In	O
x86	B-Operating_System
systems	O
,	O
the	O
x86	B-Operating_System
hardware	O
virtualization	B-General_Concept
(	O
VT-x	O
and	O
SVM	O
)	O
is	O
referred	O
as	O
"	O
ring−1	O
"	O
,	O
the	O
System	B-Architecture
Management	I-Architecture
Mode	I-Architecture
is	O
referred	O
as	O
"	O
ring−2	O
"	O
,	O
the	O
Intel	B-Device
Management	I-Device
Engine	I-Device
and	O
AMD	B-Device
Platform	I-Device
Security	I-Device
Processor	I-Device
are	O
sometimes	O
referred	O
as	O
"	O
ring−3	O
"	O
.	O
</s>
<s>
Many	O
CPU	B-General_Concept
hardware	O
architectures	O
provide	O
far	O
more	O
flexibility	O
than	O
is	O
exploited	O
by	O
the	O
operating	B-General_Concept
systems	I-General_Concept
that	O
they	O
normally	O
run	O
.	O
</s>
<s>
Proper	O
use	O
of	O
complex	O
CPU	B-General_Concept
modes	I-General_Concept
requires	O
very	O
close	O
cooperation	O
between	O
the	O
operating	B-General_Concept
system	I-General_Concept
and	O
the	O
CPU	B-General_Concept
,	O
and	O
thus	O
tends	O
to	O
tie	O
the	O
OS	O
to	O
the	O
CPU	B-General_Concept
architecture	B-General_Concept
.	O
</s>
<s>
When	O
the	O
OS	O
and	O
the	O
CPU	B-General_Concept
are	O
specifically	O
designed	O
for	O
each	O
other	O
,	O
this	O
is	O
not	O
a	O
problem	O
(	O
although	O
some	O
hardware	O
features	O
may	O
still	O
be	O
left	O
unexploited	O
)	O
,	O
but	O
when	O
the	O
OS	O
is	O
designed	O
to	O
be	O
compatible	O
with	O
multiple	O
,	O
different	O
CPU	B-General_Concept
architectures	O
,	O
a	O
large	O
part	O
of	O
the	O
CPU	B-General_Concept
mode	I-General_Concept
features	O
may	O
be	O
ignored	O
by	O
the	O
OS	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
reason	O
Windows	B-Application
uses	O
only	O
two	O
levels	O
(	O
ring	B-Operating_System
0	I-Operating_System
and	O
ring	B-Operating_System
3	I-Operating_System
)	O
is	O
that	O
some	O
hardware	O
architectures	O
that	O
were	O
supported	O
in	O
the	O
past	O
(	O
such	O
as	O
PowerPC	B-Architecture
or	O
MIPS	B-Device
)	O
implemented	O
only	O
two	O
privilege	B-Operating_System
levels	I-Operating_System
.	O
</s>
<s>
Multics	B-Application
was	O
an	O
operating	B-General_Concept
system	I-General_Concept
designed	O
specifically	O
for	O
a	O
special	O
CPU	B-General_Concept
architecture	B-General_Concept
(	O
which	O
in	O
turn	O
was	O
designed	O
specifically	O
for	O
Multics	B-Application
)	O
,	O
and	O
it	O
took	O
full	O
advantage	O
of	O
the	O
CPU	B-General_Concept
modes	I-General_Concept
available	O
to	O
it	O
.	O
</s>
<s>
Ultimately	O
,	O
the	O
purpose	O
of	O
distinct	O
operating	O
modes	O
for	O
the	O
CPU	B-General_Concept
is	O
to	O
provide	O
hardware	O
protection	O
against	O
accidental	O
or	O
deliberate	O
corruption	O
of	O
the	O
system	O
environment	O
(	O
and	O
corresponding	O
breaches	O
of	O
system	O
security	O
)	O
by	O
software	O
.	O
</s>
<s>
Only	O
"	O
trusted	O
"	O
portions	O
of	O
system	B-Application
software	I-Application
are	O
allowed	O
to	O
execute	O
in	O
the	O
unrestricted	O
environment	O
of	O
kernel	B-Operating_System
mode	O
,	O
and	O
then	O
,	O
in	O
paradigmatic	O
designs	O
,	O
only	O
when	O
absolutely	O
necessary	O
.	O
</s>
<s>
All	O
other	O
software	O
executes	O
in	O
one	O
or	O
more	O
user	B-Operating_System
modes	I-Operating_System
.	O
</s>
<s>
If	O
a	O
processor	O
generates	O
a	O
fault	O
or	O
exception	O
condition	O
in	O
a	O
user	B-Operating_System
mode	I-Operating_System
,	O
in	O
most	O
cases	O
system	O
stability	O
is	O
unaffected	O
;	O
if	O
a	O
processor	O
generates	O
a	O
fault	O
or	O
exception	O
condition	O
in	O
kernel	B-Operating_System
mode	O
,	O
most	O
operating	B-General_Concept
systems	I-General_Concept
will	O
halt	O
the	O
system	O
with	O
an	O
unrecoverable	O
error	O
.	O
</s>
<s>
When	O
a	O
hierarchy	O
of	O
modes	O
exists	O
(	O
ring-based	O
security	O
)	O
,	O
faults	O
and	O
exceptions	O
at	O
one	O
privilege	O
level	B-Architecture
may	O
destabilize	O
only	O
the	O
higher-numbered	O
privilege	B-Operating_System
levels	I-Operating_System
.	O
</s>
<s>
Thus	O
,	O
a	O
fault	O
in	O
Ring	B-Operating_System
0	I-Operating_System
(	O
the	O
kernel	B-Operating_System
mode	O
with	O
the	O
highest	O
privilege	O
)	O
will	O
crash	O
the	O
entire	O
system	O
,	O
but	O
a	O
fault	O
in	O
Ring	B-Operating_System
2	I-Operating_System
will	O
only	O
affect	O
Rings	O
3	O
and	O
beyond	O
and	O
Ring	B-Operating_System
2	I-Operating_System
itself	O
,	O
at	O
most	O
.	O
</s>
<s>
Transitions	O
between	O
modes	O
are	O
at	O
the	O
discretion	O
of	O
the	O
executing	O
thread	B-Operating_System
when	O
the	O
transition	O
is	O
from	O
a	O
level	B-Architecture
of	O
high	O
privilege	O
to	O
one	O
of	O
low	O
privilege	O
(	O
as	O
from	O
kernel	B-Operating_System
to	O
user	B-Operating_System
modes	I-Operating_System
)	O
,	O
but	O
transitions	O
from	O
lower	O
to	O
higher	O
levels	O
of	O
privilege	O
can	O
take	O
place	O
only	O
through	O
secure	O
,	O
hardware-controlled	O
"	O
gates	O
"	O
that	O
are	O
traversed	O
by	O
executing	O
special	O
instructions	O
or	O
when	O
external	O
interrupts	O
are	O
received	O
.	O
</s>
<s>
Microkernel	B-Operating_System
operating	B-General_Concept
systems	I-General_Concept
attempt	O
to	O
minimize	O
the	O
amount	O
of	O
code	O
running	O
in	O
privileged	B-Operating_System
mode	I-Operating_System
,	O
for	O
purposes	O
of	O
security	O
and	O
elegance	O
,	O
but	O
ultimately	O
sacrificing	O
performance	O
.	O
</s>
