Linux 5.19 Makes It Much Easier To Clear CPUID Features
Written by Michael Larabel in Linux Kernel on 24 May 2022 at 02:40 PM EDT. 1 Comment
LINUX KERNEL --
The Linux x86/x86_64 kernel has long honored the "clearcpuid=" kernel parameter to disable select CPUID features from being used by the kernel or readily advertised. However, it hasn't been very intuitive to use since it relied on passing the bit numbers for the specific features. With Linux 5.19 it's much easier to deal with in now allowing the CPUID string from /proc/cpuinfo to be passed if wanting particular CPUID features disabled.

Rather annoyingly, up to now if wanting to disable select CPUID features from use by the Linux kernel, you've needed to look at the cpufeatures.h header file within the x86 area of the kernel and find the bit number for the given feature(s) you want to disable. Like, for example, disabling AVX meant setting clearcpuid=156. Even worse, some of the bit numbers aren't stable across Linux kernel versions.


Going through a header file to figure out a bit number to pass to a kernel parameter isn't exactly intuitive.


With Linux 5.19, the clearcpuid= kernel parameter can be set to strings from the flags output in /proc/cpuinfo. So rather than needing to remember numbers like clearcpuid=156, you could just do clearcpuid=avx. Multiple CPUID flags can continue to be specified via delimiting them with commas.


But with Linux 5.19+, now you can just pass it the flag values shown within /proc/cpuinfo.


This is a long overdue improvement for a kernel usability improvement for administrators and those debugging kernel behavior on their systems. The bit numbers can still be used if desired while for Linux 5.19+ the feature bit names are fair game. It's important to note though that using clearcpuid= to clear CPUID bits isn't intended for production use. User-space software calling CPUID directly or just directly using any relevant instructions will continue to work, clearcpuid= is just about avoiding the usage by the Linux kernel and removing it from the /proc/cpuinfo output too. Linux 5.19 is additionally treating the kernel as tainted when clearcpuid is in use.

This change was sent in as part of the x86/cpu updates for Linux 5.19. This pull also drops the nosep, nosmep, noexec, and noclflush kernel parameters with no longer being relevant for having said dedicated options.
Related News
About The Author
Author picture

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