Skip to content

crypto: x86 - stop using the SIMD helper

Eric Biggers linux-crypto lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest posting 2/29 patches 13 repliesIn review
  2. v2 posting 1/21 patch 0 repliesSuperseded
  3. v11 patch 0 repliesSuperseded

Patches in v2 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9crypto: x86/aes - drop the avx10_256 AES-XTS and AES-CTR codearch/x86/crypto/aes-ctr-avx-x86_64.S arch/x86/crypto/aes-xts-avx-x86_64.S arch/x86/crypto/aesni-intel_glue.c+74 -1210 replies
2/9crypto: x86/aegis - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/aegis128-aesni-glue.c+4 -100 replies
3/9crypto: x86/aes - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/aesni-intel_glue.c+59 -1000 replies
4/9crypto: x86/aria - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/aria_aesni_avx2_glue.c arch/x86/crypto/aria_aesni_avx_glue.c +1 more+20 -470 replies
5/9crypto: x86/camellia - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/camellia_aesni_avx2_glue.c arch/x86/crypto/camellia_aesni_avx_glue.c+14 -290 replies
6/9crypto: x86/cast - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/cast5_avx_glue.c arch/x86/crypto/cast6_avx_glue.c+13 -300 replies
7/9crypto: x86/serpent - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/serpent_avx2_glue.c arch/x86/crypto/serpent_avx_glue.c +1 more+21 -450 replies
8/9crypto: x86/sm4 - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/sm4_aesni_avx2_glue.c arch/x86/crypto/sm4_aesni_avx_glue.c+22 -420 replies
9/9crypto: x86/twofish - stop using the SIMD helperarch/x86/crypto/Kconfig arch/x86/crypto/twofish_avx_glue.c+7 -150 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/9] crypto: x86 - stop using the SIMD helper

Patches 2-9 are almost identical to
https://lore.kernel.org/r/[email protected]/
but now split into multiple patches. Patch 1 is just a resend of
https://lore.kernel.org/r/[email protected]/
which is needed for the series to apply cleanly but is otherwise unrelated. Description of patches 2-9 follows:

Stop wrapping skcipher and aead algorithms with the crypto SIMD helper (crypto/simd.c). The only purpose of doing so was to work around x86 not always supporting kernel-mode FPU in softirqs. Specifically, if a hardirq interrupted a task context kernel-mode FPU section and then a softirqs were run at the end of that hardirq, those softirqs could not use kernel-mode FPU. This has now been fixed. In combination with the fact that the skcipher and aead APIs only support task and softirq contexts, these can now just use kernel-mode FPU unconditionally on x86.

This simplifies the code and improves performance.

En/decryption gets at least somewhat faster for everyone, since the crypto API functions such as crypto_skcipher_encrypt() now go directly to the underlying algorithm rather than taking a detour through crypto/simd.c which involved an extra indirect call. For example, on a Ryzen 9 9950X desktop processor, AES-256-XTS is now 23% faster for 512-byte messages and 7% faster for 4096-byte messages (when accessed through crypto_skcipher_encrypt() or crypto_skcipher_decrypt()).

There's also a much larger performance improvement for crypto API users that only support synchronous algorithms. These users will now actually use the x86 SIMD (e.g. AES-NI or VAES) optimized en/decryption modes, which they couldn't before because they were marked as asynchronous.

Eric Biggers (9):
crypto: x86/aes - drop the avx10_256 AES-XTS and AES-CTR code
crypto: x86/aegis - stop using the SIMD helper
crypto: x86/aes - stop using the SIMD helper
crypto: x86/aria - stop using the SIMD helper
crypto: x86/camellia - stop using the SIMD helper
crypto: x86/cast - stop using the SIMD helper
crypto: x86/serpent - stop using the SIMD helper
crypto: x86/sm4 - stop using the SIMD helper
crypto: x86/twofish - stop using the SIMD helper

 arch/x86/crypto/Kconfig                    |  14 --
 arch/x86/crypto/aegis128-aesni-glue.c      |  13 +-
 arch/x86/crypto/aes-ctr-avx-x86_64.S       |  47 ++----
 arch/x86/crypto/aes-xts-avx-x86_64.S       | 118 ++++++--------
 arch/x86/crypto/aesni-intel_glue.c         | 174 ++++++++-------------
 arch/x86/crypto/aria_aesni_avx2_glue.c     |  22 +--
 arch/x86/crypto/aria_aesni_avx_glue.c      |  20 +--
 arch/x86/crypto/aria_gfni_avx512_glue.c    |  22 +--
 arch/x86/crypto/camellia_aesni_avx2_glue.c |  21 +--
 arch/x86/crypto/camellia_aesni_avx_glue.c  |  21 +--
 arch/x86/crypto/cast5_avx_glue.c           |  21 +--
 arch/x86/crypto/cast6_avx_glue.c           |  20 +--
 arch/x86/crypto/serpent_avx2_glue.c        |  21 +--
 arch/x86/crypto/serpent_avx_glue.c         |  21 +--
 arch/x86/crypto/serpent_sse2_glue.c        |  21 +--
 arch/x86/crypto/sm4_aesni_avx2_glue.c      |  31 ++--
 arch/x86/crypto/sm4_aesni_avx_glue.c       |  31 ++--
 arch/x86/crypto/twofish_avx_glue.c         |  21 +--
 18 files changed, 227 insertions(+), 432 deletions(-)

base-commit: 91e5bfe317d8f8471fbaa3e70cf66cae1314a516

Signature · 1 line
2.49.0