]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / OvmfPkg / QemuFlashFvbServicesRuntimeDxe / FwBlockServiceDxe.c
index 37deece363e6e586df290101653290fd09abc12b..1fbe1342a57cb3f4dceaedbac541a96033beb952 100644 (file)
@@ -18,6 +18,7 @@
 #include <Library/DebugLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/DxeServicesTableLib.h>\r
+#include <Library/MemEncryptSevLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
@@ -203,5 +204,21 @@ MarkIoMemoryRangeForRuntimeAccess (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // When SEV is active, AmdSevDxe mapped the BaseAddress with C=0 but\r
+  // SetMemorySpaceAttributes() remaps the range with C=1. Let's restore\r
+  // the mapping so that both guest and hyervisor can access the flash\r
+  // memory range.\r
+  //\r
+  if (MemEncryptSevIsEnabled ()) {\r
+    Status = MemEncryptSevClearPageEncMask (\r
+               0,\r
+               BaseAddress,\r
+               EFI_SIZE_TO_PAGES (Length),\r
+               FALSE\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
   return Status;\r
 }\r