OSDN Git Service

crypto: arm64/aes-ctr - improve tail handling
authorArd Biesheuvel <ardb@kernel.org>
Thu, 17 Dec 2020 18:55:16 +0000 (19:55 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 2 Jan 2021 21:41:37 +0000 (08:41 +1100)
commit5318d3db465d29efe97b0e18da29ad95156e6142
tree6af228ab6514eda25d6ff44c4b18d5a79a0b2818
parent15deb4333cd6d4e1e3216582e4c531ec40a6b060
crypto: arm64/aes-ctr - improve tail handling

Counter mode is a stream cipher chaining mode that is typically used
with inputs that are of arbitrarily length, and so a tail block which
is smaller than a full AES block is rule rather than exception.

The current ctr(aes) implementation for arm64 always makes a separate
call into the assembler routine to process this tail block, which is
suboptimal, given that it requires reloading of the AES round keys,
and prevents us from handling this tail block using the 5-way stride
that we use for better performance on deep pipelines.

So let's update the assembler routine so it can handle any input size,
and uses NEON permutation instructions and overlapping loads and stores
to handle the tail block. This results in a ~16% speedup for 1420 byte
blocks on cores with deep pipelines such as ThunderX2.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm64/crypto/aes-glue.c
arch/arm64/crypto/aes-modes.S