03.03.2013 Views

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

Intel® Architecture Instruction Set Extensions Programming Reference

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.

SYSTEM PROGRAMMING MODEL<br />

• Verify the processor supports XSAVE/XRSTOR/XSETBV/XGETBV instructions and the<br />

XFEATURE_ENABLED_MASK register by checking CPUID.1.ECX.XSAVE[bit 26]=1.<br />

• Verify the processor supports YMM state (i.e. bit 2 of XFEATURE_ENABLED_MASK is valid) by checking<br />

CPUID.(EAX=0DH, ECX=0):EAX.YMM[2]. The OS should also verify CPUID.(EAX=0DH, ECX=0):EAX.SSE[bit<br />

1]=1, because the lower 128-bits of an YMM register are aliased to an XMM register.<br />

The OS must determine the buffer size requirement for the XSAVE area that will be used by XSAVE/XRSTOR<br />

(see CPUID instruction in Section 2.9).<br />

• <strong>Set</strong> CR4.OSXSAVE[bit 18]=1 to enable the use of XSETBV/XGETBV instructions to write/read the<br />

XFEATURE_ENABLED_MASK register.<br />

• Supply an appropriate mask via EDX:EAX to execute XSETBV to enable the processor state components that<br />

the OS wishes to manage using XSAVE/XRSTOR instruction. To enable x87 FPU, SSE and YMM state<br />

management using XSAVE/XRSTOR, the enable mask is EDX=0H, EAX=7H (The individual bits of<br />

XFEATURE_ENABLED_MASK is listed in Table 3-1).<br />

To enable YMM state, the OS must use EDX:EAX[2:1] = 11B when executing XSETBV. An attempt to execute<br />

XSETBV with EDX:EAX[2:1] = 10B causes a #GP(0) exception.<br />

Table 3-1. XFEATURE_ENABLED_MASK and Processor State Components<br />

Bit Meaning<br />

0 - x87<br />

1 - SSE<br />

2 - YMM<br />

3.2.3 Enabling of SIMD Floating-Exception Support<br />

AVX and FMA instruction may generate SIMD floating-point exceptions. An OS must enable SIMD floating-point<br />

exception support by setting CR4.OSXMMEXCPT[bit 10]=1.<br />

The effect of CR4 setting that affects AVX and FMA enabling is listed in Table 3-2<br />

3.2.4 The Layout of XSAVE Area<br />

If set, the processor supports x87 FPU state management via XSAVE/XRSTOR. This bit must be 1 if<br />

CPUID.01H:ECX.XSAVE[26] = 1.<br />

If set, the processor supports SSE state (XMM and MXCSR) management via XSAVE/XRSTOR. This bit<br />

must be set to ‘1’ to enable AVX.<br />

If set, the processor supports YMM state (upper 128 bits of YMM registers) management via XSAVE. This<br />

bit must be set to ‘1’ to enable AVX and FMA.<br />

Table 3-2. CR4 bits for AVX New <strong>Instruction</strong>s technology support<br />

Bit Meaning<br />

CR4.OSXSAVE[bit 18] If set, the OS supports use of XSETBV/XGETBV instruction to access the XFEATURE_ENABLED_MASK<br />

register, XSAVE/XRSTOR to manage processor extended state. Must be set to ‘1’ to enable AVX and<br />

FMA.<br />

CR4.OSXMMEXCPT[bit 10] Must be set to 1 to enable SIMD floating-point exceptions. This applies to AVX, FMA operating on YMM<br />

states, and legacy 128-bit SIMD floating-point instructions operating on XMM states.<br />

CR4.OSFXSR[bit 9] Ignored by AVX and FMA instructions operating on YMM states.<br />

Must be set to 1 to enable SIMD instructions operating on XMM state.<br />

The OS must determine the buffer size requirement by querying CPUID with EAX=0DH, ECX=0. If the OS wishes to<br />

enable all processor extended state components in the XFEATURE_ENABLED_MASK, it can allocate the buffer size<br />

according to CPUID.(EAX=0DH, ECX=0):ECX.<br />

After the memory buffer for XSAVE is allocated, the entire buffer must to cleared to zero prior to use by XSAVE.<br />

For processors that support SSE and YMM states, the XSAVE area layout is listed in Table 3-3. The register fields of<br />

the first 512 byte of the XSAVE area are identical to those of the FXSAVE/FXRSTOR area.<br />

3-2 Ref. # 319433-014

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

Saved successfully!

Ooh no, something went wrong!