cc_platform.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 <[email protected]>
  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. * @CC_ATTR_GUEST_UNROLL_STRING_IO: String I/O is implemented with
  60. * IN/OUT instructions
  61. *
  62. * The platform/OS is running as a guest/virtual machine and uses
  63. * IN/OUT instructions in place of string I/O.
  64. *
  65. * Examples include TDX guest & SEV.
  66. */
  67. CC_ATTR_GUEST_UNROLL_STRING_IO,
  68. /**
  69. * @CC_ATTR_SEV_SNP: Guest SNP is active.
  70. *
  71. * The platform/OS is running as a guest/virtual machine and actively
  72. * using AMD SEV-SNP features.
  73. */
  74. CC_ATTR_GUEST_SEV_SNP,
  75. /**
  76. * @CC_ATTR_HOTPLUG_DISABLED: Hotplug is not supported or disabled.
  77. *
  78. * The platform/OS is running as a guest/virtual machine does not
  79. * support CPU hotplug feature.
  80. *
  81. * Examples include TDX Guest.
  82. */
  83. CC_ATTR_HOTPLUG_DISABLED,
  84. };
  85. #ifdef CONFIG_ARCH_HAS_CC_PLATFORM
  86. /**
  87. * cc_platform_has() - Checks if the specified cc_attr attribute is active
  88. * @attr: Confidential computing attribute to check
  89. *
  90. * The cc_platform_has() function will return an indicator as to whether the
  91. * specified Confidential Computing attribute is currently active.
  92. *
  93. * Context: Any context
  94. * Return:
  95. * * TRUE - Specified Confidential Computing attribute is active
  96. * * FALSE - Specified Confidential Computing attribute is not active
  97. */
  98. bool cc_platform_has(enum cc_attr attr);
  99. #else /* !CONFIG_ARCH_HAS_CC_PLATFORM */
  100. static inline bool cc_platform_has(enum cc_attr attr) { return false; }
  101. #endif /* CONFIG_ARCH_HAS_CC_PLATFORM */
  102. #endif /* _LINUX_CC_PLATFORM_H */