]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Include/Library/MemEncryptTdxLib.h
OvmfPkg/BaseMemEncryptTdxLib: Add TDX helper library
[mirror_edk2.git] / OvmfPkg / Include / Library / MemEncryptTdxLib.h
diff --git a/OvmfPkg/Include/Library/MemEncryptTdxLib.h b/OvmfPkg/Include/Library/MemEncryptTdxLib.h
new file mode 100644 (file)
index 0000000..2350dd4
--- /dev/null
@@ -0,0 +1,81 @@
+/** @file\r
+\r
+  Define Memory Encrypted Virtualization base library helper function\r
+\r
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef MEM_ENCRYPT_TDX_LIB_H_\r
+#define MEM_ENCRYPT_TDX_LIB_H_\r
+\r
+#include <Base.h>\r
+\r
+/**\r
+  Returns boolean to indicate whether to indicate which, if any, memory encryption is enabled\r
+\r
+  @param[in]  Type          Bitmask of encryption technologies to check is enabled\r
+\r
+  @retval TRUE              The encryption type(s) are enabled\r
+  @retval FALSE             The encryption type(s) are not enabled\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MemEncryptTdxIsEnabled (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function clears memory encryption bit for the memory region specified by\r
+  BaseAddress and NumPages from the current page table context.\r
+\r
+  @param[in]  Cr3BaseAddress          Cr3 Base Address (if zero then use\r
+                                      current CR3)\r
+  @param[in]  BaseAddress             The physical address that is the start\r
+                                      address of a memory region.\r
+  @param[in]  NumPages                The number of pages from start memory\r
+                                      region.\r
+\r
+  @retval RETURN_SUCCESS              The attributes were cleared for the\r
+                                      memory region.\r
+  @retval RETURN_INVALID_PARAMETER    Number of pages is zero.\r
+  @retval RETURN_UNSUPPORTED          Clearing the memory encryption attribute\r
+                                      is not supported\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MemEncryptTdxSetPageSharedBit (\r
+  IN PHYSICAL_ADDRESS  Cr3BaseAddress,\r
+  IN PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINTN             NumPages\r
+  );\r
+\r
+/**\r
+  This function sets memory encryption bit for the memory region specified by\r
+  BaseAddress and NumPages from the current page table context.\r
+\r
+  @param[in]  Cr3BaseAddress          Cr3 Base Address (if zero then use\r
+                                      current CR3)\r
+  @param[in]  BaseAddress             The physical address that is the start\r
+                                      address of a memory region.\r
+  @param[in]  NumPages                The number of pages from start memory\r
+                                      region.\r
+\r
+  @retval RETURN_SUCCESS              The attributes were set for the memory\r
+                                      region.\r
+  @retval RETURN_INVALID_PARAMETER    Number of pages is zero.\r
+  @retval RETURN_UNSUPPORTED          Setting the memory encryption attribute\r
+                                      is not supported\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MemEncryptTdxClearPageSharedBit (\r
+  IN PHYSICAL_ADDRESS  Cr3BaseAddress,\r
+  IN PHYSICAL_ADDRESS  BaseAddress,\r
+  IN UINTN             NumPages\r
+  );\r
+\r
+#endif // _MEM_ENCRYPT_TDX_LIB_H_\r