Skip to contentSkip to conversation

lib/crypto: x86/blake2s: Drop redundant checks for AVX and AVX512F

PATCH Applied Eric Biggers 2 participants 3 messages Nov 11 – Nov 14

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crypto: x86/blake2s: Drop redundant checks for AVX and AVX512F

X86_FEATURE_AVX2 implies X86_FEATURE_AVX. Similarly, X86_FEATURE_AVX512VL implies X86_FEATURE_AVX512F (and X86_FEATURE_AVX).

Simplify blake2s_mod_init_arch() accordingly. Also nest these checks under the block that sets the static key for blake2s_use_ssse3, mirroring the code that uses these static keys.

(Note: as usual, arch/x86/kernel/cpu/cpuid-deps.c is non-enforcing: if a dependency isn't met, it warns and doesn't prevent booting. However, that case doesn't occur in real CPUs and is unsupported.)

---
 lib/crypto/x86/blake2s.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
lib/crypto/x86/blake2s.h +5 -7
index 952db559eed34..e504279a2fa38 100644
@@ -49,12 +49,10 @@ static void blake2s_compress(struct blake2s_ctx *ctx,
 #define blake2s_mod_init_arch blake2s_mod_init_arch
 static void blake2s_mod_init_arch(void)
 {
-	if (boot_cpu_has(X86_FEATURE_SSSE3))
+	if (boot_cpu_has(X86_FEATURE_SSSE3)) {
 		static_branch_enable(&blake2s_use_ssse3);
-
-	if (boot_cpu_has(X86_FEATURE_AVX) &&
-	    boot_cpu_has(X86_FEATURE_AVX2) &&
-	    boot_cpu_has(X86_FEATURE_AVX512F) &&
-	    boot_cpu_has(X86_FEATURE_AVX512VL))
-		static_branch_enable(&blake2s_use_avx512);
+		if (boot_cpu_has(X86_FEATURE_AVX2) &&
+		    boot_cpu_has(X86_FEATURE_AVX512VL))
+			static_branch_enable(&blake2s_use_avx512);
+	}
 }

base-commit: 33b4f31b1aea3f62b61c892daefc0e6a77859032

Signature · 1 line
2.56.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Eric Biggers

X86_FEATURE_AVX2 implies X86_FEATURE_AVX. Similarly, X86_FEATURE_AVX512VL implies X86_FEATURE_AVX512F (and X86_FEATURE_AVX).

Simplify blake2s_mod_init_arch() accordingly. Also nest these checks under the block that sets the static key for blake2s_use_ssse3, mirroring the code that uses these static keys.

Quoted 9 lines

(Note: as usual, arch/x86/kernel/cpu/cpuid-deps.c is non-enforcing: if a dependency isn't met, it warns and doesn't prevent booting. However, that case doesn't occur in real CPUs and is unsupported.)

---
 lib/crypto/x86/blake2s.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
author maintainer Applied
#2 lore raw
In reply to Eric Biggers
Quoted 7 lines · Eric Biggers

X86_FEATURE_AVX2 implies X86_FEATURE_AVX. Similarly, X86_FEATURE_AVX512VL implies X86_FEATURE_AVX512F (and X86_FEATURE_AVX).

Simplify blake2s_mod_init_arch() accordingly. Also nest these checks under the block that sets the static key for blake2s_use_ssse3, mirroring the code that uses these static keys.

Quoted 8 lines

(Note: as usual, arch/x86/kernel/cpu/cpuid-deps.c is non-enforcing: if a dependency isn't met, it warns and doesn't prevent booting. However, that case doesn't occur in real CPUs and is unsupported.)

---
 lib/crypto/x86/blake2s.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric