Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: x86/aegis128 - optimize length block preparation using SSE4.1

Start using SSE4.1 instructions in the AES-NI AEGIS code, with the first
use case being preparing the length block in fewer instructions.

In practice this does not reduce the set of CPUs on which the code can
run, because all Intel and AMD CPUs with AES-NI also have SSE4.1.

Upgrade the existing SSE2 feature check to SSE4.1, though it seems this
check is not strictly necessary; the aesni-intel module has been getting
away with using SSE4.1 despite checking for AES-NI only.

Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
af2aff7c 595bca25

+7 -9
+2 -2
arch/x86/crypto/Kconfig
··· 363 363 - AVX-512VL (Advanced Vector Extensions-512VL) 364 364 365 365 config CRYPTO_AEGIS128_AESNI_SSE2 366 - tristate "AEAD ciphers: AEGIS-128 (AES-NI/SSE2)" 366 + tristate "AEAD ciphers: AEGIS-128 (AES-NI/SSE4.1)" 367 367 depends on X86 && 64BIT 368 368 select CRYPTO_AEAD 369 369 select CRYPTO_SIMD ··· 372 372 373 373 Architecture: x86_64 using: 374 374 - AES-NI (AES New Instructions) 375 - - SSE2 (Streaming SIMD Extensions 2) 375 + - SSE4.1 (Streaming SIMD Extensions 4.1) 376 376 377 377 config CRYPTO_NHPOLY1305_SSE2 378 378 tristate "Hash functions: NHPoly1305 (SSE2)"
+2 -4
arch/x86/crypto/aegis128-aesni-asm.S
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 2 /* 3 - * AES-NI + SSE2 implementation of AEGIS-128 3 + * AES-NI + SSE4.1 implementation of AEGIS-128 4 4 * 5 5 * Copyright (c) 2017-2018 Ondrej Mosnacek <omosnacek@gmail.com> 6 6 * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. ··· 638 638 639 639 /* prepare length block: */ 640 640 movd %edx, MSG 641 - movd %ecx, T0 642 - pslldq $8, T0 643 - pxor T0, MSG 641 + pinsrd $2, %ecx, MSG 644 642 psllq $3, MSG /* multiply by 8 (to get bit count) */ 645 643 646 644 pxor STATE3, MSG
+3 -3
arch/x86/crypto/aegis128-aesni-glue.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 /* 3 3 * The AEGIS-128 Authenticated-Encryption Algorithm 4 - * Glue for AES-NI + SSE2 implementation 4 + * Glue for AES-NI + SSE4.1 implementation 5 5 * 6 6 * Copyright (c) 2017-2018 Ondrej Mosnacek <omosnacek@gmail.com> 7 7 * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. ··· 254 254 255 255 static int __init crypto_aegis128_aesni_module_init(void) 256 256 { 257 - if (!boot_cpu_has(X86_FEATURE_XMM2) || 257 + if (!boot_cpu_has(X86_FEATURE_XMM4_1) || 258 258 !boot_cpu_has(X86_FEATURE_AES) || 259 259 !cpu_has_xfeatures(XFEATURE_MASK_SSE, NULL)) 260 260 return -ENODEV; ··· 273 273 274 274 MODULE_LICENSE("GPL"); 275 275 MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>"); 276 - MODULE_DESCRIPTION("AEGIS-128 AEAD algorithm -- AESNI+SSE2 implementation"); 276 + MODULE_DESCRIPTION("AEGIS-128 AEAD algorithm -- AESNI+SSE4.1 implementation"); 277 277 MODULE_ALIAS_CRYPTO("aegis128"); 278 278 MODULE_ALIAS_CRYPTO("aegis128-aesni");