Skip to content

Commit

Permalink
MdeModulePkg: PeiMain: Adds performance measurement for PeiMain
Browse files Browse the repository at this point in the history
This change was split off the commit:
7a38833
  • Loading branch information
Bret Barkelew authored and Flickdm committed Jul 4, 2024
1 parent 8ca2a21 commit 1dd1a5b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 13 deletions.
7 changes: 5 additions & 2 deletions MdeModulePkg/Core/Pei/PeiMain.inf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
PeCoffLib
PeiServicesTablePointerLib
PcdLib
TimerLib ## MU_CHANGE

[Guids]
gPeiAprioriFileNameGuid ## SOMETIMES_CONSUMES ## File
Expand All @@ -79,8 +80,8 @@
gStatusCodeCallbackGuid
gEdkiiMigratedFvInfoGuid ## SOMETIMES_PRODUCES ## HOB
gEdkiiMigrationInfoGuid ## SOMETIMES_CONSUMES ## HOB
gEfiFirmwarePerformanceGuid ## MU_CHANGE - needed to build SEC perf HOB
gEfiDelayedDispatchTableGuid ## MU_CHANGE
gPerfDelayedDispatchEndOfPei ## MU_CHANGE

[Ppis]
gEfiPeiStatusCodePpiGuid ## SOMETIMES_CONSUMES # PeiReportStatusService is not ready if this PPI doesn't exist
Expand All @@ -103,7 +104,9 @@
gEfiPeiReset2PpiGuid ## SOMETIMES_CONSUMES
gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES
gEfiPeiCoreFvLocationPpiGuid ## SOMETIMES_CONSUMES
gEfiDelayedDispatchPpiGuid # MSCHANGE
gPeiSecPerformancePpiGuid # MU_CHANGE_161871 - needed to build SEC perf HOB
gEfiDelayedDispatchPpiGuid # MU_CHANGE
gEfiEndOfPeiSignalPpiGuid # MU_CHANGE

[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES
Expand Down
38 changes: 38 additions & 0 deletions MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#include "PeiMain.h"

// MU_CHANGE [BEGIN]
// MU_CHANGE - Include these in order to build the performance HOB here instead of
// FirmwarePerformancePei. Necessary because Firmware firmwarePerformancePei
// is loaded postmem when CAR is gone.
#include <Ppi/SecPerformance.h>
#include <Guid/FirmwarePerformance.h>
// MU_CHANGE [END]

EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiMemoryDiscoveredPpiGuid,
Expand Down Expand Up @@ -178,6 +186,12 @@ PeiCore (
EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;
EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi;
UINTN Index;
// MU_CHANGE [BEGIN]
// MU_CHANGE - Build the performance HOB here instead of FirmwarePerformancePei.
FIRMWARE_SEC_PERFORMANCE Performance;
PEI_SEC_PERFORMANCE_PPI *SecPerf;

// MU_CHANGE [END]

//
// Retrieve context passed into PEI Core
Expand Down Expand Up @@ -437,6 +451,30 @@ PeiCore (
if (PpiList != NULL) {
ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps, PpiList);
}

// MU_CHANGE [BEGIN]
//
// MU_CHANGE: Build Hob for SEC performance data.
//
Status = PeiServicesLocatePpi (
&gPeiSecPerformancePpiGuid,
0,
NULL,
(VOID **)&SecPerf
);
if (!EFI_ERROR (Status)) {
Status = SecPerf->GetPerformance ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps, SecPerf, &Performance);
if (!EFI_ERROR (Status)) {
BuildGuidDataHob (
&gEfiFirmwarePerformanceGuid,
&Performance,
sizeof (FIRMWARE_SEC_PERFORMANCE)
);
DEBUG ((DEBUG_ERROR, "SEC Performance Hob ResetEnd = %ld\n", Performance.ResetEnd));
}
}

// MU_CHANGE [END]
} else {
if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
//
Expand Down
31 changes: 21 additions & 10 deletions MdeModulePkg/Core/PiSmmCore/Dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,18 +664,27 @@ SmmLoadImage (
// Print the load address and the PDB file name if it is available
//

DEBUG_CODE_BEGIN ();
// MS_CHANGE_304324
// DEBUG_CODE_BEGIN ();
// END

UINTN Index;
UINTN StartIndex;
CHAR8 EfiFileName[256];

DEBUG ((
DEBUG_INFO | DEBUG_LOAD,
"Loading SMM driver at 0x%11p EntryPoint=0x%11p ",
(VOID *)(UINTN)ImageContext.ImageAddress,
FUNCTION_ENTRY_POINT (ImageContext.EntryPoint)
));
// // MU_CHANGE [BEGIN]
if (DebugCodeEnabled ()) {
DEBUG ((
DEBUG_INFO | DEBUG_LOAD,
"Loading SMM driver at 0x%11p EntryPoint=0x%11p ",
(VOID *)(UINTN)ImageContext.ImageAddress,
FUNCTION_ENTRY_POINT (ImageContext.EntryPoint)
));
} else {
DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "Loading SMM driver "));
}

// MU_CHANGE [END]

//
// Print Module Name by Pdb file path.
Expand Down Expand Up @@ -713,12 +722,14 @@ SmmLoadImage (
EfiFileName[Index] = 0;
}

DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex]));
DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "%a", EfiFileName)); // &Image->ImageContext.PdbPointer[StartIndex])); // MU_CHANGE
}

DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));
DEBUG ((DEBUG_ERROR | DEBUG_LOAD, "\n")); // MU_CHANGE

DEBUG_CODE_END ();
// MU_CHANGE [BEGIN]
// DEBUG_CODE_END ();
// MU_CHANGE [END]

//
// Free buffer allocated by Fv->ReadSection.
Expand Down
9 changes: 8 additions & 1 deletion MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,14 @@ ExecuteSmmCoreFromSmram (
//
// Print debug message showing SMM Core load address.
//
DEBUG ((DEBUG_INFO, "SMM IPL loading SMM Core at SMRAM address %p\n", (VOID *)(UINTN)ImageContext.ImageAddress));
// MU_CHANGE [BEGIN]
if (DebugCodeEnabled ()) {
DEBUG ((DEBUG_INFO, "SMM IPL loading SMM Core at SMRAM address %p\n", (VOID *)(UINTN)ImageContext.ImageAddress));
} else {
DEBUG ((DEBUG_ERROR, "SMM IPL loading SMM Core (PiSmmCore.efi)\n"));
}

// MU_CHANGE [END]

//
// Load the image to our new buffer
Expand Down

0 comments on commit 1dd1a5b

Please sign in to comment.