2 * Glue Code for x86_64/AVX2/AES-NI assembler optimized version of Camellia
4 * Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/crypto.h>
16 #include <linux/err.h>
17 #include <crypto/ablk_helper.h>
18 #include <crypto/algapi.h>
19 #include <crypto/ctr.h>
20 #include <crypto/lrw.h>
21 #include <crypto/xts.h>
23 #include <asm/xsave.h>
24 #include <asm/crypto/camellia.h>
25 #include <asm/crypto/glue_helper.h>
27 #define CAMELLIA_AESNI_PARALLEL_BLOCKS 16
28 #define CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS 32
30 /* 32-way AVX2/AES-NI parallel cipher functions */
31 asmlinkage
void camellia_ecb_enc_32way(struct camellia_ctx
*ctx
, u8
*dst
,
33 asmlinkage
void camellia_ecb_dec_32way(struct camellia_ctx
*ctx
, u8
*dst
,
36 asmlinkage
void camellia_cbc_dec_32way(struct camellia_ctx
*ctx
, u8
*dst
,
38 asmlinkage
void camellia_ctr_32way(struct camellia_ctx
*ctx
, u8
*dst
,
39 const u8
*src
, le128
*iv
);
41 asmlinkage
void camellia_xts_enc_32way(struct camellia_ctx
*ctx
, u8
*dst
,
42 const u8
*src
, le128
*iv
);
43 asmlinkage
void camellia_xts_dec_32way(struct camellia_ctx
*ctx
, u8
*dst
,
44 const u8
*src
, le128
*iv
);
46 static const struct common_glue_ctx camellia_enc
= {
48 .fpu_blocks_limit
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
51 .num_blocks
= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
,
52 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_ecb_enc_32way
) }
54 .num_blocks
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
55 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_ecb_enc_16way
) }
58 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_enc_blk_2way
) }
61 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_enc_blk
) }
65 static const struct common_glue_ctx camellia_ctr
= {
67 .fpu_blocks_limit
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
70 .num_blocks
= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
,
71 .fn_u
= { .ctr
= GLUE_CTR_FUNC_CAST(camellia_ctr_32way
) }
73 .num_blocks
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
74 .fn_u
= { .ctr
= GLUE_CTR_FUNC_CAST(camellia_ctr_16way
) }
77 .fn_u
= { .ctr
= GLUE_CTR_FUNC_CAST(camellia_crypt_ctr_2way
) }
80 .fn_u
= { .ctr
= GLUE_CTR_FUNC_CAST(camellia_crypt_ctr
) }
84 static const struct common_glue_ctx camellia_enc_xts
= {
86 .fpu_blocks_limit
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
89 .num_blocks
= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
,
90 .fn_u
= { .xts
= GLUE_XTS_FUNC_CAST(camellia_xts_enc_32way
) }
92 .num_blocks
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
93 .fn_u
= { .xts
= GLUE_XTS_FUNC_CAST(camellia_xts_enc_16way
) }
96 .fn_u
= { .xts
= GLUE_XTS_FUNC_CAST(camellia_xts_enc
) }
100 static const struct common_glue_ctx camellia_dec
= {
102 .fpu_blocks_limit
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
105 .num_blocks
= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
,
106 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_ecb_dec_32way
) }
108 .num_blocks
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
109 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_ecb_dec_16way
) }
112 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_dec_blk_2way
) }
115 .fn_u
= { .ecb
= GLUE_FUNC_CAST(camellia_dec_blk
) }
119 static const struct common_glue_ctx camellia_dec_cbc
= {
121 .fpu_blocks_limit
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
124 .num_blocks
= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
,
125 .fn_u
= { .cbc
= GLUE_CBC_FUNC_CAST(camellia_cbc_dec_32way
) }
127 .num_blocks
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
128 .fn_u
= { .cbc
= GLUE_CBC_FUNC_CAST(camellia_cbc_dec_16way
) }
131 .fn_u
= { .cbc
= GLUE_CBC_FUNC_CAST(camellia_decrypt_cbc_2way
) }
134 .fn_u
= { .cbc
= GLUE_CBC_FUNC_CAST(camellia_dec_blk
) }
138 static const struct common_glue_ctx camellia_dec_xts
= {
140 .fpu_blocks_limit
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
143 .num_blocks
= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
,
144 .fn_u
= { .xts
= GLUE_XTS_FUNC_CAST(camellia_xts_dec_32way
) }
146 .num_blocks
= CAMELLIA_AESNI_PARALLEL_BLOCKS
,
147 .fn_u
= { .xts
= GLUE_XTS_FUNC_CAST(camellia_xts_dec_16way
) }
150 .fn_u
= { .xts
= GLUE_XTS_FUNC_CAST(camellia_xts_dec
) }
154 static int ecb_encrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
155 struct scatterlist
*src
, unsigned int nbytes
)
157 return glue_ecb_crypt_128bit(&camellia_enc
, desc
, dst
, src
, nbytes
);
160 static int ecb_decrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
161 struct scatterlist
*src
, unsigned int nbytes
)
163 return glue_ecb_crypt_128bit(&camellia_dec
, desc
, dst
, src
, nbytes
);
166 static int cbc_encrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
167 struct scatterlist
*src
, unsigned int nbytes
)
169 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(camellia_enc_blk
), desc
,
173 static int cbc_decrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
174 struct scatterlist
*src
, unsigned int nbytes
)
176 return glue_cbc_decrypt_128bit(&camellia_dec_cbc
, desc
, dst
, src
,
180 static int ctr_crypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
181 struct scatterlist
*src
, unsigned int nbytes
)
183 return glue_ctr_crypt_128bit(&camellia_ctr
, desc
, dst
, src
, nbytes
);
186 static inline bool camellia_fpu_begin(bool fpu_enabled
, unsigned int nbytes
)
188 return glue_fpu_begin(CAMELLIA_BLOCK_SIZE
,
189 CAMELLIA_AESNI_PARALLEL_BLOCKS
, NULL
, fpu_enabled
,
193 static inline void camellia_fpu_end(bool fpu_enabled
)
195 glue_fpu_end(fpu_enabled
);
198 static int camellia_setkey(struct crypto_tfm
*tfm
, const u8
*in_key
,
199 unsigned int key_len
)
201 return __camellia_setkey(crypto_tfm_ctx(tfm
), in_key
, key_len
,
206 struct camellia_ctx
*ctx
;
210 static void encrypt_callback(void *priv
, u8
*srcdst
, unsigned int nbytes
)
212 const unsigned int bsize
= CAMELLIA_BLOCK_SIZE
;
213 struct crypt_priv
*ctx
= priv
;
216 ctx
->fpu_enabled
= camellia_fpu_begin(ctx
->fpu_enabled
, nbytes
);
218 if (nbytes
>= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
* bsize
) {
219 camellia_ecb_enc_32way(ctx
->ctx
, srcdst
, srcdst
);
220 srcdst
+= bsize
* CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
;
221 nbytes
-= bsize
* CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
;
224 if (nbytes
>= CAMELLIA_AESNI_PARALLEL_BLOCKS
* bsize
) {
225 camellia_ecb_enc_16way(ctx
->ctx
, srcdst
, srcdst
);
226 srcdst
+= bsize
* CAMELLIA_AESNI_PARALLEL_BLOCKS
;
227 nbytes
-= bsize
* CAMELLIA_AESNI_PARALLEL_BLOCKS
;
230 while (nbytes
>= CAMELLIA_PARALLEL_BLOCKS
* bsize
) {
231 camellia_enc_blk_2way(ctx
->ctx
, srcdst
, srcdst
);
232 srcdst
+= bsize
* CAMELLIA_PARALLEL_BLOCKS
;
233 nbytes
-= bsize
* CAMELLIA_PARALLEL_BLOCKS
;
236 for (i
= 0; i
< nbytes
/ bsize
; i
++, srcdst
+= bsize
)
237 camellia_enc_blk(ctx
->ctx
, srcdst
, srcdst
);
240 static void decrypt_callback(void *priv
, u8
*srcdst
, unsigned int nbytes
)
242 const unsigned int bsize
= CAMELLIA_BLOCK_SIZE
;
243 struct crypt_priv
*ctx
= priv
;
246 ctx
->fpu_enabled
= camellia_fpu_begin(ctx
->fpu_enabled
, nbytes
);
248 if (nbytes
>= CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
* bsize
) {
249 camellia_ecb_dec_32way(ctx
->ctx
, srcdst
, srcdst
);
250 srcdst
+= bsize
* CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
;
251 nbytes
-= bsize
* CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
;
254 if (nbytes
>= CAMELLIA_AESNI_PARALLEL_BLOCKS
* bsize
) {
255 camellia_ecb_dec_16way(ctx
->ctx
, srcdst
, srcdst
);
256 srcdst
+= bsize
* CAMELLIA_AESNI_PARALLEL_BLOCKS
;
257 nbytes
-= bsize
* CAMELLIA_AESNI_PARALLEL_BLOCKS
;
260 while (nbytes
>= CAMELLIA_PARALLEL_BLOCKS
* bsize
) {
261 camellia_dec_blk_2way(ctx
->ctx
, srcdst
, srcdst
);
262 srcdst
+= bsize
* CAMELLIA_PARALLEL_BLOCKS
;
263 nbytes
-= bsize
* CAMELLIA_PARALLEL_BLOCKS
;
266 for (i
= 0; i
< nbytes
/ bsize
; i
++, srcdst
+= bsize
)
267 camellia_dec_blk(ctx
->ctx
, srcdst
, srcdst
);
270 static int lrw_encrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
271 struct scatterlist
*src
, unsigned int nbytes
)
273 struct camellia_lrw_ctx
*ctx
= crypto_blkcipher_ctx(desc
->tfm
);
274 be128 buf
[CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
];
275 struct crypt_priv crypt_ctx
= {
276 .ctx
= &ctx
->camellia_ctx
,
277 .fpu_enabled
= false,
279 struct lrw_crypt_req req
= {
281 .tbuflen
= sizeof(buf
),
283 .table_ctx
= &ctx
->lrw_table
,
284 .crypt_ctx
= &crypt_ctx
,
285 .crypt_fn
= encrypt_callback
,
289 desc
->flags
&= ~CRYPTO_TFM_REQ_MAY_SLEEP
;
290 ret
= lrw_crypt(desc
, dst
, src
, nbytes
, &req
);
291 camellia_fpu_end(crypt_ctx
.fpu_enabled
);
296 static int lrw_decrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
297 struct scatterlist
*src
, unsigned int nbytes
)
299 struct camellia_lrw_ctx
*ctx
= crypto_blkcipher_ctx(desc
->tfm
);
300 be128 buf
[CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS
];
301 struct crypt_priv crypt_ctx
= {
302 .ctx
= &ctx
->camellia_ctx
,
303 .fpu_enabled
= false,
305 struct lrw_crypt_req req
= {
307 .tbuflen
= sizeof(buf
),
309 .table_ctx
= &ctx
->lrw_table
,
310 .crypt_ctx
= &crypt_ctx
,
311 .crypt_fn
= decrypt_callback
,
315 desc
->flags
&= ~CRYPTO_TFM_REQ_MAY_SLEEP
;
316 ret
= lrw_crypt(desc
, dst
, src
, nbytes
, &req
);
317 camellia_fpu_end(crypt_ctx
.fpu_enabled
);
322 static int xts_encrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
323 struct scatterlist
*src
, unsigned int nbytes
)
325 struct camellia_xts_ctx
*ctx
= crypto_blkcipher_ctx(desc
->tfm
);
327 return glue_xts_crypt_128bit(&camellia_enc_xts
, desc
, dst
, src
, nbytes
,
328 XTS_TWEAK_CAST(camellia_enc_blk
),
329 &ctx
->tweak_ctx
, &ctx
->crypt_ctx
);
332 static int xts_decrypt(struct blkcipher_desc
*desc
, struct scatterlist
*dst
,
333 struct scatterlist
*src
, unsigned int nbytes
)
335 struct camellia_xts_ctx
*ctx
= crypto_blkcipher_ctx(desc
->tfm
);
337 return glue_xts_crypt_128bit(&camellia_dec_xts
, desc
, dst
, src
, nbytes
,
338 XTS_TWEAK_CAST(camellia_enc_blk
),
339 &ctx
->tweak_ctx
, &ctx
->crypt_ctx
);
342 static struct crypto_alg cmll_algs
[10] = { {
343 .cra_name
= "__ecb-camellia-aesni-avx2",
344 .cra_driver_name
= "__driver-ecb-camellia-aesni-avx2",
346 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
|
348 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
349 .cra_ctxsize
= sizeof(struct camellia_ctx
),
351 .cra_type
= &crypto_blkcipher_type
,
352 .cra_module
= THIS_MODULE
,
355 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
356 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
357 .setkey
= camellia_setkey
,
358 .encrypt
= ecb_encrypt
,
359 .decrypt
= ecb_decrypt
,
363 .cra_name
= "__cbc-camellia-aesni-avx2",
364 .cra_driver_name
= "__driver-cbc-camellia-aesni-avx2",
366 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
|
368 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
369 .cra_ctxsize
= sizeof(struct camellia_ctx
),
371 .cra_type
= &crypto_blkcipher_type
,
372 .cra_module
= THIS_MODULE
,
375 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
376 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
377 .setkey
= camellia_setkey
,
378 .encrypt
= cbc_encrypt
,
379 .decrypt
= cbc_decrypt
,
383 .cra_name
= "__ctr-camellia-aesni-avx2",
384 .cra_driver_name
= "__driver-ctr-camellia-aesni-avx2",
386 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
|
389 .cra_ctxsize
= sizeof(struct camellia_ctx
),
391 .cra_type
= &crypto_blkcipher_type
,
392 .cra_module
= THIS_MODULE
,
395 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
396 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
397 .ivsize
= CAMELLIA_BLOCK_SIZE
,
398 .setkey
= camellia_setkey
,
399 .encrypt
= ctr_crypt
,
400 .decrypt
= ctr_crypt
,
404 .cra_name
= "__lrw-camellia-aesni-avx2",
405 .cra_driver_name
= "__driver-lrw-camellia-aesni-avx2",
407 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
|
409 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
410 .cra_ctxsize
= sizeof(struct camellia_lrw_ctx
),
412 .cra_type
= &crypto_blkcipher_type
,
413 .cra_module
= THIS_MODULE
,
414 .cra_exit
= lrw_camellia_exit_tfm
,
417 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
+
419 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
+
421 .ivsize
= CAMELLIA_BLOCK_SIZE
,
422 .setkey
= lrw_camellia_setkey
,
423 .encrypt
= lrw_encrypt
,
424 .decrypt
= lrw_decrypt
,
428 .cra_name
= "__xts-camellia-aesni-avx2",
429 .cra_driver_name
= "__driver-xts-camellia-aesni-avx2",
431 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
|
433 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
434 .cra_ctxsize
= sizeof(struct camellia_xts_ctx
),
436 .cra_type
= &crypto_blkcipher_type
,
437 .cra_module
= THIS_MODULE
,
440 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
* 2,
441 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
* 2,
442 .ivsize
= CAMELLIA_BLOCK_SIZE
,
443 .setkey
= xts_camellia_setkey
,
444 .encrypt
= xts_encrypt
,
445 .decrypt
= xts_decrypt
,
449 .cra_name
= "ecb(camellia)",
450 .cra_driver_name
= "ecb-camellia-aesni-avx2",
452 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
453 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
454 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
456 .cra_type
= &crypto_ablkcipher_type
,
457 .cra_module
= THIS_MODULE
,
458 .cra_init
= ablk_init
,
459 .cra_exit
= ablk_exit
,
462 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
463 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
464 .setkey
= ablk_set_key
,
465 .encrypt
= ablk_encrypt
,
466 .decrypt
= ablk_decrypt
,
470 .cra_name
= "cbc(camellia)",
471 .cra_driver_name
= "cbc-camellia-aesni-avx2",
473 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
474 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
475 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
477 .cra_type
= &crypto_ablkcipher_type
,
478 .cra_module
= THIS_MODULE
,
479 .cra_init
= ablk_init
,
480 .cra_exit
= ablk_exit
,
483 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
484 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
485 .ivsize
= CAMELLIA_BLOCK_SIZE
,
486 .setkey
= ablk_set_key
,
487 .encrypt
= __ablk_encrypt
,
488 .decrypt
= ablk_decrypt
,
492 .cra_name
= "ctr(camellia)",
493 .cra_driver_name
= "ctr-camellia-aesni-avx2",
495 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
497 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
499 .cra_type
= &crypto_ablkcipher_type
,
500 .cra_module
= THIS_MODULE
,
501 .cra_init
= ablk_init
,
502 .cra_exit
= ablk_exit
,
505 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
506 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
507 .ivsize
= CAMELLIA_BLOCK_SIZE
,
508 .setkey
= ablk_set_key
,
509 .encrypt
= ablk_encrypt
,
510 .decrypt
= ablk_encrypt
,
515 .cra_name
= "lrw(camellia)",
516 .cra_driver_name
= "lrw-camellia-aesni-avx2",
518 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
519 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
520 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
522 .cra_type
= &crypto_ablkcipher_type
,
523 .cra_module
= THIS_MODULE
,
524 .cra_init
= ablk_init
,
525 .cra_exit
= ablk_exit
,
528 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
+
530 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
+
532 .ivsize
= CAMELLIA_BLOCK_SIZE
,
533 .setkey
= ablk_set_key
,
534 .encrypt
= ablk_encrypt
,
535 .decrypt
= ablk_decrypt
,
539 .cra_name
= "xts(camellia)",
540 .cra_driver_name
= "xts-camellia-aesni-avx2",
542 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
543 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
544 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
546 .cra_type
= &crypto_ablkcipher_type
,
547 .cra_module
= THIS_MODULE
,
548 .cra_init
= ablk_init
,
549 .cra_exit
= ablk_exit
,
552 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
* 2,
553 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
* 2,
554 .ivsize
= CAMELLIA_BLOCK_SIZE
,
555 .setkey
= ablk_set_key
,
556 .encrypt
= ablk_encrypt
,
557 .decrypt
= ablk_decrypt
,
562 static int __init
camellia_aesni_init(void)
566 if (!cpu_has_avx2
|| !cpu_has_avx
|| !cpu_has_aes
|| !cpu_has_osxsave
) {
567 pr_info("AVX2 or AES-NI instructions are not detected.\n");
571 xcr0
= xgetbv(XCR_XFEATURE_ENABLED_MASK
);
572 if ((xcr0
& (XSTATE_SSE
| XSTATE_YMM
)) != (XSTATE_SSE
| XSTATE_YMM
)) {
573 pr_info("AVX2 detected but unusable.\n");
577 return crypto_register_algs(cmll_algs
, ARRAY_SIZE(cmll_algs
));
580 static void __exit
camellia_aesni_fini(void)
582 crypto_unregister_algs(cmll_algs
, ARRAY_SIZE(cmll_algs
));
585 module_init(camellia_aesni_init
);
586 module_exit(camellia_aesni_fini
);
588 MODULE_LICENSE("GPL");
589 MODULE_DESCRIPTION("Camellia Cipher Algorithm, AES-NI/AVX2 optimized");
590 MODULE_ALIAS_CRYPTO("camellia");
591 MODULE_ALIAS_CRYPTO("camellia-asm");