Linux Kernel Patches Updated for x86/x86_64 SLS Mitigation

Written by Michael Larabel in Linux Kernel on 20 November 2021 at 05:34 AM EST. 3 Comments
With GCC 12 having added a new option to enable Straight Line Speculation "SLS" mitigation for x86/x86_64 CPUs, Linux kernel developers are preparing to enable this new compiler feature for further reducing undesirable speculation exposure.

GCC 12 landed the -mharden-sls= option this week for x86/86_64 after Arm merged its Straight-Line Speculation mitigation to the open-source code compilers last year. The -mharden-sls= option supports values of none, all, return, or indirect-branch. The behavior mitigates against straight-line speculation of speculatively executing instructions linearly in memory past an unconditional change in control flow.

The kernel patch sent out on Friday proposes adding straight-line speculation mitigation handling and can be configured via the SLS Kconfig switch.

The compiler-based mitigation is handled by adding an INT3 instruction after function returns and indirect branches. As such, the generated Linux kernel image with SLS mitigations enabled may be larger by ~2.4%.

Another kernel patch proposes flipping on "-mindirect-branch-cs-prefix" that is new for GCC 12 as well and would be on by default for Retpoline-enabled kernel builds. The option should allow for fully inlining the AMD Retpoline configuration for the GCC 12+ kernel builds.

The LLVM Clang compiler is in the process of supporting these same options as well.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via

Popular News This Week