MONITOR--Setup Monitor Address

 

Instruction

Description

 

MONITOR EAX, ECX, EDX

Sets up a linear address range to be monitored by hardware and activates the monitor. The address range should be of a write-back memory caching type.

Description

The MONITOR instruction relies on a state in the processor called the monitor event pending flag. The monitor event pending flag is either set or clear; its value is not architecturally visible except through the behavior of the MWAIT instruction. The monitor event pending flag is set by multiple events including a write to the address range being monitored and reset by the MONITOR instruction. The MONITOR instruction sets up the address monitoring hardware using the address specified in EAX and resets the monitor event pending flag. The address range that the hardware checks for stores can be determined by calling CPUID. Additional details for determining setup of this address range to prevent false wake ups are provided in The monitoring hardware detects stores to an address within the address range and sets the monitor event pending flag when the write is detected. The state of the monitor event pending flag is used by the MWAIT instruction. Other events will also set the monitor event pending flag. The address range must be in memory of write-back caching type. Only write-back memory type stores to the monitored address range set the monitor event pending flag. The content of EAX is a logical address. By default, the DS segment is used to create a linear address that is then monitored. Segment overrides can be used with the MONITOR instruction. ECX and EDX are used to communicate other information to the MONITOR instruction. ECX specifies optional extensions for the MONITOR instruction. EDX may contain hints and will not change the architectural behavior of the instruction. For the Intel® Pentium® 4 processor with Streaming SIMD Extensions 3 (SSE3), no extensions or hints are defined and the value for ECX and EDX should be zero. Non-zero values for ECX and EDX are reserved and the processor will raise a general protection fault exception on the execution of the MONITOR instruction with reserved values in ECX. The processor ignores setting of reserved bits in EDX. The MONITOR instruction is ordered as a load operation with respect to other memory trans­actions. The instruction can be used at all privilege levels and is subject to all permission checking and faults associated with a byte load. Like a load, the MONITOR instruction sets the A-bit but not the D-bit in page tables. The MONITOR CPUID feature flag (bit 3 of ECX when CPUID is executed with EAX=1) indi­cates that a processor supports this instruction. The operating system or system BIOS may disable this instruction through the IA32_MISC_ENABLES MSR; disabling the instruction clears the CPUID feature flag and causes execution of the MONITOR instruction to generate an illegal opcode exception.
See also: Guideline for MONITOR/MWAIT.

Operation

MONITOR sets up an address range for the monitor hardware using the content of EAX as a logical address and resets the monitor event pending flag. The memory address range should be within memory of the write-back caching type. A store to the specified address range will set the monitor event pending flag. The content of ECX and EDX are used to communicate other information to the MONITOR instruction.

Exceptions

None

Protected Mode Exceptions

#GP(0) For an illegal memory operand effective address in the CS, DS, ES, FS or GS segments. #GP(0) For ECX has a value other than 0. #SS(0) For an illegal address in the SS segment. #PF(fault-code) For a page fault (TBD). #UD If CPUID feature flag MONITOR is 0. If LOCK, REP, REPNE/NZ and Operand Size override prefixes are used.

Real Address Mode Exceptions

#GP If any part of the operand lies outside of the effective address space from 0 to FFFFH.
#GP(0) For ECX has a value other than 0.
#UD If CPUID feature flag MONITOR is 0. If LOCK, REP, REPNE/NZ and Operand Size override prefixes are used.

Virtual 8086 Mode Exceptions

#GP If any part of the operand lies outside of the effective address space from 0 to FFFFH.

#GP(0) For ECX has a value other than 0;

#UD if CPUID feature flag MONITOR is 0.

#UD If LOCK, REP, REPNE/NZ and Operand Size override prefixes are used. #PF(fault-code) For a page fault.