xref: /linux/arch/powerpc/crypto/vmx.c (revision aec2f682d47c54ef434b2d440992626d80b1ebdc)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Routines supporting VMX instructions on the Power 8
4  *
5  * Copyright (C) 2015 International Business Machines Inc.
6  *
7  * Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com>
8  */
9 
10 #include <linux/module.h>
11 #include <linux/moduleparam.h>
12 #include <linux/types.h>
13 #include <linux/err.h>
14 #include <linux/cpufeature.h>
15 #include <linux/crypto.h>
16 #include <asm/cputable.h>
17 #include <crypto/internal/skcipher.h>
18 
19 #include "aesp8-ppc.h"
20 
21 static int __init p8_init(void)
22 {
23 	int ret;
24 
25 	ret = crypto_register_skcipher(&p8_aes_cbc_alg);
26 	if (ret)
27 		goto err;
28 
29 	ret = crypto_register_skcipher(&p8_aes_ctr_alg);
30 	if (ret)
31 		goto err_unregister_aes_cbc;
32 
33 	ret = crypto_register_skcipher(&p8_aes_xts_alg);
34 	if (ret)
35 		goto err_unregister_aes_ctr;
36 
37 	return 0;
38 
39 err_unregister_aes_ctr:
40 	crypto_unregister_skcipher(&p8_aes_ctr_alg);
41 err_unregister_aes_cbc:
42 	crypto_unregister_skcipher(&p8_aes_cbc_alg);
43 err:
44 	return ret;
45 }
46 
47 static void __exit p8_exit(void)
48 {
49 	crypto_unregister_skcipher(&p8_aes_xts_alg);
50 	crypto_unregister_skcipher(&p8_aes_ctr_alg);
51 	crypto_unregister_skcipher(&p8_aes_cbc_alg);
52 }
53 
54 module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, p8_init);
55 module_exit(p8_exit);
56 
57 MODULE_AUTHOR("Marcelo Cerri<mhcerri@br.ibm.com>");
58 MODULE_DESCRIPTION("IBM VMX cryptographic acceleration instructions "
59 		   "support on Power 8");
60 MODULE_LICENSE("GPL");
61 MODULE_VERSION("1.0.0");
62