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/algapi.h>
18 #include <crypto/ctr.h>
19 #include <crypto/lrw.h>
20 #include <crypto/xts.h>
22 #include <asm/xsave.h>
23 #include <asm/crypto/camellia.h>
24 #include <asm/crypto/ablk_helper.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
,
347 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
348 .cra_ctxsize
= sizeof(struct camellia_ctx
),
350 .cra_type
= &crypto_blkcipher_type
,
351 .cra_module
= THIS_MODULE
,
354 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
355 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
356 .setkey
= camellia_setkey
,
357 .encrypt
= ecb_encrypt
,
358 .decrypt
= ecb_decrypt
,
362 .cra_name
= "__cbc-camellia-aesni-avx2",
363 .cra_driver_name
= "__driver-cbc-camellia-aesni-avx2",
365 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
,
366 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
367 .cra_ctxsize
= sizeof(struct camellia_ctx
),
369 .cra_type
= &crypto_blkcipher_type
,
370 .cra_module
= THIS_MODULE
,
373 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
374 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
375 .setkey
= camellia_setkey
,
376 .encrypt
= cbc_encrypt
,
377 .decrypt
= cbc_decrypt
,
381 .cra_name
= "__ctr-camellia-aesni-avx2",
382 .cra_driver_name
= "__driver-ctr-camellia-aesni-avx2",
384 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
,
386 .cra_ctxsize
= sizeof(struct camellia_ctx
),
388 .cra_type
= &crypto_blkcipher_type
,
389 .cra_module
= THIS_MODULE
,
392 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
393 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
394 .ivsize
= CAMELLIA_BLOCK_SIZE
,
395 .setkey
= camellia_setkey
,
396 .encrypt
= ctr_crypt
,
397 .decrypt
= ctr_crypt
,
401 .cra_name
= "__lrw-camellia-aesni-avx2",
402 .cra_driver_name
= "__driver-lrw-camellia-aesni-avx2",
404 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
,
405 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
406 .cra_ctxsize
= sizeof(struct camellia_lrw_ctx
),
408 .cra_type
= &crypto_blkcipher_type
,
409 .cra_module
= THIS_MODULE
,
410 .cra_exit
= lrw_camellia_exit_tfm
,
413 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
+
415 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
+
417 .ivsize
= CAMELLIA_BLOCK_SIZE
,
418 .setkey
= lrw_camellia_setkey
,
419 .encrypt
= lrw_encrypt
,
420 .decrypt
= lrw_decrypt
,
424 .cra_name
= "__xts-camellia-aesni-avx2",
425 .cra_driver_name
= "__driver-xts-camellia-aesni-avx2",
427 .cra_flags
= CRYPTO_ALG_TYPE_BLKCIPHER
,
428 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
429 .cra_ctxsize
= sizeof(struct camellia_xts_ctx
),
431 .cra_type
= &crypto_blkcipher_type
,
432 .cra_module
= THIS_MODULE
,
435 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
* 2,
436 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
* 2,
437 .ivsize
= CAMELLIA_BLOCK_SIZE
,
438 .setkey
= xts_camellia_setkey
,
439 .encrypt
= xts_encrypt
,
440 .decrypt
= xts_decrypt
,
444 .cra_name
= "ecb(camellia)",
445 .cra_driver_name
= "ecb-camellia-aesni-avx2",
447 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
448 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
449 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
451 .cra_type
= &crypto_ablkcipher_type
,
452 .cra_module
= THIS_MODULE
,
453 .cra_init
= ablk_init
,
454 .cra_exit
= ablk_exit
,
457 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
458 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
459 .setkey
= ablk_set_key
,
460 .encrypt
= ablk_encrypt
,
461 .decrypt
= ablk_decrypt
,
465 .cra_name
= "cbc(camellia)",
466 .cra_driver_name
= "cbc-camellia-aesni-avx2",
468 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
469 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
470 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
472 .cra_type
= &crypto_ablkcipher_type
,
473 .cra_module
= THIS_MODULE
,
474 .cra_init
= ablk_init
,
475 .cra_exit
= ablk_exit
,
478 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
479 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
480 .ivsize
= CAMELLIA_BLOCK_SIZE
,
481 .setkey
= ablk_set_key
,
482 .encrypt
= __ablk_encrypt
,
483 .decrypt
= ablk_decrypt
,
487 .cra_name
= "ctr(camellia)",
488 .cra_driver_name
= "ctr-camellia-aesni-avx2",
490 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
492 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
494 .cra_type
= &crypto_ablkcipher_type
,
495 .cra_module
= THIS_MODULE
,
496 .cra_init
= ablk_init
,
497 .cra_exit
= ablk_exit
,
500 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
,
501 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
,
502 .ivsize
= CAMELLIA_BLOCK_SIZE
,
503 .setkey
= ablk_set_key
,
504 .encrypt
= ablk_encrypt
,
505 .decrypt
= ablk_encrypt
,
510 .cra_name
= "lrw(camellia)",
511 .cra_driver_name
= "lrw-camellia-aesni-avx2",
513 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
514 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
515 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
517 .cra_type
= &crypto_ablkcipher_type
,
518 .cra_module
= THIS_MODULE
,
519 .cra_init
= ablk_init
,
520 .cra_exit
= ablk_exit
,
523 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
+
525 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
+
527 .ivsize
= CAMELLIA_BLOCK_SIZE
,
528 .setkey
= ablk_set_key
,
529 .encrypt
= ablk_encrypt
,
530 .decrypt
= ablk_decrypt
,
534 .cra_name
= "xts(camellia)",
535 .cra_driver_name
= "xts-camellia-aesni-avx2",
537 .cra_flags
= CRYPTO_ALG_TYPE_ABLKCIPHER
| CRYPTO_ALG_ASYNC
,
538 .cra_blocksize
= CAMELLIA_BLOCK_SIZE
,
539 .cra_ctxsize
= sizeof(struct async_helper_ctx
),
541 .cra_type
= &crypto_ablkcipher_type
,
542 .cra_module
= THIS_MODULE
,
543 .cra_init
= ablk_init
,
544 .cra_exit
= ablk_exit
,
547 .min_keysize
= CAMELLIA_MIN_KEY_SIZE
* 2,
548 .max_keysize
= CAMELLIA_MAX_KEY_SIZE
* 2,
549 .ivsize
= CAMELLIA_BLOCK_SIZE
,
550 .setkey
= ablk_set_key
,
551 .encrypt
= ablk_encrypt
,
552 .decrypt
= ablk_decrypt
,
557 static int __init
camellia_aesni_init(void)
561 if (!cpu_has_avx2
|| !cpu_has_avx
|| !cpu_has_aes
|| !cpu_has_osxsave
) {
562 pr_info("AVX2 or AES-NI instructions are not detected.\n");
566 xcr0
= xgetbv(XCR_XFEATURE_ENABLED_MASK
);
567 if ((xcr0
& (XSTATE_SSE
| XSTATE_YMM
)) != (XSTATE_SSE
| XSTATE_YMM
)) {
568 pr_info("AVX2 detected but unusable.\n");
572 return crypto_register_algs(cmll_algs
, ARRAY_SIZE(cmll_algs
));
575 static void __exit
camellia_aesni_fini(void)
577 crypto_unregister_algs(cmll_algs
, ARRAY_SIZE(cmll_algs
));
580 module_init(camellia_aesni_init
);
581 module_exit(camellia_aesni_fini
);
583 MODULE_LICENSE("GPL");
584 MODULE_DESCRIPTION("Camellia Cipher Algorithm, AES-NI/AVX2 optimized");
585 MODULE_ALIAS("camellia");
586 MODULE_ALIAS("camellia-asm");