Linux Kernel Patches Updated for x86/x86_64 SLS Mitigation
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.