]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/BaseMemEncryptSevLib/Ia32/MemEncryptSevLib.c
OvmfPkg/BaseMemEncryptSevLib: remove Flush parameter
[mirror_edk2.git] / OvmfPkg / Library / BaseMemEncryptSevLib / Ia32 / MemEncryptSevLib.c
index b4f6e5738e6eb29fe284614ad58b9d4c8fc0b974..be260e0d10146884e9b55f05277219aee0508632 100644 (file)
@@ -2,7 +2,7 @@
 \r
   Secure Encrypted Virtualization (SEV) library helper function\r
 \r
-  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2020, AMD Incorporated. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -25,8 +25,6 @@
                                       address of a memory region.\r
   @param[in]  NumPages                The number of pages from start memory\r
                                       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\r
                                       memory region.\r
@@ -39,8 +37,7 @@ EFIAPI
 MemEncryptSevClearPageEncMask (\r
   IN PHYSICAL_ADDRESS         Cr3BaseAddress,\r
   IN PHYSICAL_ADDRESS         BaseAddress,\r
-  IN UINTN                    NumPages,\r
-  IN BOOLEAN                  Flush\r
+  IN UINTN                    NumPages\r
   )\r
 {\r
   //\r
@@ -59,8 +56,6 @@ MemEncryptSevClearPageEncMask (
                                       address of a memory region.\r
   @param[in]  NumPages                The number of pages from start memory\r
                                       region.\r
-  @param[in]  Flush                   Flush the caches before setting the bit\r
-                                      (mostly TRUE except MMIO addresses)\r
 \r
   @retval RETURN_SUCCESS              The attributes were set for the memory\r
                                       region.\r
@@ -73,8 +68,67 @@ EFIAPI
 MemEncryptSevSetPageEncMask (\r
   IN PHYSICAL_ADDRESS         Cr3BaseAddress,\r
   IN PHYSICAL_ADDRESS         BaseAddress,\r
-  IN UINTN                    NumPages,\r
-  IN BOOLEAN                  Flush\r
+  IN UINTN                    NumPages\r
+  )\r
+{\r
+  //\r
+  // Memory encryption bit is not accessible in 32-bit mode\r
+  //\r
+  return RETURN_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Returns the encryption state of the specified virtual address range.\r
+\r
+  @param[in]  Cr3BaseAddress          Cr3 Base Address (if zero then use\r
+                                      current CR3)\r
+  @param[in]  BaseAddress             Base address to check\r
+  @param[in]  Length                  Length of virtual address range\r
+\r
+  @retval MemEncryptSevAddressRangeUnencrypted  Address range is mapped\r
+                                                unencrypted\r
+  @retval MemEncryptSevAddressRangeEncrypted    Address range is mapped\r
+                                                encrypted\r
+  @retval MemEncryptSevAddressRangeMixed        Address range is mapped mixed\r
+  @retval MemEncryptSevAddressRangeError        Address range is not mapped\r
+**/\r
+MEM_ENCRYPT_SEV_ADDRESS_RANGE_STATE\r
+EFIAPI\r
+MemEncryptSevGetAddressRangeState (\r
+  IN PHYSICAL_ADDRESS         Cr3BaseAddress,\r
+  IN PHYSICAL_ADDRESS         BaseAddress,\r
+  IN UINTN                    Length\r
+  )\r
+{\r
+  //\r
+  // Memory is always encrypted in 32-bit mode\r
+  //\r
+  return MemEncryptSevAddressRangeEncrypted;\r
+}\r
+\r
+/**\r
+  This function clears memory encryption bit for the MMIO region specified by\r
+  BaseAddress and NumPages.\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 MMIO 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
+MemEncryptSevClearMmioPageEncMask (\r
+  IN PHYSICAL_ADDRESS         Cr3BaseAddress,\r
+  IN PHYSICAL_ADDRESS         BaseAddress,\r
+  IN UINTN                    NumPages\r
   )\r
 {\r
   //\r