linux-um archives
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: x86@kernel.org, linux-um@lists.infradead.org,
	linux-raid@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 4/8] lib/crypto: x86: Stop using cpu_has_xfeatures()
Date: Thu, 30 Jul 2026 23:47:42 +0000	[thread overview]
Message-ID: <20260730234742.GB2459987@google.com> (raw)
In-Reply-To: <20260730231944.GLamvcEBNkNIXjQt26@fat_crate.local>

On Thu, Jul 30, 2026 at 04:19:44PM -0700, Borislav Petkov wrote:
> 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 <ebiggers@kernel.org>
> > ---
> >  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.

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, as they just check the features once at module init time to toggle
static keys.

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.

After that, there would be a mix of both versions.  So sure, it could
make sense to use cpu_feature_enabled() everywhere anyway, even when not
helpful.  I'm not sure it's clearly better than the status quo, though.

- Eric


  reply	other threads:[~2026-07-30 23:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  2:15 [PATCH v2 0/8] x86: Remove cpu_has_xfeatures() and add AVX-512 xor_gen() Eric Biggers
2026-07-28  2:15 ` [PATCH v2 1/8] x86/fpu: Check for missing AVX and AVX-512 xstate bits Eric Biggers
2026-07-28  5:27   ` Borislav Petkov
2026-07-28  5:45     ` Eric Biggers
2026-07-28 18:20       ` Borislav Petkov
2026-07-28 18:34         ` Eric Biggers
2026-07-28 22:59           ` Borislav Petkov
2026-07-28 23:34             ` Eric Biggers
2026-07-28 23:47               ` Borislav Petkov
2026-07-28  9:23     ` David Laight
2026-07-28 22:35   ` Thomas Gleixner
2026-07-28  2:15 ` [PATCH v2 2/8] um: " Eric Biggers
2026-07-30 23:06   ` Borislav Petkov
2026-07-28  2:15 ` [PATCH v2 3/8] crypto: x86 - Stop using cpu_has_xfeatures() Eric Biggers
2026-07-28  9:30   ` David Laight
2026-07-28 23:40     ` Eric Biggers
2026-07-28  2:15 ` [PATCH v2 4/8] lib/crypto: x86: " Eric Biggers
2026-07-30 23:19   ` Borislav Petkov
2026-07-30 23:47     ` Eric Biggers [this message]
2026-07-28  2:16 ` [PATCH v2 5/8] lib/crc: " Eric Biggers
2026-07-28  2:16 ` [PATCH v2 6/8] x86/fpu: Remove cpu_has_xfeatures() Eric Biggers
2026-07-28  2:16 ` [PATCH v2 7/8] lib/raid/xor: x86: Remove redundant X86_FEATURE_OSXSAVE check Eric Biggers
2026-07-28  3:41   ` Christoph Hellwig
2026-07-28  2:16 ` [PATCH v2 8/8] lib/raid/xor: x86: Add AVX-512 optimized xor_gen() Eric Biggers
2026-07-28  3:44   ` Christoph Hellwig
2026-07-28  3:44 ` [PATCH v2 0/8] x86: Remove cpu_has_xfeatures() and add AVX-512 xor_gen() Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260730234742.GB2459987@google.com \
    --to=ebiggers@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=hch@lst.de \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox