]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
crypto: x86/aes-ni-xts - use direct calls to and 4-way stride
authorArd Biesheuvel <ardb@kernel.org>
Thu, 31 Dec 2020 16:41:54 +0000 (17:41 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 23 Apr 2021 09:48:29 +0000 (11:48 +0200)
commit3ea592b76abc8a7f9cefb9aec7ce845df85285e4
tree095fc037aa86c545457e57a6abe9d18bb0cdac27
parentc000b6fc36af85d1fa6b2b37be9cdb3a692fcaf5
crypto: x86/aes-ni-xts - use direct calls to and 4-way stride

BugLink: https://bugs.launchpad.net/bugs/1923210
commit 86ad60a65f29dd862a11c22bb4b5be28d6c5cef1 upstream.

The XTS asm helper arrangement is a bit odd: the 8-way stride helper
consists of back-to-back calls to the 4-way core transforms, which
are called indirectly, based on a boolean that indicates whether we
are performing encryption or decryption.

Given how costly indirect calls are on x86, let's switch to direct
calls, and given how the 8-way stride doesn't really add anything
substantial, use a 4-way stride instead, and make the asm core
routine deal with any multiple of 4 blocks. Since 512 byte sectors
or 4 KB blocks are the typical quantities XTS operates on, increase
the stride exported to the glue helper to 512 bytes as well.

As a result, the number of indirect calls is reduced from 3 per 64 bytes
of in/output to 1 per 512 bytes of in/output, which produces a 65% speedup
when operating on 1 KB blocks (measured on a Intel(R) Core(TM) i7-8650U CPU)

Fixes: 9697fa39efd3f ("x86/retpoline/crypto: Convert crypto assembler indirect jumps")
Tested-by: Eric Biggers <ebiggers@google.com> # x86_64
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[ardb: rebase onto stable/linux-5.4.y]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/crypto/aesni-intel_asm.S
arch/x86/crypto/aesni-intel_glue.c