This is a patch that enables the S3 Resume path from PEI without permanent 
memory installed.  There is not a strict requirement that we can see to have 
permanent memory installed for S3 resume.  We have platforms that hold PEI code 
(not just data) in cache-as-ram and these require S3 Resume from temporary 
memory.

This change does the following:

1. Relax the ASSERT in PEI core for permanent memory before launching IPL so 
that it only enforces this in non-S3 Resume boot modes
2. Remove the gEfiPeiMemoryDiscoveredPpiGuid depex for DXE IPL so it can load 
before permanent memory.  Since DXE IPL is really driven by the IPL PPI this is 
generally harmless.  This may cause IPL to be loaded pre-memory in a normal 
boot and be shadowed to permanent memory
3.  Add a check in DXE IPL that permanent memory is present for boot paths that 
load the DXE core (e.g. normal)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eugene Cohen <eug...@hp.com>
---
 MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf |  3 ++-
 MdeModulePkg/Core/DxeIplPeim/DxeLoad.c  | 11 +++++++++++
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c |  6 ++++--
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf 
b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 04ad928..9623f96 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -93,6 +93,7 @@
   ## SOMETIMES_CONSUMES
   ## UNDEFINED # HOB
   gEfiVectorHandoffInfoPpiGuid
+  gEfiPeiMemoryDiscoveredPpiGuid    ## SOMETIMES_CONSUMES # Consumed on normal 
path
 
 [Guids]
   ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"
@@ -115,7 +116,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack               ## 
SOMETIMES_CONSUMES
 
 [Depex]
-  gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiLoadFilePpiGuid AND 
gEfiPeiMasterBootModePpiGuid
+  gEfiPeiLoadFilePpiGuid AND gEfiPeiMasterBootModePpiGuid
 
 #
 # [BootMode]
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c 
b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
index d7d693f..888a710 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c
@@ -193,6 +193,7 @@ DxeLoadCore (
   )
 {
   EFI_STATUS                                Status;
+  VOID                                      *Dummy;
   EFI_FV_FILE_INFO                          DxeCoreFileInfo;
   EFI_PHYSICAL_ADDRESS                      DxeCoreAddress;
   UINT64                                    DxeCoreSize;
@@ -273,6 +274,16 @@ DxeLoadCore (
     //
   }
 
+  // DXE core load requires permanent memory
+  Status = PeiServicesLocatePpi (
+             &gEfiPeiMemoryDiscoveredPpiGuid,
+             0,
+             NULL,
+             (VOID **)&Dummy
+             );
+  ASSERT_EFI_ERROR (Status);
+  if( EFI_ERROR(Status)) return Status;
+
   if (GetFirstGuidHob ((CONST EFI_GUID *)&gEfiMemoryTypeInformationGuid) == 
NULL) {
     //
     // Don't build GuidHob if GuidHob has been installed.
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c 
b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index d36f89c..8f2dfa3 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -421,9 +421,11 @@ PeiCore (
   PeiDispatcher (SecCoreData, &PrivateData);
 
   //
-  // Check if InstallPeiMemory service was called.
+  // If we're not doing S3 resume then we require permanent memory
   //
-  ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
+  if(PrivateData.HobList.HandoffInformationTable->BootMode != 
BOOT_ON_S3_RESUME) {
+    ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
+  }
 
   //
   // Measure PEI Core execution time.
-- 
1.9.5.msysgit.0

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to