]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/SmmCpuFeaturesLib: Skip SMBASE configuration
authorWu, Jiaxin <jiaxin.wu@intel.com>
Thu, 16 Feb 2023 06:16:32 +0000 (14:16 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 6 Mar 2023 06:07:48 +0000 (06:07 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4337

This patch is to avoid configure SMBASE if SmBase relocation has been
done. If gSmmBaseHobGuid found, means SmBase info has been relocated
and recorded in the SmBase array. No need to do the relocation in
SmmCpuFeaturesInitializeProcessor().

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h
UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf

index fd3e902547c3e7740c5963ec53d86dcc4d6290e6..c2e4fbe96b53701538045e8f7d32f1a8a3c38cd9 100644 (file)
@@ -9,11 +9,13 @@
 #ifndef CPU_FEATURES_LIB_H_\r
 #define CPU_FEATURES_LIB_H_\r
 \r
+#include <Guid/SmmBaseHob.h>\r
 #include <Library/SmmCpuFeaturesLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
 \r
 /**\r
   Performs library initialization.\r
index d5eaaa7a991e31cad52cd3d8260841580defc4b3..1a2c706fa1f12e130b90699fc4d120826640609d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation shared across all library instances.\r
 \r
-Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) Microsoft Corporation.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -38,6 +38,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 UINT32  mSmrrPhysBaseMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE;\r
 UINT32  mSmrrPhysMaskMsr = SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK;\r
 \r
+//\r
+// Indicate SmBase for each Processors has been relocated or not. If TRUE,\r
+// means no need to do the relocation in SmmCpuFeaturesInitializeProcessor().\r
+//\r
+BOOLEAN  mSmmCpuFeaturesSmmRelocated;\r
+\r
 //\r
 // Set default value to assume MTRRs need to be configured on each SMI\r
 //\r
@@ -144,6 +150,12 @@ CpuFeaturesLibInitialization (
   //\r
   mSmrrEnabled = (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLogicalProcessorNumber ());\r
   ASSERT (mSmrrEnabled != NULL);\r
+\r
+  //\r
+  // If gSmmBaseHobGuid found, means SmBase info has been relocated and recorded\r
+  // in the SmBase array.\r
+  //\r
+  mSmmCpuFeaturesSmmRelocated = (BOOLEAN)(GetFirstGuidHob (&gSmmBaseHobGuid) != NULL);\r
 }\r
 \r
 /**\r
@@ -187,10 +199,15 @@ SmmCpuFeaturesInitializeProcessor (
   UINTN                 ModelId;\r
 \r
   //\r
-  // Configure SMBASE.\r
+  // No need to configure SMBASE if SmBase relocation has been done.\r
   //\r
-  CpuState             = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);\r
-  CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex];\r
+  if (!mSmmCpuFeaturesSmmRelocated) {\r
+    //\r
+    // Configure SMBASE.\r
+    //\r
+    CpuState             = (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET);\r
+    CpuState->x86.SMBASE = (UINT32)CpuHotPlugData->SmBase[CpuIndex];\r
+  }\r
 \r
   //\r
   // Intel(R) 64 and IA-32 Architectures Software Developer's Manual\r
index 9ac7dde78f852b366f52c26aac1fabee41748a49..46ae2bf85ea6df67d28a6c3e6a664695d3f5ad7a 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  The CPU specific programming for PiSmmCpuDxeSmm module.\r
 #\r
-#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
   PcdLib\r
   MemoryAllocationLib\r
   DebugLib\r
+  HobLib\r
+\r
+[Guids]\r
+  gSmmBaseHobGuid                ## CONSUMES\r
 \r
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES\r
index 86d367e0a09018c168e1a1fff78f6424e445a001..51322ff189fb38067ba70314b4b9f40edd88544c 100644 (file)
@@ -2,7 +2,7 @@
 #  The CPU specific programming for PiSmmCpuDxeSmm module when STM support\r
 #  is included.\r
 #\r
-#  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -64,6 +64,7 @@
   gMsegSmramGuid                           ## SOMETIMES_CONSUMES ## HOB\r
   gEfiAcpi20TableGuid                      ## SOMETIMES_CONSUMES ## SystemTable\r
   gEfiAcpi10TableGuid                      ## SOMETIMES_CONSUMES ## SystemTable\r
+  gSmmBaseHobGuid                          ## CONSUMES\r
 \r
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES\r
index 3cf162ada016df03f92af79ecbbaa664e63264f7..6cb1c515c0fd43cf106521db169e370b28732855 100644 (file)
@@ -1,14 +1,13 @@
 /** @file\r
   SMM STM support functions\r
 \r
-  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #include <PiMm.h>\r
 #include <Library/BaseMemoryLib.h>\r
-#include <Library/HobLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/SmmServicesTableLib.h>\r
 #include <Library/TpmMeasurementLib.h>\r
index b1f60a55055d7be095b4c0219203e20b08fc2b1f..c836939d338fabf8aa8fa86606bdb8e3e1f43289 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Standalone MM CPU specific programming.\r
 #\r
-#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.<BR>\r
 #  Copyright (c) Microsoft Corporation.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
   DebugLib\r
   MemoryAllocationLib\r
   PcdLib\r
+  HobLib\r
+\r
+[Guids]\r
+  gSmmBaseHobGuid                ## CONSUMES\r
 \r
 [FixedPcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES\r