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; } /**