[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <oniuohiub4q75xwflf2nsz32aackbt3yrdweg2y6wimbzz5nvv@yxf2xnl7cgcn>
Date: Tue, 22 Jul 2025 20:19:11 +0200
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: "H. Peter Anvin" <hpa@...or.com>
CC: Xin Li <xin@...or.com>, Gleixner Thomas <tglx@...utronix.de>, Molnar Ingo
<mingo@...hat.com>, Petkov Borislav <bp@...en8.de>, Hansen Dave
<dave.hansen@...ux.intel.com>, <x86@...nel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86: Clear LAM and FRED feature bits
On 2025-07-22 at 09:46:42 -0700, H. Peter Anvin wrote:
>On July 22, 2025 2:08:28 AM PDT, Xin Li <xin@...or.com> wrote:
>>> On Jul 22, 2025, at 12:54 AM, Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com> wrote:
>>> ---
>>> arch/x86/kernel/cpu/common.c | 10 ++++++++++
>>> 1 file changed, 10 insertions(+)
>>>
>>> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
>>> index 77afca95cced..1c5af795cedc 100644
>>> --- a/arch/x86/kernel/cpu/common.c
>>> +++ b/arch/x86/kernel/cpu/common.c
>>> @@ -1782,6 +1782,16 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
>>> if (!pgtable_l5_enabled())
>>> setup_clear_cpu_cap(X86_FEATURE_LA57);
>>>
>>> + /*
>>> + * 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).
>>
>>Thanks!
>> Xin
>
>The easiest thing would be to initialize the setup disabled mask with the
>DISABLED bitmask instead of zero. This can be done statically; if it isn't
>already the awk script can produce the disabled bitmask in array form.
Oh, that does sound simple. I'll try that too, see what ends up with cleaner
code.
Thanks :)
--
Kind regards
Maciej Wieczór-Retman
Powered by blists - more mailing lists