TianoCore EDK2 master
Loading...
Searching...
No Matches
SmmCorePerformanceLib.c File Reference

Go to the source code of this file.

Functions

BOOLEAN MmCorePerformanceIsNonPrimaryBufferValid (IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
 
BOOLEAN MmCorePerformanceIsPrimaryBufferValid (IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)
 
EFI_LOADED_IMAGE_PROTOCOLGetLoadedImageProtocol (IN EFI_HANDLE Handle)
 
EFI_STATUS GetNameFromUiSection (IN EFI_GUID *ModuleGuid, OUT CHAR8 *NameString, IN UINTN BufferSize)
 
VOID EFIAPI InitializeSmmCorePerformanceLib (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI SmmCorePerformanceLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

PERFORMANCE_PROPERTY mPerformanceProperty
 
SPIN_LOCK mSmmFpdtLock
 
EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface
 

Detailed Description

Performance library instance used by SMM Core.

This library provides the performance measurement interfaces and initializes performance logging for the SMM phase. It initializes SMM phase performance logging by publishing the SMM Performance and PerformanceEx Protocol, which is consumed by SmmPerformanceLib to logging performance data in SMM phase.

This library is mainly used by SMM Core to start performance logging to ensure that SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.

Caution: This module requires additional review when modified. This driver will have external input - performance data and communicate buffer in SMM mode. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow.

SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation.

Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SmmCorePerformanceLib.c.

Function Documentation

◆ GetLoadedImageProtocol()

EFI_LOADED_IMAGE_PROTOCOL * GetLoadedImageProtocol ( IN EFI_HANDLE  Handle)

Return a pointer to the loaded image protocol for the given handle.

Parameters
[in]HandleA handle to query for the loaded image protocol.
Returns
A pointer to a loaded image protocol instance or null if the handle does not support load image protocol.

Definition at line 93 of file SmmCorePerformanceLib.c.

◆ GetNameFromUiSection()

EFI_STATUS GetNameFromUiSection ( IN EFI_GUID ModuleGuid,
OUT CHAR8 *  NameString,
IN UINTN  BufferSize 
)

Get the module name from the user interface section.

Parameters
[in]ModuleGuidThe GUID of the module.
[out]NameStringThe buffer to store the name string.
[in]BufferSizeThe size of the buffer in bytes.
Return values
EFI_SUCCESSThe name string is successfully retrieved.
EFI_NOT_FOUNDThe module name was not found.

Definition at line 154 of file SmmCorePerformanceLib.c.

◆ InitializeSmmCorePerformanceLib()

VOID EFIAPI InitializeSmmCorePerformanceLib ( IN EFI_EVENT  Event,
IN VOID Context 
)

Initializes the MM Core Performance library after MM services are available.

Parameters
[in]EventThe event of notify protocol.
[in]ContextNotify event context.

Definition at line 195 of file SmmCorePerformanceLib.c.

◆ MmCorePerformanceIsNonPrimaryBufferValid()

BOOLEAN MmCorePerformanceIsNonPrimaryBufferValid ( IN EFI_PHYSICAL_ADDRESS  Buffer,
IN UINT64  Length 
)

A library internal MM-instance specific implementation to check if a buffer outside MM is valid.

This function is provided so Standalone MM and Traditional MM may use a different implementation of data buffer check logic.

Parameters
[in]BufferThe buffer start address to be checked.
[in]LengthThe buffer length to be checked.
Return values
TRUEThis buffer is valid per processor architecture.
FALSEThis buffer is not valid per processor architecture.

Definition at line 56 of file SmmCorePerformanceLib.c.

◆ MmCorePerformanceIsPrimaryBufferValid()

BOOLEAN MmCorePerformanceIsPrimaryBufferValid ( IN EFI_PHYSICAL_ADDRESS  Buffer,
IN UINT64  Length 
)

A library internal MM-instance specific implementation to check if a comm buffer is valid.

This function is provided so Standalone MM and Traditional MM may use a different implementation of comm buffer check logic.

Parameters
[in]BufferThe buffer start address to be checked.
[in]LengthThe buffer length to be checked.
Return values
TRUEThis communicate buffer is valid per processor architecture.
FALSEThis communicate buffer is not valid per processor architecture.

Definition at line 77 of file SmmCorePerformanceLib.c.

◆ SmmCorePerformanceLibConstructor()

EFI_STATUS EFIAPI SmmCorePerformanceLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The constructor function initializes the Performance Measurement Enable flag and registers SmmBase2 protocol notify callback. It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe constructor always returns EFI_SUCCESS.

Definition at line 268 of file SmmCorePerformanceLib.c.

Variable Documentation

◆ mPerformanceMeasurementInterface

EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface
Initial value:
= {
}
EFI_STATUS EFIAPI CreatePerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 TimeStamp, IN UINT64 Address OPTIONAL, IN UINT32 Identifier, IN PERF_MEASUREMENT_ATTRIBUTE Attribute)

Definition at line 39 of file SmmCorePerformanceLib.c.

◆ mPerformanceProperty

PERFORMANCE_PROPERTY mPerformanceProperty

Definition at line 35 of file SmmCorePerformanceLib.c.

◆ mSmmFpdtLock

SPIN_LOCK mSmmFpdtLock
extern

Definition at line 40 of file MmCorePerformanceLib.c.