]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Include/Library/MemEncryptSevLib.h
OvmfPkg/BaseMemcryptSevLib: Add SEV helper library
[mirror_edk2.git] / OvmfPkg / Include / Library / MemEncryptSevLib.h
diff --git a/OvmfPkg/Include/Library/MemEncryptSevLib.h b/OvmfPkg/Include/Library/MemEncryptSevLib.h
new file mode 100644 (file)
index 0000000..b675376
--- /dev/null
@@ -0,0 +1,81 @@
+/** @file\r
+\r
+  Define Secure Encrypted Virtualization (SEV) base library helper function\r
+\r
+  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _MEM_ENCRYPT_SEV_LIB_H_\r
+#define _MEM_ENCRYPT_SEV_LIB_H_\r
+\r
+#include <Base.h>\r
+\r
+/**\r
+  Returns a boolean to indicate whether SEV is enabled\r
+\r
+  @retval TRUE           SEV is active\r
+  @retval FALSE          SEV is not enabled\r
+  **/\r
+BOOLEAN\r
+EFIAPI\r
+MemEncryptSevIsEnabled (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function clears memory encryption bit for the memory region specified\r
+  by BaseAddress and Number of pages from the current page table context.\r
+\r
+  @param[in]  BaseAddress           The physical address that is the start address\r
+                                    of a memory region.\r
+  @param[in]  NumberOfPages         The number of pages from start memory region.\r
+  @param[in]  Flush                 Flush the caches before clearing the bit\r
+                                    (mostly TRUE except MMIO addresses)\r
+\r
+  @retval RETURN_SUCCESS            The attributes were cleared for the memory region.\r
+  @retval RETURN_INVALID_PARAMETER  Number of pages is zero.\r
+  @retval RETURN_UNSUPPORTED        Clearing memory encryption attribute is not\r
+                                    supported\r
+  **/\r
+RETURN_STATUS\r
+EFIAPI\r
+MemEncryptSevClearPageEncMask (\r
+  IN PHYSICAL_ADDRESS         Cr3BaseAddress,\r
+  IN PHYSICAL_ADDRESS         BaseAddress,\r
+  IN UINTN                    NumberOfPages,\r
+  IN BOOLEAN                  CacheFlush\r
+  );\r
+\r
+/**\r
+  This function sets memory encryption bit for the memory region specified by\r
+  BaseAddress and Number of pages from the current page table context.\r
+\r
+  @param[in]  BaseAddress           The physical address that is the start address\r
+                                    of a memory region.\r
+  @param[in]  NumberOfPages         The number of pages from start memory region.\r
+  @param[in]  Flush                 Flush the caches before clearing the bit\r
+                                    (mostly TRUE except MMIO addresses)\r
+\r
+  @retval RETURN_SUCCESS            The attributes were set for the memory region.\r
+  @retval RETURN_INVALID_PARAMETER  Number of pages is zero.\r
+  @retval RETURN_UNSUPPORTED        Clearing memory encryption attribute is not\r
+                                    supported\r
+  **/\r
+RETURN_STATUS\r
+EFIAPI\r
+MemEncryptSevSetPageEncMask (\r
+  IN PHYSICAL_ADDRESS         Cr3BaseAddress,\r
+  IN PHYSICAL_ADDRESS         BaseAddress,\r
+  IN UINTN                    NumberOfPages,\r
+  IN BOOLEAN                  CacheFlush\r
+  );\r
+#endif // _MEM_ENCRYPT_SEV_LIB_H_\r