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 2005• RFLAGS.RF is cleared to 0.For further details on the SYSCALL and SYSRET instructions and their associatedMSR registers (STAR, LSTAR, CSTAR, and SYSCALL_FLAG_MASK), see “FastSystem Call and Return” in Volume 2.Mnemonic Opcode DescriptionSYSCALL 0F 05 Call operating system.Action// See “Pseudocode Definitions” on page 49.SYSCALL_START:IF (MSR_EFER.SCE = 0)EXCEPTION [#UD]// Check if syscall/sysret are enabled.IF (LONG_MODE)SYSCALL_LONG_MODEELSE // (LEGACY_MODE)SYSCALL_LEGACY_MODESYSCALL_LONG_MODE:RCX.q = next_RIPR11.q = RFLAGS// with rf clearedIF (64BIT_MODE)temp_RIP.q = MSR_LSTARELSE // (COMPATIBILITY_MODE)temp_RIP.q = MSR_CSTARCS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFCCS.attr = 64-bit code,dpl0 // Always switch to 64-bit mode in long mode.CS.base = 0x00000000CS.limit = 0xFFFFFFFFSS.sel = MSR_STAR.SYSCALL_CS + 8SS.attr = 64-bit stack,dpl0SS.base = 0x00000000SS.limit = 0xFFFFFFFFRFLAGS = RFLAGS AND ~MSR_SFMASKRFLAGS.RF = 0CPL = 0356 SYSCALL

24594 Rev. 3.10 February 2005 AMD64 TechnologyRIP = temp_RIPEXITSYSCALL_LEGACY_MODE:RCX.d = next_RIPtemp_RIP.d = MSR_STAR.EIPCS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFCCS.attr = 32-bit code,dpl0 // Always switch to 32-bit mode in legacy mode.CS.base = 0x00000000CS.limit = 0xFFFFFFFFSS.sel = MSR_STAR.SYSCALL_CS + 8SS.attr = 32-bit stack,dpl0SS.base = 0x00000000SS.limit = 0xFFFFFFFFRFLAGS.VM,IF,RF=0CPL = 0RIP = temp_RIPEXITRelated InstructionsSYSRET, SYSENTER, SYSEXITrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFM M M M 0 0 M M M M M M M M M M M21 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. Undefinedflags are U.SYSCALL 357

24594 Rev. 3.10 February 2005 AMD64 TechnologyRIP = temp_RIPEXITSYSCALL_LEGACY_MODE:RCX.d = next_RIPtemp_RIP.d = MSR_STAR.EIPCS.sel = MSR_STAR.SYSCALL_CS AND 0xFFFCCS.attr = 32-bit code,dpl0 // Always switch to 32-bit mode in legacy mode.CS.base = 0x00000000CS.limit = 0xFFFFFFFFSS.sel = MSR_STAR.SYSCALL_CS + 8SS.attr = 32-bit stack,dpl0SS.base = 0x00000000SS.limit = 0xFFFFFFFFRFLAGS.VM,IF,RF=0CPL = 0RIP = temp_RIPEXITRelated <strong>Instructions</strong>SYSRET, SYSENTER, SYSEXITrFLAGS AffectedID VIP VIF AC VM RF NT IOPL OF DF IF TF SF ZF AF PF CFM M M M 0 0 M M M M M M M M M M M21 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. Undefinedflags are U.SYSCALL 357

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

Saved successfully!

Ooh no, something went wrong!