Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ... Volume 3: General-Purpose and System Instructions - Stanford ...

scs.stanford.edu
from scs.stanford.edu More from this publisher
13.07.2015 Views

AMD64 Technology 24594 Rev. 3.10 February 2005Mnemonic Opcode DescriptionSYSEXIT 0F 35 Return from operating system to application.Related InstructionsSYSCALL, SYSENTER, SYSRETrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFExceptions021 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to one or cleared to zero is M (modified). Unaffected flags are blank.Exception RealInvalid opcode, #UD X X XVirtual8086 Protected Cause of ExceptionThe SYSENTER and SYSEXIT instructions are notsupported, as indicated by EDX bit 11 returned by CPUIDstandard function 1.General protection, #GP X XXXXThis instruction is not recognized in long mode.This instruction is only recognized in protected mode.CPL was not 0.MSR_SYSENTER_CS was cleared to 0.362 SYSEXIT

24594 Rev. 3.10 February 2005 AMD64 TechnologySYSRETFast System ReturnReturns from the operating system to an application. It is a low-latency system returninstruction designed for use by system and application software implementing a flatsegmentation memory model.The SYSCALL and SYSRET instructions are low-latency system call and returncontrol-transfer instructions that assume that the operating system implements a flatsegmentmemory model. By eliminating unneeded checks, and by loading predeterminedvalues into the CS and SS segment registers (both visible and hiddenportions), calls to and returns from the operating system are greatly simplified. Theseinstructions can be used in protected mode and are particularly well-suited for use in64-bit mode, which requires implementation of a paged, flat-segment memory model.This instruction has been optimized by reducing the number of checks and memoryreferences that are normally made so that a call or return takes substantially fewerinternal clock cycles when compared to the CALL/RET instruction method.It is assumed that the base, limit, and attributes of the Code Segment will remain flatfor all processes and for the operating system, and that only the current privilege levelfor the selector of the calling process should be changed from a current privilege levelof 0 to a new privilege level of 3. It is also assumed (but not checked) that the RPL ofthe SYSCALL and SYSRET target selectors are set to 0 and 3, respectively.SYSRET sets the CPL to 3, regardless of the values of bits 49–48 of the star register.SYSRET can only be executed in protected mode at CPL 0. SYSCALL and SYSRETmust be enabled by setting EFER.SCE to 1.It is the responsibility of the operating system to keep the descriptors in memory thatcorrespond to the CS and SS selectors loaded by the SYSCALL and SYSRETinstructions consistent with the segment base, limit, and attribute values forced bythese instructions.When a system procedure performs a SYSRET back to application software, the CSselector is updated from bits 63–50 of the STAR register (STAR.SYSRET_CS) asfollows:• If the return is to 32-bit mode (legacy or compatibility), CS is updated with thevalue of STAR.SYSRET_CS.• If the return is to 64-bit mode, CS is updated with the value of STAR.SYSRET_CS+ 16.SYSRET 363

AMD64 Technology 24594 Rev. 3.10 February 2005Mnemonic Opcode DescriptionSYSEXIT 0F 35 Return from operating system to application.Related <strong>Instructions</strong>SYSCALL, SYSENTER, SYSRETrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFExceptions021 20 19 18 17 16 14 13–12 11 10 9 8 7 6 4 2 0Note: Bits 31–22, 15, 5, 3, <strong>and</strong> 1 are reserved. A flag set to one or cleared to zero is M (modified). Unaffected flags are blank.Exception RealInvalid opcode, #UD X X XVirtual8086 Protected Cause of ExceptionThe SYSENTER <strong>and</strong> SYSEXIT instructions are notsupported, as indicated by EDX bit 11 returned by CPUIDst<strong>and</strong>ard function 1.<strong>General</strong> protection, #GP X XXXXThis instruction is not recognized in long mode.This instruction is only recognized in protected mode.CPL was not 0.MSR_SYSENTER_CS was cleared to 0.362 SYSEXIT

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!