Intel 64 and IA-32 Architectures Software Developers Manual Volume 2B, Instruction Set Reference, N-Z
4-366 Vol. 2B
INSTRUCTION SET REFERENCE, N-Z
SYSEXIT—Fast Return from Fast System Call
Description
Executes a fast return to privilege level 3 user code. SYSEXIT is a companion instruc-
tion to the SYSENTER instruction. The instruction is optimized to provide the
maximum performance for returns from system procedures executing at protections
levels 0 to user procedures executing at protection level 3. It must be executed from
code executing at privilege level 0.
Prior to executing SYSEXIT, software must specify the privilege level 3 code segment
and code entry point, and the privilege level 3 stack segment and stack pointer by
writing values into the following MSR and general-purpose registers:
• IA32_SYSENTER_CS — Contains a 32-bit value, of which the lower 16 bits are
the segment selector for the privilege level 0 code segment in which the
processor is currently executing. This value is used to compute the segment
selectors for the privilege level 3 code and stack segments.
• EDX — Contains the 32-bit offset into the privilege level 3 code segment to the
first instruction to be executed in the user code.
• ECX — Contains the 32-bit stack pointer for the privilege level 3 stack.
The IA32_SYSENTER_CS MSR can be read from and written to using
RDMSR/WRMSR. The register address is listed in Table 4-6. This address is defined to
remain fixed for future Intel 64 and IA-32 processors.
When SYSEXIT is executed, the processor:
1. Adds 16 to the value in IA32_SYSENTER_CS and loads the sum into the CS
selector register.
2. Loads the instruction pointer from the EDX register into the EIP register.
3. Adds 24 to the value in IA32_SYSENTER_CS and loads the sum into the SS
selector register.
4. Loads the stack pointer from the ECX register into the ESP register.
5. Switches to privilege level 3.
6. Begins executing the user code at the EIP address.
See “SWAPGS—Swap GS Base Register” in this chapter for information about using
the SYSENTER and SYSEXIT instructions as companion call and return instructions.
Opcode Instruction
64-Bit
Mode
Compat/
Leg Mode Description
0F 35 SYSEXIT Valid Valid Fast return to privilege level 3 user code.
REX.W +
0F 35
SYSEXIT Valid Valid Fast return to 64-bit mode privilege level
3 user code.