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 4/8] lib/crypto: x86/sha512: Keep XMM_QWORD_BSWAP in %xmm14 across blocks
Date: Sat, 21 Nov 2026 18:20:26 -0800 [thread overview]
Message-ID: <20261122022030.296468-5-ebiggers@kernel.org> (raw)
In-Reply-To: <20261122022030.296468-1-ebiggers@kernel.org>
Load the byte-swap shuffle mask into a free XMM register once before the
block loop instead of reloading it from memory on every block.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
lib/crypto/x86/sha512-ssse3-asm.S | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/crypto/x86/sha512-ssse3-asm.S b/lib/crypto/x86/sha512-ssse3-asm.S
index f2a43c4ac8bec..d40a3361aefeb 100644
--- a/lib/crypto/x86/sha512-ssse3-asm.S
+++ b/lib/crypto/x86/sha512-ssse3-asm.S
@@ -85,6 +85,7 @@ XW4 = %xmm10
XW5 = %xmm11
XW6 = %xmm12
XW7 = %xmm13
+XBSWAP = %xmm14 # XMM_QWORD_BSWAP
# Useful QWORD "arrays" for simpler memory references
# MSG, DIGEST, K_t are arrays
@@ -301,6 +302,8 @@ SYM_FUNC_START(sha512_transform_ssse3)
push msglen
push digest
+ movdqa XMM_QWORD_BSWAP(%rip), XBSWAP
+
.Lupdateblock:
# Load state variables
@@ -314,15 +317,14 @@ SYM_FUNC_START(sha512_transform_ssse3)
mov DIGEST(7), h_64
# Rounds 0 - 13: BSWAP W[0..15] into XW0..XW7 and compute rounds 0..13.
- movdqa XMM_QWORD_BSWAP(%rip), %xmm1
movdqu MSG(0), XW0
- pshufb %xmm1, XW0 # BSWAP
+ pshufb XBSWAP, XW0 # BSWAP
movdqa XW0, XWK
paddq K_t(0), XWK # Compute W[0..1]+K[0..1]
t = 2
.irp reg, XW1,XW2,XW3,XW4,XW5,XW6,XW7
movdqu MSG(t), \reg
- pshufb %xmm1, \reg # BSWAP
+ pshufb XBSWAP, \reg # BSWAP
SHA512_Round (t-2) # Round t-2
movdqa \reg, %xmm0
paddq K_t(t), %xmm0 # Compute W[t]+K[t]
--
2.56.1
next prev parent reply other threads:[~2026-11-22 2:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 2:20 [PATCH 0/8] lib/crypto: De-bloat and optimize sha512-ssse3-asm.S Eric Biggers
2026-11-22 2:20 ` [PATCH 1/8] lib/crypto: x86/sha512: Partially roll up sha512_transform_ssse3() Eric Biggers
2026-11-22 2:20 ` [PATCH 2/8] lib/crypto: x86/sha512: Keep message schedule in XMM registers Eric Biggers
2026-11-22 2:20 ` [PATCH 3/8] lib/crypto: x86/sha512: Keep W[t]+K[t] in %xmm5 instead of stack Eric Biggers
2026-11-22 2:20 ` Eric Biggers [this message]
2026-11-22 2:20 ` [PATCH 5/8] lib/crypto: x86/sha512: Use pshufb for ror64(x, 8) in SSSE3 s0 Eric Biggers
2026-11-22 2:20 ` [PATCH 6/8] lib/crypto: x86/sha512: Keep state in registers across blocks in SSSE3 Eric Biggers
2026-11-22 2:20 ` [PATCH 7/8] lib/crypto: x86/sha512: Shorten critical-path additions " Eric Biggers
2026-11-22 2:20 ` [PATCH 8/8] lib/crypto: x86/sha512: Use local labels for data 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=20261122022030.296468-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox