]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/Fv.c
OvmfPkg/PlatformPei: prepare for PcdQ35TsegMbytes becoming dynamic
[mirror_edk2.git] / OvmfPkg / PlatformPei / Fv.c
index 3ed775c850832f472df524cf8f0522662ec5dae5..248c58508558a2741848073776a8db3d4a17193e 100644 (file)
@@ -32,6 +32,8 @@ PeiFvInitialization (
   VOID\r
   )\r
 {\r
+  BOOLEAN SecureS3Needed;\r
+\r
   DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));\r
 \r
   //\r
@@ -50,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