vmx.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <[email protected]>
  8. */
  9. #include <linux/module.h>
  10. #include <linux/moduleparam.h>
  11. #include <linux/types.h>
  12. #include <linux/err.h>
  13. #include <linux/cpufeature.h>
  14. #include <linux/crypto.h>
  15. #include <asm/cputable.h>
  16. #include <crypto/internal/hash.h>
  17. #include <crypto/internal/skcipher.h>
  18. #include "aesp8-ppc.h"
  19. static int __init p8_init(void)
  20. {
  21. int ret;
  22. ret = crypto_register_shash(&p8_ghash_alg);
  23. if (ret)
  24. goto err;
  25. ret = crypto_register_alg(&p8_aes_alg);
  26. if (ret)
  27. goto err_unregister_ghash;
  28. ret = crypto_register_skcipher(&p8_aes_cbc_alg);
  29. if (ret)
  30. goto err_unregister_aes;
  31. ret = crypto_register_skcipher(&p8_aes_ctr_alg);
  32. if (ret)
  33. goto err_unregister_aes_cbc;
  34. ret = crypto_register_skcipher(&p8_aes_xts_alg);
  35. if (ret)
  36. goto err_unregister_aes_ctr;
  37. return 0;
  38. err_unregister_aes_ctr:
  39. crypto_unregister_skcipher(&p8_aes_ctr_alg);
  40. err_unregister_aes_cbc:
  41. crypto_unregister_skcipher(&p8_aes_cbc_alg);
  42. err_unregister_aes:
  43. crypto_unregister_alg(&p8_aes_alg);
  44. err_unregister_ghash:
  45. crypto_unregister_shash(&p8_ghash_alg);
  46. err:
  47. return ret;
  48. }
  49. static void __exit p8_exit(void)
  50. {
  51. crypto_unregister_skcipher(&p8_aes_xts_alg);
  52. crypto_unregister_skcipher(&p8_aes_ctr_alg);
  53. crypto_unregister_skcipher(&p8_aes_cbc_alg);
  54. crypto_unregister_alg(&p8_aes_alg);
  55. crypto_unregister_shash(&p8_ghash_alg);
  56. }
  57. module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, p8_init);
  58. module_exit(p8_exit);
  59. MODULE_AUTHOR("Marcelo Cerri<[email protected]>");
  60. MODULE_DESCRIPTION("IBM VMX cryptographic acceleration instructions "
  61. "support on Power 8");
  62. MODULE_LICENSE("GPL");
  63. MODULE_VERSION("1.0.0");
  64. MODULE_IMPORT_NS(CRYPTO_INTERNAL);