#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
/** @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
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
//\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
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
## @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
# 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
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
/** @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
## @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