Re: [PATCH] x86/cpufeatures: Free up unused feature bits
From: Dave Hansen
Date: Thu Nov 07 2024 - 20:13:01 EST
On 11/7/24 15:49, H. Peter Anvin wrote:
> Be careful - these bits are used in module strings and so modutils need to understand them.
Yeah, very true. But I didn't ever see these features get used in a
MODULE_DEVICE_TABLE(). Do you still have concerns if there was never an
in-tree user that used X86_FEATURE_P3/P4 in a MODULE_DEVICE_TABLE()?$
Sohil, go look at:
# cat /sys/devices/system/cpu/modalias
cpu:type:x86,ven0000fam0006mod008C:feature:,0000,0001,0002,0003,0004,0005,0006,...
and, for instance:
# modinfo /lib/modules/5.17.0-rc4/kernel/arch/x86/kvm/kvm-intel.ko
filename: /lib/modules/5.17.0-rc4/kernel/arch/x86/kvm/kvm-intel.ko
license: GPL
author: Qumranet
srcversion: ED99EA15FCA9B58172BAEB4
alias: cpu:type:x86,ven*fam*mod*:feature:*0085*
Those magic strings get matched up by udev (I think) to auto-load
modules when the CPU 'modalias' matches the module 'alias'. Let's say
we had an ooooooooold module that did this:
#ifdef MODULE
static const struct x86_cpu_id foo_cpu_id[] = {
X86_MATCH_FEATURE(X86_FEATURE_P3, NULL),
{}
};
MODULE_DEVICE_TABLE(x86cpu, foo_cpu_id);
#endif
which generated a modalias like this:
alias: cpu:type:x86,ven*fam*mod*:feature:*0067*
and then we recycled number 67:
-#define X86_FEATURE_P3 ( 3*32+ 6) /* P3 */
+#define X86_FEATURE_WHIZZY_NEW_FEATURE ( 3*32+ 6) /* P3 */
udev might try to load the old module on a new CPU with
X86_FEATURE_WHIZZY_NEW_FEATURE that's not a P3.
I sure hope we haven't been using too many of these synthetic features
in MODULE_DEVICE_TABLE()s, because we tend to move them around, but I
guess it's possible.