
Background
3
21086C/0—May 1998
SYSCALL and SYSRET Instruction Specification
Background
The x86 operating system designers use both segmentation and
paging to implement various memory models in their designs.
Memory can be protected or unprotected, and segmentation
and paging can be implemented with attributes such as
supervisor, user, read, write, and execute.
Segment descriptors provide the necessary memory protection
and privilege checking of segment accesses. By setting the
fields within the segment descriptors appropriately, operating
systems can enforce access restrictions as needed. One
disadvantage of segment-based protection and privilege
checking is the overhead associated with the loading of new
segments (and their descriptors) into segment registers. Even
with pure 32-bit code, this overhead still occurs when switching
between ring or privilege levels, and Code Segment (CS) and
Stack Segment (SS) are reloaded with different segment
descriptors.
To initiate a call to the operating system, an application
transfers control to the OS through gate descriptors (task,
interrupt, trap, or call gates). Control transfer is done by using
either a CALL instruction or a software interrupt. (The
Windows
95 operating system uses CALL gates while Windows
NT
uses software interrupts.) Setting up these control gates
(as well as the later return via a RET or IRET instruction) is
slowed down by the segmentation-related overhead. For
example, a CALL to a call gate must initiate the following
checks to ensure protection and stability:
I
The CS selector must not be a NULL selector. If the selector
is NULL, a General Protection Fault occurs.
The Type field must define the selected descriptor as a code
segment descriptor. If the descriptor is not a code segment
descriptor, a General Protection Fault occurs.
The CS selector must be able to index within the limits of
the descriptor table. If the index is not within these limits, a
General Protection Fault occurs.
The Descriptor Privilege Level of the call gate must be
greater than or equal to the Requestor Privilege level. If it is
not, a General Protection Fault occurs.
I
I
I