GCC Compiler Lands Mitigation For Arm's Straight Line Speculation Vulnerability
It took a month after Arm disclosed the CPU "SLS" vulnerability and when the LLVM compiler landed their initial mitigation, but the GNU Compiler Collection (GCC) now has mitigations as well for this Straight Line Speculation vulnerability.
The Straight Line Speculation vulnerability could lead to instructions on ARMv8 processors being executed following a change in control flow. Mitigating SLS involves using SB instructions for a speculation barrier following vulnerable instructions.
Arm has merged into GCC Git today its initial SLS mitigation covering RET and BR instructions. The SB instruction is used on supported SoCs for the speculation barrier otherwise a DSB SY + ISB sequence. Another commit mitigated SLS for the BLR instruction.
Enabling the Arm SLS mitigation for GCC can be done with the -mharden-sls= where a value of "all" mitigates all vulnerable instructions, "retbr" to insert speculation barriers on just RET and BR instructions, or "blr" for mitigating just BLR usage. Mitigating on a per-function basis isn't yet supported.
Benchmarks of the Arm SLS mitigation impact to come as time allows.