]> git.ipfire.org Git - thirdparty/linux.git/commit
lib/crypto: riscv/ghash: Migrate optimized code into library
authorEric Biggers <ebiggers@kernel.org>
Thu, 19 Mar 2026 06:17:13 +0000 (23:17 -0700)
committerEric Biggers <ebiggers@kernel.org>
Mon, 23 Mar 2026 23:44:29 +0000 (16:44 -0700)
commitaf413d71f09d4dde28277319926c1c3a6ec8b8d4
treefd196684b58f0b8e3610b9b7e13e03a26a873453
parent73f315c15d6ec1ef33202e7253af90dd44ff4a3b
lib/crypto: riscv/ghash: Migrate optimized code into library

Remove the "ghash-riscv64-zvkg" crypto_shash algorithm.  Move the
corresponding assembly code into lib/crypto/, modify it to take the
length in blocks instead of bytes, and wire it up to the GHASH library.

This makes the GHASH library be optimized with the RISC-V Vector
Cryptography Extension.  It also greatly reduces the amount of
riscv-specific glue code that is needed, and it fixes the issue where
this optimized GHASH code was disabled by default.

Note that this RISC-V code has multiple opportunities for improvement,
such as adding more parallelism, providing an optimized multiplication
function, and directly supporting POLYVAL.  But for now, this commit
simply tweaks ghash_zvkg() slightly to make it compatible with the
library, then wires it up to ghash_blocks_arch().

ghash_preparekey_arch() is also implemented to store the copy of the raw
key needed by the vghsh.vv instruction.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20260319061723.1140720-13-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
arch/riscv/crypto/Kconfig
arch/riscv/crypto/Makefile
arch/riscv/crypto/ghash-riscv64-glue.c [deleted file]
include/crypto/gf128hash.h
lib/crypto/Kconfig
lib/crypto/Makefile
lib/crypto/riscv/gf128hash.h [new file with mode: 0644]
lib/crypto/riscv/ghash-riscv64-zvkg.S [moved from arch/riscv/crypto/ghash-riscv64-zvkg.S with 91% similarity]