On 2025-07-23 at 07:08:43 -0700, H. Peter Anvin wrote:
On 2025-07-23 02:22, Maciej Wieczor-Retman wrote:
arch/x86/kernel/cpu/common.c | 12 ++++++++++++ arch/x86/tools/cpufeaturemasks.awk | 8 ++++++++ 2 files changed, 20 insertions(+)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 77afca95cced..ba8b5fba8552 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1709,6 +1709,16 @@ static void __init cpu_parse_early_param(void) } } +static __init void init_cpu_cap(struct cpuinfo_x86 *c) +{
- int i;
- for (i = 0; i < NCAPINTS; i++) {
cpu_caps_set[i] = REQUIRED_MASK(i);
cpu_caps_cleared[i] = DISABLED_MASK(i);
- }
+}
No... just use an static array initializer for cpu_caps_cleared[]. You don't even need to add any code at all.
Oh, right, that seems simpler
Ironically enough, I actually had those macros generated in the original awk script version, but they weren't used.
And you MUST NOT initialize cpu_caps_set[].
After thinking about it more I can see why doing that could be a problem, yes.
What we *can* and probably should do is, at the very end of the process, verify that the final mask conforms to cpu_caps_set[] and print a nasty message and set the TAINT_CPU_OUT_OF_SPEC flag:
add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK)
Where would that end be though? End of identify_cpu()? apply_forced_caps() is almost at the end of the function, and other functions don't seem to modify x86_cpuinfo or cpu_caps_set[].
... but that is a separate patch, and doesn't need to be backported.
Xin send me a patch privately (attached) but it needs to have the REQUIRED_MASK_INIT_VALUES part removed and made into a proper patch.
Xin didn't add an SoB on it, but you can use mine:
Signed-off-by: H. Peter Anvin (Intel) hpa@zytor.com
Thanks, I'll work with that.
-hpa