From e6e32ec36c037dc8ab0eba2480eb9d661da8d06b Mon Sep 17 00:00:00 2001 From: "Zhao,Yanxin" Date: Wed, 18 Dec 2024 10:45:40 +0800 Subject: [PATCH] UefiPkg/PiSmmCpuDxeSmm: Set SmmProfile Variable only for DXE SMM Some platforms plan to move the Standalone MM CPU driver into the FSP. However, there is no variable service support in FSP. Therefore, the SetVariable logic for the Standalone MM CPU will be removed. With this change, users can dump the SmmProfile data from the Memory Allocation HOB: gMmProfileDataHobGuid. This change does not impact the DXE SMM, which will still retrieve the SmmProfile data from the variable service. Signed-off-by: Yanxin Zhao --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 38 +++++++++++++++----------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c index 4862cf075fed0..778b904f637da 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -714,24 +714,30 @@ InitSmmProfileCallBack ( EFI_STATUS Status; EFI_SMM_VARIABLE_PROTOCOL *SmmProfileVariable; - // - // Locate SmmVariableProtocol. - // - Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **)&SmmProfileVariable); - ASSERT_EFI_ERROR (Status); + Status = EFI_SUCCESS; + if (!mIsStandaloneMm) { + // + // Locate SmmVariableProtocol. + // + Status = gMmst->MmLocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **)&SmmProfileVariable); + ASSERT_EFI_ERROR (Status); - // - // Save to variable so that SMM profile data can be found. - // - SmmProfileVariable->SmmSetVariable ( - SMM_PROFILE_NAME, - &gEfiCallerIdGuid, - EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - sizeof (mSmmProfileBase), - &mSmmProfileBase - ); + // + // Save to variable so that SMM profile data can be found. + // + Status = SmmProfileVariable->SmmSetVariable ( + SMM_PROFILE_NAME, + &gEfiCallerIdGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof (mSmmProfileBase), + &mSmmProfileBase + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Set SmmProfile variable failure! Status = %r\n", Status)); + } + } - return EFI_SUCCESS; + return Status; } /**