
2-83
2
PRELIMINARY
Protection
Protection
2-83
2.17.2 I/O Privilege Levels
The I/O Privilege Level (IOPL) allows the oper-
ating system executing at CPL=0 to define the
least privileged level at which IOPL-sensitive
instructions can unconditionally be used. The
IOPL-sensitive instructions include CLI, IN,
OUT, INS, OUTS, REP INS, REP OUTS, and
STI. Modification of the IF bit in the EFLAGS
register is also sensitive to the I/O privilege level.
The IOPL is stored in the EFLAGS register.
An I/O permission bit map is available as
defined by the 32-bit Task State Segment
(TSS). Since each task can have its own TSS,
access to individual processor I/O ports can be
granted through separate I/O permission bit
maps.
If CPL
≤ IOPL, IOPL-sensitive operations can
be performed. If CPL > IOPL, a general
protection fault is generated if the current task
is associated with a 16-bit TSS. If the current
task is associated with a 32-bit TSS and CPL >
IOPL, the CPU consults the I/O permission
bitmap in the TSS to determine on a port-by-port
basis whether or not I/O instructions (IN,
OUT, INS, OUTS, REP INS, REP OUTS) are
permitted, and the remaining IOPL-sensitive
operations generate a general protection fault.
2.17.3 Privilege Level Transfers
A task’s CPL can be changed only through
intersegment control transfers using gates or
task switches to a code segment with a different
privilege level. Control transfers result from
exception and interrupt servicing and from
execution of the CALL, JMP, INT, IRET and
RET instructions.
There are five types of control transfers that are
summarized in Table 2-40 (Page 2-84). Control
transfers can be made only when the operation
causing the control transfer references the correct
descriptor type. Any violation of these descriptor
usage rules causes a general protection fault.
Any control transfer that changes the CPL
within a task results in a change of stack. The
initial values for the stack segment (SS) and
stack pointer (ESP) for privilege levels 0, 1,
and 2 are stored in the TSS. During a CALL
control transfer, the SS and ESP are loaded
with the new stack pointer and the previous
stack pointer is saved on the new stack. When
returning to the original privilege level, the
RET or IRET instruction restores the less-privi-
leged stack