
2-82
PRELIMINARY
Protection
Advanci ng the S tandar ds
Protection
2-82
2.17
Protection
Segment protection and page protection are
safeguards built into the M II CPU protected
mode architecture which deny unauthorized
or incorrect access to selected memory
addresses. These safeguards allow multi-
tasking programs to be isolated from each
other and from the operating system. Page
protection is discussed earlier in this chapter.
This section concentrates on segment protec-
tion.
Selectors and descriptors are the key elements
in the segment protection mechanism. The
segment base address, size, and privilege level
are established by a segment descriptor. Privi-
lege levels control the use of privileged instruc-
tions, I/O instructions and access to segments
and segment descriptors. Selectors are used to
locate segment descriptors.
Segment accesses are divided into two basic
types, those involving code segments (e.g.,
control transfers) and those involving data
accesses. The ability of a task to access a
segment depends on the:
Segment type
Instruction requesting access
Type of descriptor used to define the
segment
Associated privilege levels (described
below).
Data stored in a segment can be accessed only
by code executing at the same or a more privi-
leged level. A code segment or procedure can
only be called by a task executing at the same
or a less privileged level.
2.17.1 Privilege Levels
The values for privilege levels range between
0 and 3. Level 0 is the highest privilege level
(most privileged), and level 3 is the lowest
privilege level (least privileged). The privilege
level in real mode is effectively 0.
The Descriptor Privilege Level (DPL) is the
privilege level defined for a segment in the
segment descriptor. The DPL field specifies the
minimum privilege level needed to access the
memory segment pointed to by the descriptor.
The Current Privilege Level (CPL) is defined
as the current task’s privilege level. The CPL of
an executing task is stored in the hidden
portion of the code segment register and essen-
tially is the DPL for the current code segment.
The Requested Privilege Level (RPL) speci-
fies a selector’s privilege level and is used to
distinguish between the privilege level of a routine
actually accessing memory (the CPL), and the
privilege level of the original requestor (the RPL)
of the memory access. The lesser of the RPL
and CPL is called the effective privilege level (EPL).
Therefore, if RPL = 0 in a segment selector, the
effective privilege level is always determined
by the CPL. If RPL = 3, the effective privilege
level is always 3 regardless of the CPL.
For a memory access to succeed, the effective
privilege level (EPL) must be at least as privi-
leged as the descriptor privilege level (EPL
≤
DPL). If the EPL is less privileged than the
DPL (EPL > DPL), a general protection fault is
generated. For example, if a segment has a
DPL = 2, an instruction accessing the segment
only succeeds if executed with an EPL
≤ 2.