Re: [PATCH v2] x86: Clear feature bits disabled at compile-time
From: H. Peter Anvin
Date: Wed Jul 23 2025 - 11:29:36 EST
On July 23, 2025 8:13:07 AM PDT, Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx> wrote:
>On 2025-07-23 at 15:46:40 +0200, Borislav Petkov wrote:
>>On Wed, Jul 23, 2025 at 11:22:49AM +0200, Maciej Wieczor-Retman wrote:
>>> +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);
>>> + }
>>> +}
>>
>>There's already apply_forced_caps(). Not another cap massaging function
>>please. Add that stuff there.
>
>I'll try that, but can't it overwrite some things? apply_forced_caps() is called
>three times and cpu_caps_set/cleared are modified in between from what I can
>see. init_cpu_cap() was supposed to only initialize these arrays.
>
>>
>>As to what the Fixes: tag should be - it should not have any Fixes: tag
>>because AFAICT, this has always been this way. So this fix should be
>>backported everywhere.
>
>I found that in 5.9-rc1 the documentation for how /proc/cpuinfo should work was
>merged [1]. I understand that from that point on, while one can't rely on a
>feature's absence, it's a reliable convention that if a flag is present, then
>the feature is working. So from 5.9 on, it seems like a bug when these features
>show up as working while they're not due to not being compiled.
>
>[1] ea4e3bef4c94 ("Documentation/x86: Add documentation for /proc/cpuinfo feature flags")
>
>>
>>Thx.
>>
>>--
>>Regards/Gruss,
>> Boris.
>>
>>https://people.kernel.org/tglx/notes-about-netiquette
>
What are you concerned it would overwrite? I'm confused.