13.07.2015 Views

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

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

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

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

24594 Rev. 3.10 February 2005 AMD64 Technology• The CS_base <strong>and</strong> the SS_base are both forced to zero.• The CS_limit <strong>and</strong> the SS_limit are both forced to 4 Gbyte.• The CS segment attributes are set to execute/read 32-bit code with a CPL of zero.• The SS segment attributes are set to read/write <strong>and</strong> exp<strong>and</strong>-up with a 32-bit stackreferenced by ESP.Long Mode. When long mode is activated, the behavior of the SYSCALL instructiondepends on whether the calling software is in 64-bit mode or compatibility mode. In64-bit mode, SYSCALL saves the RIP of the instruction following the SYSCALL intoRCX <strong>and</strong> loads the new RIP from LSTAR bits 63–0. (The LSTAR register is modelspecificregister C000_0082h.) In compatibility mode, SYSCALL saves the RIP of theinstruction following the SYSCALL into RCX <strong>and</strong> loads the new RIP from CSTAR bits63–0. (The CSTAR register is model-specific register C000_0083h.)New selectors are loaded, without permission checking (see above), as follows:• Bits 47–32 of the STAR register specify the selector that is copied into the CS register.• Bits 47–32 of the STAR register + 8 specify the selector that is copied into the SSregister.• The CS_base <strong>and</strong> the SS_base are both forced to zero.• The CS_limit <strong>and</strong> the SS_limit are both forced to 4 Gbyte.• The CS segment attributes are set to execute/read 64-bit code with a CPL of zero.• The SS segment attributes are set to read/write <strong>and</strong> exp<strong>and</strong>-up with a 64-bit stackreferenced by RSP.The WRMSR instruction loads the target RIP into the LSTAR <strong>and</strong> CSTAR registers. Ifan RIP written by WRMSR is not in canonical form, a general-protection exception(#GP) occurs.How SYSCALL <strong>and</strong> SYSRET h<strong>and</strong>le rFLAGS, depends on the processor’s operatingmode.In legacy mode, SYSCALL treats EFLAGS as follows:• EFLAGS.IF is cleared to 0.• EFLAGS.RF is cleared to 0.• EFLAGS.VM is cleared to 0.In long mode, SYSCALL treats RFLAGS as follows:• The current value of RFLAGS is saved in R11.• RFLAGS is masked using the value stored in SYSCALL_FLAG_MASK.SYSCALL 355

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

Saved successfully!

Ooh no, something went wrong!