]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: arm64/aes-ce - Simplify round key load sequence
authorArd Biesheuvel <ardb@kernel.org>
Mon, 15 Apr 2024 13:04:26 +0000 (15:04 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Apr 2024 09:26:09 +0000 (17:26 +0800)
commit571e557cbaf748124aaf0f0ac26772d7380e78fc
treee389c6402d42783ca2c0bfa818457baa238ce080
parent3f4d1482dad9a87c3bf00490fcf339cb5f6d53a8
crypto: arm64/aes-ce - Simplify round key load sequence

Tweak the round key logic so that they can be loaded using a single
branchless sequence using overlapping loads. This is shorter and
simpler, and puts the conditional branches based on the key size further
apart, which might benefit microarchitectures that cannot record taken
branches at every instruction. For these branches, use test-bit-branch
instructions that don't clobber the condition flags.

Note that none of this has any impact on performance, positive or
otherwise (and the branch prediction benefit would only benefit AES-192
which nobody uses). It does make for nicer code, though.

While at it, use \@ to generate the labels inside the macros, which is
more robust than using fixed numbers, which could clash inadvertently.
Also, bring aes-neon.S in line with these changes, including the switch
to test-and-branch instructions, to avoid surprises in the future when
we might start relying on the condition flags being preserved in the
chaining mode wrappers in aes-modes.S

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm64/crypto/aes-ce.S
arch/arm64/crypto/aes-neon.S