"Beyond Stupid" Paranoid L1d Cache Flushing Looks Like It Will Try Again For Linux 5.15

Written by Michael Larabel in Linux Security on 28 July 2021 at 09:30 AM EDT. 18 Comments
The work going on for over a year to optionally flush the L1 data cache on context switching is going to try again for the next kernel cycle as an opt-in feature for select tasks. This was the feature rejected last year by Linus Torvalds that went on to "beyond stupid" and other concerns about it when it was trying to be mainlined originally.

This paranoid L1d cache flushing on context switch remains an opt-in feature and led by Amazon engineers. While frequently flushing the L1 data cache leads to significant performance implications, Amazon's motivation is over the increasing number of CPU vulnerabilities with the likes of the CVE-2020-0550 improper data forwarding vulnerability and others along with concerns over other yet-to-be-found vulnerabilities.

After Linus Torvalds dismissed the functionality last year, the L1d cache flushing patches were revised for better handling where some CPU cores may have SMT/HT disabled. This functionality also won't be available unless the kernel is booted with a special flag to enable it, while still needing to opt-in to the L1d flushing at context switch on a per-task basis via the prctl() interface. Further, the L1d flushing feature will be disabled for CPUs not affected by the Intel L1TF "Foreshadow" vulnerability. The software flushing of the L1d is no longer supported/used by this feature.

So in recap the current paranoid L1d flushing code will flush out the L1 data cache when a task is scheduled out and the incoming task is from a different process and only in cases where there is hardware-based L1d flushing available for vulnerable processors. The kernel must be booted with "l1d_flush=on" and then tasks can use PR_SPEC_L1D_FLUSH with prctl to enable the mitigation. By default there is no change to the kernel behavior.

The paranoid L1d flushing patches were queued up this morning via tip.git's x86/cpu branch which unless reverted in turn will be sent in for the Linux 5.15 merge window opening up around the start of September -- we'll see what Linus Torvalds thinks of the feature in its current form.
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