Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH 0/3] crc, crypto: Opt out of initializing MXCSR and 387 state
@ 2026-11-05  0:55 Eric Biggers
  2026-11-05  0:55 ` [PATCH 1/3] lib/crc: x86: " Eric Biggers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Biggers @ 2026-11-05  0:55 UTC (permalink / raw)
  To: linux-crypto
  Cc: Ard Biesheuvel, Jason A . Donenfeld, Herbert Xu, x86,
	Eric Biggers

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-05  0:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-05  0:55 ` [PATCH 2/3] lib/crypto: " Eric Biggers
2026-11-05  0:55 ` [PATCH 3/3] crypto: x86 - " Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox