VMWRITE

Write Field to Virtual-Machine Control Structure

Opcodes

Hex Mnemonic Encoding Long Mode Legacy Mode Description
0F 79 VMWRITE r32, r/m32 None None None Writes a specified VMCS field (outside 64-bit mode)
0F 79 VMWRITE r64, r/m64 None None None Writes a specified VMCS field (in 64-bit mode)

Description

Writes to a specified field in the VMCS specified by a secondary source operand (register only) using the contents of a primary source operand (register or memory).

The VMCS field is identified by the VMCS-field encoding contained in the register secondary source operand. Outside IA-32e mode, the secondary source operand is always 32 bits, regardless of the value of CS.D. In 64-bit mode, the secondary source operand has 64 bits; however, if bits 63:32 of the secondary source operand are not zero, VMWRITE will fail due to an attempt to access an unsupported VMCS component (see operation section).

The effective size of the primary source operand, which may be a register or in memory, is always 32 bits outside IA-32e mode (the setting of CS.D is ignored with respect to operand size) and 64 bits in 64-bit mode. If the VMCS field specified by the secondary source operand is shorter than this effective operand size, the high bits of the primary source operand are ignored. If the VMCS field is longer, then the high bits of the field are cleared to 0.

Note that any faults resulting from accessing a memory source operand occur after determining, in the operation section below, that the VMCS pointer is valid but before determining if the destination VMCS field is supported.

Pseudo Code

IF (not in VMX operation) or (CR0.PE = 0) or (RFLAGS.VM = 1) or (IA32_EFER.LMA = 1 and CS.L = 0)
	#UD;
ELSE
	IF in VMX non-root operation
		VMexit;
	ELSE
		IF CPL > 0
			#GP(0);
		ELSE
			IF current-VMCS pointer is not valid
				VMfailInvalid;
			ELSE
				IF register destination operand does not correspond to any VMCS field
					VMfailValid(VMREAD/VMWRITE from/to unsupported VMCS component);
				ELSE
					IF VMCS field indexed by register destination operand is read-only)
						VMfailValid(VMWRITE to read-only VMCS component);
					ELSE
						VMCS field indexed by register destination operand = SRC;
						VMsucceed;
					FI;
				FI;
			FI;
		FI;
	FI;
FI;

Flags Affected

See the operation section and Section 5.2.

Exceptions

64-Bit Mode Exceptions

Exception Description
#UD If not in VMX operation.
#SS(0) If the memory source operand is in the SS segment and the memory address is in a non-canonical form.
#PF(fault-code) If a page fault occurs in accessing a memory source operand.
#GP(0) If the current privilege level is not 0. If the memory source operand is in the CS, DS, ES, FS, or GS segments and the memory address is in a non-canonical form.

Compatibility Mode Exceptions

Exception Description
#UD The VMWRITE instruction is not recognized in compatibility mode.

Virtual-8086 Mode Exceptions

Exception Description
#UD The VMWRITE instruction is not recognized in virtual-8086 mode.

Real-Address Mode Exceptions

Exception Description
#UD A logical processor cannot be in real-address mode while in VMX operation and the VMWRITE instruction is not recognized outside VMX operation.

Protected Mode Exceptions

Exception Description
#UD If not in VMX operation.
#SS(0) If a memory source operand effective address is outside the SS segment limit. If the SS register contains an unusable segment.
#PF(fault-code) If a page fault occurs in accessing a memory source operand.
#GP(0) If the current privilege level is not 0. If a memory source operand effective address is outside the CS, DS, ES, FS, or GS segment limit. If the DS, ES, FS, or GS register contains an unusable segment. If the source operand is located in an execute-only code segment.