Re: [PATCH] x86: Clear LAM and FRED feature bits
From: Dave Hansen
Date: Tue Jul 22 2025 - 10:24:58 EST
On 7/22/25 02:08, Xin Li wrote:
>> + /*
>> + * If a feature is disabled during compile time clear its feature
>> + * bit to prevent it from showing up in the x86_capability bitmask.
>> + */
>> + if (!cpu_feature_enabled(X86_FEATURE_LAM))
>> + setup_clear_cpu_cap(X86_FEATURE_LAM);
>> +
>> + if (!cpu_feature_enabled(X86_FEATURE_FRED))
>> + setup_clear_cpu_cap(X86_FEATURE_FRED);
>> +
>
> The following code will work as a generic fix:
>
> c->x86_capability[i] &= ~DISABLED_MASK(i);
>
> And DISABLED_MASK(x) needs to be defined like DISABLED_MASK_BIT_SET(x).
Maciej, I would much rather have a generic fix than force everyone to
remember to open-code this for every new feature that gets disabled.