VMREAD

Read Field from Virtual-Machine Control Structure

Opcodes

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

Description

Reads a specified field from the VMCS and stores it into a specified destination operand (register or memory).

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

The effective size of the destination 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 source operand is shorter than this effective operand size, the high bits of the destination operand are cleared to 0. If the VMCS field is longer, then the high bits of the field are not read.

Note that any faults resulting from accessing a memory destination operand can occur only after determining, in the operation section below, that the VMCS pointer is valid and that the specified VMCS field is supported.

Pseudo Code

IF (not in VMX operation) 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 source operand does not correspond to any VMCS field
					VMfailValid(VMREAD/VMWRITE from/to unsupported VMCS component);
				ELSE
					DEST = contents of VMCS field indexed by register source operand;
					VMsucceed;
				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 destination 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 destination operand.
#GP(0) If the current privilege level is not 0. If the memory destination 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 VMREAD instruction is not recognized in compatibility mode.

Virtual-8086 Mode Exceptions

Exception Description
#UD The VMREAD 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 VMREAD instruction is not recognized outside VMX operation.

Protected Mode Exceptions

Exception Description
#UD If not in VMX operation.
#SS(0) If a memory destination 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 destination operand.
#GP(0) If the current privilege level is not 0. If a memory destination 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 destination operand is located in a read-only data segment or any code segment.