Skip to contentSkip to conversation

lib/crypto: x86/nh: Remove unnecessary check for SSE2 support on x86_64

PATCH Applied Eric Biggers 1 participant 2 messages Nov 5 – Nov 7

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crypto: x86/nh: Remove unnecessary check for SSE2 support on x86_64

Remove the unnecessary check for X86_FEATURE_XMM2 (and the have_sse2 static key it controls) from the x86_64 optimized NH code.

This code is 64-bit only, and x86_64 kernels require X86_FEATURE_XMM2. (See X86_REQUIRED_FEATURE_XMM2.)

Also replace <linux/static_call.h> with <linux/jump_label.h>, since this file uses static keys, not static calls.

---
 lib/crypto/x86/nh.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
lib/crypto/x86/nh.h +4 -9
index 342636dcb750..3972c7ae28fd 100644
@@ -6,9 +6,8 @@
  */
 
 #include <asm/fpu/api.h>
-#include <linux/static_call.h>
+#include <linux/jump_label.h>
 
-static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_sse2);
 static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_avx2);
 
 asmlinkage void nh_sse2(const u32 *key, const u8 *message, size_t message_len,
@@ -19,8 +18,7 @@ asmlinkage void nh_avx2(const u32 *key, const u8 *message, size_t message_len,
 static bool nh_arch(const u32 *key, const u8 *message, size_t message_len,
 		    __le64 hash[NH_NUM_PASSES])
 {
-	if (message_len >= 64 && static_branch_likely(&have_sse2) &&
-	    irq_fpu_usable()) {
+	if (message_len >= 64 && irq_fpu_usable()) {
 		kernel_fpu_begin();
 		if (static_branch_likely(&have_avx2))
 			nh_avx2(key, message, message_len, hash);
@@ -35,9 +33,6 @@ static bool nh_arch(const u32 *key, const u8 *message, size_t message_len,
 #define nh_mod_init_arch nh_mod_init_arch
 static void nh_mod_init_arch(void)
 {
-	if (boot_cpu_has(X86_FEATURE_XMM2)) {
-		static_branch_enable(&have_sse2);
-		if (boot_cpu_has(X86_FEATURE_AVX2))
-			static_branch_enable(&have_avx2);
-	}
+	if (boot_cpu_has(X86_FEATURE_AVX2))
+		static_branch_enable(&have_avx2);
 }

base-commit: 9fbbbaefd5f95551da18426c200cf41e1b4255a1

Signature · 1 line
2.56.0
author maintainer Applied
#1 lore raw
Quoted 6 lines · Eric Biggers

Remove the unnecessary check for X86_FEATURE_XMM2 (and the have_sse2 static key it controls) from the x86_64 optimized NH code.

This code is 64-bit only, and x86_64 kernels require X86_FEATURE_XMM2. (See X86_REQUIRED_FEATURE_XMM2.)

Quoted 7 lines

Also replace <linux/static_call.h> with <linux/jump_label.h>, since this file uses static keys, not static calls.

---
 lib/crypto/x86/nh.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

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

- Eric