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

Borislav Petkov <[email protected]> Thu, 30 Jul 2026 16:19:44 -0700
Newsgroups gmane.linux.uml.devel,gmane.linux.raid,gmane.linux.kernel.cryptoapi,gmane.linux.kernel
Message-ID <20260730231944.GLamvcEBNkNIXjQt26@fat_crate.local>
On Mon, Jul 27, 2026 at 07:15:59PM -0700, Eric Biggers wrote:
> Checking both boot_cpu_has() and cpu_has_xfeatures() has never really
> been needed in practice, and it's never been universally done (e.g.,
> lib/raid/ omits cpu_has_xfeatures()).  Nevertheless, both x86 and UML
> now explicitly clear the AVX and AVX-512 flags if their xfeatures are
> missing, which should remove any remaining doubts.
> 
> Thus, remove all the calls to cpu_has_xfeatures().
> 
> Signed-off-by: Eric Biggers <[email protected]>
> ---
>  lib/crypto/x86/blake2s.h  | 4 +---
>  lib/crypto/x86/chacha.h   | 3 +--
>  lib/crypto/x86/nh.h       | 4 +---
>  lib/crypto/x86/poly1305.h | 7 ++-----
>  lib/crypto/x86/sha1.h     | 4 +---
>  lib/crypto/x86/sha256.h   | 4 +---
>  lib/crypto/x86/sha512.h   | 3 +--
>  lib/crypto/x86/sm3.h      | 3 +--
>  8 files changed, 9 insertions(+), 23 deletions(-)
> 
> diff --git a/lib/crypto/x86/blake2s.h b/lib/crypto/x86/blake2s.h
> index f8eed6cb042e4..0f7c51f055c8f 100644
> --- a/lib/crypto/x86/blake2s.h
> +++ b/lib/crypto/x86/blake2s.h
> @@ -55,8 +55,6 @@ static void blake2s_mod_init_arch(void)
>  	if (boot_cpu_has(X86_FEATURE_AVX) &&
>  	    boot_cpu_has(X86_FEATURE_AVX2) &&
>  	    boot_cpu_has(X86_FEATURE_AVX512F) &&
> -	    boot_cpu_has(X86_FEATURE_AVX512VL) &&
> -	    cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM |
> -			      XFEATURE_MASK_AVX512, NULL))
> +	    boot_cpu_has(X86_FEATURE_AVX512VL))
>  		static_branch_enable(&blake2s_use_avx512);
>  }

You could add a patch at the end or I can do it which does

	s/boot_cpu_has/cpu_feature_enabled/

as latter is the interface we use now everywhere.

But yeah, it should be a separate patch.

Thx.

-- 
Regards/Gruss,
    Boris.

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