invd
Invalidate Internal Caches
INVD
Flushes internal caches without writing back data (Privileged).
Details
Invalidates all internal cache lines without writing back modified data to memory. This privileged instruction (CPL=0 only) causes a complete pipeline flush and memory ordering barrier; dirty cache lines are discarded, potentially losing uncommitted writes, making it dangerous for general use. No flags are affected.
Pseudocode Operation
invalidate_all_cache_lines(); flush_pipeline(); memory_barrier()
Example
INVD
Encoding
Binary Layout
0F
+0
08
+1
Operands
Reference (Intel® SDM)
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| 0F 08 | INVD | ZO | Valid Valid | Flush internal caches; initiate flushing of external caches. |
Description
Invalidates (flushes) the processor’s internal caches and issues a special-function bus cycle that directs external caches to also flush themselves. Data held in internal caches is not written back to main memory.
After executing this instruction, the processor does not wait for the external caches to complete their flushing operation before proceeding with instruction execution. It is the responsibility of hardware to respond to the cache flush signal.
The INVD instruction is a privileged instruction. When the processor is running in protected mode, the CPL of a program or procedure must be 0 to execute this instruction.
The INVD instruction may be used when the cache is used as temporary memory and the cache contents need to be invalidated rather than written back to memory. When the cache is used as temporary memory, no external device should be actively writing data to main memory.
Use this instruction with care. Data cached internally and not written back to main memory will be lost. Note that any data from an external device to main memory (for example, via a PCIWrite) can be temporarily stored in the caches; these data can be lost when an INVD instruction is executed. Unless there is a specific requirement or benefit to flushing caches without writing back modified cache lines (for example, temporary memory, testing, or fault recovery where cache coherency with main memory is not a concern), software should instead use the
WBINVD instruction.
On processors that support processor reserved memory, the INVD instruction cannot be executed when processor reserved memory protections are activated. See Section 39.5, “EPC and Management of EPC Pages,” in the Intel®
64 and IA-32 Architectures Software Developer’s Manual, Volume 3D.
On processors that support SEAM, the INVD instruction cannot be executed when the SEAM range is protected. See
Section 35.4, “Memory Protection,” in the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume
3.
Some processors prevent execution of INVD after BIOS execution is complete. They report this by enumerating
CPUID.07H.01H:EAX[30] as 1. On such processors, INVD cannot be executed if bit 0 of SR_BIOS_DONE (MSR address 151H) is 1.
This instruction’s operation is the same in non-64-bit modes and 64-bit mode.
IA-32 Architecture Compatibility
The INVD instruction is implementation dependent; it may be implemented differently on different families of Intel
64 or IA-32 processors. This instruction is not supported on IA-32 processors earlier than the Intel486 processor.
Operation
Flush(InternalCaches); SignalFlush(ExternalCaches); Continue (* Continue execution *) INVD—Invalidate Internal Caches Vol. 2A 3-483
Flags Affected
None.
Exceptions
Protected Mode Exceptions
#GP(0) If the current privilege level is not 0.
If the processor reserved memory protections are activated.
If the SEAM range is protected.
If CPUID.07H.01H:EAX[30] = 1 and bit 0 is set in MSR_BIOS_DONE (MSR address 151H).
#UD If the LOCK prefix is used.
Real-Address Mode Exceptions
#GP(0) If CPUID.07H.01H:EAX[30] = 1 and bit 0 is set in MSR_BIOS_DONE (MSR address 151H).
If the processor reserved memory protections are activated.
If the SEAM range is protected.
#UD If the LOCK prefix is used.
Virtual-8086 Mode Exceptions
#GP(0) The INVD instruction cannot be executed in virtual-8086 mode.
Compatibility Mode Exceptions
Same exceptions as in protected mode.
64-Bit Mode Exceptions
Same exceptions as in protected mode.
INVD—Invalidate Internal Caches Vol. 2A 3-484