* [PATCH] lib/crypto: x86/poly1305: Drop redundant checks for AVX and AVX2
@ 2026-11-11 20:15 Eric Biggers
2026-11-13 8:29 ` Ard Biesheuvel
2026-11-14 4:24 ` Eric Biggers
0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2026-11-11 20:15 UTC (permalink / raw)
To: linux-crypto
Cc: Ard Biesheuvel, Jason A . Donenfeld, Herbert Xu, x86,
Eric Biggers
Reorganize the code in poly1305_mod_init_arch() to use nesting. This
eliminates redundant boot_cpu_has() calls. It also makes the code
structure more closely match poly1305_blocks(), which has an early
return if poly1305_use_avx isn't set.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
lib/crypto/x86/poly1305.h | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/lib/crypto/x86/poly1305.h b/lib/crypto/x86/poly1305.h
index 3b92e20f4f9b3..89d3b6add442a 100644
--- a/lib/crypto/x86/poly1305.h
+++ b/lib/crypto/x86/poly1305.h
@@ -143,13 +143,17 @@ static void poly1305_emit(const struct poly1305_state *ctx,
#define poly1305_mod_init_arch poly1305_mod_init_arch
static void poly1305_mod_init_arch(void)
{
- if (boot_cpu_has(X86_FEATURE_AVX))
+ if (boot_cpu_has(X86_FEATURE_AVX)) {
static_branch_enable(&poly1305_use_avx);
- if (boot_cpu_has(X86_FEATURE_AVX) && boot_cpu_has(X86_FEATURE_AVX2))
- static_branch_enable(&poly1305_use_avx2);
- if (boot_cpu_has(X86_FEATURE_AVX) && boot_cpu_has(X86_FEATURE_AVX2) &&
- boot_cpu_has(X86_FEATURE_AVX512F) &&
- /* Skylake downclocks unacceptably much when using zmm, but later generations are fast. */
- boot_cpu_data.x86_vfm != INTEL_SKYLAKE_X)
- static_branch_enable(&poly1305_use_avx512);
+ if (boot_cpu_has(X86_FEATURE_AVX2)) {
+ static_branch_enable(&poly1305_use_avx2);
+ /*
+ * Skylake downclocks unacceptably much when using zmm,
+ * but later generations are fast.
+ */
+ if (boot_cpu_has(X86_FEATURE_AVX512F) &&
+ boot_cpu_data.x86_vfm != INTEL_SKYLAKE_X)
+ static_branch_enable(&poly1305_use_avx512);
+ }
+ }
}
base-commit: 33b4f31b1aea3f62b61c892daefc0e6a77859032
--
2.56.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] lib/crypto: x86/poly1305: Drop redundant checks for AVX and AVX2
2026-11-11 20:15 [PATCH] lib/crypto: x86/poly1305: Drop redundant checks for AVX and AVX2 Eric Biggers
@ 2026-11-13 8:29 ` Ard Biesheuvel
2026-11-14 4:24 ` Eric Biggers
1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2026-11-13 8:29 UTC (permalink / raw)
To: Eric Biggers, linux-crypto; +Cc: Jason A . Donenfeld, Herbert Xu, x86
On Wed, 11 Nov 2026, at 21:15, Eric Biggers wrote:
> Reorganize the code in poly1305_mod_init_arch() to use nesting. This
> eliminates redundant boot_cpu_has() calls. It also makes the code
> structure more closely match poly1305_blocks(), which has an early
> return if poly1305_use_avx isn't set.
>
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> lib/crypto/x86/poly1305.h | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/crypto: x86/poly1305: Drop redundant checks for AVX and AVX2
2026-11-11 20:15 [PATCH] lib/crypto: x86/poly1305: Drop redundant checks for AVX and AVX2 Eric Biggers
2026-11-13 8:29 ` Ard Biesheuvel
@ 2026-11-14 4:24 ` Eric Biggers
1 sibling, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2026-11-14 4:24 UTC (permalink / raw)
To: linux-crypto; +Cc: Ard Biesheuvel, Jason A . Donenfeld, Herbert Xu, x86
On Wed, Nov 11, 2026 at 12:15:25PM -0800, Eric Biggers wrote:
> Reorganize the code in poly1305_mod_init_arch() to use nesting. This
> eliminates redundant boot_cpu_has() calls. It also makes the code
> structure more closely match poly1305_blocks(), which has an early
> return if poly1305_use_avx isn't set.
>
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> lib/crypto/x86/poly1305.h | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next
- Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-14 4:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 20:15 [PATCH] lib/crypto: x86/poly1305: Drop redundant checks for AVX and AVX2 Eric Biggers
2026-11-13 8:29 ` Ard Biesheuvel
2026-11-14 4:24 ` Eric Biggers
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.