Skip to content

Commit fb5b47a

Browse files
Eric Biggersgregkh
authored andcommitted
lib/crypto: riscv: Depend on RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
commit 1cd5bb6 upstream. Replace the RISCV_ISA_V dependency of the RISC-V crypto code with RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS, which implies RISCV_ISA_V as well as vector unaligned accesses being efficient. This is necessary because this code assumes that vector unaligned accesses are supported and are efficient. (It does so to avoid having to use lots of extra vsetvli instructions to switch the element width back and forth between 8 and either 32 or 64.) This was omitted from the code originally just because the RISC-V kernel support for detecting this feature didn't exist yet. Support has now been added, but it's fragmented into per-CPU runtime detection, a command-line parameter, and a kconfig option. The kconfig option is the only reasonable way to do it, though, so let's just rely on that. Fixes: eb24af5 ("crypto: riscv - add vector crypto accelerated AES-{ECB,CBC,CTR,XTS}") Fixes: bb54668 ("crypto: riscv - add vector crypto accelerated ChaCha20") Fixes: 600a385 ("crypto: riscv - add vector crypto accelerated GHASH") Fixes: 8c8e404 ("crypto: riscv - add vector crypto accelerated SHA-{256,224}") Fixes: b341592 ("crypto: riscv - add vector crypto accelerated SHA-{512,384}") Fixes: 563a525 ("crypto: riscv - add vector crypto accelerated SM3") Fixes: b8d0635 ("crypto: riscv - add vector crypto accelerated SM4") Cc: stable@vger.kernel.org Reported-by: Vivian Wang <wangruikang@iscas.ac.cn> Closes: https://lore.kernel.org/r/b3cfcdac-0337-4db0-a611-258f2868855f@iscas.ac.cn/ Reviewed-by: Jerry Shih <jerry.shih@sifive.com> Link: https://lore.kernel.org/r/20251206213750.81474-1-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 19d61f0 commit fb5b47a

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

arch/riscv/crypto/Kconfig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ menu "Accelerated Cryptographic Algorithms for CPU (riscv)"
44

55
config CRYPTO_AES_RISCV64
66
tristate "Ciphers: AES, modes: ECB, CBC, CTS, CTR, XTS"
7-
depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
7+
depends on 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
8+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
89
select CRYPTO_ALGAPI
910
select CRYPTO_LIB_AES
1011
select CRYPTO_SKCIPHER
@@ -20,7 +21,8 @@ config CRYPTO_AES_RISCV64
2021

2122
config CRYPTO_GHASH_RISCV64
2223
tristate "Hash functions: GHASH"
23-
depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
24+
depends on 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
25+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
2426
select CRYPTO_GCM
2527
help
2628
GCM GHASH function (NIST SP 800-38D)
@@ -30,7 +32,8 @@ config CRYPTO_GHASH_RISCV64
3032

3133
config CRYPTO_SM3_RISCV64
3234
tristate "Hash functions: SM3 (ShangMi 3)"
33-
depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
35+
depends on 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
36+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
3437
select CRYPTO_HASH
3538
select CRYPTO_LIB_SM3
3639
help
@@ -42,7 +45,8 @@ config CRYPTO_SM3_RISCV64
4245

4346
config CRYPTO_SM4_RISCV64
4447
tristate "Ciphers: SM4 (ShangMi 4)"
45-
depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
48+
depends on 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
49+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
4650
select CRYPTO_ALGAPI
4751
select CRYPTO_SM4
4852
help

lib/crypto/Kconfig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ config CRYPTO_LIB_CHACHA_ARCH
5050
default y if ARM64 && KERNEL_MODE_NEON
5151
default y if MIPS && CPU_MIPS32_R2
5252
default y if PPC64 && CPU_LITTLE_ENDIAN && VSX
53-
default y if RISCV && 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
53+
default y if RISCV && 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
54+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
5455
default y if S390
5556
default y if X86_64
5657

@@ -161,7 +162,8 @@ config CRYPTO_LIB_SHA256_ARCH
161162
default y if ARM64
162163
default y if MIPS && CPU_CAVIUM_OCTEON
163164
default y if PPC && SPE
164-
default y if RISCV && 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
165+
default y if RISCV && 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
166+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
165167
default y if S390
166168
default y if SPARC64
167169
default y if X86_64
@@ -179,7 +181,8 @@ config CRYPTO_LIB_SHA512_ARCH
179181
default y if ARM && !CPU_V7M
180182
default y if ARM64
181183
default y if MIPS && CPU_CAVIUM_OCTEON
182-
default y if RISCV && 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
184+
default y if RISCV && 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \
185+
RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS
183186
default y if S390
184187
default y if SPARC64
185188
default y if X86_64

0 commit comments

Comments
 (0)