Why is it needed after modifying code?
Data-store visibility does not automatically make new instructions visible to the instruction-fetch path; FENCE.I is the local synchronization point.
Synchronize instruction and data streams; ensure subsequent instruction fetches observe prior data stores (for self-modifying code and JIT)
FENCE.I (opcode=MISC-MEM, funct3=001) from the Zifencei extension synchronizes instruction and data streams. Instruction fetches initiated after FENCE.I will observe any prior data stores to instruction memory. Essential for self-modifying code, JIT compilation, and dynamic code generation. Unlike FENCE (data ordering), FENCE.I is specifically for instruction-data serialization.
FENCE.I synchronizes prior data stores with subsequent instruction fetches on the current hart, so self-modified or generated code can be seen by later instruction fetches on that hart.
Understand this scenario with real code like «fence.i # sync instruction fetch with prior data stores».
Understand this scenario with real code like «fence.i # sync instruction fetch with prior data stores».
Understand this scenario with real code like «fence.i # sync instruction fetch with prior data stores».
Data-store visibility does not automatically make new instructions visible to the instruction-fetch path; FENCE.I is the local synchronization point.
No. Address-translation synchronization uses SFENCE.VMA or related privileged invalidation sequences.