diff options
author | Mathias Krause <minipli@googlemail.com> | 2010-11-27 03:34:46 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-11-27 03:34:46 -0500 |
commit | 0d258efb6a58fe047197c3b9cff8746bb176d58a (patch) | |
tree | 8576f2af5212ec50509de1071cf7afe1ed9531a8 /arch/x86/crypto/aesni-intel_glue.c | |
parent | 21ea28abcf825729f9698afd7357dfbf7040d4f8 (diff) |
crypto: aesni-intel - Ported implementation to x86-32
The AES-NI instructions are also available in legacy mode so the 32-bit
architecture may profit from those, too.
To illustrate the performance gain here's a short summary of a dm-crypt
speed test on a Core i7 M620 running at 2.67GHz comparing both assembler
implementations:
x86: i568 aes-ni delta
ECB, 256 bit: 93.8 MB/s 123.3 MB/s +31.4%
CBC, 256 bit: 84.8 MB/s 262.3 MB/s +209.3%
LRW, 256 bit: 108.6 MB/s 222.1 MB/s +104.5%
XTS, 256 bit: 105.0 MB/s 205.5 MB/s +95.7%
Additionally, due to some minor optimizations, the 64-bit version also
got a minor performance gain as seen below:
x86-64: old impl. new impl. delta
ECB, 256 bit: 121.1 MB/s 123.0 MB/s +1.5%
CBC, 256 bit: 285.3 MB/s 290.8 MB/s +1.9%
LRW, 256 bit: 263.7 MB/s 265.3 MB/s +0.6%
XTS, 256 bit: 251.1 MB/s 255.3 MB/s +1.7%
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Reviewed-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/x86/crypto/aesni-intel_glue.c')
-rw-r--r-- | arch/x86/crypto/aesni-intel_glue.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index 02d349d64423..8a3b80075216 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c | |||
@@ -94,8 +94,10 @@ asmlinkage void aesni_cbc_enc(struct crypto_aes_ctx *ctx, u8 *out, | |||
94 | const u8 *in, unsigned int len, u8 *iv); | 94 | const u8 *in, unsigned int len, u8 *iv); |
95 | asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out, | 95 | asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out, |
96 | const u8 *in, unsigned int len, u8 *iv); | 96 | const u8 *in, unsigned int len, u8 *iv); |
97 | #ifdef CONFIG_X86_64 | ||
97 | asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out, | 98 | asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out, |
98 | const u8 *in, unsigned int len, u8 *iv); | 99 | const u8 *in, unsigned int len, u8 *iv); |
100 | #endif | ||
99 | 101 | ||
100 | /* asmlinkage void aesni_gcm_enc() | 102 | /* asmlinkage void aesni_gcm_enc() |
101 | * void *ctx, AES Key schedule. Starts on a 16 byte boundary. | 103 | * void *ctx, AES Key schedule. Starts on a 16 byte boundary. |
@@ -410,6 +412,7 @@ static struct crypto_alg blk_cbc_alg = { | |||
410 | }, | 412 | }, |
411 | }; | 413 | }; |
412 | 414 | ||
415 | #ifdef CONFIG_X86_64 | ||
413 | static void ctr_crypt_final(struct crypto_aes_ctx *ctx, | 416 | static void ctr_crypt_final(struct crypto_aes_ctx *ctx, |
414 | struct blkcipher_walk *walk) | 417 | struct blkcipher_walk *walk) |
415 | { | 418 | { |
@@ -475,6 +478,7 @@ static struct crypto_alg blk_ctr_alg = { | |||
475 | }, | 478 | }, |
476 | }, | 479 | }, |
477 | }; | 480 | }; |
481 | #endif | ||
478 | 482 | ||
479 | static int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, | 483 | static int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, |
480 | unsigned int key_len) | 484 | unsigned int key_len) |
@@ -622,6 +626,7 @@ static struct crypto_alg ablk_cbc_alg = { | |||
622 | }, | 626 | }, |
623 | }; | 627 | }; |
624 | 628 | ||
629 | #ifdef CONFIG_X86_64 | ||
625 | static int ablk_ctr_init(struct crypto_tfm *tfm) | 630 | static int ablk_ctr_init(struct crypto_tfm *tfm) |
626 | { | 631 | { |
627 | struct cryptd_ablkcipher *cryptd_tfm; | 632 | struct cryptd_ablkcipher *cryptd_tfm; |
@@ -698,6 +703,7 @@ static struct crypto_alg ablk_rfc3686_ctr_alg = { | |||
698 | }, | 703 | }, |
699 | }; | 704 | }; |
700 | #endif | 705 | #endif |
706 | #endif | ||
701 | 707 | ||
702 | #ifdef HAS_LRW | 708 | #ifdef HAS_LRW |
703 | static int ablk_lrw_init(struct crypto_tfm *tfm) | 709 | static int ablk_lrw_init(struct crypto_tfm *tfm) |
@@ -1249,18 +1255,20 @@ static int __init aesni_init(void) | |||
1249 | goto blk_ecb_err; | 1255 | goto blk_ecb_err; |
1250 | if ((err = crypto_register_alg(&blk_cbc_alg))) | 1256 | if ((err = crypto_register_alg(&blk_cbc_alg))) |
1251 | goto blk_cbc_err; | 1257 | goto blk_cbc_err; |
1252 | if ((err = crypto_register_alg(&blk_ctr_alg))) | ||
1253 | goto blk_ctr_err; | ||
1254 | if ((err = crypto_register_alg(&ablk_ecb_alg))) | 1258 | if ((err = crypto_register_alg(&ablk_ecb_alg))) |
1255 | goto ablk_ecb_err; | 1259 | goto ablk_ecb_err; |
1256 | if ((err = crypto_register_alg(&ablk_cbc_alg))) | 1260 | if ((err = crypto_register_alg(&ablk_cbc_alg))) |
1257 | goto ablk_cbc_err; | 1261 | goto ablk_cbc_err; |
1262 | #ifdef CONFIG_X86_64 | ||
1263 | if ((err = crypto_register_alg(&blk_ctr_alg))) | ||
1264 | goto blk_ctr_err; | ||
1258 | if ((err = crypto_register_alg(&ablk_ctr_alg))) | 1265 | if ((err = crypto_register_alg(&ablk_ctr_alg))) |
1259 | goto ablk_ctr_err; | 1266 | goto ablk_ctr_err; |
1260 | #ifdef HAS_CTR | 1267 | #ifdef HAS_CTR |
1261 | if ((err = crypto_register_alg(&ablk_rfc3686_ctr_alg))) | 1268 | if ((err = crypto_register_alg(&ablk_rfc3686_ctr_alg))) |
1262 | goto ablk_rfc3686_ctr_err; | 1269 | goto ablk_rfc3686_ctr_err; |
1263 | #endif | 1270 | #endif |
1271 | #endif | ||
1264 | #ifdef HAS_LRW | 1272 | #ifdef HAS_LRW |
1265 | if ((err = crypto_register_alg(&ablk_lrw_alg))) | 1273 | if ((err = crypto_register_alg(&ablk_lrw_alg))) |
1266 | goto ablk_lrw_err; | 1274 | goto ablk_lrw_err; |
@@ -1296,18 +1304,20 @@ ablk_pcbc_err: | |||
1296 | crypto_unregister_alg(&ablk_lrw_alg); | 1304 | crypto_unregister_alg(&ablk_lrw_alg); |
1297 | ablk_lrw_err: | 1305 | ablk_lrw_err: |
1298 | #endif | 1306 | #endif |
1307 | #ifdef CONFIG_X86_64 | ||
1299 | #ifdef HAS_CTR | 1308 | #ifdef HAS_CTR |
1300 | crypto_unregister_alg(&ablk_rfc3686_ctr_alg); | 1309 | crypto_unregister_alg(&ablk_rfc3686_ctr_alg); |
1301 | ablk_rfc3686_ctr_err: | 1310 | ablk_rfc3686_ctr_err: |
1302 | #endif | 1311 | #endif |
1303 | crypto_unregister_alg(&ablk_ctr_alg); | 1312 | crypto_unregister_alg(&ablk_ctr_alg); |
1304 | ablk_ctr_err: | 1313 | ablk_ctr_err: |
1314 | crypto_unregister_alg(&blk_ctr_alg); | ||
1315 | blk_ctr_err: | ||
1316 | #endif | ||
1305 | crypto_unregister_alg(&ablk_cbc_alg); | 1317 | crypto_unregister_alg(&ablk_cbc_alg); |
1306 | ablk_cbc_err: | 1318 | ablk_cbc_err: |
1307 | crypto_unregister_alg(&ablk_ecb_alg); | 1319 | crypto_unregister_alg(&ablk_ecb_alg); |
1308 | ablk_ecb_err: | 1320 | ablk_ecb_err: |
1309 | crypto_unregister_alg(&blk_ctr_alg); | ||
1310 | blk_ctr_err: | ||
1311 | crypto_unregister_alg(&blk_cbc_alg); | 1321 | crypto_unregister_alg(&blk_cbc_alg); |
1312 | blk_cbc_err: | 1322 | blk_cbc_err: |
1313 | crypto_unregister_alg(&blk_ecb_alg); | 1323 | crypto_unregister_alg(&blk_ecb_alg); |
@@ -1332,13 +1342,15 @@ static void __exit aesni_exit(void) | |||
1332 | #ifdef HAS_LRW | 1342 | #ifdef HAS_LRW |
1333 | crypto_unregister_alg(&ablk_lrw_alg); | 1343 | crypto_unregister_alg(&ablk_lrw_alg); |
1334 | #endif | 1344 | #endif |
1345 | #ifdef CONFIG_X86_64 | ||
1335 | #ifdef HAS_CTR | 1346 | #ifdef HAS_CTR |
1336 | crypto_unregister_alg(&ablk_rfc3686_ctr_alg); | 1347 | crypto_unregister_alg(&ablk_rfc3686_ctr_alg); |
1337 | #endif | 1348 | #endif |
1338 | crypto_unregister_alg(&ablk_ctr_alg); | 1349 | crypto_unregister_alg(&ablk_ctr_alg); |
1350 | crypto_unregister_alg(&blk_ctr_alg); | ||
1351 | #endif | ||
1339 | crypto_unregister_alg(&ablk_cbc_alg); | 1352 | crypto_unregister_alg(&ablk_cbc_alg); |
1340 | crypto_unregister_alg(&ablk_ecb_alg); | 1353 | crypto_unregister_alg(&ablk_ecb_alg); |
1341 | crypto_unregister_alg(&blk_ctr_alg); | ||
1342 | crypto_unregister_alg(&blk_cbc_alg); | 1354 | crypto_unregister_alg(&blk_cbc_alg); |
1343 | crypto_unregister_alg(&blk_ecb_alg); | 1355 | crypto_unregister_alg(&blk_ecb_alg); |
1344 | crypto_unregister_alg(&__aesni_alg); | 1356 | crypto_unregister_alg(&__aesni_alg); |