UefiCpuPkg/PiSmmCpuDxeSmm: Check SMM Debug Agent support or not

This patch is to check SMM Debug Agent support or not before
InitializeDebugAgent.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: 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>
This commit is contained in:
Jiaxin Wu 2023-12-15 16:38:13 +08:00 committed by mergify[bot]
parent c7c2de798a
commit e1b62f3e28
4 changed files with 23 additions and 11 deletions

View File

@ -837,7 +837,9 @@ SmmRestoreCpu (
// //
// Initialize Debug Agent to support source level debug // Initialize Debug Agent to support source level debug
// //
InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL); if (mSmmDebugAgentSupport) {
InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL);
}
} }
mBspApicId = GetApicId (); mBspApicId = GetApicId ();

View File

@ -476,10 +476,12 @@ BSPHandler (
// //
*mSmmMpSyncData->InsideSmm = TRUE; *mSmmMpSyncData->InsideSmm = TRUE;
// if (mSmmDebugAgentSupport) {
// Initialize Debug Agent to start source level debug in BSP handler //
// // Initialize Debug Agent to start source level debug in BSP handler
InitializeDebugAgent (DEBUG_AGENT_INIT_ENTER_SMI, NULL, NULL); //
InitializeDebugAgent (DEBUG_AGENT_INIT_ENTER_SMI, NULL, NULL);
}
// //
// Mark this processor's presence // Mark this processor's presence
@ -648,11 +650,13 @@ BSPHandler (
SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex); SmmCpuSyncWaitForAPs (mSmmMpSyncData->SyncContext, ApCount, CpuIndex);
} }
// if (mSmmDebugAgentSupport) {
// Stop source level debug in BSP handler, the code below will not be //
// debugged. // Stop source level debug in BSP handler, the code below will not be
// // debugged.
InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL); //
InitializeDebugAgent (DEBUG_AGENT_INIT_EXIT_SMI, NULL, NULL);
}
// //
// Signal APs to Reset states/semaphore for this processor // Signal APs to Reset states/semaphore for this processor

View File

@ -112,6 +112,11 @@ BOOLEAN mSmmReadyToLock = FALSE;
// //
BOOLEAN mSmmCodeAccessCheckEnable = FALSE; BOOLEAN mSmmCodeAccessCheckEnable = FALSE;
//
// Global used to cache SMM Debug Agent Supported ot not
//
BOOLEAN mSmmDebugAgentSupport = FALSE;
// //
// Global copy of the PcdPteMemoryEncryptionAddressOrMask // Global copy of the PcdPteMemoryEncryptionAddressOrMask
// //
@ -897,7 +902,7 @@ PiCpuSmmEntry (
// //
// Initialize Debug Agent to support source level debug in SMM code // Initialize Debug Agent to support source level debug in SMM code
// //
InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, NULL, NULL); InitializeDebugAgent (DEBUG_AGENT_INIT_SMM, &mSmmDebugAgentSupport, NULL);
// //
// Report the start of CPU SMM initialization. // Report the start of CPU SMM initialization.

View File

@ -483,6 +483,7 @@ extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock;
extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; extern EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges;
extern UINTN mSmmCpuSmramRangeCount; extern UINTN mSmmCpuSmramRangeCount;
extern UINT8 mPhysicalAddressBits; extern UINT8 mPhysicalAddressBits;
extern BOOLEAN mSmmDebugAgentSupport;
// //
// Copy of the PcdPteMemoryEncryptionAddressOrMask // Copy of the PcdPteMemoryEncryptionAddressOrMask