1 gates in ia-32e mode, 3 task-state segments and task gates – Intel IA-32 User Manual
Page 54
2-6 Vol. 3A
SYSTEM ARCHITECTURE OVERVIEW
For example, a CALL to a call gate can provide access to a procedure in a code segment that is
at the same or a numerically lower privilege level (more privileged) than the current code
segment. To access a procedure through a call gate, the calling procedure
1
supplies the selector
for the call gate. The processor then performs an access rights check on the call gate, comparing
the CPL with the privilege level of the call gate and the destination code segment pointed to by
the call gate.
If access to the destination code segment is allowed, the processor gets the segment selector for
the destination code segment and an offset into that code segment from the call gate. If the call
requires a change in privilege level, the processor also switches to the stack for the targeted priv-
ilege level. The segment selector for the new stack is obtained from the TSS for the currently
running task. Gates also facilitate transitions between 16-bit and 32-bit code segments, and vice
versa.
2.1.2.1
Gates in IA-32e Mode
In IA-32e mode, the following descriptors are 16-byte descriptors (expanded to allow a 64-bit
base): LDT descriptors, 64-bit TSSs, call gates, interrupt gates, and trap gates.
Call gates facilitate transitions between 64-bit mode and compatibility mode. Task gates are not
supported in IA-32e mode. On privilege level changes, stack segment selectors are not read from
the TSS. Instead, they are set to NULL.
2.1.3
Task-State Segments and Task Gates
The TSS (see Figure 2-1) defines the state of the execution environment for a task. It includes
the state of general-purpose registers, segment registers, the EFLAGS register, the EIP register,
and segment selectors with stack pointers for three stack segments (one stack for each privilege
level). The TSS also includes the segment selector for the LDT associated with the task and the
page-table base address.
All program execution in protected mode happens within the context of a task (called the current
task). The segment selector for the TSS for the current task is stored in the task register. The
simplest method for switching to a task is to make a call or jump to the new task. Here, the
segment selector for the TSS of the new task is given in the CALL or JMP instruction. In
switching tasks, the processor performs the following actions:
1.
Stores the state of the current task in the current TSS.
2.
Loads the task register with the segment selector for the new task.
3.
Accesses the new TSS through a segment descriptor in the GDT.
4.
Loads the state of the new task from the new TSS into the general-purpose registers, the
segment registers, the LDTR, control register CR3 (page-table base address), the EFLAGS
register, and the EIP register.
5.
Begins execution of the new task.
1. The word “procedure” is commonly used in this document as a general term for a logical unit or block of
code (such as a program, procedure, function, or routine).