]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/Fv.c
OvmfPkg/AmdSevDxe: sort #includes, and entries in INF file sections
[mirror_edk2.git] / OvmfPkg / PlatformPei / Fv.c
index fbdb597043ec5a124d5422c65b1484b3e339e796..248c58508558a2741848073776a8db3d4a17193e 100644 (file)
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include "PiPei.h"\r
+#include "Platform.h"\r
 #include <Library/DebugLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/PeiServicesLib.h>\r
@@ -31,17 +32,19 @@ PeiFvInitialization (
   VOID\r
   )\r
 {\r
+  BOOLEAN SecureS3Needed;\r
+\r
   DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));\r
 \r
   //\r
   // Create a memory allocation HOB for the PEI FV.\r
   //\r
-  // This is marked as ACPI NVS so it will still be available on S3 resume.\r
+  // Allocate as ACPI NVS is S3 is supported\r
   //\r
   BuildMemoryAllocationHob (\r
     PcdGet32 (PcdOvmfPeiMemFvBase),\r
     PcdGet32 (PcdOvmfPeiMemFvSize),\r
-    EfiACPIMemoryNVS\r
+    mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData\r
     );\r
 \r
   //\r
@@ -49,15 +52,38 @@ PeiFvInitialization (
   //\r
   BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));\r
 \r
+  SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);\r
+\r
   //\r
   // Create a memory allocation HOB for the DXE FV.\r
   //\r
+  // If "secure" S3 is needed, then SEC will decompress both PEI and DXE\r
+  // firmware volumes at S3 resume too, hence we need to keep away the OS from\r
+  // DXEFV as well. Otherwise we only need to keep away DXE itself from the\r
+  // DXEFV area.\r
+  //\r
   BuildMemoryAllocationHob (\r
     PcdGet32 (PcdOvmfDxeMemFvBase),\r
     PcdGet32 (PcdOvmfDxeMemFvSize),\r
-    EfiBootServicesData\r
+    SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData\r
     );\r
 \r
+  //\r
+  // Additionally, said decompression will use temporary memory above the end\r
+  // of DXEFV, so let's keep away the OS from there too.\r
+  //\r
+  if (SecureS3Needed) {\r
+    UINT32 DxeMemFvEnd;\r
+\r
+    DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +\r
+                  PcdGet32 (PcdOvmfDxeMemFvSize);\r
+    BuildMemoryAllocationHob (\r
+      DxeMemFvEnd,\r
+      PcdGet32 (PcdOvmfDecompressionScratchEnd) - DxeMemFvEnd,\r
+      EfiACPIMemoryNVS\r
+      );\r
+  }\r
+\r
   //\r
   // Let PEI know about the DXE FV so it can find the DXE Core\r
   //\r