background image

13-20 Vol. 1

MANAGING STATE USING THE XSAVE FEATURE SET

= CPL;

= 1 if and only if the logical processor is in VMX non-root operation;

y is the linear address of the XSAVE area being used by XSAVEOPT; and

z[63] is 1 and z[62:0] = RFBM[62:0]. (This last item implies that XSAVES does not use the modified optimi-
zation if the last execution of XRSTOR used the standard form and followed the last execution of XRSTORS.)

If XSAVES uses the modified optimization and XMODIFIED[i] = 0 (see Section 13.6), state component i is not 
saved to the XSAVE area.

13.12  OPERATION OF XRSTORS

The operation of XRSTORS is similar to that of XRSTOR. Three main differences are (1) XRSTORS can be executed 
only if CPL = 0; (2) XRSTORS can operate on the state components whose bits are set in XCR0 | IA32_XSS and can 
thus operate on supervisor state components; and (3) XRSTORS has only a compacted form (no standard form; 
see Section 13.8). See Section 13.2 for details of how to determine whether XRSTORS is supported.
The XRSTORS instruction takes a single memory operand, which is an XSAVE area. In addition, the register pair 
EDX:EAX is an implicit operand used as a state-component bitmap (see Section 13.1) called the instruction 
mask
. EDX:EAX & (XCR0 | IA32_XSS) (the logical AND the instruction mask with the logical OR of XCR0 and 
IA32_XSS) is the requested-feature bitmap (RFBM) of the state components to be restored.
The following conditions cause execution of the XRSTOR instruction to generate a fault:

If the XSAVE feature set is not enabled (CR4.OSXSAVE = 0), an invalid-opcode exception (#UD) occurs.

If CR0.TS[bit 3] is 1, a device-not-available exception (#NM) occurs.

If CPL > 0 or if the address of the XSAVE area is not 64-byte aligned, a general-protection exception (#GP) 
occurs.

1

After checking for these faults, the XRSTORS instruction reads the first 64 bytes of the XSAVE header, including the 
XSTATE_BV and XCOMP_BV fields (see Section 13.4.2). A #GP occurs if any of the following conditions hold for the 
values read:

XCOMP_BV[63] = 0.

XCOMP_BV sets a bit in the range 62:0 that is not set in XCR0 | IA32_XSS.

XSTATE_BV sets a bit (including bit 63) that is not set in XCOMP_BV.

Bytes 63:16 of the XSAVE header are not all 0.

If none of these conditions cause a fault, the processor updates each state component i for which RFBM[i] =  1. 
XRSTORS updates state component i based on the value of bit i in the XSTATE_BV field of the XSAVE header:

If XSTATE_BV[i] = 0, the state component is set to its initial configuration. Section 13.6 specifies the initial 
configuration of each state component. If XSTATE_BV[1] = 0, XRSTORS initializes MXCSR to 1F80H.
State component i is set to its initial configuration as indicated above if RFBM[i] = 1 and XSTATE_BV[i] =  0  — 
even if XCOMP_BV[i] =  0. This is true for all values of i, including 0 (x87 state) and 1 (SSE state).

If XSTATE_BV[i] = 1, the state component is loaded with data from the XSAVE area.

2

 See Section 13.5 for 

specifics for each state component and for details regarding mode-specific operation and operation determined 
by instruction prefixes; in particular, see Section 13.5.6 for some special treatment of PT state by XRSTORS. 
See Section 13.13 for details regarding faults caused by memory accesses.
If XRSTORS is restoring a supervisor state component, the instruction causes a general-protection exception 
(#GP) if it would load any element of that component with an unsupported value (e.g., by setting a reserved bit 
in an MSR) or if a bit is set in any reserved portion of the state component in the XSAVE area.

1. If CR0.AM = 1, CPL = 3, and EFLAGS.AC =1, an alignment-check exception (#AC) may occur instead of #GP.
2. Earlier fault checking ensured that, if the instruction has reached this point in execution and XSTATE_BV[i] is 1, then XCOMP_BV[i] is 

also 1.