aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/crypto/aesni-intel_glue.c12
-rw-r--r--arch/x86/crypto/crc32c-intel.c11
-rw-r--r--arch/x86/crypto/ghash-clmulni-intel_glue.c12
-rw-r--r--drivers/crypto/padlock-aes.c9
-rw-r--r--drivers/crypto/padlock-sha.c16
5 files changed, 41 insertions, 19 deletions
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 545d0ce59818..b3350bd32c60 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -28,6 +28,7 @@
28#include <crypto/aes.h> 28#include <crypto/aes.h>
29#include <crypto/cryptd.h> 29#include <crypto/cryptd.h>
30#include <crypto/ctr.h> 30#include <crypto/ctr.h>
31#include <asm/cpu_device_id.h>
31#include <asm/i387.h> 32#include <asm/i387.h>
32#include <asm/aes.h> 33#include <asm/aes.h>
33#include <crypto/scatterwalk.h> 34#include <crypto/scatterwalk.h>
@@ -1253,14 +1254,19 @@ static struct crypto_alg __rfc4106_alg = {
1253}; 1254};
1254#endif 1255#endif
1255 1256
1257
1258static const struct x86_cpu_id aesni_cpu_id[] = {
1259 X86_FEATURE_MATCH(X86_FEATURE_AES),
1260 {}
1261};
1262MODULE_DEVICE_TABLE(x86cpu, aesni_cpu_id);
1263
1256static int __init aesni_init(void) 1264static int __init aesni_init(void)
1257{ 1265{
1258 int err; 1266 int err;
1259 1267
1260 if (!cpu_has_aes) { 1268 if (!x86_match_cpu(aesni_cpu_id))
1261 printk(KERN_INFO "Intel AES-NI instructions are not detected.\n");
1262 return -ENODEV; 1269 return -ENODEV;
1263 }
1264 1270
1265 if ((err = crypto_fpu_init())) 1271 if ((err = crypto_fpu_init()))
1266 goto fpu_err; 1272 goto fpu_err;
diff --git a/arch/x86/crypto/crc32c-intel.c b/arch/x86/crypto/crc32c-intel.c
index b9d00261703c..493f959261f7 100644
--- a/arch/x86/crypto/crc32c-intel.c
+++ b/arch/x86/crypto/crc32c-intel.c
@@ -31,6 +31,7 @@
31#include <crypto/internal/hash.h> 31#include <crypto/internal/hash.h>
32 32
33#include <asm/cpufeature.h> 33#include <asm/cpufeature.h>
34#include <asm/cpu_device_id.h>
34 35
35#define CHKSUM_BLOCK_SIZE 1 36#define CHKSUM_BLOCK_SIZE 1
36#define CHKSUM_DIGEST_SIZE 4 37#define CHKSUM_DIGEST_SIZE 4
@@ -173,13 +174,17 @@ static struct shash_alg alg = {
173 } 174 }
174}; 175};
175 176
177static const struct x86_cpu_id crc32c_cpu_id[] = {
178 X86_FEATURE_MATCH(X86_FEATURE_XMM4_2),
179 {}
180};
181MODULE_DEVICE_TABLE(x86cpu, crc32c_cpu_id);
176 182
177static int __init crc32c_intel_mod_init(void) 183static int __init crc32c_intel_mod_init(void)
178{ 184{
179 if (cpu_has_xmm4_2) 185 if (!x86_match_cpu(crc32c_cpu_id))
180 return crypto_register_shash(&alg);
181 else
182 return -ENODEV; 186 return -ENODEV;
187 return crypto_register_shash(&alg);
183} 188}
184 189
185static void __exit crc32c_intel_mod_fini(void) 190static void __exit crc32c_intel_mod_fini(void)
diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c
index 976aa64d9a20..b4bf0a63b520 100644
--- a/arch/x86/crypto/ghash-clmulni-intel_glue.c
+++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c
@@ -20,6 +20,7 @@
20#include <crypto/gf128mul.h> 20#include <crypto/gf128mul.h>
21#include <crypto/internal/hash.h> 21#include <crypto/internal/hash.h>
22#include <asm/i387.h> 22#include <asm/i387.h>
23#include <asm/cpu_device_id.h>
23 24
24#define GHASH_BLOCK_SIZE 16 25#define GHASH_BLOCK_SIZE 16
25#define GHASH_DIGEST_SIZE 16 26#define GHASH_DIGEST_SIZE 16
@@ -294,15 +295,18 @@ static struct ahash_alg ghash_async_alg = {
294 }, 295 },
295}; 296};
296 297
298static const struct x86_cpu_id pcmul_cpu_id[] = {
299 X86_FEATURE_MATCH(X86_FEATURE_PCLMULQDQ), /* Pickle-Mickle-Duck */
300 {}
301};
302MODULE_DEVICE_TABLE(x86cpu, pcmul_cpu_id);
303
297static int __init ghash_pclmulqdqni_mod_init(void) 304static int __init ghash_pclmulqdqni_mod_init(void)
298{ 305{
299 int err; 306 int err;
300 307
301 if (!cpu_has_pclmulqdq) { 308 if (!x86_match_cpu(pcmul_cpu_id))
302 printk(KERN_INFO "Intel PCLMULQDQ-NI instructions are not"
303 " detected.\n");
304 return -ENODEV; 309 return -ENODEV;
305 }
306 310
307 err = crypto_register_shash(&ghash_alg); 311 err = crypto_register_shash(&ghash_alg);
308 if (err) 312 if (err)
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 29b9469f8378..37b2e9406af6 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -19,6 +19,7 @@
19#include <linux/percpu.h> 19#include <linux/percpu.h>
20#include <linux/smp.h> 20#include <linux/smp.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <asm/cpu_device_id.h>
22#include <asm/byteorder.h> 23#include <asm/byteorder.h>
23#include <asm/processor.h> 24#include <asm/processor.h>
24#include <asm/i387.h> 25#include <asm/i387.h>
@@ -503,12 +504,18 @@ static struct crypto_alg cbc_aes_alg = {
503 } 504 }
504}; 505};
505 506
507static struct x86_cpu_id padlock_cpu_id[] = {
508 X86_FEATURE_MATCH(X86_FEATURE_XCRYPT),
509 {}
510};
511MODULE_DEVICE_TABLE(x86cpu, padlock_cpu_id);
512
506static int __init padlock_init(void) 513static int __init padlock_init(void)
507{ 514{
508 int ret; 515 int ret;
509 struct cpuinfo_x86 *c = &cpu_data(0); 516 struct cpuinfo_x86 *c = &cpu_data(0);
510 517
511 if (!cpu_has_xcrypt) 518 if (!x86_match_cpu(padlock_cpu_id))
512 return -ENODEV; 519 return -ENODEV;
513 520
514 if (!cpu_has_xcrypt_enabled) { 521 if (!cpu_has_xcrypt_enabled) {
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index 06bdb4b2c6a6..9266c0e25492 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -22,6 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/scatterlist.h> 24#include <linux/scatterlist.h>
25#include <asm/cpu_device_id.h>
25#include <asm/i387.h> 26#include <asm/i387.h>
26 27
27struct padlock_sha_desc { 28struct padlock_sha_desc {
@@ -526,6 +527,12 @@ static struct shash_alg sha256_alg_nano = {
526 } 527 }
527}; 528};
528 529
530static struct x86_cpu_id padlock_sha_ids[] = {
531 X86_FEATURE_MATCH(X86_FEATURE_PHE),
532 {}
533};
534MODULE_DEVICE_TABLE(x86cpu, padlock_sha_ids);
535
529static int __init padlock_init(void) 536static int __init padlock_init(void)
530{ 537{
531 int rc = -ENODEV; 538 int rc = -ENODEV;
@@ -533,15 +540,8 @@ static int __init padlock_init(void)
533 struct shash_alg *sha1; 540 struct shash_alg *sha1;
534 struct shash_alg *sha256; 541 struct shash_alg *sha256;
535 542
536 if (!cpu_has_phe) { 543 if (!x86_match_cpu(padlock_sha_ids) || !cpu_has_phe_enabled)
537 printk(KERN_NOTICE PFX "VIA PadLock Hash Engine not detected.\n");
538 return -ENODEV;
539 }
540
541 if (!cpu_has_phe_enabled) {
542 printk(KERN_NOTICE PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n");
543 return -ENODEV; 544 return -ENODEV;
544 }
545 545
546 /* Register the newly added algorithm module if on * 546 /* Register the newly added algorithm module if on *
547 * VIA Nano processor, or else just do as before */ 547 * VIA Nano processor, or else just do as before */