From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
x86@kernel.org, Antonio Quartulli <antonio@mandelbit.com>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 05/11] lib/crypto: x86/gf128hash: Optimize GHASH and POLYVAL with PCLMULQDQ and AVX
Date: Sun, 29 Nov 2026 12:02:39 -0800 [thread overview]
Message-ID: <20261129200245.146503-6-ebiggers@kernel.org> (raw)
In-Reply-To: <20261129200245.146503-1-ebiggers@kernel.org>
Currently, the x86_64 GHASH and POLYVAL code is fragmented and in many
cases inefficient:
- The GHASH library (used by the AES-GCM library and the "gcm" template)
is optimized only with a slow one-block-at-a-time implementation using
PCLMULQDQ only (no AVX). It optimizes for old CPUs with slow
pclmulqdq support by using Karatsuba multiplication and the
multiplication-less reduction algorithm.
- The POLYVAL library (used by HCTR2) is optimized with an
8-blocks-at-a-time implementation using PCLMULQDQ + AVX. It optimizes
for CPUs with fast pclmulqdq support by using schoolbook
multiplication and the two-multiplication reduction algorithm.
- The x86_64 "gcm(aes)" code in arch/x86/crypto/aes-gcm-*.S has several
implementations of GHASH, using PCLMULQDQ, PCLMULQDQ + AVX, VPCLMULQDQ
+ AVX2, and VPCLMULQDQ + AVX512. They differ slightly in their
implementation strategies. E.g., the VPCLMULQDQ ones are parallelized
across multiple vectors while the PCLMULQDQ one is parallelized only
in the combined GHASH + AES-CTR, and the AVX512 one uses schoolbook
multiplication while the others use Karatsuba multiplication.
The main problem is that the AES-GCM library isn't properly optimized.
Solving that requires migrating the GHASH and AES-GCM code in
arch/x86/crypto/aes-gcm-*.S to lib/crypto/ and making the AES-GCM
assembly code use the same GHASH key struct as the GHASH library.
However, there's more that's worth fixing too:
- The PCLMULQDQ code paths lack full parallelization of GHASH.
- POLYVAL lacks VPCLMULQDQ optimization, so HCTR2 isn't properly
optimized on recent x86_64 CPUs. Yet, POLYVAL is nearly identical to
GHASH. If the code is structured properly, we can easily optimize
both together. (Indeed, this was one of the reasons to have a single
gf128hash module instead of separate ghash and polyval.)
- POLYVAL is unoptimized on CPUs without AVX support. This isn't too
important, but it's another inconsistency.
- POLYVAL uses schoolbook multiplication, whereas the PCLMULQDQ
optimized GHASH code uses Karatsuba multiplication. Again, these
algorithms are nearly identical, so if one strategy is better it
should be used for both. As I determined earlier when I wrote
aes-gcm-aesni-x86_64.S, Karatsuba seems like a better choice, since it
helps on AMD CPUs as well as older Intel CPUs, and with the narrow
128-bit vectors there's easily space for the XOR'd key powers.
This commit begins the process of fixing this. Specifically, it handles
the PCLMULQDQ (non-VPCLMULQDQ) case: it introduces a shared
'struct gf128hash_key_x86' (208 bytes, growing 'struct ghash_key' from
16 bytes and 'struct polyval_key' from 128 bytes on x86_64) and shared
CPU feature predicates in lib/crypto/x86/gf128hash-cpu.h, and replaces
ghash-pclmul.S and polyval-pclmul-avx.S with a new file
gf128hash-pclmul.S which provides:
- gf128hash_mul_pclmul{,_avx}()
- {ghash,polyval}_preparekey_pclmul{,_avx}()
- {ghash,polyval}_blocks_pclmul{,_avx}()
The file is derived from aes-gcm-aesni-x86_64.S, so it inherits its
copyright and license.
The following implementation choices are made:
- The AVX and non-AVX code is mostly unified, as is the GHASH and
POLYVAL code.
- Key powers H^8 through H^1 are precomputed, and up to 8 blocks are
processed in parallel with a single deferred reduction. (This is like
polyval-pclmul-avx.S and the combined GHASH + AES-CTR code in
aes-gcm-aesni-x86_64.S.)
- Bulk data processing is optimized with Karatsuba multiplication and
the two-multiplication reduction algorithm (multiplication-less
reduction isn't used). H^1 * x^-64 mod G(x) is precomputed and stored
in key->h_times_xm64 so that both the key-power loop and single-block
multiplications (gf128hash_mul_pclmul{,_avx}() and the nblocks == 1
path) need only a single reduction step.
Since parts of the key structs are now initialized in assembly code,
make CRYPTO_LIB_GF128HASH_ARCH depend on !KMSAN.
Benchmark results on AMD Ryzen 9 9950X (Zen 5) using ghash_kunit and
polyval_kunit:
Length GHASH before GHASH after POLYVAL before POLYVAL after
------ ------------ ----------- -------------- -------------
1 99 MB/s 129 MB/s 98 MB/s 131 MB/s
16 1287 MB/s 2105 MB/s 1650 MB/s 2278 MB/s
64 1694 MB/s 5881 MB/s 5646 MB/s 6015 MB/s
127 1792 MB/s 6017 MB/s 5612 MB/s 6161 MB/s
128 1791 MB/s 8796 MB/s 7513 MB/s 8726 MB/s
200 1758 MB/s 7658 MB/s 6815 MB/s 7728 MB/s
256 1865 MB/s 10651 MB/s 8744 MB/s 10620 MB/s
511 1897 MB/s 10212 MB/s 8711 MB/s 10478 MB/s
512 1897 MB/s 11991 MB/s 9653 MB/s 12082 MB/s
1024 1916 MB/s 13081 MB/s 10250 MB/s 12857 MB/s
3173 1921 MB/s 13096 MB/s 10400 MB/s 13118 MB/s
4096 1919 MB/s 13535 MB/s 10490 MB/s 13351 MB/s
16384 1928 MB/s 13446 MB/s 10689 MB/s 13233 MB/s
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
include/crypto/gf128hash.h | 24 +-
lib/crypto/Kconfig | 2 +-
lib/crypto/Makefile | 3 +-
lib/crypto/x86/gf128hash-cpu.h | 26 ++
lib/crypto/x86/gf128hash-pclmul.S | 559 ++++++++++++++++++++++++++++
lib/crypto/x86/gf128hash.h | 225 +++++++----
lib/crypto/x86/ghash-pclmul.S | 127 -------
lib/crypto/x86/polyval-pclmul-avx.S | 319 ----------------
8 files changed, 766 insertions(+), 519 deletions(-)
create mode 100644 lib/crypto/x86/gf128hash-cpu.h
create mode 100644 lib/crypto/x86/gf128hash-pclmul.S
delete mode 100644 lib/crypto/x86/ghash-pclmul.S
delete mode 100644 lib/crypto/x86/polyval-pclmul-avx.S
diff --git a/include/crypto/gf128hash.h b/include/crypto/gf128hash.h
index 41c557d559655..c8b523a2d33cf 100644
--- a/include/crypto/gf128hash.h
+++ b/include/crypto/gf128hash.h
@@ -34,12 +34,29 @@ struct polyval_elem {
};
};
+/* Format of struct ghash_key and struct polyval_key on x86_64 */
+struct gf128hash_key_x86 {
+ /* Powers of the hash key H^8 through H^1, in POLYVAL format */
+ struct polyval_elem h_powers[8];
+ /* Halves of each entry of @h_powers XOR'd together */
+ __le64 h_powers_xored[8];
+ /*
+ * H^1 * x^-64 mod G(x) in POLYVAL format. This is used to optimize
+ * single-block multiplications using 1-step reduction.
+ */
+ struct polyval_elem h_times_xm64;
+};
+
/**
* struct ghash_key - Prepared key for GHASH
*
* Use ghash_preparekey() to initialize this.
*/
struct ghash_key {
+#if defined(CONFIG_CRYPTO_LIB_GF128HASH_ARCH) && defined(CONFIG_X86_64)
+ /** @k: Prepared key in x86_64 format */
+ struct gf128hash_key_x86 k;
+#else
#if defined(CONFIG_CRYPTO_LIB_GF128HASH_ARCH) && defined(CONFIG_PPC64)
/** @htable: GHASH key format used by the POWER8 assembly code */
u64 htable[4][2];
@@ -50,6 +67,7 @@ struct ghash_key {
#endif
/** @h: The hash key H, in POLYVAL format */
struct polyval_elem h;
+#endif
};
/**
@@ -63,8 +81,10 @@ struct ghash_key {
* exponentiation repeats the POLYVAL dot operation, with its "extra" x^-128.
*/
struct polyval_key {
-#if defined(CONFIG_CRYPTO_LIB_GF128HASH_ARCH) && \
- (defined(CONFIG_ARM64) || defined(CONFIG_X86))
+#if defined(CONFIG_CRYPTO_LIB_GF128HASH_ARCH) && defined(CONFIG_X86_64)
+ /** @k: Prepared key in x86_64 format */
+ struct gf128hash_key_x86 k;
+#elif defined(CONFIG_CRYPTO_LIB_GF128HASH_ARCH) && defined(CONFIG_ARM64)
/** @h_powers: Powers of the hash key H^8 through H^1 */
struct polyval_elem h_powers[8];
#else
diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig
index 4644dee78ae3d..1a5ca64097568 100644
--- a/lib/crypto/Kconfig
+++ b/lib/crypto/Kconfig
@@ -150,7 +150,7 @@ config CRYPTO_LIB_GF128HASH
config CRYPTO_LIB_GF128HASH_ARCH
bool
- depends on CRYPTO_LIB_GF128HASH && !UML
+ depends on CRYPTO_LIB_GF128HASH && !UML && !KMSAN
default y if ARM && KERNEL_MODE_NEON
default y if ARM64
default y if PPC64 && VSX
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index 5ddf64ce1d453..5b458b6f20e32 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -42,8 +42,7 @@ OBJECT_FILES_NON_STANDARD_powerpc/ghashp8-ppc.o := y
endif
libgf128hash-$(CONFIG_RISCV) += riscv/ghash-riscv64-zvkg.o
-libgf128hash-$(CONFIG_X86) += x86/ghash-pclmul.o \
- x86/polyval-pclmul-avx.o
+libgf128hash-$(CONFIG_X86_64) += x86/gf128hash-pclmul.o
endif # CONFIG_CRYPTO_LIB_GF128HASH_ARCH
# clean-files must be defined unconditionally
diff --git a/lib/crypto/x86/gf128hash-cpu.h b/lib/crypto/x86/gf128hash-cpu.h
new file mode 100644
index 0000000000000..157da0a49c416
--- /dev/null
+++ b/lib/crypto/x86/gf128hash-cpu.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * This header contains the x86_64 gf128hash CPU feature predicates and some
+ * internal functions, so that the x86_64 AES-GCM code can reuse them.
+ *
+ * Copyright 2026 Google LLC
+ */
+#ifndef _LIB_CRYPTO_X86_GF128HASH_CPU_H
+#define _LIB_CRYPTO_X86_GF128HASH_CPU_H
+
+#include <crypto/gf128hash.h>
+#include <linux/cpufeature.h>
+
+static inline bool gf128hash_use_pclmul(void)
+{
+ return IS_ENABLED(CONFIG_X86_64) &&
+ cpu_feature_enabled(X86_FEATURE_PCLMULQDQ) &&
+ cpu_feature_enabled(X86_FEATURE_SSSE3);
+}
+
+static inline bool gf128hash_use_pclmul_avx(void)
+{
+ return gf128hash_use_pclmul() && cpu_feature_enabled(X86_FEATURE_AVX);
+}
+
+#endif /* _LIB_CRYPTO_X86_GF128HASH_CPU_H */
diff --git a/lib/crypto/x86/gf128hash-pclmul.S b/lib/crypto/x86/gf128hash-pclmul.S
new file mode 100644
index 0000000000000..7bb0a25b9df02
--- /dev/null
+++ b/lib/crypto/x86/gf128hash-pclmul.S
@@ -0,0 +1,559 @@
+/* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause */
+//
+// Accelerated GHASH and POLYVAL implementation with PCLMULQDQ and AVX
+//
+// Copyright 2024 Google LLC
+//
+// Author: Eric Biggers <ebiggers@google.com>
+//
+//------------------------------------------------------------------------------
+//
+// This file is dual-licensed, meaning that you can use it under your choice of
+// either of the following two licenses:
+//
+// Licensed under the Apache License 2.0 (the "License"). You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// or
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+//------------------------------------------------------------------------------
+//
+// This file implements GHASH and POLYVAL using PCLMULQDQ on 128-bit vectors
+// (xmm registers). Two variants are generated from the same macros:
+//
+// - *_pclmul: non-VEX instructions (PCLMULQDQ, plus SSSE3 which all real CPUs
+// with PCLMULQDQ have)
+// - *_pclmul_avx: VEX-coded 128-bit instructions (PCLMULQDQ + AVX + SSSE3),
+// avoiding extra movdqa instructions and AVX-SSE transition penalties
+//
+// This file also documents the math shared with gf128hash-vpclmul-avx2.S and
+// gf128hash-vpclmul-avx512.S.
+//
+// Mathematical background
+// -----------------------
+//
+// GHASH (NIST SP 800-38D) and POLYVAL (RFC 8452) are polynomial evaluation
+// hashes over GF(2^128). Each 16-byte block represents a polynomial of degree
+// < 128 over GF(2) (so polynomial addition is XOR), and each message block M_i
+// updates the accumulator by adding M_i and multiplying by the key H. GHASH
+// and POLYVAL differ only in field representation and multiplication:
+//
+// - POLYVAL uses LSB-first bit order: bit j of byte i (bit 0 = LSB, bit 7 =
+// MSB) is the coefficient of x^(8i + j). The modulus is G(x) = x^128 + x^127
+// + x^126 + x^121 + 1, and multiplication is Montgomery multiplication,
+// updating acc to dot(acc + M_i, H) where:
+//
+// dot(A, B) = A * B * x^-128 (mod G(x))
+//
+// - GHASH uses MSB-first bit order: bit j of byte i is the coefficient of
+// x^(8i + 7 - j). The modulus is F(x) = x^128 + x^7 + x^2 + x + 1, and
+// multiplication is ordinary, updating acc to (acc + M_i) * H mod F(x).
+//
+// However, GHASH is difficult to implement in the way it's described above,
+// since the MSB-first bit order is very inconvenient. Instead, this code
+// implements GHASH via POLYVAL, by re-expressing each GHASH computation as an
+// equivalent POLYVAL computation.
+//
+// Reversing the 16 bytes of a GHASH block A (without reversing bits within each
+// byte) moves byte i to 15 - i. Read in POLYVAL's representation, bit j of
+// byte 15 - i is the coefficient of x^(8*(15 - i) + j) =
+// x^(127 - (8i + 7 - j)), so the resulting POLYVAL polynomial is:
+//
+// ByteReverse(A) = x^127 * A(x^-1)
+//
+// Now let A(x) * B(x) = Q(x) * F(x) + R(x), where R = A * B mod F(x) and
+// deg(Q) <= 126. Since G(x) = x^128 * F(x^-1) and x^126 * Q(x^-1) is a
+// polynomial:
+//
+// ByteReverse(A) * ByteReverse(B)
+// = x^254 * A(x^-1) * B(x^-1)
+// = x^254 * (Q(x^-1) * F(x^-1) + R(x^-1))
+// = (x^126 * Q(x^-1)) * (x^128 * F(x^-1)) + x^127 * (x^127 * R(x^-1))
+// = (x^126 * Q(x^-1)) * G(x) + x^127 * ByteReverse(R)
+// = x^127 * ByteReverse(A * B mod F(x)) (mod G(x))
+//
+// Pre-multiplying ByteReverse(H) by x cancels the x^127 * x^-128 = x^-1 factor
+// when using dot():
+//
+// dot(ByteReverse(A), x * ByteReverse(H))
+// = ByteReverse(A) * (x * ByteReverse(H)) * x^-128 (mod G(x))
+// = ByteReverse(A) * ByteReverse(H) * x^-127 (mod G(x))
+// = ByteReverse(A * H mod F(x)) (mod G(x))
+//
+// Since ByteReverse is linear over GF(2), GHASH is computed with POLYVAL
+// arithmetic by keeping the accumulator in POLYVAL form, byte-reversing each
+// message block, replacing H with x * ByteReverse(H) mod G(x), and
+// byte-reversing the final accumulator (done in C by polyval_acc_to_ghash()).
+//
+// Reduction
+// ---------
+//
+// Since G(x) = x^64 * (x^64 + x^63 + x^62 + x^57) + 1, we have
+// x^-64 = x^64 + x^63 + x^62 + x^57 (mod G(x)). For a 128-bit polynomial
+// P = P_L + P_H * x^64 (with 64-bit halves P_L and P_H):
+//
+// P * x^-64 = P_H + P_L * x^64 + P_L * (x^63 + x^62 + x^57) (mod G(x))
+//
+// This is a swap of P's 64-bit halves (pshufd $0x4e) plus one 64x64=>128-bit
+// carryless multiply of P_L by .Lgfpoly, yielding a reduced result (degree <
+// 128).
+//
+// For dot(A, B), the 256-bit product A * B = LO + MI * x^64 + HI * x^128
+// (with overlapping 128-bit parts LO = A_L * B_L, MI = A_L * B_H + A_H * B_L,
+// and HI = A_H * B_H) is multiplied by x^-128 in two steps: MI += LO * x^-64,
+// then HI += MI * x^-64, leaving dot(A, B) in HI.
+//
+// Implementation notes
+// --------------------
+//
+// - Aggregation: To hide multiply-and-reduce latency, key powers H^8..H^1
+// (H^1 = H in POLYVAL format, H^k = dot(H^(k-1), H^1)) are precomputed, and
+// 8 blocks are processed per reduction:
+//
+// acc = dot(acc + M_0, H^8) + dot(M_1, H^7) + ... + dot(M_7, H^1)
+//
+// The 256-bit products are summed and reduced once per 8 blocks. The inner
+// loop is kept rolled for code size; out-of-order execution overlaps it.
+//
+// - Karatsuba multiplication: Multi-block strides compute
+// MI = (A_L + A_H) * (B_L + B_H) + LO + HI, with (H^k)_L + (H^k)_H
+// precomputed in key->h_powers_xored and "+ LO + HI" deferred to the end of
+// the stride. Relative to schoolbook, this saves 1 pclmulqdq per block (plus
+// 2 movdqa in *_pclmul) at the cost of 1 64-bit load, 1 pshufd, and 0.25 pxor
+// per block in the 8-block loop. This wins on AMD and older Intel CPUs and
+// breaks even on newer Intel CPUs.
+//
+// - Reduction uses 2 pclmulqdq instructions (0.25 per block in the 8-block
+// loop), which is faster than a shift/XOR-only reduction.
+//
+// - 1-step reduction for single-block multiplies and preparekey: Precomputing
+// A * x^-64 mod G(x) lets dot(A, B) skip one reduction step. preparekey
+// precomputes H^1 * x^-64 mod G(x) for computing H^2..H^8 and stores it in
+// key->h_times_xm64 for gf128hash_mul_pclmul{,_avx} and the 1-block path in
+// {ghash,polyval}_blocks_pclmul{,_avx}.
+
+#include <linux/linkage.h>
+
+.section .rodata
+ // Keep the 16-byte constants 16-byte aligned for non-VEX SSE memory
+ // operands (pshufb, movdqa, pand).
+.p2align 4
+
+ // pshufb mask that reverses the order of the bytes in a 16-byte block
+.Lbswap_mask:
+ .octa 0x000102030405060708090a0b0c0d0e0f
+
+ // Mask for multiplying by x mod G(x): G(x) - x^128 = x^127 + x^126 +
+ // x^121 + 1 (bits 127, 126, 121, and 0), and bit 64 for the carry from
+ // bit 63 that paddq doesn't propagate
+.Lgfpoly_and_internal_carrybit:
+ .octa 0xc2000000000000010000000000000001
+
+ // (G(x) - x^128 - 1) / x^64 = x^63 + x^62 + x^57, the constant used to
+ // multiply by x^-64 mod G(x)
+.Lgfpoly:
+ .quad 0xc200000000000000
+
+// Offsets in struct gf128hash_key_x86, using the 8-power non-permuted layout.
+// h_powers[0..7] holds H^8..H^1, h_powers_xored[i] holds the XOR of the two
+// 64-bit halves of h_powers[i], and h_times_xm64 holds H^1 * x^-64 mod G(x).
+#define OFFSETOF_H_POWERS 0
+#define OFFSETOFEND_H_POWERS 128
+#define OFFSETOF_H_POWERS_XORED 128
+#define OFFSETOF_H_TIMES_XM64 192
+
+.text
+
+// Do a vpclmulqdq, or fall back to a movdqa and a pclmulqdq. The fallback
+// assumes that \src1 and \dst are distinct registers.
+.macro _vpclmulqdq imm, src1, src2, dst
+.if USE_AVX
+ vpclmulqdq \imm, \src1, \src2, \dst
+.else
+ movdqa \src2, \dst
+ pclmulqdq \imm, \src1, \dst
+.endif
+.endm
+
+// Set \b = dot(\a, \b), given \a_times_xm64 = \a * x^-64 mod G(x). Letting
+// c = \a_times_xm64, this uses:
+//
+// a * b * x^-128 = (a * b_H + c * b_L) * x^-64
+// = (MI + HI * x^64) * x^-64
+// = HI + MI * x^-64 (mod G(x))
+//
+// where MI = a_L * b_H + c_L * b_L and HI = a_H * b_H + c_H * b_L. So only
+// one reduction step is needed, to fold MI into HI. \gfpoly must contain
+// .Lgfpoly in its low qword. Clobbers \t0 and \t1. All operands must be
+// distinct registers.
+.macro _gf128hash_mul a, a_times_xm64, b, gfpoly, t0, t1
+ _vpclmulqdq $0x01, \a, \b, \t0 // a_L * b_H
+ _vpclmulqdq $0x00, \a_times_xm64, \b, \t1 // (a*x^-64)_L * b_L
+ pxor \t1, \t0 // MI
+ _vpclmulqdq $0x11, \a, \b, \t1 // a_H * b_H
+ pclmulqdq $0x10, \a_times_xm64, \b // (a*x^-64)_H * b_L
+ pxor \t1, \b // HI
+ pshufd $0x4e, \t0, \t1 // MI_H + MI_L * x^64
+ pclmulqdq $0x00, \gfpoly, \t0 // MI_L*(x^63+x^62+x^57)
+ pxor \t1, \b // Fold MI into HI (1)
+ pxor \t0, \b // Fold MI into HI (2)
+.endm
+
+// Reduce the 256-bit product LO + MI * x^64 + HI * x^128 given in \lo, \mi,
+// and \hi: multiply it by x^-128 mod G(x) and store the 128-bit result in \hi.
+// This is done in two steps, MI += LO * x^-64 then HI += MI * x^-64. \gfpoly
+// must contain .Lgfpoly in its low qword. Clobbers \lo, \mi, and \tmp. All
+// operands must be distinct registers.
+.macro _gf128hash_reduce lo, mi, hi, gfpoly, tmp
+ pshufd $0x4e, \lo, \tmp // LO_H + LO_L * x^64
+ pclmulqdq $0x00, \gfpoly, \lo // LO_L*(x^63+x^62+x^57)
+ pxor \tmp, \mi // Fold LO into MI (1)
+ pxor \lo, \mi // Fold LO into MI (2)
+ pshufd $0x4e, \mi, \tmp // MI_H + MI_L * x^64
+ pclmulqdq $0x00, \gfpoly, \mi // MI_L*(x^63+x^62+x^57)
+ pxor \tmp, \hi // Fold MI into HI (1)
+ pxor \mi, \hi // Fold MI into HI (2)
+.endm
+
+// void {ghash,polyval}_preparekey_pclmul{,_avx}(struct gf128hash_key_x86 *key,
+// const u8 raw_key[16]);
+//
+// Given the raw GHASH key (\is_ghash=1) or POLYVAL key (\is_ghash=0), set:
+// - key->h_powers[0..7] to H^8..H^1 in POLYVAL format
+// - key->h_powers_xored[i] to the XOR of the two 64-bit halves of h_powers[i]
+// - key->h_times_xm64 to H^1 * x^-64 mod G(x)
+.macro _gf128hash_preparekey is_ghash
+ .set KEY, %rdi
+ .set RAW_KEY, %rsi
+ // %rax is used as a loop/offset register.
+ .set TMP0, %xmm0
+ .set TMP1, %xmm1
+ .set H_CUR, %xmm2
+ .set H_POW1, %xmm3
+ .set H_POW1_XM64, %xmm4
+ .set GFPOLY, %xmm5
+
+ movdqu (RAW_KEY), H_POW1
+.if \is_ghash
+ // Convert the GHASH key to POLYVAL format: byte-reverse it, then
+ // multiply it by x mod G(x). Multiplying by x is a left shift by 1
+ // bit, then an XOR of G(x) - x^128 if bit 127 was set. However,
+ // there's no instruction that shifts a 128-bit value by 1 bit.
+ // Instead, use paddq to shift each 64-bit half, then add the carry from
+ // bit 63 to bit 64. 'pshufd $0xd3' and 'psrad $31' set dwords 0 and 3
+ // to copies of bit 127 and dword 2 to copies of bit 63; pand then
+ // selects the bits to XOR in from G(x) - x^128 and the carry bit.
+ pshufb .Lbswap_mask(%rip), H_POW1
+ pshufd $0xd3, H_POW1, TMP0
+ psrad $31, TMP0
+ paddq H_POW1, H_POW1
+ pand .Lgfpoly_and_internal_carrybit(%rip), TMP0
+ pxor TMP0, H_POW1
+.endif
+
+ // Store H^1 in h_powers[7].
+ movdqu H_POW1, OFFSETOF_H_POWERS+7*16(KEY)
+
+ // Compute H_POW1_XM64 = H^1 * x^-64 mod G(x) = (H^1)_H + (H^1)_L * x^64
+ // + (H^1)_L * (x^63 + x^62 + x^57), and store it in h_times_xm64.
+ movq .Lgfpoly(%rip), GFPOLY
+ pshufd $0x4e, H_POW1, TMP0
+ _vpclmulqdq $0x00, GFPOLY, H_POW1, H_POW1_XM64
+ pxor TMP0, H_POW1_XM64
+ movdqu H_POW1_XM64, OFFSETOF_H_TIMES_XM64(KEY)
+
+ // Store the XOR of the halves of H^1 in h_powers_xored[7], reusing the
+ // swapped halves of H^1 still in TMP0.
+ pxor H_POW1, TMP0
+ movq TMP0, OFFSETOF_H_POWERS_XORED+7*8(KEY)
+
+ // Compute H^2..H^8 and store them in h_powers[6..0], and store the XORs
+ // of their halves in h_powers_xored[6..0]. %eax (zero-extended to
+ // %rax) counts down from 6*8 to 0 by 8; %rax is the offset into
+ // h_powers_xored, and 2*%rax is the offset into h_powers.
+ movdqa H_POW1, H_CUR
+ mov $6*8, %eax
+.Lpreparekey_next\@:
+ _gf128hash_mul H_POW1, H_POW1_XM64, H_CUR, GFPOLY, TMP0, TMP1
+ movdqu H_CUR, OFFSETOF_H_POWERS(KEY,%rax,2)
+ pshufd $0x4e, H_CUR, TMP0
+ pxor H_CUR, TMP0
+ movq TMP0, OFFSETOF_H_POWERS_XORED(KEY,%rax)
+ sub $8, %eax
+ jge .Lpreparekey_next\@
+
+ RET
+.endm
+
+// void gf128hash_mul_pclmul{,_avx}(struct polyval_elem *acc,
+// const struct gf128hash_key_x86 *key);
+//
+// Set *acc = dot(*acc, H^1) using the precomputed H^1 and H^1 * x^-64 in @key.
+// The C code uses this to multiply the accumulator by H^1 after XOR'ing in a
+// buffered (possibly partial) block. Works with both the 8-power and 16-power
+// key layouts, so no separate AVX2 or AVX512 version is needed.
+.macro _gf128hash_mul_func
+ .set ACC_PTR, %rdi
+ .set KEY, %rsi
+ .set TMP0, %xmm0
+ .set TMP1, %xmm1
+ .set ACC, %xmm2
+ .set H_POW1, %xmm3
+ .set H_POW1_XM64, %xmm4
+ .set GFPOLY, %xmm5
+
+ movdqu (ACC_PTR), ACC
+ movdqu OFFSETOFEND_H_POWERS-16(KEY), H_POW1
+ movdqu OFFSETOF_H_TIMES_XM64(KEY), H_POW1_XM64
+ movq .Lgfpoly(%rip), GFPOLY
+ _gf128hash_mul H_POW1, H_POW1_XM64, ACC, GFPOLY, TMP0, TMP1
+ movdqu ACC, (ACC_PTR)
+ RET
+.endm
+
+// void
+// {ghash,polyval}_blocks_pclmul{,_avx}(struct polyval_elem *acc,
+// const struct gf128hash_key_x86 *key,
+// const u8 *data, size_t nblocks);
+//
+// Update the POLYVAL-format accumulator @acc with @nblocks >= 1 full 16-byte
+// blocks from @data. If \bswap_data=1 (GHASH), each block is byte-reversed to
+// convert it to POLYVAL format.
+.macro _gf128hash_blocks bswap_data
+ .set ACC_PTR, %rdi
+ .set KEY, %rsi
+ .set DATA, %rdx
+ .set NBLOCKS, %rcx
+ .set NBLOCKS_32, %ecx
+ .set POWERS_XORED_PTR, %r8
+
+ // %rax and %r9d are used as loop/temporary registers.
+ .set TMP0, %xmm0
+ .set TMP1, %xmm1
+ .set TMP2, %xmm2
+ .set LO, %xmm3
+ .set MI, %xmm4
+ .set ACC, %xmm5
+ .set BSWAP_MASK, %xmm6
+ .set GFPOLY, %xmm7
+
+.if \bswap_data
+ movdqa .Lbswap_mask(%rip), BSWAP_MASK
+.endif
+ movdqu (ACC_PTR), ACC
+ movq .Lgfpoly(%rip), GFPOLY
+
+ // Handle nblocks == 1 specially. This case is common (e.g. for 1-block
+ // associated data, the incremental AES-GCM lengths block, and the HCTR2
+ // length and tweak blocks), and the stride loop below requires at least
+ // 2 blocks.
+ cmp $1, NBLOCKS
+ je .Lblocks_1x\@
+
+ // Process the blocks in strides of 8, then process any remaining 2..7
+ // blocks as one final stride (or 1 remaining block via .Lblocks_1x).
+ // For an n-block stride of POLYVAL-format message blocks M_0..M_{n-1},
+ // let B_0 = M_0 + acc, B_i = M_i for 1 <= i < n, and K_i = H^(n-i).
+ // Compute the unreduced sum of the products K_i * B_i using Karatsuba
+ // multiplication:
+ //
+ // LO = sum (K_i)_L * (B_i)_L
+ // HI = sum (K_i)_H * (B_i)_H
+ // MI = sum (K_i)_x * (B_i)_x + LO + HI
+ //
+ // where A_x = A_L + A_H. HI is accumulated in ACC, and the "+ LO + HI"
+ // term of MI is added just once at the end. Then (LO, MI, HI) is
+ // reduced into ACC.
+ //
+ // In the loop, %rax = 8*i, so K_i is at OFFSETOF_H_POWERS(KEY,%rax,2),
+ // M_i is at (DATA,%rax,2), and (K_i)_x is at (POWERS_XORED_PTR,%rax).
+ // %r9d = 8*(n-1) is the final value of %rax. The h_powers_xored
+ // entries are loaded with movq instead of being used as 16-byte
+ // (v)pclmulqdq memory operands, since the entries are 8 bytes wide and
+ // non-VEX pclmulqdq also requires 16-byte alignment (while struct
+ // gf128hash_key_x86 is only 8-byte aligned).
+ lea OFFSETOF_H_POWERS_XORED(KEY), POWERS_XORED_PTR
+ sub $8, NBLOCKS
+ jb .Lblocks_tail\@
+ mov $7*8, %r9d
+.Lblocks_karatsuba\@:
+ // i = 0: XOR ACC into M_0 to form B_0, and initialize LO, MI, and HI.
+ xor %eax, %eax
+ movdqu OFFSETOF_H_POWERS(KEY), TMP0 // K_0 = H^n
+ movdqu (DATA), TMP1 // M_0 (before bswap)
+.if \bswap_data
+ pshufb BSWAP_MASK, TMP1
+.endif
+ pxor TMP1, ACC // B_0 = M_0 + ACC
+ pshufd $0x4e, ACC, MI
+ pxor ACC, MI // (B_0)_x = (B_0)_L + (B_0)_H
+ _vpclmulqdq $0x00, TMP0, ACC, LO // LO = (K_0)_L * (B_0)_L
+ pclmulqdq $0x11, TMP0, ACC // HI = (K_0)_H * (B_0)_H
+ movq (POWERS_XORED_PTR), TMP1 // (K_0)_x = (K_0)_L + (K_0)_H
+ pclmulqdq $0x00, TMP1, MI // MI = (K_0)_x * (B_0)_x
+
+ // i = 1..n-1 (B_i = M_i): accumulate into LO, MI, and HI.
+.Lblocks_karatsuba_loop\@:
+ add $8, %eax
+ movdqu OFFSETOF_H_POWERS(KEY,%rax,2), TMP0 // K_i = H^(n-i)
+ movdqu (DATA,%rax,2), TMP1 // M_i (before bswap)
+.if \bswap_data
+ pshufb BSWAP_MASK, TMP1
+.endif
+ _vpclmulqdq $0x00, TMP0, TMP1, TMP2
+ pxor TMP2, LO // LO += (K_i)_L * (M_i)_L
+ pshufd $0x4e, TMP1, TMP2
+ pxor TMP1, TMP2 // (M_i)_x = (M_i)_L + (M_i)_H
+ pclmulqdq $0x11, TMP0, TMP1
+ pxor TMP1, ACC // HI += (K_i)_H * (M_i)_H
+ movq (POWERS_XORED_PTR,%rax), TMP1 // (K_i)_x
+ pclmulqdq $0x00, TMP1, TMP2
+ pxor TMP2, MI // MI += (K_i)_x * (M_i)_x
+ cmp %r9d, %eax
+ jne .Lblocks_karatsuba_loop\@
+
+ // Finish MI, then reduce (LO, MI, HI) into ACC.
+ pxor LO, MI
+ pxor ACC, MI
+ _gf128hash_reduce LO, MI, ACC, GFPOLY, TMP2
+
+ sub $-128, DATA // DATA += 128 (compact imm8)
+ sub $8, NBLOCKS
+ jae .Lblocks_karatsuba\@
+
+.Lblocks_tail\@:
+ add $8, NBLOCKS
+ jz .Lblocks_done\@
+ cmp $1, NBLOCKS
+ je .Lblocks_1x\@
+
+ // 2 <= n = NBLOCKS <= 7 blocks remain. Process them as one more stride
+ // that starts with K_0 = H^n = h_powers[8-n]: advance KEY by 16*(8-n)
+ // and POWERS_XORED_PTR by 8*(8-n), and set %r9d = 8*(n-1). Set
+ // NBLOCKS = 0 so that after the stride, the sub $8 underflows into
+ // .Lblocks_tail, where add $8 yields 0 and jumps to .Lblocks_done
+ // (over-advancing DATA by 128 is harmless since it is no longer used).
+ lea -8(,NBLOCKS,8), %r9d // 8*(n-1)
+ mov $7*8, %eax
+ sub %r9d, %eax // 8*(8-n)
+ add %rax, POWERS_XORED_PTR // POWERS_XORED_PTR += 8*(8-n)
+ lea (KEY,%rax,2), KEY // KEY += 16*(8-n)
+ xor NBLOCKS_32, NBLOCKS_32
+ jmp .Lblocks_karatsuba\@
+
+.Lblocks_1x\@:
+ // Process one block: ACC = dot(ACC + M_0, H^1), using H^1 and
+ // H^1 * x^-64 from KEY.
+ movdqu (DATA), TMP0
+.if \bswap_data
+ pshufb BSWAP_MASK, TMP0
+.endif
+ pxor TMP0, ACC
+ movdqu OFFSETOFEND_H_POWERS-16(KEY), TMP0 // H^1
+ movdqu OFFSETOF_H_TIMES_XM64(KEY), TMP1 // H^1 * x^-64
+ _gf128hash_mul TMP0, TMP1, ACC, GFPOLY, TMP2, LO
+
+.Lblocks_done\@:
+ movdqu ACC, (ACC_PTR)
+ RET
+.endm
+
+.set USE_AVX, 0
+SYM_FUNC_START(ghash_preparekey_pclmul)
+ _gf128hash_preparekey 1
+SYM_FUNC_END(ghash_preparekey_pclmul)
+SYM_FUNC_START(polyval_preparekey_pclmul)
+ _gf128hash_preparekey 0
+SYM_FUNC_END(polyval_preparekey_pclmul)
+SYM_FUNC_START(gf128hash_mul_pclmul)
+ _gf128hash_mul_func
+SYM_FUNC_END(gf128hash_mul_pclmul)
+SYM_FUNC_START(ghash_blocks_pclmul)
+ _gf128hash_blocks 1
+SYM_FUNC_END(ghash_blocks_pclmul)
+SYM_FUNC_START(polyval_blocks_pclmul)
+ _gf128hash_blocks 0
+SYM_FUNC_END(polyval_blocks_pclmul)
+
+.set USE_AVX, 1
+
+// Re-encode the remaining SSE mnemonics as VEX.128 so *_pclmul_avx contains no
+// legacy SSE instructions. Use vararg for instructions whose operand count
+// doesn't change so memory operands containing commas pass through intact.
+// (movq is only used for xmm<->memory transfers above, never for GPR moves.)
+.macro movdqu args:vararg
+ vmovdqu \args
+.endm
+.macro movdqa args:vararg
+ vmovdqa \args
+.endm
+.macro movq args:vararg
+ vmovq \args
+.endm
+.macro pshufd args:vararg
+ vpshufd \args
+.endm
+.macro pxor a, b
+ vpxor \a, \b, \b
+.endm
+.macro pand a, b
+ vpand \a, \b, \b
+.endm
+.macro paddq a, b
+ vpaddq \a, \b, \b
+.endm
+.macro psrad a, b
+ vpsrad \a, \b, \b
+.endm
+.macro pshufb a, b
+ vpshufb \a, \b, \b
+.endm
+.macro pclmulqdq imm, a, b
+ vpclmulqdq \imm, \a, \b, \b
+.endm
+
+SYM_FUNC_START(ghash_preparekey_pclmul_avx)
+ _gf128hash_preparekey 1
+SYM_FUNC_END(ghash_preparekey_pclmul_avx)
+SYM_FUNC_START(polyval_preparekey_pclmul_avx)
+ _gf128hash_preparekey 0
+SYM_FUNC_END(polyval_preparekey_pclmul_avx)
+SYM_FUNC_START(gf128hash_mul_pclmul_avx)
+ _gf128hash_mul_func
+SYM_FUNC_END(gf128hash_mul_pclmul_avx)
+SYM_FUNC_START(ghash_blocks_pclmul_avx)
+ _gf128hash_blocks 1
+SYM_FUNC_END(ghash_blocks_pclmul_avx)
+SYM_FUNC_START(polyval_blocks_pclmul_avx)
+ _gf128hash_blocks 0
+SYM_FUNC_END(polyval_blocks_pclmul_avx)
diff --git a/lib/crypto/x86/gf128hash.h b/lib/crypto/x86/gf128hash.h
index 5ef8f2f7b6f3c..9abdea7f9ba86 100644
--- a/lib/crypto/x86/gf128hash.h
+++ b/lib/crypto/x86/gf128hash.h
@@ -5,61 +5,143 @@
* Copyright 2025 Google LLC
*/
#include <asm/fpu/api.h>
-#include <linux/cpufeature.h>
+#include "gf128hash-cpu.h"
#define NUM_H_POWERS 8
+/* The assembly code assumes the following offsets. */
+static_assert(sizeof_field(struct gf128hash_key_x86, h_powers) ==
+ NUM_H_POWERS * sizeof(struct polyval_elem));
+static_assert(offsetof(struct gf128hash_key_x86, h_powers) == 0);
+static_assert(offsetof(struct gf128hash_key_x86, h_powers_xored) == 128);
+static_assert(offsetof(struct gf128hash_key_x86, h_times_xm64) == 192);
+static_assert(sizeof(struct gf128hash_key_x86) == 208);
+
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmul);
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pclmul_avx);
-asmlinkage void polyval_mul_pclmul(struct polyval_elem *a,
- const struct polyval_elem *b);
-asmlinkage void polyval_mul_pclmul_avx(struct polyval_elem *a,
- const struct polyval_elem *b);
+void gf128hash_mul_pclmul(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key);
+void gf128hash_mul_pclmul_avx(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key);
-asmlinkage void ghash_blocks_pclmul(struct polyval_elem *acc,
- const struct polyval_elem *key,
- const u8 *data, size_t nblocks);
-asmlinkage void polyval_blocks_pclmul_avx(struct polyval_elem *acc,
- const struct polyval_key *key,
- const u8 *data, size_t nblocks);
+void ghash_preparekey_pclmul(struct gf128hash_key_x86 *key,
+ const u8 raw_key[GHASH_BLOCK_SIZE]);
+void ghash_preparekey_pclmul_avx(struct gf128hash_key_x86 *key,
+ const u8 raw_key[GHASH_BLOCK_SIZE]);
+void polyval_preparekey_pclmul(struct gf128hash_key_x86 *key,
+ const u8 raw_key[POLYVAL_BLOCK_SIZE]);
+void polyval_preparekey_pclmul_avx(struct gf128hash_key_x86 *key,
+ const u8 raw_key[POLYVAL_BLOCK_SIZE]);
-#define polyval_preparekey_arch polyval_preparekey_arch
-static void polyval_preparekey_arch(struct polyval_key *key,
- const u8 raw_key[POLYVAL_BLOCK_SIZE])
+void ghash_blocks_pclmul(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key, const u8 *data,
+ size_t nblocks);
+void ghash_blocks_pclmul_avx(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key,
+ const u8 *data, size_t nblocks);
+void polyval_blocks_pclmul(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key, const u8 *data,
+ size_t nblocks);
+void polyval_blocks_pclmul_avx(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key,
+ const u8 *data, size_t nblocks);
+
+static __always_inline void
+__gf128hash_mul_x86_fpu(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key)
+{
+ if (static_branch_likely(&have_pclmul_avx))
+ gf128hash_mul_pclmul_avx(acc, key);
+ else
+ gf128hash_mul_pclmul(acc, key);
+}
+
+static __always_inline void
+__ghash_blocks_x86_fpu(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key, const u8 *data,
+ size_t nblocks)
+{
+ if (static_branch_likely(&have_pclmul_avx))
+ ghash_blocks_pclmul_avx(acc, key, data, nblocks);
+ else
+ ghash_blocks_pclmul(acc, key, data, nblocks);
+}
+
+/*
+ * Compute *out = *in * x^-64 mod G(x), where
+ * x^-64 = x^64 + x^63 + x^62 + x^57 (mod G(x)).
+ */
+static void polyval_mul_xm64_generic(struct polyval_elem *out,
+ const struct polyval_elem *in)
{
- static_assert(ARRAY_SIZE(key->h_powers) == NUM_H_POWERS);
- memcpy(&key->h_powers[NUM_H_POWERS - 1], raw_key, POLYVAL_BLOCK_SIZE);
- if (static_branch_likely(&have_pclmul_avx) && irq_fpu_usable()) {
+ u64 lo = le64_to_cpu(in->lo);
+ u64 hi = le64_to_cpu(in->hi);
+
+ out->lo = cpu_to_le64(hi ^ (lo << 63) ^ (lo << 62) ^ (lo << 57));
+ out->hi = cpu_to_le64(lo ^ (lo >> 1) ^ (lo >> 2) ^ (lo >> 7));
+}
+
+static __always_inline void
+gf128hash_preparekey_x86(struct gf128hash_key_x86 *key, const u8 raw_key[16],
+ bool is_ghash)
+{
+ if (static_branch_likely(&have_pclmul) && likely(irq_fpu_usable())) {
kernel_fpu_begin_mask(0);
- for (int i = NUM_H_POWERS - 2; i >= 0; i--) {
- key->h_powers[i] = key->h_powers[i + 1];
- polyval_mul_pclmul_avx(
- &key->h_powers[i],
- &key->h_powers[NUM_H_POWERS - 1]);
+ if (static_branch_likely(&have_pclmul_avx)) {
+ if (is_ghash)
+ ghash_preparekey_pclmul_avx(key, raw_key);
+ else
+ polyval_preparekey_pclmul_avx(key, raw_key);
+ } else {
+ if (is_ghash)
+ ghash_preparekey_pclmul(key, raw_key);
+ else
+ polyval_preparekey_pclmul(key, raw_key);
}
kernel_fpu_end();
- } else {
- for (int i = NUM_H_POWERS - 2; i >= 0; i--) {
- key->h_powers[i] = key->h_powers[i + 1];
- polyval_mul_generic(&key->h_powers[i],
- &key->h_powers[NUM_H_POWERS - 1]);
- }
+ return;
}
+ if (is_ghash)
+ ghash_key_to_polyval(raw_key, &key->h_powers[NUM_H_POWERS - 1]);
+ else
+ memcpy(&key->h_powers[NUM_H_POWERS - 1], raw_key,
+ POLYVAL_BLOCK_SIZE);
+ for (int i = NUM_H_POWERS - 2; i >= 0; i--) {
+ key->h_powers[i] = key->h_powers[i + 1];
+ polyval_mul_generic(&key->h_powers[i],
+ &key->h_powers[NUM_H_POWERS - 1]);
+ }
+ for (int i = 0; i < NUM_H_POWERS; i++)
+ key->h_powers_xored[i] = key->h_powers[i].lo ^
+ key->h_powers[i].hi;
+ polyval_mul_xm64_generic(&key->h_times_xm64,
+ &key->h_powers[NUM_H_POWERS - 1]);
}
-static void polyval_mul_x86(struct polyval_elem *a,
- const struct polyval_elem *b)
+#define ghash_preparekey_arch ghash_preparekey_arch
+static void ghash_preparekey_arch(struct ghash_key *key,
+ const u8 raw_key[GHASH_BLOCK_SIZE])
{
- if (static_branch_likely(&have_pclmul) && irq_fpu_usable()) {
+ gf128hash_preparekey_x86(&key->k, raw_key, true);
+}
+
+#define polyval_preparekey_arch polyval_preparekey_arch
+static void polyval_preparekey_arch(struct polyval_key *key,
+ const u8 raw_key[POLYVAL_BLOCK_SIZE])
+{
+ gf128hash_preparekey_x86(&key->k, raw_key, false);
+}
+
+static void gf128hash_mul_x86(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key)
+{
+ if (static_branch_likely(&have_pclmul) && likely(irq_fpu_usable())) {
kernel_fpu_begin_mask(0);
- if (static_branch_likely(&have_pclmul_avx))
- polyval_mul_pclmul_avx(a, b);
- else
- polyval_mul_pclmul(a, b);
+ __gf128hash_mul_x86_fpu(acc, key);
kernel_fpu_end();
} else {
- polyval_mul_generic(a, b);
+ polyval_mul_generic(acc, &key->h_powers[NUM_H_POWERS - 1]);
}
}
@@ -67,67 +149,74 @@ static void polyval_mul_x86(struct polyval_elem *a,
static void ghash_mul_arch(struct polyval_elem *acc,
const struct ghash_key *key)
{
- polyval_mul_x86(acc, &key->h);
+ gf128hash_mul_x86(acc, &key->k);
}
#define polyval_mul_arch polyval_mul_arch
static void polyval_mul_arch(struct polyval_elem *acc,
const struct polyval_key *key)
{
- polyval_mul_x86(acc, &key->h_powers[NUM_H_POWERS - 1]);
+ gf128hash_mul_x86(acc, &key->k);
}
-#define ghash_blocks_arch ghash_blocks_arch
-static void ghash_blocks_arch(struct polyval_elem *acc,
- const struct ghash_key *key,
- const u8 *data, size_t nblocks)
+static __always_inline void
+gf128hash_blocks_x86(struct polyval_elem *acc,
+ const struct gf128hash_key_x86 *key, const u8 *data,
+ size_t nblocks, bool is_ghash)
{
- if (static_branch_likely(&have_pclmul) && irq_fpu_usable()) {
+ if (static_branch_likely(&have_pclmul) && likely(irq_fpu_usable())) {
+ static_assert(GHASH_BLOCK_SIZE == POLYVAL_BLOCK_SIZE);
do {
- /* Allow rescheduling every 4 KiB. */
+ /* Allow rescheduling every 32 KiB. */
size_t n = min_t(size_t, nblocks,
- 4096 / GHASH_BLOCK_SIZE);
+ 32768 / GHASH_BLOCK_SIZE);
kernel_fpu_begin_mask(0);
- ghash_blocks_pclmul(acc, &key->h, data, n);
+ if (is_ghash)
+ __ghash_blocks_x86_fpu(acc, key, data, n);
+ else if (static_branch_likely(&have_pclmul_avx))
+ polyval_blocks_pclmul_avx(acc, key, data, n);
+ else
+ polyval_blocks_pclmul(acc, key, data, n);
kernel_fpu_end();
data += n * GHASH_BLOCK_SIZE;
nblocks -= n;
} while (nblocks);
} else {
- ghash_blocks_generic(acc, &key->h, data, nblocks);
+ if (is_ghash)
+ ghash_blocks_generic(acc,
+ &key->h_powers[NUM_H_POWERS - 1],
+ data, nblocks);
+ else
+ polyval_blocks_generic(acc,
+ &key->h_powers[NUM_H_POWERS - 1],
+ data, nblocks);
}
}
+#define ghash_blocks_arch ghash_blocks_arch
+static void ghash_blocks_arch(struct polyval_elem *acc,
+ const struct ghash_key *key, const u8 *data,
+ size_t nblocks)
+{
+ gf128hash_blocks_x86(acc, &key->k, data, nblocks, true);
+}
+
#define polyval_blocks_arch polyval_blocks_arch
static void polyval_blocks_arch(struct polyval_elem *acc,
const struct polyval_key *key,
const u8 *data, size_t nblocks)
{
- if (static_branch_likely(&have_pclmul_avx) && irq_fpu_usable()) {
- do {
- /* Allow rescheduling every 4 KiB. */
- size_t n = min_t(size_t, nblocks,
- 4096 / POLYVAL_BLOCK_SIZE);
-
- kernel_fpu_begin_mask(0);
- polyval_blocks_pclmul_avx(acc, key, data, n);
- kernel_fpu_end();
- data += n * POLYVAL_BLOCK_SIZE;
- nblocks -= n;
- } while (nblocks);
- } else {
- polyval_blocks_generic(acc, &key->h_powers[NUM_H_POWERS - 1],
- data, nblocks);
- }
+ gf128hash_blocks_x86(acc, &key->k, data, nblocks, false);
}
#define gf128hash_mod_init_arch gf128hash_mod_init_arch
static void gf128hash_mod_init_arch(void)
{
- if (boot_cpu_has(X86_FEATURE_PCLMULQDQ)) {
- static_branch_enable(&have_pclmul);
- if (boot_cpu_has(X86_FEATURE_AVX))
- static_branch_enable(&have_pclmul_avx);
- }
+ if (!gf128hash_use_pclmul())
+ return;
+
+ if (gf128hash_use_pclmul_avx())
+ static_branch_enable(&have_pclmul_avx);
+ static_branch_enable(&have_pclmul);
}
diff --git a/lib/crypto/x86/ghash-pclmul.S b/lib/crypto/x86/ghash-pclmul.S
deleted file mode 100644
index 6ffb5aea6063d..0000000000000
--- a/lib/crypto/x86/ghash-pclmul.S
+++ /dev/null
@@ -1,127 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Accelerated GHASH implementation with Intel PCLMULQDQ-NI
- * instructions. This file contains accelerated part of ghash
- * implementation. More information about PCLMULQDQ can be found at:
- *
- * https://www.intel.com/content/dam/develop/external/us/en/documents/clmul-wp-rev-2-02-2014-04-20.pdf
- *
- * Copyright (c) 2009 Intel Corp.
- * Author: Huang Ying <ying.huang@intel.com>
- * Vinodh Gopal
- * Erdinc Ozturk
- * Deniz Karakoyunlu
- */
-
-#include <linux/linkage.h>
-#include <asm/frame.h>
-
-.section .rodata.cst16.bswap_mask, "aM", @progbits, 16
-.align 16
-.Lbswap_mask:
- .octa 0x000102030405060708090a0b0c0d0e0f
-
-#define ACC %xmm0
-#define KEY %xmm1
-#define T1 %xmm2
-#define T2 %xmm3
-#define T3 %xmm4
-#define BSWAP %xmm5
-#define IN1 %xmm6
-
-.text
-
-/*
- * __clmul_gf128mul_ble: internal ABI
- * input:
- * ACC: operand1
- * KEY: operand2, hash_key << 1 mod poly
- * output:
- * ACC: operand1 * operand2 mod poly
- * changed:
- * T1
- * T2
- * T3
- */
-SYM_FUNC_START_LOCAL(__clmul_gf128mul_ble)
- movaps ACC, T1
- pshufd $0b01001110, ACC, T2
- pshufd $0b01001110, KEY, T3
- pxor ACC, T2
- pxor KEY, T3
-
- pclmulqdq $0x00, KEY, ACC # ACC = a0 * b0
- pclmulqdq $0x11, KEY, T1 # T1 = a1 * b1
- pclmulqdq $0x00, T3, T2 # T2 = (a1 + a0) * (b1 + b0)
- pxor ACC, T2
- pxor T1, T2 # T2 = a0 * b1 + a1 * b0
-
- movaps T2, T3
- pslldq $8, T3
- psrldq $8, T2
- pxor T3, ACC
- pxor T2, T1 # <T1:ACC> is result of
- # carry-less multiplication
-
- # first phase of the reduction
- movaps ACC, T3
- psllq $1, T3
- pxor ACC, T3
- psllq $5, T3
- pxor ACC, T3
- psllq $57, T3
- movaps T3, T2
- pslldq $8, T2
- psrldq $8, T3
- pxor T2, ACC
- pxor T3, T1
-
- # second phase of the reduction
- movaps ACC, T2
- psrlq $5, T2
- pxor ACC, T2
- psrlq $1, T2
- pxor ACC, T2
- psrlq $1, T2
- pxor T2, T1
- pxor T1, ACC
- RET
-SYM_FUNC_END(__clmul_gf128mul_ble)
-
-/*
- * void polyval_mul_pclmul(struct polyval_elem *a,
- * const struct polyval_elem *b)
- */
-SYM_FUNC_START(polyval_mul_pclmul)
- FRAME_BEGIN
- movups (%rdi), ACC
- movups (%rsi), KEY
- call __clmul_gf128mul_ble
- movups ACC, (%rdi)
- FRAME_END
- RET
-SYM_FUNC_END(polyval_mul_pclmul)
-
-/*
- * void ghash_blocks_pclmul(struct polyval_elem *acc,
- * const struct polyval_elem *key,
- * const u8 *data, size_t nblocks)
- */
-SYM_FUNC_START(ghash_blocks_pclmul)
- FRAME_BEGIN
- movaps .Lbswap_mask(%rip), BSWAP
- movups (%rdi), ACC
- movups (%rsi), KEY
-.align 4
-.Lnext_block:
- movups (%rdx), IN1
- pshufb BSWAP, IN1
- pxor IN1, ACC
- call __clmul_gf128mul_ble
- add $16, %rdx
- dec %rcx
- jnz .Lnext_block
- movups ACC, (%rdi)
- FRAME_END
- RET
-SYM_FUNC_END(ghash_blocks_pclmul)
diff --git a/lib/crypto/x86/polyval-pclmul-avx.S b/lib/crypto/x86/polyval-pclmul-avx.S
deleted file mode 100644
index 7f739465ad35f..0000000000000
--- a/lib/crypto/x86/polyval-pclmul-avx.S
+++ /dev/null
@@ -1,319 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright 2021 Google LLC
- */
-/*
- * This is an efficient implementation of POLYVAL using intel PCLMULQDQ-NI
- * instructions. It works on 8 blocks at a time, by precomputing the first 8
- * keys powers h^8, ..., h^1 in the POLYVAL finite field. This precomputation
- * allows us to split finite field multiplication into two steps.
- *
- * In the first step, we consider h^i, m_i as normal polynomials of degree less
- * than 128. We then compute p(x) = h^8m_0 + ... + h^1m_7 where multiplication
- * is simply polynomial multiplication.
- *
- * In the second step, we compute the reduction of p(x) modulo the finite field
- * modulus g(x) = x^128 + x^127 + x^126 + x^121 + 1.
- *
- * This two step process is equivalent to computing h^8m_0 + ... + h^1m_7 where
- * multiplication is finite field multiplication. The advantage is that the
- * two-step process only requires 1 finite field reduction for every 8
- * polynomial multiplications. Further parallelism is gained by interleaving the
- * multiplications and polynomial reductions.
- */
-
-#include <linux/linkage.h>
-#include <asm/frame.h>
-
-#define STRIDE_BLOCKS 8
-
-#define GSTAR %xmm7
-#define PL %xmm8
-#define PH %xmm9
-#define TMP_XMM %xmm11
-#define LO %xmm12
-#define HI %xmm13
-#define MI %xmm14
-#define SUM %xmm15
-
-#define ACCUMULATOR %rdi
-#define KEY_POWERS %rsi
-#define MSG %rdx
-#define BLOCKS_LEFT %rcx
-#define TMP %rax
-
-.section .rodata.cst16.gstar, "aM", @progbits, 16
-.align 16
-
-.Lgstar:
- .quad 0xc200000000000000, 0xc200000000000000
-
-.text
-
-/*
- * Performs schoolbook1_iteration on two lists of 128-bit polynomials of length
- * count pointed to by MSG and KEY_POWERS.
- */
-.macro schoolbook1 count
- .set i, 0
- .rept (\count)
- schoolbook1_iteration i 0
- .set i, (i +1)
- .endr
-.endm
-
-/*
- * Computes the product of two 128-bit polynomials at the memory locations
- * specified by (MSG + 16*i) and (KEY_POWERS + 16*i) and XORs the components of
- * the 256-bit product into LO, MI, HI.
- *
- * Given:
- * X = [X_1 : X_0]
- * Y = [Y_1 : Y_0]
- *
- * We compute:
- * LO += X_0 * Y_0
- * MI += X_0 * Y_1 + X_1 * Y_0
- * HI += X_1 * Y_1
- *
- * Later, the 256-bit result can be extracted as:
- * [HI_1 : HI_0 + MI_1 : LO_1 + MI_0 : LO_0]
- * This step is done when computing the polynomial reduction for efficiency
- * reasons.
- *
- * If xor_sum == 1, then also XOR the value of SUM into m_0. This avoids an
- * extra multiplication of SUM and h^8.
- */
-.macro schoolbook1_iteration i xor_sum
- movups (16*\i)(MSG), %xmm0
- .if (\i == 0 && \xor_sum == 1)
- pxor SUM, %xmm0
- .endif
- vpclmulqdq $0x01, (16*\i)(KEY_POWERS), %xmm0, %xmm2
- vpclmulqdq $0x00, (16*\i)(KEY_POWERS), %xmm0, %xmm1
- vpclmulqdq $0x10, (16*\i)(KEY_POWERS), %xmm0, %xmm3
- vpclmulqdq $0x11, (16*\i)(KEY_POWERS), %xmm0, %xmm4
- vpxor %xmm2, MI, MI
- vpxor %xmm1, LO, LO
- vpxor %xmm4, HI, HI
- vpxor %xmm3, MI, MI
-.endm
-
-/*
- * Performs the same computation as schoolbook1_iteration, except we expect the
- * arguments to already be loaded into xmm0 and xmm1 and we set the result
- * registers LO, MI, and HI directly rather than XOR'ing into them.
- */
-.macro schoolbook1_noload
- vpclmulqdq $0x01, %xmm0, %xmm1, MI
- vpclmulqdq $0x10, %xmm0, %xmm1, %xmm2
- vpclmulqdq $0x00, %xmm0, %xmm1, LO
- vpclmulqdq $0x11, %xmm0, %xmm1, HI
- vpxor %xmm2, MI, MI
-.endm
-
-/*
- * Computes the 256-bit polynomial represented by LO, HI, MI. Stores
- * the result in PL, PH.
- * [PH : PL] = [HI_1 : HI_0 + MI_1 : LO_1 + MI_0 : LO_0]
- */
-.macro schoolbook2
- vpslldq $8, MI, PL
- vpsrldq $8, MI, PH
- pxor LO, PL
- pxor HI, PH
-.endm
-
-/*
- * Computes the 128-bit reduction of PH : PL. Stores the result in dest.
- *
- * This macro computes p(x) mod g(x) where p(x) is in montgomery form and g(x) =
- * x^128 + x^127 + x^126 + x^121 + 1.
- *
- * We have a 256-bit polynomial PH : PL = P_3 : P_2 : P_1 : P_0 that is the
- * product of two 128-bit polynomials in Montgomery form. We need to reduce it
- * mod g(x). Also, since polynomials in Montgomery form have an "extra" factor
- * of x^128, this product has two extra factors of x^128. To get it back into
- * Montgomery form, we need to remove one of these factors by dividing by x^128.
- *
- * To accomplish both of these goals, we add multiples of g(x) that cancel out
- * the low 128 bits P_1 : P_0, leaving just the high 128 bits. Since the low
- * bits are zero, the polynomial division by x^128 can be done by right shifting.
- *
- * Since the only nonzero term in the low 64 bits of g(x) is the constant term,
- * the multiple of g(x) needed to cancel out P_0 is P_0 * g(x). The CPU can
- * only do 64x64 bit multiplications, so split P_0 * g(x) into x^128 * P_0 +
- * x^64 * g*(x) * P_0 + P_0, where g*(x) is bits 64-127 of g(x). Adding this to
- * the original polynomial gives P_3 : P_2 + P_0 + T_1 : P_1 + T_0 : 0, where T
- * = T_1 : T_0 = g*(x) * P_0. Thus, bits 0-63 got "folded" into bits 64-191.
- *
- * Repeating this same process on the next 64 bits "folds" bits 64-127 into bits
- * 128-255, giving the answer in bits 128-255. This time, we need to cancel P_1
- * + T_0 in bits 64-127. The multiple of g(x) required is (P_1 + T_0) * g(x) *
- * x^64. Adding this to our previous computation gives P_3 + P_1 + T_0 + V_1 :
- * P_2 + P_0 + T_1 + V_0 : 0 : 0, where V = V_1 : V_0 = g*(x) * (P_1 + T_0).
- *
- * So our final computation is:
- * T = T_1 : T_0 = g*(x) * P_0
- * V = V_1 : V_0 = g*(x) * (P_1 + T_0)
- * p(x) / x^{128} mod g(x) = P_3 + P_1 + T_0 + V_1 : P_2 + P_0 + T_1 + V_0
- *
- * The implementation below saves a XOR instruction by computing P_1 + T_0 : P_0
- * + T_1 and XORing into dest, rather than separately XORing P_1 : P_0 and T_0 :
- * T_1 into dest. This allows us to reuse P_1 + T_0 when computing V.
- */
-.macro montgomery_reduction dest
- vpclmulqdq $0x00, PL, GSTAR, TMP_XMM # TMP_XMM = T_1 : T_0 = P_0 * g*(x)
- pshufd $0b01001110, TMP_XMM, TMP_XMM # TMP_XMM = T_0 : T_1
- pxor PL, TMP_XMM # TMP_XMM = P_1 + T_0 : P_0 + T_1
- pxor TMP_XMM, PH # PH = P_3 + P_1 + T_0 : P_2 + P_0 + T_1
- pclmulqdq $0x11, GSTAR, TMP_XMM # TMP_XMM = V_1 : V_0 = V = [(P_1 + T_0) * g*(x)]
- vpxor TMP_XMM, PH, \dest
-.endm
-
-/*
- * Compute schoolbook multiplication for 8 blocks
- * m_0h^8 + ... + m_7h^1
- *
- * If reduce is set, also computes the montgomery reduction of the
- * previous full_stride call and XORs with the first message block.
- * (m_0 + REDUCE(PL, PH))h^8 + ... + m_7h^1.
- * I.e., the first multiplication uses m_0 + REDUCE(PL, PH) instead of m_0.
- */
-.macro full_stride reduce
- pxor LO, LO
- pxor HI, HI
- pxor MI, MI
-
- schoolbook1_iteration 7 0
- .if \reduce
- vpclmulqdq $0x00, PL, GSTAR, TMP_XMM
- .endif
-
- schoolbook1_iteration 6 0
- .if \reduce
- pshufd $0b01001110, TMP_XMM, TMP_XMM
- .endif
-
- schoolbook1_iteration 5 0
- .if \reduce
- pxor PL, TMP_XMM
- .endif
-
- schoolbook1_iteration 4 0
- .if \reduce
- pxor TMP_XMM, PH
- .endif
-
- schoolbook1_iteration 3 0
- .if \reduce
- pclmulqdq $0x11, GSTAR, TMP_XMM
- .endif
-
- schoolbook1_iteration 2 0
- .if \reduce
- vpxor TMP_XMM, PH, SUM
- .endif
-
- schoolbook1_iteration 1 0
-
- schoolbook1_iteration 0 1
-
- addq $(8*16), MSG
- schoolbook2
-.endm
-
-/*
- * Process BLOCKS_LEFT blocks, where 0 < BLOCKS_LEFT < STRIDE_BLOCKS
- */
-.macro partial_stride
- mov BLOCKS_LEFT, TMP
- shlq $4, TMP
- addq $(16*STRIDE_BLOCKS), KEY_POWERS
- subq TMP, KEY_POWERS
-
- movups (MSG), %xmm0
- pxor SUM, %xmm0
- movups (KEY_POWERS), %xmm1
- schoolbook1_noload
- dec BLOCKS_LEFT
- addq $16, MSG
- addq $16, KEY_POWERS
-
- test $4, BLOCKS_LEFT
- jz .Lpartial4BlocksDone
- schoolbook1 4
- addq $(4*16), MSG
- addq $(4*16), KEY_POWERS
-.Lpartial4BlocksDone:
- test $2, BLOCKS_LEFT
- jz .Lpartial2BlocksDone
- schoolbook1 2
- addq $(2*16), MSG
- addq $(2*16), KEY_POWERS
-.Lpartial2BlocksDone:
- test $1, BLOCKS_LEFT
- jz .LpartialDone
- schoolbook1 1
-.LpartialDone:
- schoolbook2
- montgomery_reduction SUM
-.endm
-
-/*
- * Computes a = a * b * x^{-128} mod x^128 + x^127 + x^126 + x^121 + 1.
- *
- * void polyval_mul_pclmul_avx(struct polyval_elem *a,
- * const struct polyval_elem *b);
- */
-SYM_FUNC_START(polyval_mul_pclmul_avx)
- FRAME_BEGIN
- vmovdqa .Lgstar(%rip), GSTAR
- movups (%rdi), %xmm0
- movups (%rsi), %xmm1
- schoolbook1_noload
- schoolbook2
- montgomery_reduction SUM
- movups SUM, (%rdi)
- FRAME_END
- RET
-SYM_FUNC_END(polyval_mul_pclmul_avx)
-
-/*
- * Perform polynomial evaluation as specified by POLYVAL. This computes:
- * h^n * accumulator + h^n * m_0 + ... + h^1 * m_{n-1}
- * where n=nblocks, h is the hash key, and m_i are the message blocks.
- *
- * rdi - pointer to the accumulator
- * rsi - pointer to precomputed key powers h^8 ... h^1
- * rdx - pointer to message blocks
- * rcx - number of blocks to hash
- *
- * void polyval_blocks_pclmul_avx(struct polyval_elem *acc,
- * const struct polyval_key *key,
- * const u8 *data, size_t nblocks);
- */
-SYM_FUNC_START(polyval_blocks_pclmul_avx)
- FRAME_BEGIN
- vmovdqa .Lgstar(%rip), GSTAR
- movups (ACCUMULATOR), SUM
- subq $STRIDE_BLOCKS, BLOCKS_LEFT
- js .LstrideLoopExit
- full_stride 0
- subq $STRIDE_BLOCKS, BLOCKS_LEFT
- js .LstrideLoopExitReduce
-.LstrideLoop:
- full_stride 1
- subq $STRIDE_BLOCKS, BLOCKS_LEFT
- jns .LstrideLoop
-.LstrideLoopExitReduce:
- montgomery_reduction SUM
-.LstrideLoopExit:
- add $STRIDE_BLOCKS, BLOCKS_LEFT
- jz .LskipPartial
- partial_stride
-.LskipPartial:
- movups SUM, (ACCUMULATOR)
- FRAME_END
- RET
-SYM_FUNC_END(polyval_blocks_pclmul_avx)
--
2.56.1
next prev parent reply other threads:[~2026-11-29 20:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 20:02 [PATCH 00/11] Migrate x86_64 AES-GCM code into library Eric Biggers
2026-11-29 20:02 ` [PATCH 01/11] crypto: aes - Flush dcache in CBC-CTS and XTS linear fast paths Eric Biggers
2026-11-29 20:02 ` [PATCH 02/11] lib/crypto: gf128hash: Link libgf128hash before libaes Eric Biggers
2026-11-29 20:02 ` [PATCH 03/11] lib/crypto: aes-gcm: Add one-shot AES-GCM arch hooks Eric Biggers
2026-11-29 20:02 ` [PATCH 04/11] crypto: aes - Add linear fast path for AES-GCM Eric Biggers
2026-11-29 20:02 ` Eric Biggers [this message]
2026-11-29 20:02 ` [PATCH 06/11] lib/crypto: x86/gf128hash: Optimize GHASH and POLYVAL with VPCLMULQDQ and AVX2 Eric Biggers
2026-11-29 20:02 ` [PATCH 07/11] lib/crypto: x86/gf128hash: Optimize GHASH and POLYVAL with VPCLMULQDQ and AVX512 Eric Biggers
2026-11-29 20:02 ` [PATCH 08/11] lib/crypto: x86/aes-gcm: Migrate AES-NI optimized code into library Eric Biggers
2026-11-29 20:02 ` [PATCH 09/11] lib/crypto: x86/aes-gcm: Migrate VAES+AVX2 " Eric Biggers
2026-11-29 20:02 ` [PATCH 10/11] lib/crypto: x86/aes-gcm: Migrate VAES+AVX512 " Eric Biggers
2026-11-29 20:02 ` [PATCH 11/11] crypto: x86/aesni-intel - Remove empty module Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129200245.146503-6-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=antonio@mandelbit.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox