x86 assembler's -mlfence-after-load option refined
Assembler logic for -mlfence-after-load is corrected to exclude non-impactful instructions and obsolete encodings.
The x86 assembler’s handling of the -mlfence-after-load option has been refined to accurately identify instructions that require an lfence. This change excludes instructions like POP, NOT, and certain shift operations with memory operands that do not affect subsequent memory accesses. It also removes support for obsolete alias encodings and simplifies checks related to VEX prefixes and instruction sizes, improving correctness.
In Details
The load_insn_p function in the x86 assembler's i386 backend has been adjusted to correctly identify loads that may affect speculative execution or subsequent memory accesses, particularly in the context of microarchitectural vulnerabilities. This commit refines the conditions under which lfence is inserted by the -mlfence-after-load option, excluding instructions that do not alter registers relevant to address calculations (e.g., POP, NOT, shifts with memory operands) and dropping support for aliased opcodes and unnecessary VEX checks.
- -mlfence-after-load
- An assembler option for x86 that controls the insertion of
lfence(load fence) instructions after certain memory load instructions. This is primarily to mitigate speculative execution vulnerabilities. - lfence
- An x86 instruction that acts as a barrier, ensuring that all loads that precede it complete before any subsequent loads are initiated. Used for security and performance predictability.
- VEX prefix
- A prefix used in x86 instruction encoding to support advanced features like wider vector registers (256-bit and 512-bit) and new instruction sets. It also influences instruction decoding and behavior.