forked from NRZCode/ia32-64
135 lines
7.3 KiB
HTML
135 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:x86="http://www.felixcloutier.com/x86"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="style.css"></link><title>MONITOR
|
||
— Set Up Monitor Address</title></head><body><header><nav><ul><li><a href='index.html'>Index</a></li><li>December 2023</li></ul></nav></header><h1>MONITOR
|
||
— Set Up Monitor Address</h1>
|
||
|
||
<table>
|
||
<tr>
|
||
<th>Opcode</th>
|
||
<th>Instruction</th>
|
||
<th>Op/En</th>
|
||
<th>64-Bit Mode</th>
|
||
<th>Compat/Leg Mode</th>
|
||
<th>Description</th></tr>
|
||
<tr>
|
||
<td>0F 01 C8</td>
|
||
<td>MONITOR</td>
|
||
<td>ZO</td>
|
||
<td>Valid</td>
|
||
<td>Valid</td>
|
||
<td>Sets up a linear address range to be monitored by hardware and activates the monitor. The address range should be a write-back memory caching type. The address is DS:RAX/EAX/AX.</td></tr></table>
|
||
<h2 id="instruction-operand-encoding">Instruction Operand Encoding<a class="anchor" href="#instruction-operand-encoding">
|
||
¶
|
||
</a></h2>
|
||
<table>
|
||
<tr>
|
||
<th>Op/En</th>
|
||
<th>Operand 1</th>
|
||
<th>Operand 2</th>
|
||
<th>Operand 3</th>
|
||
<th>Operand 4</th></tr>
|
||
<tr>
|
||
<td>ZO</td>
|
||
<td>N/A</td>
|
||
<td>N/A</td>
|
||
<td>N/A</td>
|
||
<td>N/A</td></tr></table>
|
||
<h2 id="description">Description<a class="anchor" href="#description">
|
||
¶
|
||
</a></h2>
|
||
<p>The MONITOR instruction arms address monitoring hardware using an address specified in EAX (the address range that the monitoring hardware checks for store operations can be determined by using CPUID). A store to an address within the specified address range triggers the monitoring hardware. The state of monitor hardware is used by MWAIT.</p>
|
||
<p>The address is specified in RAX/EAX/AX and the size is based on the effective address size of the encoded instruction. By default, the DS segment is used to create a linear address that is monitored. Segment overrides can be used.</p>
|
||
<p>ECX and EDX are also used. They communicate other information to MONITOR. ECX specifies optional extensions. EDX specifies optional hints; it does not change the architectural behavior of the instruction. For the Pentium 4 processor (family 15, model 3), no extensions or hints are defined. Undefined hints in EDX are ignored by the processor; undefined extensions in ECX raises a general protection fault.</p>
|
||
<p>The address range must use memory of the write-back type. Only write-back memory will correctly trigger the monitoring hardware. Additional information on determining what address range to use in order to prevent false wake-ups is described in Chapter 9, “Multiple-Processor Management‚” of the Intel<sup>®</sup> 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A.</p>
|
||
<p>The MONITOR instruction is ordered as a load operation with respect to other memory transactions. The instruction is subject to the permission checking and faults associated with a byte load. Like a load, MONITOR sets the A-bit but not the D-bit in page tables.</p>
|
||
<p>CPUID.01H:ECX.MONITOR[bit 3] indicates the availability of MONITOR and MWAIT in the processor. When set, MONITOR may be executed only at privilege level 0 (use at any other privilege level results in an invalid-opcode exception). The operating system or system BIOS may disable this instruction by using the IA32_MISC_ENABLE MSR; disabling MONITOR clears the CPUID feature flag and causes execution to generate an invalid-opcode exception.</p>
|
||
<p>The instruction’s operation is the same in non-64-bit modes and 64-bit mode.</p>
|
||
<h2 id="operation">Operation<a class="anchor" href="#operation">
|
||
¶
|
||
</a></h2>
|
||
<pre>MONITOR sets up an address range for the monitor hardware using the content of EAX (RAX in 64-bit mode) as an effective address
|
||
and puts the monitor hardware in armed state. Always use memory of the write-back caching type. A store to the specified address
|
||
range will trigger the monitor hardware. The content of ECX and EDX are used to communicate other information to the monitor
|
||
hardware.
|
||
</pre>
|
||
<h2 id="intel-c-c++-compiler-intrinsic-equivalent">Intel C/C++ Compiler Intrinsic Equivalent<a class="anchor" href="#intel-c-c++-compiler-intrinsic-equivalent">
|
||
¶
|
||
</a></h2>
|
||
<pre>MONITOR void _mm_monitor(void const *p, unsigned extensions,unsigned hints)
|
||
</pre>
|
||
<h2 class="exceptions" id="numeric-exceptions">Numeric Exceptions<a class="anchor" href="#numeric-exceptions">
|
||
¶
|
||
</a></h2>
|
||
<p>None.</p>
|
||
<h2 class="exceptions" id="protected-mode-exceptions">Protected Mode Exceptions<a class="anchor" href="#protected-mode-exceptions">
|
||
¶
|
||
</a></h2>
|
||
<table>
|
||
<tr>
|
||
<td rowspan="3">#GP(0)</td>
|
||
<td>If the value in EAX is outside the CS, DS, ES, FS, or GS segment limit.</td></tr>
|
||
<tr>
|
||
<td>If the DS, ES, FS, or GS register is used to access memory and it contains a NULL segment selector.</td></tr>
|
||
<tr>
|
||
<td>If ECX ≠ 0.</td></tr>
|
||
<tr>
|
||
<td>#SS(0)</td>
|
||
<td>If the value in EAX is outside the SS segment limit.</td></tr>
|
||
<tr>
|
||
<td>#PF(fault-code)</td>
|
||
<td>For a page fault.</td></tr>
|
||
<tr>
|
||
<td rowspan="2">#UD</td>
|
||
<td>If CPUID.01H:ECX.MONITOR[bit 3] = 0.</td></tr>
|
||
<tr>
|
||
<td>If current privilege level is not 0.</td></tr></table>
|
||
<h2 class="exceptions" id="real-address-mode-exceptions">Real Address Mode Exceptions<a class="anchor" href="#real-address-mode-exceptions">
|
||
¶
|
||
</a></h2>
|
||
<table>
|
||
<tr>
|
||
<td rowspan="2">#GP</td>
|
||
<td>If the CS, DS, ES, FS, or GS register is used to access memory and the value in EAX is outside of the effective address space from 0 to FFFFH.</td></tr>
|
||
<tr>
|
||
<td>If ECX ≠ 0.</td></tr>
|
||
<tr>
|
||
<td>#SS</td>
|
||
<td>If the SS register is used to access memory and the value in EAX is outside of the effective address space from 0 to FFFFH.</td></tr>
|
||
<tr>
|
||
<td>#UD</td>
|
||
<td>If CPUID.01H:ECX.MONITOR[bit 3] = 0.</td></tr></table>
|
||
<h2 class="exceptions" id="virtual-8086-mode-exceptions">Virtual 8086 Mode Exceptions<a class="anchor" href="#virtual-8086-mode-exceptions">
|
||
¶
|
||
</a></h2>
|
||
<table>
|
||
<tr>
|
||
<td>#UD</td>
|
||
<td>The MONITOR instruction is not recognized in virtual-8086 mode (even if CPUID.01H:ECX.MONITOR[bit 3] = 1).</td></tr></table>
|
||
<h2 class="exceptions" id="compatibility-mode-exceptions">Compatibility Mode Exceptions<a class="anchor" href="#compatibility-mode-exceptions">
|
||
¶
|
||
</a></h2>
|
||
<p>Same exceptions as in protected mode.</p>
|
||
<h2 class="exceptions" id="64-bit-mode-exceptions">64-Bit Mode Exceptions<a class="anchor" href="#64-bit-mode-exceptions">
|
||
¶
|
||
</a></h2>
|
||
<table>
|
||
<tr>
|
||
<td rowspan="2">#GP(0)</td>
|
||
<td>If the linear address of the operand in the CS, DS, ES, FS, or GS segment is in a non-canonical form.</td></tr>
|
||
<tr>
|
||
<td>If RCX ≠ 0.</td></tr>
|
||
<tr>
|
||
<td>#SS(0)</td>
|
||
<td>If the SS register is used to access memory and the value in EAX is in a non-canonical form.</td></tr>
|
||
<tr>
|
||
<td>#PF(fault-code)</td>
|
||
<td>For a page fault.</td></tr>
|
||
<tr>
|
||
<td rowspan="2">#UD</td>
|
||
<td>If the current privilege level is not 0.</td></tr>
|
||
<tr>
|
||
<td>If CPUID.01H:ECX.MONITOR[bit 3] = 0.</td></tr></table><footer><p>
|
||
This UNOFFICIAL, mechanically-separated, non-verified reference is provided for convenience, but it may be
|
||
inc<span style="opacity: 0.2">omp</span>lete or b<sub>r</sub>oke<sub>n</sub> in various obvious or non-obvious
|
||
ways. Refer to <a href="https://software.intel.com/en-us/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4">Intel® 64 and IA-32 Architectures Software Developer’s Manual</a> for anything serious.
|
||
</p></footer></body></html>
|