TianoCore EDK2 master
|
#include <PiMm.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/TpmMeasurementLib.h>
#include <Register/Intel/Cpuid.h>
#include <Register/Intel/ArchitecturalMsr.h>
#include <Register/Intel/SmramSaveStateMap.h>
#include <Protocol/MpService.h>
#include "CpuFeaturesLib.h"
#include "SmmStm.h"
Go to the source code of this file.
Macros | |
#define | TXT_EVTYPE_BASE 0x400 |
#define | TXT_EVTYPE_STM_HASH (TXT_EVTYPE_BASE + 14) |
#define | RDWR_ACCS 3 |
#define | FULL_ACCS 7 |
#define | CPUID1_EDX_XD_SUPPORT 0x100000 |
Functions | |
EFI_STATUS EFIAPI | SmmCpuFeaturesLibStmConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) |
VOID | FinishSmmCpuFeaturesInitializeProcessor (VOID) |
UINTN EFIAPI | SmmCpuFeaturesGetSmiHandlerSize (VOID) |
VOID EFIAPI | SmmCpuFeaturesInstallSmiHandler (IN UINTN CpuIndex, IN UINT32 SmBase, IN VOID *SmiStack, IN UINTN StackSize, IN UINTN GdtBase, IN UINTN GdtSize, IN UINTN IdtBase, IN UINTN IdtSize, IN UINT32 Cr3) |
EFI_STATUS EFIAPI | SmmEndOfDxeEventNotify (IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle) |
VOID | StmSmmConfigurationTableInit (VOID) |
EFI_SM_MONITOR_STATE EFIAPI | GetMonitorState (VOID) |
BOOLEAN | HandleSingleResource (IN STM_RSC *Resource, IN STM_RSC *Record) |
VOID | AddSingleResource (IN STM_RSC *Resource) |
VOID | AddResource (IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL) |
BOOLEAN | ValidateResource (IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL) |
UINTN | GetResourceSize (IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL) |
EFI_STATUS EFIAPI | AddPiResource (IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL) |
EFI_STATUS EFIAPI | DeletePiResource (IN STM_RSC *ResourceList, IN UINT32 NumEntries OPTIONAL) |
EFI_STATUS EFIAPI | GetPiResource (OUT STM_RSC *ResourceList, IN OUT UINT32 *ResourceSize) |
VOID EFIAPI | EnableMsegMsr (IN VOID *Buffer) |
UINT32 | GetVmcsSize (VOID) |
BOOLEAN | StmCheckStmImage (IN EFI_PHYSICAL_ADDRESS StmImage, IN UINTN StmImageSize) |
VOID | StmLoadStmImage (IN EFI_PHYSICAL_ADDRESS StmImage, IN UINTN StmImageSize) |
EFI_STATUS EFIAPI | LoadMonitor (IN EFI_PHYSICAL_ADDRESS StmImage, IN UINTN StmImageSize) |
VOID * | GetStmResource (VOID) |
VOID | NotifyStmResourceChange (VOID *StmResource) |
VOID EFIAPI | SmmStmSetup (VOID) |
VOID EFIAPI | SmmStmTeardown (VOID) |
Variables | |
EFI_HANDLE | mStmSmmCpuHandle = NULL |
BOOLEAN | mLockLoadMonitor = FALSE |
GLOBAL_REMOVE_IF_UNREFERENCED STM_RSC_END | mRscEndNode |
GLOBAL_REMOVE_IF_UNREFERENCED UINT8 * | mStmResourcesPtr = NULL |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN | mStmResourceTotalSize = 0x0 |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN | mStmResourceSizeUsed = 0x0 |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN | mStmResourceSizeAvailable = 0x0 |
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 | mStmState = 0 |
GLOBAL_REMOVE_IF_UNREFERENCED EFI_SM_MONITOR_INIT_PROTOCOL | mSmMonitorInitProtocol |
CONST TXT_PROCESSOR_SMM_DESCRIPTOR | gcStmPsd |
UINT32 | gStmSmbase |
volatile UINT32 | gStmSmiStack |
UINT32 | gStmSmiCr3 |
volatile UINT8 | gcStmSmiHandlerTemplate [] |
CONST UINT16 | gcStmSmiHandlerSize |
UINT16 | gcStmSmiHandlerOffset |
BOOLEAN | gStmXdSupported |
IA32_DESCRIPTOR | gStmSmiHandlerIdtr |
EFI_MP_SERVICES_PROTOCOL * | mSmmCpuFeaturesLibMpService = NULL |
UINTN | mMsegBase = 0 |
UINTN | mMsegSize = 0 |
BOOLEAN | mStmConfigurationTableInitialized = FALSE |
SMM STM support functions
Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file SmmStm.c.
EFI_STATUS EFIAPI AddPiResource | ( | IN STM_RSC * | ResourceList, |
IN UINT32 NumEntries | OPTIONAL | ||
) |
Add resources in list to database. Allocate new memory areas as needed.
ResourceList | A pointer to resource list to be added |
NumEntries | Optional number of entries. If 0, list must be terminated by END_OF_RESOURCES. |
EFI_SUCCESS | If resources are added |
EFI_INVALID_PARAMETER | If nested procedure detected resource failer |
EFI_OUT_OF_RESOURCES | If nested procedure returned it and we cannot allocate more areas. |
EFI_STATUS EFIAPI DeletePiResource | ( | IN STM_RSC * | ResourceList, |
IN UINT32 NumEntries | OPTIONAL | ||
) |
Delete resources in list to database.
ResourceList | A pointer to resource list to be deleted NULL means delete all resources. |
NumEntries | Optional number of entries. If 0, list must be terminated by END_OF_RESOURCES. |
EFI_SUCCESS | If resources are deleted |
EFI_INVALID_PARAMETER | If nested procedure detected resource failer |
VOID EFIAPI EnableMsegMsr | ( | IN VOID * | Buffer | ) |
VOID FinishSmmCpuFeaturesInitializeProcessor | ( | VOID | ) |
Internal worker function that is called to complete CPU initialization at the end of SmmCpuFeaturesInitializeProcessor().
EFI_SM_MONITOR_STATE EFIAPI GetMonitorState | ( | VOID | ) |
EFI_STATUS EFIAPI GetPiResource | ( | OUT STM_RSC * | ResourceList, |
IN OUT UINT32 * | ResourceSize | ||
) |
Get BIOS resources.
ResourceList | A pointer to resource list to be filled |
ResourceSize | On input it means size of resource list input. On output it means size of resource list filled, or the size of resource list to be filled if size of too small. |
EFI_SUCCESS | If resources are returned. |
EFI_BUFFER_TOO_SMALL | If resource list buffer is too small to hold the whole resources. |
VOID * GetStmResource | ( | VOID | ) |
UINT32 GetVmcsSize | ( | VOID | ) |
EFI_STATUS EFIAPI LoadMonitor | ( | IN EFI_PHYSICAL_ADDRESS | StmImage, |
IN UINTN | StmImageSize | ||
) |
Load STM image to MSEG.
StmImage | STM image |
StmImageSize | STM image size |
EFI_SUCCESS | Load STM to MSEG successfully |
EFI_ALREADY_STARTED | STM image is already loaded to MSEG |
EFI_BUFFER_TOO_SMALL | MSEG is smaller than minimal requirement of STM image |
EFI_UNSUPPORTED | MSEG is not enabled |
VOID NotifyStmResourceChange | ( | VOID * | StmResource | ) |
UINTN EFIAPI SmmCpuFeaturesGetSmiHandlerSize | ( | VOID | ) |
Return the size, in bytes, of a custom SMI Handler in bytes. If 0 is returned, then a custom SMI handler is not provided by this library, and the default SMI handler must be used.
0 | Use the default SMI handler. |
> | 0 Use the SMI handler installed by SmmCpuFeaturesInstallSmiHandler() The caller is required to allocate enough SMRAM for each CPU to support the size of the custom SMI handler. |
VOID EFIAPI SmmCpuFeaturesInstallSmiHandler | ( | IN UINTN | CpuIndex, |
IN UINT32 | SmBase, | ||
IN VOID * | SmiStack, | ||
IN UINTN | StackSize, | ||
IN UINTN | GdtBase, | ||
IN UINTN | GdtSize, | ||
IN UINTN | IdtBase, | ||
IN UINTN | IdtSize, | ||
IN UINT32 | Cr3 | ||
) |
Install a custom SMI handler for the CPU specified by CpuIndex. This function is only called if SmmCpuFeaturesGetSmiHandlerSize() returns a size is greater than zero and is called by the CPU that was elected as monarch during System Management Mode initialization.
[in] | CpuIndex | The index of the CPU to install the custom SMI handler. The value must be between 0 and the NumberOfCpus field in the System Management System Table (SMST). |
[in] | SmBase | The SMBASE address for the CPU specified by CpuIndex. |
[in] | SmiStack | The stack to use when an SMI is processed by the the CPU specified by CpuIndex. |
[in] | StackSize | The size, in bytes, if the stack used when an SMI is processed by the CPU specified by CpuIndex. |
[in] | GdtBase | The base address of the GDT to use when an SMI is processed by the CPU specified by CpuIndex. |
[in] | GdtSize | The size, in bytes, of the GDT used when an SMI is processed by the CPU specified by CpuIndex. |
[in] | IdtBase | The base address of the IDT to use when an SMI is processed by the CPU specified by CpuIndex. |
[in] | IdtSize | The size, in bytes, of the IDT used when an SMI is processed by the CPU specified by CpuIndex. |
[in] | Cr3 | The base address of the page tables to use when an SMI is processed by the CPU specified by CpuIndex. |
EFI_STATUS EFIAPI SmmCpuFeaturesLibStmConstructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
The constructor function for the Traditional MM library instance with STM.
[in] | ImageHandle | The firmware allocated handle for the EFI image. |
[in] | SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The constructor always returns EFI_SUCCESS. |
EFI_STATUS EFIAPI SmmEndOfDxeEventNotify | ( | IN CONST EFI_GUID * | Protocol, |
IN VOID * | Interface, | ||
IN EFI_HANDLE | Handle | ||
) |
SMM End Of Dxe event notification handler.
STM support need patch AcpiRsdp in TXT_PROCESSOR_SMM_DESCRIPTOR.
[in] | Protocol | Points to the protocol's unique identifier. |
[in] | Interface | Points to the interface instance. |
[in] | Handle | The handle on which the interface was installed. |
EFI_SUCCESS | Notification handler runs successfully. |
VOID EFIAPI SmmStmSetup | ( | VOID | ) |
VOID EFIAPI SmmStmTeardown | ( | VOID | ) |
BOOLEAN StmCheckStmImage | ( | IN EFI_PHYSICAL_ADDRESS | StmImage, |
IN UINTN | StmImageSize | ||
) |
VOID StmLoadStmImage | ( | IN EFI_PHYSICAL_ADDRESS | StmImage, |
IN UINTN | StmImageSize | ||
) |
VOID StmSmmConfigurationTableInit | ( | VOID | ) |
GLOBAL_REMOVE_IF_UNREFERENCED STM_RSC_END mRscEndNode |
EFI_MP_SERVICES_PROTOCOL* mSmmCpuFeaturesLibMpService = NULL |
GLOBAL_REMOVE_IF_UNREFERENCED EFI_SM_MONITOR_INIT_PROTOCOL mSmMonitorInitProtocol |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceSizeAvailable = 0x0 |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceSizeUsed = 0x0 |
GLOBAL_REMOVE_IF_UNREFERENCED UINT8* mStmResourcesPtr = NULL |
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mStmResourceTotalSize = 0x0 |
EFI_HANDLE mStmSmmCpuHandle = NULL |
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mStmState = 0 |