cc_platform.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Confidential Computing Platform Capability checks
  4. *
  5. * Copyright (C) 2021 Advanced Micro Devices, Inc.
  6. *
  7. * Author: Tom Lendacky <thomas.lendacky@amd.com>
  8. */
  9. #ifndef _LINUX_CC_PLATFORM_H
  10. #define _LINUX_CC_PLATFORM_H
  11. #include <linux/types.h>
  12. #include <linux/stddef.h>
  13. /**
  14. * enum cc_attr - Confidential computing attributes
  15. *
  16. * These attributes represent confidential computing features that are
  17. * currently active.
  18. */
  19. enum cc_attr {
  20. /**
  21. * @CC_ATTR_MEM_ENCRYPT: Memory encryption is active
  22. *
  23. * The platform/OS is running with active memory encryption. This
  24. * includes running either as a bare-metal system or a hypervisor
  25. * and actively using memory encryption or as a guest/virtual machine
  26. * and actively using memory encryption.
  27. *
  28. * Examples include SME, SEV and SEV-ES.
  29. */
  30. CC_ATTR_MEM_ENCRYPT,
  31. /**
  32. * @CC_ATTR_HOST_MEM_ENCRYPT: Host memory encryption is active
  33. *
  34. * The platform/OS is running as a bare-metal system or a hypervisor
  35. * and actively using memory encryption.
  36. *
  37. * Examples include SME.
  38. */
  39. CC_ATTR_HOST_MEM_ENCRYPT,
  40. /**
  41. * @CC_ATTR_GUEST_MEM_ENCRYPT: Guest memory encryption is active
  42. *
  43. * The platform/OS is running as a guest/virtual machine and actively
  44. * using memory encryption.
  45. *
  46. * Examples include SEV and SEV-ES.
  47. */
  48. CC_ATTR_GUEST_MEM_ENCRYPT,
  49. /**
  50. * @CC_ATTR_GUEST_STATE_ENCRYPT: Guest state encryption is active
  51. *
  52. * The platform/OS is running as a guest/virtual machine and actively
  53. * using memory encryption and register state encryption.
  54. *
  55. * Examples include SEV-ES.
  56. */
  57. CC_ATTR_GUEST_STATE_ENCRYPT,
  58. };
  59. #ifdef CONFIG_ARCH_HAS_CC_PLATFORM
  60. /**
  61. * cc_platform_has() - Checks if the specified cc_attr attribute is active
  62. * @attr: Confidential computing attribute to check
  63. *
  64. * The cc_platform_has() function will return an indicator as to whether the
  65. * specified Confidential Computing attribute is currently active.
  66. *
  67. * Context: Any context
  68. * Return:
  69. * * TRUE - Specified Confidential Computing attribute is active
  70. * * FALSE - Specified Confidential Computing attribute is not active
  71. */
  72. bool cc_platform_has(enum cc_attr attr);
  73. #else /* !CONFIG_ARCH_HAS_CC_PLATFORM */
  74. static inline bool cc_platform_has(enum cc_attr attr) { return false; }
  75. #endif /* CONFIG_ARCH_HAS_CC_PLATFORM */
  76. #endif /* _LINUX_CC_PLATFORM_H */