]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
UefiCpuPkg/PiSmmCpuDxeSmm: Consume SMM Base Hob for SmBase info
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / CpuS3.c
index fb4a44eab69b585de666252573b34863e40325e8..d408b3f9f7a9c589a0cd97f048e02642097bd5c6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Code for Processor S3 restoration\r
 \r
-Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -824,9 +824,34 @@ SmmRestoreCpu (
   }\r
 \r
   //\r
-  // Restore SMBASE for BSP and all APs\r
+  // Make sure the gSmmBaseHobGuid existence status is the same between normal and S3 boot.\r
   //\r
-  SmmRelocateBases ();\r
+  ASSERT (mSmmRelocated == (BOOLEAN)(GetFirstGuidHob (&gSmmBaseHobGuid) != NULL));\r
+  if (mSmmRelocated != (BOOLEAN)(GetFirstGuidHob (&gSmmBaseHobGuid) != NULL)) {\r
+    DEBUG ((\r
+      DEBUG_ERROR,\r
+      "gSmmBaseHobGuid %a produced in normal boot but %a in S3 boot!",\r
+      mSmmRelocated ? "is" : "is not",\r
+      mSmmRelocated ? "is not" : "is"\r
+      ));\r
+    CpuDeadLoop ();\r
+  }\r
+\r
+  //\r
+  // Check whether Smm Relocation is done or not.\r
+  // If not, will do the SmmBases Relocation here!!!\r
+  //\r
+  if (!mSmmRelocated) {\r
+    //\r
+    // Restore SMBASE for BSP and all APs\r
+    //\r
+    SmmRelocateBases ();\r
+  } else {\r
+    //\r
+    // Issue SMI IPI (All Excluding  Self SMM IPI + BSP SMM IPI) to execute first SMI init.\r
+    //\r
+    ExecuteFirstSmiInit ();\r
+  }\r
 \r
   //\r
   // Skip initialization if mAcpiCpuData is not valid\r