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, Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 0/3] crc, crypto: Opt out of initializing MXCSR and 387 state
Date: Wed,  4 Nov 2026 16:55:20 -0800	[thread overview]
Message-ID: <20261105005523.84925-1-ebiggers@kernel.org> (raw)

This series is targeting libcrypto-next.

The crypto and CRC 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").

Eric Biggers (3):
  lib/crc: x86: Opt out of initializing MXCSR and 387 state
  lib/crypto: x86: Opt out of initializing MXCSR and 387 state
  crypto: x86 - Opt out of initializing MXCSR and 387 state

 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 +++---
 lib/crc/x86/crc-pclmul-template.h       | 18 +++++++++---------
 lib/crc/x86/crc32.h                     |  2 +-
 lib/crypto/x86/aes.h                    | 24 ++++++++++++------------
 lib/crypto/x86/blake2s.h                |  2 +-
 lib/crypto/x86/chacha.h                 |  4 ++--
 lib/crypto/x86/gf128hash.h              |  8 ++++----
 lib/crypto/x86/nh.h                     |  2 +-
 lib/crypto/x86/poly1305.h               |  2 +-
 lib/crypto/x86/sha1.h                   |  4 ++--
 lib/crypto/x86/sha256.h                 |  4 ++--
 lib/crypto/x86/sha512.h                 |  2 +-
 lib/crypto/x86/sm3.h                    |  2 +-
 19 files changed, 55 insertions(+), 55 deletions(-)


base-commit: 9fbbbaefd5f95551da18426c200cf41e1b4255a1
-- 
2.56.0


             reply	other threads:[~2026-11-05  0:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  0:55 Eric Biggers [this message]
2026-11-05  0:55 ` [PATCH 1/3] lib/crc: x86: Opt out of initializing MXCSR and 387 state 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

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=20261105005523.84925-1-ebiggers@kernel.org \
    --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.