xref: /linux/arch/powerpc/crypto/vmx.c (revision 20bed0d6ff62d985fe8222958825504b8aad4e88)
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/cpufeature.h>
12 #include <crypto/internal/skcipher.h>
13 
14 #include "aesp8-ppc.h"
15 
16 static int __init p8_init(void)
17 {
18 	int ret;
19 
20 	ret = crypto_register_skcipher(&p8_aes_cbc_alg);
21 	if (ret)
22 		return ret;
23 
24 	ret = crypto_register_skcipher(&p8_aes_ctr_alg);
25 	if (ret)
26 		goto err_unregister_aes_cbc;
27 
28 	ret = crypto_register_skcipher(&p8_aes_xts_alg);
29 	if (ret)
30 		goto err_unregister_aes_ctr;
31 
32 	return 0;
33 
34 err_unregister_aes_ctr:
35 	crypto_unregister_skcipher(&p8_aes_ctr_alg);
36 err_unregister_aes_cbc:
37 	crypto_unregister_skcipher(&p8_aes_cbc_alg);
38 	return ret;
39 }
40 
41 static void __exit p8_exit(void)
42 {
43 	crypto_unregister_skcipher(&p8_aes_xts_alg);
44 	crypto_unregister_skcipher(&p8_aes_ctr_alg);
45 	crypto_unregister_skcipher(&p8_aes_cbc_alg);
46 }
47 
48 module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, p8_init);
49 module_exit(p8_exit);
50 
51 MODULE_AUTHOR("Marcelo Cerri <mhcerri@br.ibm.com>");
52 MODULE_DESCRIPTION("IBM VMX cryptographic acceleration instructions support on Power 8");
53 MODULE_LICENSE("GPL");
54