Improved Retpoline Code Staged Ahead Of Linux 5.16

Written by Michael Larabel in Linux Security on 29 October 2021 at 05:45 AM EDT. Add A Comment
LINUX SECURITY
A set of patches improving the return trampoline "Retpoline" code used for Spectre V2 mitigations has made its way into tip.git's "objtool/core" staging area ahead of the upcoming Linux 5.16 merge window.

These Linux Retpoline patches are the work covered earlier this month on Phoronix around rewriting the Retpoline rewrite code.

The new code ensures that the Retpolines are rewritten to indirect instructions for cases where Retpoline is not enable, and rewriting to indirect LFENCE for the AMD Retpoline handling where size allows by the compiler. The x86 BPF code is also updated to match the behavior of the rest of the kernel around Retpolines -- previously the BPF code wasn't checking the X86_FEATURE_RETPOLINE flags but unconditionally emitting a thunk call. With the rewritten code it also makes running with the "spectre_v2=off" boot option closer to the kernel image if building the kernel without the RETPOLINE Kconfig option enabled. The exciting part is a possible (small) performance improvement by removing an indirection from the code.

The set of Retpoline improvement patches as of yesterday are now in TIP's objtool/core ahead of the Linux 5.16 merge window.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com 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 OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week