This is the question: Does clflush flush L1i? Intel ISA manual was not clear on that:
Invalidates from every level of the cache hierarchy in the cache coherence domain the cache line that contains the linear address specified with the memory operand. If that cache line contains modified data at any level of the cache hierarchy, that data is written back to memory
I would speculate by the wording
If that cache line contains modified data at any level of the cache hierarchy, that data is written back to memory.
So L1I left untouched. Is it the actual behavior of Intel CPUs?
clflush
does what it says on the tin and flushes all caches: instruction, data, and unified. (And the decoded-uop cache). Margaret Bloom actually tested to confirm this.
Instruction caches can't ever be dirty so it makes sense that discussion of modified lines talks about data. Only write-back data caches can be dirty. Note that one of the intended purposes of clflush
is to write-back dirty data to a non-volatile DIMM, so it's natural that the docs focus on data.
You're reading too much into the wording, perhaps based on a misconception that write-back is synonymous with flushing. A clean cache line (such as I-cache) can be flushed by simply dropping it, no write-back necessary. Note the difference between invd
and wbinvd
. The invd
docs use "flush" as a synonym for "invalidate". (related: What use is the INVD instruction?)
From Intel's vol.2 ISA ref manual entry for clflush
The CLFLUSH instruction can be used at all privilege levels and is subject to all permission checking and faults associated with a byte load (and in addition, a CLFLUSH instruction is allowed to flush a linear address in an execute-only segment). Like a load, the CLFLUSH instruction sets the A bit but not the D bit in the page tables.
This doesn't explicitly say that it actually flushes I-cache in such regions, but it implies that flushing is relevant for such cases where data accesses aren't even possible.
Semi-related: Flush iCache in x86