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/sha512 - load based on CPU features

x86 optimized crypto modules built as modules rather than built-in
to the kernel end up as .ko files in the filesystem, e.g., in
/usr/lib/modules. If the filesystem itself is a module, these might
not be available when the crypto API is initialized, resulting in
the generic implementation being used (e.g., sha512_transform rather
than sha512_transform_avx2).

In one test case, CPU utilization in the sha512 function dropped
from 15.34% to 7.18% after forcing loading of the optimized module.

Add module aliases for this x86 optimized crypto module based on CPU
feature bits so udev gets a chance to load them later in the boot
process when the filesystems are all running.

Signed-off-by: Robert Elliott <elliott@hpe.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Robert Elliott and committed by
Herbert Xu
aa031b8f 6a088a2c

+10
+10
arch/x86/crypto/sha512_ssse3_glue.c
··· 36 36 #include <linux/types.h> 37 37 #include <crypto/sha2.h> 38 38 #include <crypto/sha512_base.h> 39 + #include <asm/cpu_device_id.h> 39 40 #include <asm/simd.h> 40 41 41 42 asmlinkage void sha512_transform_ssse3(struct sha512_state *state, ··· 285 284 ARRAY_SIZE(sha512_avx2_algs)); 286 285 return 0; 287 286 } 287 + static const struct x86_cpu_id module_cpu_ids[] = { 288 + X86_MATCH_FEATURE(X86_FEATURE_AVX2, NULL), 289 + X86_MATCH_FEATURE(X86_FEATURE_AVX, NULL), 290 + X86_MATCH_FEATURE(X86_FEATURE_SSSE3, NULL), 291 + {} 292 + }; 293 + MODULE_DEVICE_TABLE(x86cpu, module_cpu_ids); 288 294 289 295 static void unregister_sha512_avx2(void) 290 296 { ··· 302 294 303 295 static int __init sha512_ssse3_mod_init(void) 304 296 { 297 + if (!x86_match_cpu(module_cpu_ids)) 298 + return -ENODEV; 305 299 306 300 if (register_sha512_ssse3()) 307 301 goto fail;