Re: [PATCH v2 4/8] lib/crypto: x86: Stop using cpu_has_xfeatures()

From: Borislav Petkov

Date: Fri Jul 31 2026 - 00:26:56 EST


On Thu, Jul 30, 2026 at 11:47:42PM +0000, Eric Biggers wrote:
> cpu_feature_enabled() turns into an alternative (code patching), which
> doesn't make much sense in any of the places you're asking for it to be
> used,

It is the interface to use for checking X86_FEATURE flags. The fact that it
alternative-patches doesn't really matter.

> I suppose that the static keys that are conditional on only one CPU
> feature can be replaced with cpu_feature_enabled(), which should be
> equally efficient. However, many of the keys are conditional on two or
> more features.

Yes, they all can be converted to cpu_feature_enabled(). Just forget the
efficiency angle and think of this as us unifying the interfaces to a single
one instead of the zoo we have right now.

> After that, there would be a mix of both versions. So sure, it could
> make sense to use cpu_feature_enabled() everywhere anyway,

Yap, that's the goal.

> I'm not sure it's clearly better than the status quo, though.

Yes, it is. See above.

Once everything is converted, there will be a single cpu_feature_enabled() and
all users will not care whether to use boot_cpu_has(), this_cpu_has(),
cpu_has(c, ...), static_cpu_has() and so on.

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette