UefiCpuPkg/PiSmmCpuDxeSmm: Avoid PcdCpuSmmProfileEnable check in MM
For MM, gMmProfileDataHobGuid Memory Allocation HOB is defined to indicate SMM profile feature enabled or not. If the HOB exist, SMM profile base address and size will be returned in the HOB, so no need to consume the PcdCpuSmmProfileEnable feature PCD to check enable or disable. To achieve above purpose, Add the IsSmmProfileEnabled () function. With this change, Both MM and SMM can use the new function for SMM profile feature check. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Yuanhao Xie <yuanhao.xie@intel.com>
This commit is contained in:
parent
ae0d54cd43
commit
2e6ca59e33
|
@ -33,7 +33,7 @@ SmmInitPageTable (
|
||||||
mPhysicalAddressBits = 32;
|
mPhysicalAddressBits = 32;
|
||||||
mPagingMode = PagingPae;
|
mPagingMode = PagingPae;
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable) ||
|
if (mSmmProfileEnabled ||
|
||||||
HEAP_GUARD_NONSTOP_MODE ||
|
HEAP_GUARD_NONSTOP_MODE ||
|
||||||
NULL_DETECTION_NONSTOP_MODE)
|
NULL_DETECTION_NONSTOP_MODE)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,7 @@ SmiPFHandler (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
SmmProfilePFHandler (
|
SmmProfilePFHandler (
|
||||||
SystemContext.SystemContextIa32->Eip,
|
SystemContext.SystemContextIa32->Eip,
|
||||||
SystemContext.SystemContextIa32->ExceptionData
|
SystemContext.SystemContextIa32->ExceptionData
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
;
|
;
|
||||||
;-------------------------------------------------------------------------------
|
;-------------------------------------------------------------------------------
|
||||||
|
|
||||||
extern ASM_PFX(FeaturePcdGet (PcdCpuSmmProfileEnable))
|
|
||||||
extern ASM_PFX(SmiPFHandler)
|
extern ASM_PFX(SmiPFHandler)
|
||||||
extern ASM_PFX(mSetupDebugTrap)
|
extern ASM_PFX(mSetupDebugTrap)
|
||||||
|
|
||||||
|
|
|
@ -1616,7 +1616,7 @@ SmiRendezvous (
|
||||||
InitializeSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy);
|
InitializeSpinLock (mSmmMpSyncData->CpuData[CpuIndex].Busy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
ActivateSmmProfile (CpuIndex);
|
ActivateSmmProfile (CpuIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1677,7 +1677,7 @@ SmiRendezvous (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
SmmProfileRecordSmiNum ();
|
SmmProfileRecordSmiNum ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
Get SmmProfileData.
|
Get SmmProfileData.
|
||||||
|
|
||||||
@param[in, out] Size Return Size of SmmProfileData.
|
@param[in, out] Size Return Size of SmmProfileData.
|
||||||
|
0 means the gMmProfileDataHobGuid does not exist.
|
||||||
|
|
||||||
@return Address of SmmProfileData
|
@return Address of SmmProfileData
|
||||||
|
|
||||||
|
@ -39,7 +40,10 @@ GetSmmProfileData (
|
||||||
SmmProfileDataHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (SmmProfileDataHob));
|
SmmProfileDataHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (SmmProfileDataHob));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (SmmProfileDataHob.Raw != NULL);
|
if (SmmProfileDataHob.Raw == NULL) {
|
||||||
|
*Size = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
*Size = SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryLength;
|
*Size = SmmProfileDataHob.MemoryAllocation->AllocDescriptor.MemoryLength;
|
||||||
|
|
||||||
|
|
|
@ -1153,6 +1153,11 @@ PiSmmCpuEntryCommon (
|
||||||
//
|
//
|
||||||
InitializeSmmTimer ();
|
InitializeSmmTimer ();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize mSmmProfileEnabled
|
||||||
|
//
|
||||||
|
mSmmProfileEnabled = IsSmmProfileEnabled ();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize MP globals
|
// Initialize MP globals
|
||||||
//
|
//
|
||||||
|
|
|
@ -830,6 +830,18 @@ SmiPFHandler (
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check SmmProfile is enabled or not.
|
||||||
|
|
||||||
|
@return TRUE SmmProfile is enabled.
|
||||||
|
FALSE SmmProfile is not enabled.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IsSmmProfileEnabled (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform the remaining tasks.
|
Perform the remaining tasks.
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,21 @@ const BOOLEAN mIsStandaloneMm = FALSE;
|
||||||
//
|
//
|
||||||
BOOLEAN mSmmReadyToLock = FALSE;
|
BOOLEAN mSmmReadyToLock = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check SmmProfile is enabled or not.
|
||||||
|
|
||||||
|
@return TRUE SmmProfile is enabled.
|
||||||
|
FALSE SmmProfile is not enabled.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IsSmmProfileEnabled (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FeaturePcdGet (PcdCpuSmmProfileEnable);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform the remaining tasks.
|
Perform the remaining tasks.
|
||||||
|
|
||||||
|
@ -40,7 +55,7 @@ PerformRemainingTasks (
|
||||||
//
|
//
|
||||||
// Start SMM Profile feature
|
// Start SMM Profile feature
|
||||||
//
|
//
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
SmmProfileStart ();
|
SmmProfileStart ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +75,7 @@ PerformRemainingTasks (
|
||||||
//
|
//
|
||||||
// Update Page Table for outside SMRAM.
|
// Update Page Table for outside SMRAM.
|
||||||
//
|
//
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
SmmProfileUpdateMemoryAttributes ();
|
SmmProfileUpdateMemoryAttributes ();
|
||||||
} else {
|
} else {
|
||||||
UpdateUefiMemMapAttributes ();
|
UpdateUefiMemMapAttributes ();
|
||||||
|
@ -157,7 +172,7 @@ SmmReadyToLockEventNotify (
|
||||||
//
|
//
|
||||||
// Skip SMM profile initialization if feature is disabled
|
// Skip SMM profile initialization if feature is disabled
|
||||||
//
|
//
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
//
|
//
|
||||||
// Get Software SMI from FADT
|
// Get Software SMI from FADT
|
||||||
//
|
//
|
||||||
|
|
|
@ -20,6 +20,28 @@ const BOOLEAN mIsStandaloneMm = TRUE;
|
||||||
//
|
//
|
||||||
BOOLEAN mRemainingTasksDone = FALSE;
|
BOOLEAN mRemainingTasksDone = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Check SmmProfile is enabled or not.
|
||||||
|
|
||||||
|
@return TRUE SmmProfile is enabled.
|
||||||
|
FALSE SmmProfile is not enabled.
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
IsSmmProfileEnabled (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT64 SmmProfileSize;
|
||||||
|
|
||||||
|
GetSmmProfileData (&SmmProfileSize);
|
||||||
|
if (SmmProfileSize == 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Perform the remaining tasks.
|
Perform the remaining tasks.
|
||||||
|
|
||||||
|
@ -216,7 +238,7 @@ PiCpuStandaloneMmEntry (
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
//
|
//
|
||||||
// Get Software SMI
|
// Get Software SMI
|
||||||
//
|
//
|
||||||
|
|
|
@ -1494,7 +1494,7 @@ IfReadOnlyPageTableNeeded (
|
||||||
//
|
//
|
||||||
if (!IsRestrictedMemoryAccess () ||
|
if (!IsRestrictedMemoryAccess () ||
|
||||||
((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) ||
|
((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT3 | BIT2)) != 0) ||
|
||||||
FeaturePcdGet (PcdCpuSmmProfileEnable))
|
mSmmProfileEnabled)
|
||||||
{
|
{
|
||||||
if (sizeof (UINTN) == sizeof (UINT64)) {
|
if (sizeof (UINTN) == sizeof (UINT64)) {
|
||||||
//
|
//
|
||||||
|
@ -1508,7 +1508,7 @@ IfReadOnlyPageTableNeeded (
|
||||||
//
|
//
|
||||||
// Restriction on access to non-SMRAM memory and SMM profile could not be enabled at the same time.
|
// Restriction on access to non-SMRAM memory and SMM profile could not be enabled at the same time.
|
||||||
//
|
//
|
||||||
ASSERT (!(IsRestrictedMemoryAccess () && FeaturePcdGet (PcdCpuSmmProfileEnable)));
|
ASSERT (!(IsRestrictedMemoryAccess () && mSmmProfileEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -40,6 +40,11 @@ BOOLEAN mXdEnabled = FALSE;
|
||||||
//
|
//
|
||||||
BOOLEAN mBtsSupported = TRUE;
|
BOOLEAN mBtsSupported = TRUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The flag indicates if SMM profile is enabled.
|
||||||
|
//
|
||||||
|
BOOLEAN mSmmProfileEnabled = FALSE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// The flag indicates if SMM profile starts to record data.
|
// The flag indicates if SMM profile starts to record data.
|
||||||
//
|
//
|
||||||
|
@ -342,7 +347,7 @@ IsAddressSplit (
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
//
|
//
|
||||||
// Check configuration
|
// Check configuration
|
||||||
//
|
//
|
||||||
|
@ -1018,7 +1023,7 @@ InitSmmProfile (
|
||||||
//
|
//
|
||||||
// Skip SMM profile initialization if feature is disabled
|
// Skip SMM profile initialization if feature is disabled
|
||||||
//
|
//
|
||||||
if (!FeaturePcdGet (PcdCpuSmmProfileEnable) &&
|
if (!mSmmProfileEnabled &&
|
||||||
!HEAP_GUARD_NONSTOP_MODE &&
|
!HEAP_GUARD_NONSTOP_MODE &&
|
||||||
!NULL_DETECTION_NONSTOP_MODE)
|
!NULL_DETECTION_NONSTOP_MODE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -137,6 +137,10 @@ extern BOOLEAN mXdSupported;
|
||||||
//
|
//
|
||||||
extern BOOLEAN mXdEnabled;
|
extern BOOLEAN mXdEnabled;
|
||||||
//
|
//
|
||||||
|
// The flag indicates if SMM profile is enabled.
|
||||||
|
//
|
||||||
|
extern BOOLEAN mSmmProfileEnabled;
|
||||||
|
//
|
||||||
// The flag indicates if #DB will be setup in #PF handler.
|
// The flag indicates if #DB will be setup in #PF handler.
|
||||||
//
|
//
|
||||||
extern BOOLEAN mSetupDebugTrap;
|
extern BOOLEAN mSetupDebugTrap;
|
||||||
|
|
|
@ -228,7 +228,7 @@ SmmInitPageTable (
|
||||||
//
|
//
|
||||||
PageTable = GenSmmPageTable (mPagingMode, mPhysicalAddressBits);
|
PageTable = GenSmmPageTable (mPagingMode, mPhysicalAddressBits);
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
if (m5LevelPagingNeeded) {
|
if (m5LevelPagingNeeded) {
|
||||||
Pml5Entry = (UINT64 *)PageTable;
|
Pml5Entry = (UINT64 *)PageTable;
|
||||||
//
|
//
|
||||||
|
@ -264,7 +264,7 @@ SmmInitPageTable (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable) ||
|
if (mSmmProfileEnabled ||
|
||||||
HEAP_GUARD_NONSTOP_MODE ||
|
HEAP_GUARD_NONSTOP_MODE ||
|
||||||
NULL_DETECTION_NONSTOP_MODE)
|
NULL_DETECTION_NONSTOP_MODE)
|
||||||
{
|
{
|
||||||
|
@ -820,7 +820,7 @@ SmiPFHandler (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
|
if (mSmmProfileEnabled) {
|
||||||
if (mIsStandaloneMm) {
|
if (mIsStandaloneMm) {
|
||||||
//
|
//
|
||||||
// Only logging ranges shall run here in MM env.
|
// Only logging ranges shall run here in MM env.
|
||||||
|
|
Loading…
Reference in New Issue