All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	x86@kernel.org
Subject: Re: [PATCH 3/3] crypto: x86 - Opt out of initializing MXCSR and 387 state
Date: Sat, 7 Nov 2026 13:57:42 -0800	[thread overview]
Message-ID: <20261107215742.GK137269@quark> (raw)
In-Reply-To: <20261105005523.84925-4-ebiggers@kernel.org>

On Wed, Nov 04, 2026 at 04:55:23PM -0800, Eric Biggers wrote:
> The crypto code using "kernel-mode FPU" is integer code that does not
> use any MMX or x87 instructions.  To the extent that float-domain
> instructions are used at all, they are only moves and shuffles, neither
> of which raises SIMD floating-point exceptions or depends on MXCSR.
> 
> Therefore, there's no need to initialize MXCSR or the 387 FPU state.
> 
> Opt out of this initialization by using kernel_fpu_begin_mask(0) instead
> of kernel_fpu_begin().  This eliminates an 'ldmxcsr' instruction in
> every kernel-mode FPU section, reducing overhead, which matters most for
> short input lengths.  On 32-bit kernels it also eliminates 'fninit'.
> 
> A precedent for this optimization can be found in
> commit a58db7ad80e8 ("netfilter: nft_set_pipapo_avx2: Skip LDMXCSR, we
> don't need a valid MXCSR state").
> 
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
>  arch/x86/crypto/aegis128-aesni-glue.c   |  6 +++---
>  arch/x86/crypto/aesni-intel_glue.c      | 10 +++++-----
>  arch/x86/crypto/aria_aesni_avx2_glue.c  |  4 ++--
>  arch/x86/crypto/aria_aesni_avx_glue.c   |  2 +-
>  arch/x86/crypto/aria_gfni_avx512_glue.c |  6 +++---
>  arch/x86/crypto/ecb_cbc_helpers.h       |  2 +-
>  arch/x86/crypto/sm4_aesni_avx_glue.c    |  6 +++---
>  7 files changed, 18 insertions(+), 18 deletions(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

Reviews and acks appreciated!

- Eric

      reply	other threads:[~2026-11-07 21:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  0:55 [PATCH 0/3] crc, crypto: Opt out of initializing MXCSR and 387 state Eric Biggers
2026-11-05  0:55 ` [PATCH 1/3] lib/crc: x86: " Eric Biggers
2026-11-07 21:34   ` Eric Biggers
2026-11-05  0:55 ` [PATCH 2/3] lib/crypto: " Eric Biggers
2026-11-07 21:56   ` Eric Biggers
2026-11-05  0:55 ` [PATCH 3/3] crypto: x86 - " Eric Biggers
2026-11-07 21:57   ` Eric Biggers [this message]

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=20261107215742.GK137269@quark \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.