TianoCore EDK2 master
Loading...
Searching...
No Matches
PiSmmCpuCommon.h File Reference
#include <PiSmm.h>
#include <Protocol/SmmConfiguration.h>
#include <Protocol/SmmCpu.h>
#include <Protocol/SmmReadyToLock.h>
#include <Protocol/SmmCpuService.h>
#include <Protocol/SmmMemoryAttribute.h>
#include <Protocol/MmMp.h>
#include <Protocol/SmmVariable.h>
#include <Guid/AcpiS3Context.h>
#include <Guid/MemoryAttributesTable.h>
#include <Guid/PiSmmMemoryAttributesTable.h>
#include <Guid/SmramMemoryReserve.h>
#include <Guid/SmmBaseHob.h>
#include <Guid/MpInformation2.h>
#include <Guid/MmProfileData.h>
#include <Guid/MmAcpiS3Enable.h>
#include <Guid/MmCpuSyncConfig.h>
#include <Library/BaseLib.h>
#include <Library/IoLib.h>
#include <Library/TimerLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/PcdLib.h>
#include <Library/MtrrLib.h>
#include <Library/SmmCpuPlatformHookLib.h>
#include <Library/MmServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/UefiLib.h>
#include <Library/HobLib.h>
#include <Library/LocalApicLib.h>
#include <Library/CpuLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/SmmCpuFeaturesLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/RegisterCpuFeaturesLib.h>
#include <Library/PerformanceLib.h>
#include <Library/CpuPageTableLib.h>
#include <Library/MmSaveStateLib.h>
#include <Library/SmmCpuSyncLib.h>
#include <AcpiCpuData.h>
#include <CpuHotPlugData.h>
#include <Register/Intel/Cpuid.h>
#include <Register/Intel/Msr.h>
#include "CpuService.h"
#include "SmmProfile.h"
#include "SmmMpPerf.h"

Go to the source code of this file.

Data Structures

union  MSR_IA32_CET
 
struct  PAGE_ATTRIBUTE_TABLE
 
struct  PROCEDURE_WRAPPER
 
struct  PROCEDURE_TOKEN
 
struct  TOKEN_BUFFER
 
struct  SMM_CPU_PRIVATE_DATA
 
struct  PAGE_TABLE_POOL
 
struct  SMM_CPU_DATA_BLOCK
 
struct  SMM_DISPATCHER_MP_SYNC_DATA
 
struct  SMM_CPU_SEMAPHORE_GLOBAL
 
struct  SMM_CPU_SEMAPHORE_CPU
 
struct  SMM_CPU_SEMAPHORES
 
struct  MM_CPU_MEMORY_REGION
 

Macros

#define CPUID_CET_SS   BIT7
 
#define CPUID_CET_IBT   BIT20
 
#define CR4_CET_ENABLE   BIT23
 
#define MSR_IA32_S_CET   0x6A2
 
#define MSR_IA32_PL0_SSP   0x6A4
 
#define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR   0x6A8
 
#define EFI_MSR_SMM_MCA_CAP   0x17D
 
#define SMM_CODE_ACCESS_CHK_BIT   BIT58
 
#define SMM_FEATURE_CONTROL_LOCK_BIT   BIT0
 
#define SMM_CODE_CHK_EN_BIT   BIT2
 
#define IA32_PG_P   BIT0
 
#define IA32_PG_RW   BIT1
 
#define IA32_PG_U   BIT2
 
#define IA32_PG_WT   BIT3
 
#define IA32_PG_CD   BIT4
 
#define IA32_PG_A   BIT5
 
#define IA32_PG_D   BIT6
 
#define IA32_PG_PS   BIT7
 
#define IA32_PG_PAT_2M   BIT12
 
#define IA32_PG_PAT_4K   IA32_PG_PS
 
#define IA32_PG_PMNT   BIT62
 
#define IA32_PG_NX   BIT63
 
#define PAGE_ATTRIBUTE_BITS   (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)
 
#define IA32_PAE_PDPTE_ATTRIBUTE_BITS   (IA32_PG_P)
 
#define PAGE_PROGATE_BITS   (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)
 
#define PAGING_4K_MASK   0xFFF
 
#define PAGING_2M_MASK   0x1FFFFF
 
#define PAGING_1G_MASK   0x3FFFFFFF
 
#define PAGING_PAE_INDEX_MASK   0x1FF
 
#define PAGING_4K_ADDRESS_MASK_64   0x000FFFFFFFFFF000ull
 
#define PAGING_2M_ADDRESS_MASK_64   0x000FFFFFFFE00000ull
 
#define PAGING_1G_ADDRESS_MASK_64   0x000FFFFFC0000000ull
 
#define SMRR_MAX_ADDRESS   BASE_4GB
 
#define TSS_SIZE   104
 
#define EXCEPTION_TSS_SIZE   (TSS_SIZE + 4)
 
#define TSS_X64_IST1_OFFSET   36
 
#define TSS_IA32_CR3_OFFSET   28
 
#define TSS_IA32_ESP_OFFSET   56
 
#define TSS_IA32_SSP_OFFSET   104
 
#define CR0_WP   BIT16
 
#define PROTECT_MODE_CODE_SEGMENT   0x08
 
#define LONG_MODE_CODE_SEGMENT   0x38
 
#define EXCEPTION_VECTOR_NUMBER   0x20
 
#define INVALID_APIC_ID   0xFFFFFFFFFFFFFFFFULL
 
#define PROCEDURE_TOKEN_SIGNATURE   SIGNATURE_32 ('P', 'R', 'T', 'S')
 
#define PROCEDURE_TOKEN_FROM_LINK(a)   CR (a, PROCEDURE_TOKEN, Link, PROCEDURE_TOKEN_SIGNATURE)
 
#define TOKEN_BUFFER_SIGNATURE   SIGNATURE_32 ('T', 'K', 'B', 'S')
 
#define TOKEN_BUFFER_FROM_LINK(a)   CR (a, TOKEN_BUFFER, Link, TOKEN_BUFFER_SIGNATURE)
 
#define SMM_CPU_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('s', 'c', 'p', 'u')
 
#define PAGE_TABLE_POOL_ALIGNMENT   BASE_128KB
 
#define PAGE_TABLE_POOL_UNIT_SIZE   BASE_128KB
 
#define PAGE_TABLE_POOL_UNIT_PAGES   EFI_SIZE_TO_PAGES (PAGE_TABLE_POOL_UNIT_SIZE)
 
#define PAGE_TABLE_POOL_ALIGN_MASK    (~(EFI_PHYSICAL_ADDRESS)(PAGE_TABLE_POOL_ALIGNMENT - 1))
 
#define SMM_PSD_OFFSET   0xfb00
 
#define WRITE_UNPROTECT_RO_PAGES(Wp, Cet)
 
#define WRITE_PROTECT_RO_PAGES(Wp, Cet)
 

Enumerations

enum  PAGE_ATTRIBUTE {
  PageNone , Page4K , Page2M , Page1G ,
  PageNone , Page4K , Page2M , Page1G
}
 

Functions

VOID EFIAPI DisableCet (VOID)
 
VOID EFIAPI EnableCet (VOID)
 
EFI_STATUS EFIAPI SmmReadSaveState (IN CONST EFI_SMM_CPU_PROTOCOL *This, IN UINTN Width, IN EFI_SMM_SAVE_STATE_REGISTER Register, IN UINTN CpuIndex, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI SmmWriteSaveState (IN CONST EFI_SMM_CPU_PROTOCOL *This, IN UINTN Width, IN EFI_SMM_SAVE_STATE_REGISTER Register, IN UINTN CpuIndex, IN CONST VOID *Buffer)
 
VOID InitializeSmm (VOID)
 
VOID ExecuteFirstSmiInit (VOID)
 
VOID EFIAPI SmmRelocationSemaphoreComplete (VOID)
 
UINT32 Gen4GPageTable (IN BOOLEAN Is32BitPageTable)
 
UINTN GenSmmPageTable (IN PAGING_MODE PagingMode, IN UINT8 PhysicalAddressBits)
 
UINT32 InitializeMpServiceData (IN VOID *Stacks, IN UINTN StackSize, IN UINTN ShadowStackSize)
 
VOID InitializeSmmTimer (VOID)
 
UINT64 EFIAPI StartSyncTimer (VOID)
 
BOOLEAN EFIAPI IsSyncTimerTimeout (IN UINT64 Timer, IN UINT64 Timeout)
 
VOID EFIAPI InitializeIDTSmmStackGuard (VOID)
 
VOID EFIAPI InitializeIdtIst (IN EFI_EXCEPTION_TYPE ExceptionType, IN UINT8 Ist)
 
VOID * InitGdt (IN UINTN Cr3, OUT UINTN *GdtStepSize)
 
EFI_STATUS EFIAPI RegisterSmmEntry (IN CONST EFI_SMM_CONFIGURATION_PROTOCOL *This, IN EFI_SMM_ENTRY_POINT SmmEntryPoint)
 
UINT32 SmmInitPageTable (VOID)
 
EFI_STATUS EFIAPI SmmStartupThisAp (IN EFI_AP_PROCEDURE Procedure, IN UINTN CpuIndex, IN OUT VOID *ProcArguments OPTIONAL)
 
EFI_STATUS EFIAPI SmmBlockingStartupThisAp (IN EFI_AP_PROCEDURE Procedure, IN UINTN CpuIndex, IN OUT VOID *ProcArguments OPTIONAL)
 
RETURN_STATUS ConvertMemoryPageAttributes (IN UINTN PageTableBase, IN PAGING_MODE PagingMode, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes, IN BOOLEAN IsSet, OUT BOOLEAN *IsModified OPTIONAL)
 
EFI_STATUS SmmSetMemoryAttributes (IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
EFI_STATUS SmmClearMemoryAttributes (IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI SmmGetSystemConfigurationTable (IN EFI_GUID *TableGuid, OUT VOID **Table)
 
VOID EFIAPI InitializeMpSyncData (VOID)
 
VOID FindSmramInfo (OUT UINT32 *SmrrBase, OUT UINT32 *SmrrSize)
 
VOID EFIAPI SmiPFHandler (IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext)
 
BOOLEAN IsSmmProfileEnabled (VOID)
 
VOID PerformRemainingTasks (VOID)
 
VOID PerformPreTasks (VOID)
 
VOID InitMsrSpinLockByIndex (IN UINT32 MsrIndex)
 
VOID EFIAPI ConfigSmmCodeAccessCheckOnCurrentProcessor (IN OUT VOID *Buffer)
 
VOID ConfigSmmCodeAccessCheck (VOID)
 
UINTN EFIAPI GetSmiHandlerSize (VOID)
 
VOID EFIAPI InstallSmiHandler (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)
 
VOID DumpModuleInfoByIp (IN UINTN CallerIpAddress)
 
VOID SetMemMapAttributes (EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable)
 
EFI_PHYSICAL_ADDRESS GetSmmProfileData (IN OUT UINT64 *Size)
 
BOOLEAN IsNonMmramLoggingAddress (IN UINT64 Address)
 
BOOLEAN IsSmmCommBufferForbiddenAddress (IN UINT64 Address)
 
VOID CreateExtendedProtectionRange (OUT MM_CPU_MEMORY_REGION **MemoryRegion, OUT UINTN *MemoryRegionCount)
 
VOID CreateNonMmramMemMap (IN UINT8 PhysicalAddressBits, OUT MM_CPU_MEMORY_REGION **MemoryRegion, OUT UINTN *MemoryRegionCount)
 
VOID UpdateUefiMemMapAttributes (VOID)
 
VOID GetUefiMemoryMap (VOID)
 
VOID SetPageTableAttributes (VOID)
 
EFI_STATUS SmmSetMemoryAttributesEx (IN UINTN PageTableBase, IN PAGING_MODE PagingMode, IN PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
EFI_STATUS SmmClearMemoryAttributesEx (IN UINTN PageTableBase, IN PAGING_MODE PagingMode, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
VOID * AllocatePageTableMemory (IN UINTN Pages)
 
VOID * AllocateCodePages (IN UINTN Pages)
 
VOID InitSmmS3ResumeState (VOID)
 
VOID RestoreSmmConfigurationInS3 (VOID)
 
VOID GetSmmCpuSyncConfigData (IN OUT BOOLEAN *RelaxedMode, OPTIONAL IN OUT UINT64 *SyncTimeout, OPTIONAL IN OUT UINT64 *SyncTimeout2 OPTIONAL)
 
VOID GetAcpiS3EnableFlag (VOID)
 
EFI_STATUS SetShadowStack (IN UINTN Cr3, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length)
 
VOID InitShadowStack (IN UINTN CpuIndex, IN VOID *ShadowStack)
 
EFI_STATUS EFIAPI EdkiiSmmSetMemoryAttributes (IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI EdkiiSmmClearMemoryAttributes (IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI EdkiiSmmGetMemoryAttributes (IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 *Attributes)
 
VOID EFIAPI PiSmmCpuSmiEntryFixupAddress ()
 
VOID SaveCr2 (OUT UINTN *Cr2)
 
VOID RestoreCr2 (IN UINTN Cr2)
 
EFI_STATUS InternalSmmStartupThisAp (IN EFI_AP_PROCEDURE2 Procedure, IN UINTN CpuIndex, IN OUT VOID *ProcArguments OPTIONAL, IN OUT MM_COMPLETION *Token, IN UINTN TimeoutInMicroseconds, IN OUT EFI_STATUS *CpuStatus)
 
BOOLEAN IsTokenInUse (IN SPIN_LOCK *Token)
 
EFI_STATUS IsApReady (IN SPIN_LOCK *Token)
 
BOOLEAN IsPresentAp (IN UINTN CpuIndex)
 
EFI_STATUS InternalSmmStartupAllAPs (IN EFI_AP_PROCEDURE2 Procedure, IN UINTN TimeoutInMicroseconds, IN OUT VOID *ProcedureArguments OPTIONAL, IN OUT MM_COMPLETION *Token, IN OUT EFI_STATUS *CPUStatus)
 
EFI_STATUS RegisterStartupProcedure (IN EFI_AP_PROCEDURE Procedure, IN OUT VOID *ProcedureArguments OPTIONAL)
 
VOID InitPackageFirstThreadIndexInfo (VOID)
 
VOID InitializeDataForMmMp (VOID)
 
BOOLEAN IsRestrictedMemoryAccess (VOID)
 
EFI_STATUS EFIAPI SmmCpuRendezvous (IN EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL *This, IN BOOLEAN BlockingMode)
 
VOID SmmWaitForApArrival (VOID)
 
VOID SmmWriteUnprotectReadOnlyPage (OUT BOOLEAN *WriteProtect)
 
VOID SmmWriteProtectReadOnlyPage (IN BOOLEAN WriteProtect)
 
UINTN GetSupportedMaxLogicalProcessorNumber (VOID)
 
EFI_PROCESSOR_INFORMATIONGetMpInformationFromMpServices (OUT UINTN *NumberOfCpus, OUT UINTN *MaxNumberOfCpus)
 
EFI_STATUS PiSmmCpuEntryCommon (VOID)
 

Variables

const BOOLEAN mIsStandaloneMm
 
SMM_CPU_PRIVATE_DATAgSmmCpuPrivate
 
CPU_HOT_PLUG_DATA mCpuHotPlugData
 
UINTN mMaxNumberOfCpus
 
UINTN mNumberOfCpus
 
EFI_SMM_CPU_PROTOCOL mSmmCpu
 
EFI_MM_MP_PROTOCOL mSmmMp
 
BOOLEAN m5LevelPagingNeeded
 
PAGING_MODE mPagingMode
 
UINTN mSmmShadowStackSize
 
UINT8 mSmmSaveStateRegisterLma
 
BOOLEAN mAcpiS3Enable
 
volatile BOOLEAN * mSmmInitialized
 
UINT32 mBspApicId
 
X86_ASSEMBLY_PATCH_LABEL mPatchCetSupported
 
BOOLEAN mCetSupported
 
IA32_DESCRIPTOR gcSmiGdtr
 
EFI_PHYSICAL_ADDRESS mGdtBuffer
 
UINTN mGdtBufferSize
 
IA32_DESCRIPTOR gcSmiIdtr
 
VOID * gcSmiIdtrPtr
 
UINT64 gPhyMask
 
SMM_DISPATCHER_MP_SYNC_DATAmSmmMpSyncData
 
UINTN mSmmStackArrayBase
 
UINTN mSmmStackArrayEnd
 
UINTN mSmmStackSize
 
EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService
 
SMM_CPU_SEMAPHORES mSmmCpuSemaphores
 
UINTN mSemaphoreSize
 
SPIN_LOCKmPFLock
 
SPIN_LOCKmConfigSmmCodeAccessCheckLock
 
EFI_SMRAM_DESCRIPTORmSmmCpuSmramRanges
 
UINTN mSmmCpuSmramRangeCount
 
UINT8 mPhysicalAddressBits
 
BOOLEAN mSmmDebugAgentSupport
 
BOOLEAN mSmmCodeAccessCheckEnable
 
UINT64 mAddressEncMask
 
UINT64 mTimeoutTicker
 
UINT64 mTimeoutTicker2
 
BOOLEAN mSmmS3Flag
 

Detailed Description

Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.

Copyright (c) 2009 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PiSmmCpuCommon.h.

Macro Definition Documentation

◆ CPUID_CET_IBT

#define CPUID_CET_IBT   BIT20

Definition at line 75 of file PiSmmCpuCommon.h.

◆ CPUID_CET_SS

#define CPUID_CET_SS   BIT7

Definition at line 74 of file PiSmmCpuCommon.h.

◆ CR0_WP

#define CR0_WP   BIT16

Definition at line 185 of file PiSmmCpuCommon.h.

◆ CR4_CET_ENABLE

#define CR4_CET_ENABLE   BIT23

Definition at line 77 of file PiSmmCpuCommon.h.

◆ EFI_MSR_SMM_MCA_CAP

#define EFI_MSR_SMM_MCA_CAP   0x17D

Definition at line 119 of file PiSmmCpuCommon.h.

◆ EXCEPTION_TSS_SIZE

#define EXCEPTION_TSS_SIZE   (TSS_SIZE + 4)

Definition at line 179 of file PiSmmCpuCommon.h.

◆ EXCEPTION_VECTOR_NUMBER

#define EXCEPTION_VECTOR_NUMBER   0x20

Definition at line 193 of file PiSmmCpuCommon.h.

◆ IA32_PAE_PDPTE_ATTRIBUTE_BITS

#define IA32_PAE_PDPTE_ATTRIBUTE_BITS   (IA32_PG_P)

Definition at line 146 of file PiSmmCpuCommon.h.

◆ IA32_PG_A

#define IA32_PG_A   BIT5

Definition at line 133 of file PiSmmCpuCommon.h.

◆ IA32_PG_CD

#define IA32_PG_CD   BIT4

Definition at line 132 of file PiSmmCpuCommon.h.

◆ IA32_PG_D

#define IA32_PG_D   BIT6

Definition at line 134 of file PiSmmCpuCommon.h.

◆ IA32_PG_NX

#define IA32_PG_NX   BIT63

Definition at line 139 of file PiSmmCpuCommon.h.

◆ IA32_PG_P

#define IA32_PG_P   BIT0

Page Table Entry

Definition at line 128 of file PiSmmCpuCommon.h.

◆ IA32_PG_PAT_2M

#define IA32_PG_PAT_2M   BIT12

Definition at line 136 of file PiSmmCpuCommon.h.

◆ IA32_PG_PAT_4K

#define IA32_PG_PAT_4K   IA32_PG_PS

Definition at line 137 of file PiSmmCpuCommon.h.

◆ IA32_PG_PMNT

#define IA32_PG_PMNT   BIT62

Definition at line 138 of file PiSmmCpuCommon.h.

◆ IA32_PG_PS

#define IA32_PG_PS   BIT7

Definition at line 135 of file PiSmmCpuCommon.h.

◆ IA32_PG_RW

#define IA32_PG_RW   BIT1

Definition at line 129 of file PiSmmCpuCommon.h.

◆ IA32_PG_U

#define IA32_PG_U   BIT2

Definition at line 130 of file PiSmmCpuCommon.h.

◆ IA32_PG_WT

#define IA32_PG_WT   BIT3

Definition at line 131 of file PiSmmCpuCommon.h.

◆ INVALID_APIC_ID

#define INVALID_APIC_ID   0xFFFFFFFFFFFFFFFFULL

Definition at line 195 of file PiSmmCpuCommon.h.

◆ LONG_MODE_CODE_SEGMENT

#define LONG_MODE_CODE_SEGMENT   0x38

Definition at line 191 of file PiSmmCpuCommon.h.

◆ MSR_IA32_INTERRUPT_SSP_TABLE_ADDR

#define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR   0x6A8

Definition at line 81 of file PiSmmCpuCommon.h.

◆ MSR_IA32_PL0_SSP

#define MSR_IA32_PL0_SSP   0x6A4

Definition at line 80 of file PiSmmCpuCommon.h.

◆ MSR_IA32_S_CET

#define MSR_IA32_S_CET   0x6A2

Definition at line 79 of file PiSmmCpuCommon.h.

◆ PAGE_ATTRIBUTE_BITS

#define PAGE_ATTRIBUTE_BITS   (IA32_PG_D | IA32_PG_A | IA32_PG_U | IA32_PG_RW | IA32_PG_P)

Definition at line 141 of file PiSmmCpuCommon.h.

◆ PAGE_PROGATE_BITS

#define PAGE_PROGATE_BITS   (IA32_PG_NX | PAGE_ATTRIBUTE_BITS)

Definition at line 148 of file PiSmmCpuCommon.h.

◆ PAGE_TABLE_POOL_ALIGN_MASK

#define PAGE_TABLE_POOL_ALIGN_MASK    (~(EFI_PHYSICAL_ADDRESS)(PAGE_TABLE_POOL_ALIGNMENT - 1))

Definition at line 278 of file PiSmmCpuCommon.h.

◆ PAGE_TABLE_POOL_ALIGNMENT

#define PAGE_TABLE_POOL_ALIGNMENT   BASE_128KB

Definition at line 275 of file PiSmmCpuCommon.h.

◆ PAGE_TABLE_POOL_UNIT_PAGES

#define PAGE_TABLE_POOL_UNIT_PAGES   EFI_SIZE_TO_PAGES (PAGE_TABLE_POOL_UNIT_SIZE)

Definition at line 277 of file PiSmmCpuCommon.h.

◆ PAGE_TABLE_POOL_UNIT_SIZE

#define PAGE_TABLE_POOL_UNIT_SIZE   BASE_128KB

Definition at line 276 of file PiSmmCpuCommon.h.

◆ PAGING_1G_ADDRESS_MASK_64

#define PAGING_1G_ADDRESS_MASK_64   0x000FFFFFC0000000ull

Definition at line 158 of file PiSmmCpuCommon.h.

◆ PAGING_1G_MASK

#define PAGING_1G_MASK   0x3FFFFFFF

Definition at line 152 of file PiSmmCpuCommon.h.

◆ PAGING_2M_ADDRESS_MASK_64

#define PAGING_2M_ADDRESS_MASK_64   0x000FFFFFFFE00000ull

Definition at line 157 of file PiSmmCpuCommon.h.

◆ PAGING_2M_MASK

#define PAGING_2M_MASK   0x1FFFFF

Definition at line 151 of file PiSmmCpuCommon.h.

◆ PAGING_4K_ADDRESS_MASK_64

#define PAGING_4K_ADDRESS_MASK_64   0x000FFFFFFFFFF000ull

Definition at line 156 of file PiSmmCpuCommon.h.

◆ PAGING_4K_MASK

#define PAGING_4K_MASK   0xFFF

Definition at line 150 of file PiSmmCpuCommon.h.

◆ PAGING_PAE_INDEX_MASK

#define PAGING_PAE_INDEX_MASK   0x1FF

Definition at line 154 of file PiSmmCpuCommon.h.

◆ PROCEDURE_TOKEN_FROM_LINK

#define PROCEDURE_TOKEN_FROM_LINK (   a)    CR (a, PROCEDURE_TOKEN, Link, PROCEDURE_TOKEN_SIGNATURE)

Definition at line 215 of file PiSmmCpuCommon.h.

◆ PROCEDURE_TOKEN_SIGNATURE

#define PROCEDURE_TOKEN_SIGNATURE   SIGNATURE_32 ('P', 'R', 'T', 'S')

Definition at line 205 of file PiSmmCpuCommon.h.

◆ PROTECT_MODE_CODE_SEGMENT

#define PROTECT_MODE_CODE_SEGMENT   0x08

Definition at line 190 of file PiSmmCpuCommon.h.

◆ SMM_CODE_ACCESS_CHK_BIT

#define SMM_CODE_ACCESS_CHK_BIT   BIT58

Definition at line 120 of file PiSmmCpuCommon.h.

◆ SMM_CODE_CHK_EN_BIT

#define SMM_CODE_CHK_EN_BIT   BIT2

Definition at line 123 of file PiSmmCpuCommon.h.

◆ SMM_CPU_PRIVATE_DATA_SIGNATURE

#define SMM_CPU_PRIVATE_DATA_SIGNATURE   SIGNATURE_32 ('s', 'c', 'p', 'u')

Definition at line 233 of file PiSmmCpuCommon.h.

◆ SMM_FEATURE_CONTROL_LOCK_BIT

#define SMM_FEATURE_CONTROL_LOCK_BIT   BIT0

Definition at line 122 of file PiSmmCpuCommon.h.

◆ SMM_PSD_OFFSET

#define SMM_PSD_OFFSET   0xfb00

Definition at line 420 of file PiSmmCpuCommon.h.

◆ SMRR_MAX_ADDRESS

#define SMRR_MAX_ADDRESS   BASE_4GB

Definition at line 160 of file PiSmmCpuCommon.h.

◆ TOKEN_BUFFER_FROM_LINK

#define TOKEN_BUFFER_FROM_LINK (   a)    CR (a, TOKEN_BUFFER, Link, TOKEN_BUFFER_SIGNATURE)

Definition at line 226 of file PiSmmCpuCommon.h.

◆ TOKEN_BUFFER_SIGNATURE

#define TOKEN_BUFFER_SIGNATURE   SIGNATURE_32 ('T', 'K', 'B', 'S')

Definition at line 217 of file PiSmmCpuCommon.h.

◆ TSS_IA32_CR3_OFFSET

#define TSS_IA32_CR3_OFFSET   28

Definition at line 181 of file PiSmmCpuCommon.h.

◆ TSS_IA32_ESP_OFFSET

#define TSS_IA32_ESP_OFFSET   56

Definition at line 182 of file PiSmmCpuCommon.h.

◆ TSS_IA32_SSP_OFFSET

#define TSS_IA32_SSP_OFFSET   104

Definition at line 183 of file PiSmmCpuCommon.h.

◆ TSS_SIZE

#define TSS_SIZE   104

Definition at line 178 of file PiSmmCpuCommon.h.

◆ TSS_X64_IST1_OFFSET

#define TSS_X64_IST1_OFFSET   36

Definition at line 180 of file PiSmmCpuCommon.h.

◆ WRITE_PROTECT_RO_PAGES

#define WRITE_PROTECT_RO_PAGES (   Wp,
  Cet 
)
Value:
do { \
SmmWriteProtectReadOnlyPage (Wp); \
if (Cet) { \
EnableCet (); \
} \
} while (FALSE)
#define FALSE
Definition: Base.h:307

Definition at line 1621 of file PiSmmCpuCommon.h.

◆ WRITE_UNPROTECT_RO_PAGES

#define WRITE_UNPROTECT_RO_PAGES (   Wp,
  Cet 
)
Value:
do { \
Cet = ((AsmReadCr4 () & CR4_CET_ENABLE) != 0); \
if (Cet) { \
DisableCet (); \
} \
SmmWriteUnprotectReadOnlyPage (&Wp); \
} while (FALSE)
UINTN EFIAPI AsmReadCr4(VOID)

Define macros to encapsulate the write unprotect/protect read-only pages. Below pieces of logic are defined as macros and not functions because "CET" feature disable & enable must be in the same function to avoid shadow stack and normal SMI stack mismatch, thus WRITE_UNPROTECT_RO_PAGES () must be called pair with WRITE_PROTECT_RO_PAGES () in same function.

Parameters
[in,out]WpA BOOLEAN variable local to the containing function, carrying write protection status from WRITE_UNPROTECT_RO_PAGES() to WRITE_PROTECT_RO_PAGES().
[in,out]CetA BOOLEAN variable local to the containing function, carrying control flow integrity enforcement status from WRITE_UNPROTECT_RO_PAGES() to WRITE_PROTECT_RO_PAGES().

Definition at line 1612 of file PiSmmCpuCommon.h.

Enumeration Type Documentation

◆ PAGE_ATTRIBUTE

enum PAGE_ATTRIBUTE

Definition at line 162 of file PiSmmCpuCommon.h.

Function Documentation

◆ AllocateCodePages()

VOID * AllocateCodePages ( IN UINTN  Pages)

Allocate pages for code.

Parameters
[in]PagesNumber of pages to be allocated.
Returns
Allocated memory.

Definition at line 28 of file PrePiLib.c.

◆ AllocatePageTableMemory()

VOID * AllocatePageTableMemory ( IN UINTN  Pages)

This API provides a way to allocate memory for page table.

This API can be called more once to allocate memory for page tables.

Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

This API provides a way to allocate memory for page table.

This API can be called more than once to allocate memory for page tables.

Allocates the number of 4KB pages and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary.

If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

This API provides a way to allocate memory for page table.

Parameters
PagesThe number of 4 KB pages to allocate.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

Definition at line 314 of file VirtualMemory.c.

◆ ConfigSmmCodeAccessCheck()

VOID ConfigSmmCodeAccessCheck ( VOID  )

Configure SMM Code Access Check feature for all processors. SMM Feature Control MSR will be locked after configuration.

Definition at line 1435 of file PiSmmCpuCommon.c.

◆ ConfigSmmCodeAccessCheckOnCurrentProcessor()

VOID EFIAPI ConfigSmmCodeAccessCheckOnCurrentProcessor ( IN OUT VOID *  Buffer)

Configure SMM Code Access Check feature on an AP. SMM Feature Control MSR will be locked after configuration.

Parameters
[in,out]BufferPointer to private data buffer.

Definition at line 1388 of file PiSmmCpuCommon.c.

◆ ConvertMemoryPageAttributes()

RETURN_STATUS ConvertMemoryPageAttributes ( IN UINTN  PageTableBase,
IN PAGING_MODE  PagingMode,
IN PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes,
IN BOOLEAN  IsSet,
OUT BOOLEAN *IsModified  OPTIONAL 
)

This function modifies the page attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Caller should make sure BaseAddress and Length is at page boundary.

Parameters
[in]PageTableBaseThe page table base.
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to modify for the memory region.
[in]IsSetTRUE means to set attributes. FALSE means to clear attributes.
[out]IsModifiedTRUE means page table modified. FALSE means page table not modified.
Return values
RETURN_SUCCESSThe attributes were modified for the memory region.
RETURN_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
RETURN_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
RETURN_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
RETURN_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

This function modifies the page attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Caller should make sure BaseAddress and Length is at page boundary.

Parameters
[in]PageTableBaseThe page table base.
[in]PagingModeThe paging mode.
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to modify for the memory region.
[in]IsSetTRUE means to set attributes. FALSE means to clear attributes.
[out]IsModifiedTRUE means page table modified. FALSE means page table not modified.
Return values
RETURN_SUCCESSThe attributes were modified for the memory region.
RETURN_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
RETURN_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
RETURN_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
RETURN_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

Definition at line 331 of file SmmCpuMemoryManagement.c.

◆ CreateExtendedProtectionRange()

VOID CreateExtendedProtectionRange ( OUT MM_CPU_MEMORY_REGION **  MemoryRegion,
OUT UINTN MemoryRegionCount 
)

Build extended protection MemoryRegion.

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Create extended protection MemoryRegion. Return all MMIO ranges that are reported in GCD service at EndOfDxe.

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Definition at line 609 of file NonMmramMapDxeSmm.c.

◆ CreateNonMmramMemMap()

VOID CreateNonMmramMemMap ( IN UINT8  PhysicalAddressBits,
OUT MM_CPU_MEMORY_REGION **  MemoryRegion,
OUT UINTN MemoryRegionCount 
)

Create the Non-Mmram Memory Region.

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[in]PhysicalAddressBitsThe bits of physical address to map.
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Create the Non-Mmram Memory Region. Build MemoryRegion to cover [0, 2^PhysicalAddressBits) by excluding all Smram range. The memory attribute is all-allowed (read/write/executable).

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[in]PhysicalAddressBitsThe bits of physical address to map.
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Create the Non-Mmram Memory Region within the ResourceDescriptor HOBs without Logging attribute.

The caller is responsible for freeing MemoryRegion via FreePool().

Parameters
[in]PhysicalAddressBitsThe bits of physical address to map.
[out]MemoryRegionReturned Non-Mmram Memory regions.
[out]MemoryRegionCountA pointer to the number of Memory regions.

Definition at line 689 of file NonMmramMapDxeSmm.c.

◆ DisableCet()

VOID EFIAPI DisableCet ( VOID  )

Disable CET.

◆ DumpModuleInfoByIp()

VOID DumpModuleInfoByIp ( IN UINTN  CallerIpAddress)

Search module name by input IP address and output it.

Parameters
CallerIpAddressCaller instruction pointer.

Definition at line 181 of file PiSmmCpuCommon.c.

◆ EdkiiSmmClearMemoryAttributes()

EFI_STATUS EFIAPI EdkiiSmmClearMemoryAttributes ( IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL This,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

This function clears given attributes of the memory region specified by BaseAddress and Length.

Parameters
ThisThe EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
BaseAddressThe physical address that is the start address of a memory region.
LengthThe size in bytes of the memory region.
AttributesThe bit mask of attributes to clear for the memory region.
Return values
EFI_SUCCESSThe attributes were cleared for the memory region.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be cleared together.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length.

Definition at line 1160 of file SmmCpuMemoryManagement.c.

◆ EdkiiSmmGetMemoryAttributes()

EFI_STATUS EFIAPI EdkiiSmmGetMemoryAttributes ( IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL This,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64 *  Attributes 
)

This function retrieves the attributes of the memory region specified by BaseAddress and Length. If different attributes are got from different part of the memory region, EFI_NO_MAPPING will be returned.

Parameters
ThisThe EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
BaseAddressThe physical address that is the start address of a memory region.
LengthThe size in bytes of the memory region.
AttributesPointer to attributes returned.
Return values
EFI_SUCCESSThe attributes got for the memory region.
EFI_INVALID_PARAMETERLength is zero. Attributes is NULL.
EFI_NO_MAPPINGAttributes are not consistent cross the memory region.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length.

◆ EdkiiSmmSetMemoryAttributes()

EFI_STATUS EFIAPI EdkiiSmmSetMemoryAttributes ( IN EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL This,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

This function set given attributes of the memory region specified by BaseAddress and Length.

Parameters
ThisThe EDKII_SMM_MEMORY_ATTRIBUTE_PROTOCOL instance.
BaseAddressThe physical address that is the start address of a memory region.
LengthThe size in bytes of the memory region.
AttributesThe bit mask of attributes to set for the memory region.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length.

Definition at line 1125 of file SmmCpuMemoryManagement.c.

◆ EnableCet()

VOID EFIAPI EnableCet ( VOID  )

Enable CET.

◆ ExecuteFirstSmiInit()

VOID ExecuteFirstSmiInit ( VOID  )

Issue SMI IPI (All Excluding Self SMM IPI + BSP SMM IPI) to execute first SMI init.

Definition at line 398 of file PiSmmCpuCommon.c.

◆ FindSmramInfo()

VOID FindSmramInfo ( OUT UINT32 *  SmrrBase,
OUT UINT32 *  SmrrSize 
)

Find out SMRAM information including SMRR base and SMRR size.

Parameters
SmrrBaseSMRR base
SmrrSizeSMRR size

Definition at line 1305 of file PiSmmCpuCommon.c.

◆ Gen4GPageTable()

UINT32 Gen4GPageTable ( IN BOOLEAN  Is32BitPageTable)

Create 4G PageTable in SMRAM.

Parameters
[in]Is32BitPageTableWhether the page table is 32-bit PAE
Returns
PageTable Address

◆ GenSmmPageTable()

UINTN GenSmmPageTable ( IN PAGING_MODE  PagingMode,
IN UINT8  PhysicalAddressBits 
)

Create page table based on input PagingMode and PhysicalAddressBits in smm.

Parameters
[in]PagingModeThe paging mode.
[in]PhysicalAddressBitsThe bits of physical address to map.
Return values
PageTableAddress

Definition at line 1238 of file SmmCpuMemoryManagement.c.

◆ GetAcpiS3EnableFlag()

VOID GetAcpiS3EnableFlag ( VOID  )

Get ACPI S3 enable flag.

Definition at line 230 of file PiSmmCpuDxeSmm.c.

◆ GetMpInformationFromMpServices()

EFI_PROCESSOR_INFORMATION * GetMpInformationFromMpServices ( OUT UINTN NumberOfCpus,
OUT UINTN MaxNumberOfCpus 
)

Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION for all CPU from gEfiMpServiceProtocolGuid.

Parameters
[out]NumberOfCpusPointer to NumberOfCpus.
[out]MaxNumberOfCpusPointer to MaxNumberOfCpus.
Return values
ProcessorInfoPointer to EFI_PROCESSOR_INFORMATION buffer.

Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION.

Parameters
[out]NumberOfCpusPointer to NumberOfCpus.
[out]MaxNumberOfCpusPointer to MaxNumberOfCpus.
Return values
ProcessorInfoPointer to EFI_PROCESSOR_INFORMATION buffer.

Get the MP Services Protocol

Get the number of processors

Allocate buffer for processor information

Get processor information

Definition at line 260 of file PiSmmCpuDxeSmm.c.

◆ GetSmiHandlerSize()

UINTN EFIAPI GetSmiHandlerSize ( VOID  )

Get the size of the SMI Handler in bytes.

Return values
Thesize, in bytes, of the SMI Handler.

Definition at line 80 of file SmramSaveState.c.

◆ GetSmmCpuSyncConfigData()

VOID GetSmmCpuSyncConfigData ( IN OUT BOOLEAN *  RelaxedMode,
OPTIONAL IN OUT UINT64 *  SyncTimeout,
OPTIONAL IN OUT UINT64 *SyncTimeout2  OPTIONAL 
)

Get SmmCpuSyncConfig data: RelaxedMode, SyncTimeout, SyncTimeout2.

Parameters
[in,out]RelaxedModeIt indicates if Relaxed CPU synchronization method or traditional CPU synchronization method is used when processing an SMI.
[in,out]SyncTimeoutIt indicates the 1st BSP/AP synchronization timeout value in SMM.
[in,out]SyncTimeout2It indicates the 2nd BSP/AP synchronization timeout value in SMM.

Definition at line 206 of file PiSmmCpuDxeSmm.c.

◆ GetSmmProfileData()

EFI_PHYSICAL_ADDRESS GetSmmProfileData ( IN OUT UINT64 *  Size)

Get SmmProfileData.

Parameters
[in,out]SizeReturn Size of SmmProfileData.
Returns
Address of SmmProfileData

Get SmmProfileData.

Parameters
[in,out]SizeReturn Size of SmmProfileData. 0 means the gMmProfileDataHobGuid does not exist.
Returns
Address of SmmProfileData

Definition at line 489 of file NonMmramMapDxeSmm.c.

◆ GetSupportedMaxLogicalProcessorNumber()

UINTN GetSupportedMaxLogicalProcessorNumber ( VOID  )

Get the maximum number of logical processors supported by the system.

Return values
Themaximum number of logical processors supported by the system is indicated by the return value.

Definition at line 244 of file PiSmmCpuDxeSmm.c.

◆ GetUefiMemoryMap()

VOID GetUefiMemoryMap ( VOID  )

This function caches the UEFI memory map information.

Definition at line 246 of file NonMmramMapDxeSmm.c.

◆ InitGdt()

VOID * InitGdt ( IN UINTN  Cr3,
OUT UINTN GdtStepSize 
)

Initialize Gdt for all processors.

Parameters
[in]Cr3CR3 value.
[out]GdtStepSizeThe step size for GDT table.
Returns
GdtBase for processor 0. GdtBase for processor X is: GdtBase + (GdtStepSize * X)

Definition at line 55 of file SmmFuncsArch.c.

◆ InitializeDataForMmMp()

VOID InitializeDataForMmMp ( VOID  )

Allocate buffer for SpinLock and Wrapper function buffer.

Definition at line 1791 of file MpService.c.

◆ InitializeIdtIst()

VOID EFIAPI InitializeIdtIst ( IN EFI_EXCEPTION_TYPE  ExceptionType,
IN UINT8  Ist 
)

Initialize IDT IST Field.

Parameters
[in]ExceptionTypeException type.
[in]IstIST value.

Definition at line 34 of file SmmFuncsArch.c.

◆ InitializeIDTSmmStackGuard()

VOID EFIAPI InitializeIDTSmmStackGuard ( VOID  )

Initialize IDT for SMM Stack Guard.

Definition at line 29 of file SmmFuncsArch.c.

◆ InitializeMpServiceData()

UINT32 InitializeMpServiceData ( IN VOID *  Stacks,
IN UINTN  StackSize,
IN UINTN  ShadowStackSize 
)

Initialize global data for MP synchronization.

Parameters
StacksBase address of SMI stack buffer for all processors.
StackSizeStack size for each processor in SMM.
ShadowStackSizeShadow Stack size for each processor in SMM.

Definition at line 1940 of file MpService.c.

◆ InitializeMpSyncData()

VOID EFIAPI InitializeMpSyncData ( VOID  )

Initialize MP synchronization data.

Initialize un-cacheable data.

Definition at line 1865 of file MpService.c.

◆ InitializeSmm()

VOID InitializeSmm ( VOID  )

Initialize SMM environment.

Definition at line 327 of file PiSmmCpuCommon.c.

◆ InitializeSmmTimer()

VOID InitializeSmmTimer ( VOID  )

Initialize Timer for SMM AP Sync.

Definition at line 29 of file SyncTimer.c.

◆ InitMsrSpinLockByIndex()

VOID InitMsrSpinLockByIndex ( IN UINT32  MsrIndex)

Initialize MSR spin lock by MSR index.

Parameters
MsrIndexMSR index value.

◆ InitPackageFirstThreadIndexInfo()

VOID InitPackageFirstThreadIndexInfo ( VOID  )

Initialize PackageBsp Info. Processor specified by mPackageFirstThreadIndex[PackageIndex] will do the package-scope register programming. Set default CpuIndex to (UINT32)-1, which means not specified yet.

Definition at line 1752 of file MpService.c.

◆ InitShadowStack()

VOID InitShadowStack ( IN UINTN  CpuIndex,
IN VOID *  ShadowStack 
)

Initialize the shadow stack related data structure.

Parameters
CpuIndexThe index of CPU.
ShadowStackThe bottom of the shadow stack for this CPU.

Definition at line 151 of file SmmFuncsArch.c.

◆ InitSmmS3ResumeState()

VOID InitSmmS3ResumeState ( VOID  )

Initialize SMM S3 resume state structure used during S3 Resume.

Definition at line 192 of file CpuS3.c.

◆ InstallSmiHandler()

VOID EFIAPI InstallSmiHandler ( 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 the SMI handler for the CPU specified by CpuIndex. This function is called by the CPU that was elected as monarch during System Management Mode initialization.

Parameters
[in]CpuIndexThe 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]SmBaseThe SMBASE address for the CPU specified by CpuIndex.
[in]SmiStackThe stack to use when an SMI is processed by the the CPU specified by CpuIndex.
[in]StackSizeThe size, in bytes, if the stack used when an SMI is processed by the CPU specified by CpuIndex.
[in]GdtBaseThe base address of the GDT to use when an SMI is processed by the CPU specified by CpuIndex.
[in]GdtSizeThe size, in bytes, of the GDT used when an SMI is processed by the CPU specified by CpuIndex.
[in]IdtBaseThe base address of the IDT to use when an SMI is processed by the CPU specified by CpuIndex.
[in]IdtSizeThe size, in bytes, of the IDT used when an SMI is processed by the CPU specified by CpuIndex.
[in]Cr3The base address of the page tables to use when an SMI is processed by the CPU specified by CpuIndex.

Definition at line 120 of file SmramSaveState.c.

◆ InternalSmmStartupAllAPs()

EFI_STATUS InternalSmmStartupAllAPs ( IN EFI_AP_PROCEDURE2  Procedure,
IN UINTN  TimeoutInMicroseconds,
IN OUT VOID *ProcedureArguments  OPTIONAL,
IN OUT MM_COMPLETION *  Token,
IN OUT EFI_STATUS CPUStatus 
)

Worker function to execute a caller provided function on all enabled APs.

Parameters
[in]ProcedureA pointer to the function to be run on enabled APs of the system.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for APs to return from Procedure, either for blocking or non-blocking mode.
[in,out]ProcedureArgumentsThe parameter passed into Procedure for all APs.
[in,out]TokenThis is an optional parameter that allows the caller to execute the procedure in a blocking or non-blocking fashion. If it is NULL the call is blocking, and the call will not return until the AP has completed the procedure. If the token is not NULL, the call will return immediately. The caller can check whether the procedure has completed with CheckOnProcedure or WaitForProcedure.
[in,out]CPUStatusThis optional pointer may be used to get the status code returned by Procedure when it completes execution on the target AP, or with EFI_TIMEOUT if the Procedure fails to complete within the optional timeout. The implementation will update this variable with EFI_NOT_READY prior to starting Procedure on the target AP.
Return values
EFI_SUCCESSIn blocking mode, all APs have finished before the timeout expired.
EFI_SUCCESSIn non-blocking mode, function has been dispatched to all enabled APs.
othersFailed to Startup all APs.

Definition at line 1252 of file MpService.c.

◆ InternalSmmStartupThisAp()

EFI_STATUS InternalSmmStartupThisAp ( IN EFI_AP_PROCEDURE2  Procedure,
IN UINTN  CpuIndex,
IN OUT VOID *ProcArguments  OPTIONAL,
IN OUT MM_COMPLETION *  Token,
IN UINTN  TimeoutInMicroseconds,
IN OUT EFI_STATUS CpuStatus 
)

Schedule a procedure to run on the specified CPU.

Parameters
[in]ProcedureThe address of the procedure to run
[in]CpuIndexTarget CPU Index
[in,out]ProcArgumentsThe parameter to pass to the procedure
[in,out]TokenThis is an optional parameter that allows the caller to execute the procedure in a blocking or non-blocking fashion. If it is NULL the call is blocking, and the call will not return until the AP has completed the procedure. If the token is not NULL, the call will return immediately. The caller can check whether the procedure has completed with CheckOnProcedure or WaitForProcedure.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for the APs to finish execution of Procedure, either for blocking or non-blocking mode. Zero means infinity. If the timeout expires before all APs return from Procedure, then Procedure on the failed APs is terminated. If the timeout expires in blocking mode, the call returns EFI_TIMEOUT. If the timeout expires in non-blocking mode, the timeout determined can be through CheckOnProcedure or WaitForProcedure. Note that timeout support is optional. Whether an implementation supports this feature can be determined via the Attributes data member.
[in,out]CpuStatusThis optional pointer may be used to get the status code returned by Procedure when it completes execution on the target AP, or with EFI_TIMEOUT if the Procedure fails to complete within the optional timeout. The implementation will update this variable with EFI_NOT_READY prior to starting Procedure on the target AP.
Return values
EFI_INVALID_PARAMETERCpuNumber not valid
EFI_INVALID_PARAMETERCpuNumber specifying BSP
EFI_INVALID_PARAMETERThe AP specified by CpuNumber did not enter SMM
EFI_INVALID_PARAMETERThe AP specified by CpuNumber is busy
EFI_SUCCESSThe procedure has been successfully scheduled

◆ IsApReady()

EFI_STATUS IsApReady ( IN SPIN_LOCK Token)

Checks status of specified AP.

This function checks whether the specified AP has finished the task assigned by StartupThisAP(), and whether timeout expires.

Parameters
[in]TokenThis parameter describes the token that was passed into DispatchProcedure or BroadcastProcedure.
Return values
EFI_SUCCESSSpecified AP has finished task assigned by StartupThisAPs().
EFI_NOT_READYSpecified AP has not finished task and timeout has not expired.

Definition at line 1082 of file MpService.c.

◆ IsNonMmramLoggingAddress()

BOOLEAN IsNonMmramLoggingAddress ( IN UINT64  Address)

Return if the Address is the NonMmram logging Address.

Parameters
[in]Addressthe address to be checked
Returns
TRUE The address is the NonMmram logging Address.
FALSE The address is not the NonMmram logging Address.

Definition at line 522 of file NonMmramMapDxeSmm.c.

◆ IsPresentAp()

BOOLEAN IsPresentAp ( IN UINTN  CpuIndex)

Check whether it is an present AP.

Parameters
CpuIndexThe AP index which calls this function.
Return values
TRUEIt's a present AP.
TRUEThis is not an AP or it is not present.

Definition at line 403 of file MpService.c.

◆ IsRestrictedMemoryAccess()

BOOLEAN IsRestrictedMemoryAccess ( VOID  )

Return whether access to non-SMRAM is restricted.

Return values
TRUEAccess to non-SMRAM is restricted.
FALSEAccess to non-SMRAM is not restricted.

Definition at line 17 of file SmmFuncsArchDxeSmm.c.

◆ IsSmmCommBufferForbiddenAddress()

BOOLEAN IsSmmCommBufferForbiddenAddress ( IN UINT64  Address)

Return if the Address is forbidden as SMM communication buffer.

Parameters
[in]Addressthe address to be checked
Returns
TRUE The address is forbidden as SMM communication buffer.
FALSE The address is allowed as SMM communication buffer.

Definition at line 540 of file NonMmramMapDxeSmm.c.

◆ IsSmmProfileEnabled()

BOOLEAN IsSmmProfileEnabled ( VOID  )

Check SmmProfile is enabled or not.

Returns
TRUE SmmProfile is enabled. FALSE SmmProfile is not enabled.

Definition at line 34 of file PiSmmCpuDxeSmm.c.

◆ IsSyncTimerTimeout()

BOOLEAN EFIAPI IsSyncTimerTimeout ( IN UINT64  Timer,
IN UINT64  Timeout 
)

Check if the SMM AP Sync Timer is timeout specified by Timeout.

Parameters
TimerThe start timer from the begin.
TimeoutThe timeout ticker to wait.

Definition at line 83 of file SyncTimer.c.

◆ IsTokenInUse()

BOOLEAN IsTokenInUse ( IN SPIN_LOCK Token)

Checks whether the input token is the current used token.

Parameters
[in]TokenThis parameter describes the token that was passed into DispatchProcedure or BroadcastProcedure.
Return values
TRUEThe input token is the current used token.
FALSEThe input token is not the current used token.

Definition at line 949 of file MpService.c.

◆ PerformPreTasks()

VOID PerformPreTasks ( VOID  )

Perform the pre tasks.

Definition at line 1533 of file PiSmmCpuCommon.c.

◆ PerformRemainingTasks()

VOID PerformRemainingTasks ( VOID  )

Perform the remaining tasks.

Definition at line 46 of file PiSmmCpuDxeSmm.c.

◆ PiSmmCpuEntryCommon()

EFI_STATUS PiSmmCpuEntryCommon ( VOID  )

The common Entry Point of the SMM CPU driver.

Return values
EFI_SUCCESSThe common entry point is executed successfully.
OtherSome error occurs when executing this entry point.

The module Entry Point of the CPU SMM driver.

Return values
EFI_SUCCESSThe common entry point is executed successfully.
OtherSome error occurs when executing this entry point.

Definition at line 740 of file PiSmmCpuCommon.c.

◆ PiSmmCpuSmiEntryFixupAddress()

VOID EFIAPI PiSmmCpuSmiEntryFixupAddress ( )

This function fixes up the address of the global variable or function referred in SmiEntry assembly files to be the absolute address.

◆ RegisterSmmEntry()

EFI_STATUS EFIAPI RegisterSmmEntry ( IN CONST EFI_SMM_CONFIGURATION_PROTOCOL This,
IN EFI_SMM_ENTRY_POINT  SmmEntryPoint 
)

Register the SMM Foundation entry point.

Parameters
ThisPointer to EFI_SMM_CONFIGURATION_PROTOCOL instance
SmmEntryPointSMM Foundation EntryPoint
Return values
EFI_SUCCESSSuccessfully to register SMM foundation entry point

Definition at line 2041 of file MpService.c.

◆ RegisterStartupProcedure()

EFI_STATUS RegisterStartupProcedure ( IN EFI_AP_PROCEDURE  Procedure,
IN OUT VOID *ProcedureArguments  OPTIONAL 
)

Register the SMM Foundation entry point.

Parameters
[in]ProcedureA pointer to the code stream to be run on the designated target AP of the system. Type EFI_AP_PROCEDURE is defined below in Volume 2 with the related definitions of EFI_MP_SERVICES_PROTOCOL.StartupAllAPs. If caller may pass a value of NULL to deregister any existing startup procedure.
[in,out]ProcedureArgumentsAllows the caller to pass a list of parameters to the code that is run by the AP. It is an optional common mailbox between APs and the caller to share information
Return values
EFI_SUCCESSThe Procedure has been set successfully.
EFI_INVALID_PARAMETERThe Procedure is NULL but ProcedureArguments not NULL.

Definition at line 2072 of file MpService.c.

◆ RestoreCr2()

VOID RestoreCr2 ( IN UINTN  Cr2)

This function writes into CR2 register when on-demand paging is enabled for 64 bit and no action for 32 bit.

Parameters
[in]Cr2Value to write into CR2 register.

This function returns with no action for 32 bit.

Parameters
[in]Cr2Value to write into CR2 register.

This function restores CR2 register.

Parameters
[in]Cr2Value to write into CR2 register.

Definition at line 226 of file PageTbl.c.

◆ RestoreSmmConfigurationInS3()

VOID RestoreSmmConfigurationInS3 ( VOID  )

Restore SMM Configuration in S3 boot path.

Definition at line 31 of file CpuS3.c.

◆ SaveCr2()

VOID SaveCr2 ( OUT UINTN Cr2)

This function reads CR2 register when on-demand paging is enabled for 64 bit and no action for 32 bit.

Parameters
[out]*Cr2Pointer to variable to hold CR2 register value.

This function returns with no action for 32 bit.

Parameters
[out]*Cr2Pointer to variable to hold CR2 register value.

This function reads CR2 register.

Parameters
[out]*Cr2Pointer to variable to hold CR2 register value.

Definition at line 213 of file PageTbl.c.

◆ SetMemMapAttributes()

VOID SetMemMapAttributes ( EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE MemoryAttributesTable)

This function sets memory attribute according to MemoryAttributesTable.

Parameters
MemoryAttributesTableA pointer to the buffer of SmmMemoryAttributesTable.

Definition at line 1001 of file SmmCpuMemoryManagement.c.

◆ SetPageTableAttributes()

VOID SetPageTableAttributes ( VOID  )

This function sets memory attribute for page table.

Definition at line 1507 of file SmmCpuMemoryManagement.c.

◆ SetShadowStack()

EFI_STATUS SetShadowStack ( IN UINTN  Cr3,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length 
)

Set ShadowStack memory.

Parameters
[in]Cr3The page table base address.
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
Return values
EFI_SUCCESSThe shadow stack memory is set.

Definition at line 719 of file SmmCpuMemoryManagement.c.

◆ SmiPFHandler()

VOID EFIAPI SmiPFHandler ( IN EFI_EXCEPTION_TYPE  InterruptType,
IN EFI_SYSTEM_CONTEXT  SystemContext 
)

Page Fault handler for SMM use.

Parameters
InterruptTypeDefines the type of interrupt or exception that occurred on the processor.This parameter is processor architecture specific.
SystemContextA pointer to the processor context when the interrupt occurred on the processor.

ThePage Fault handler wrapper for SMM use.

Parameters
InterruptTypeDefines the type of interrupt or exception that occurred on the processor.This parameter is processor architecture specific.
SystemContextA pointer to the processor context when the interrupt occurred on the processor.

Definition at line 95 of file PageTbl.c.

◆ SmmBlockingStartupThisAp()

EFI_STATUS EFIAPI SmmBlockingStartupThisAp ( IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  CpuIndex,
IN OUT VOID *ProcArguments  OPTIONAL 
)

Schedule a procedure to run on the specified CPU in a blocking fashion.

Parameters
ProcedureThe address of the procedure to run
CpuIndexTarget CPU Index
ProcArgumentsThe parameter to pass to the procedure
Return values
EFI_INVALID_PARAMETERCpuNumber not valid
EFI_INVALID_PARAMETERCpuNumber specifying BSP
EFI_INVALID_PARAMETERThe AP specified by CpuNumber did not enter SMM
EFI_INVALID_PARAMETERThe AP specified by CpuNumber is busy
EFI_SUCCESSThe procedure has been successfully scheduled

Schedule a procedure to run on the specified CPU in blocking mode.

Parameters
[in]ProcedureThe address of the procedure to run
[in]CpuIndexTarget CPU Index
[in,out]ProcArgumentsThe parameter to pass to the procedure
Return values
EFI_INVALID_PARAMETERCpuNumber not valid
EFI_INVALID_PARAMETERCpuNumber specifying BSP
EFI_INVALID_PARAMETERThe AP specified by CpuNumber did not enter SMM
EFI_INVALID_PARAMETERThe AP specified by CpuNumber is busy
EFI_SUCCESSThe procedure has been successfully scheduled

Definition at line 1401 of file MpService.c.

◆ SmmClearMemoryAttributes()

EFI_STATUS SmmClearMemoryAttributes ( IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

This function clears the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to clear for the memory region.
Return values
EFI_SUCCESSThe attributes were cleared for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

This function clears the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to clear for the memory region.
Return values
EFI_SUCCESSThe attributes were cleared for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be cleared together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length.

Definition at line 697 of file SmmCpuMemoryManagement.c.

◆ SmmClearMemoryAttributesEx()

EFI_STATUS SmmClearMemoryAttributesEx ( IN UINTN  PageTableBase,
IN PAGING_MODE  PagingMode,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

This function clears the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
[in]PageTableBaseThe page table base.
[in]PagingModeThe paging mode.
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to clear for the memory region.
Return values
EFI_SUCCESSThe attributes were cleared for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be cleared together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length.

Definition at line 615 of file SmmCpuMemoryManagement.c.

◆ SmmCpuRendezvous()

EFI_STATUS EFIAPI SmmCpuRendezvous ( IN EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL This,
IN BOOLEAN  BlockingMode 
)

Choose blocking or non-blocking mode to Wait for all APs.

Parameters
[in]ThisA pointer to the EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL instance.
[in]BlockingModeBlocking or non-blocking mode.
Return values
EFI_SUCCESSAll APs have arrived SMM mode except SMI disabled APs.
EFI_TIMEOUTThere are APs not in SMM mode in given timeout constraint.

Wait for all processors enterring SMM until all CPUs are already synchronized or not.

If BlockingMode is False, timeout value is zero.

Parameters
ThisA pointer to the EDKII_SMM_CPU_RENDEZVOUS_PROTOCOL instance.
BlockingModeBlocking mode or non-blocking mode.
Return values
EFI_SUCCESSAll avaiable APs arrived.
EFI_TIMEOUTWait for all APs until timeout.

Definition at line 414 of file CpuService.c.

◆ SmmGetSystemConfigurationTable()

EFI_STATUS EFIAPI SmmGetSystemConfigurationTable ( IN EFI_GUID TableGuid,
OUT VOID **  Table 
)

Retrieves a pointer to the system configuration table from the SMM System Table based on a specified GUID.

Parameters
[in]TableGuidThe pointer to table's GUID type.
[out]TableThe pointer to the table associated with TableGuid in the EFI System Table.
Return values
EFI_SUCCESSA configuration table matching TableGuid was found.
EFI_NOT_FOUNDA configuration table matching TableGuid could not be found.

Definition at line 747 of file SmmCpuMemoryManagement.c.

◆ SmmInitPageTable()

UINT32 SmmInitPageTable ( VOID  )

Create PageTable for SMM use.

Returns
PageTable Address

Create PageTable for SMM use.

Returns
The address of PML4 (to set CR3). Zero if any error occurs.

Definition at line 20 of file PageTbl.c.

◆ SmmReadSaveState()

EFI_STATUS EFIAPI SmmReadSaveState ( IN CONST EFI_SMM_CPU_PROTOCOL This,
IN UINTN  Width,
IN EFI_SMM_SAVE_STATE_REGISTER  Register,
IN UINTN  CpuIndex,
OUT VOID *  Buffer 
)

Read information from the CPU save state.

Parameters
ThisEFI_SMM_CPU_PROTOCOL instance
WidthThe number of bytes to read from the CPU save state.
RegisterSpecifies the CPU register to read form the save state.
CpuIndexSpecifies the zero-based index of the CPU save state
BufferUpon return, this holds the CPU register value read from the save state.
Return values
EFI_SUCCESSThe register was read from Save State
EFI_NOT_FOUNDThe register is not defined for the Save State of Processor
EFI_INVALID_PARAMETERThis or Buffer is NULL.

Read information from the CPU save state.

Parameters
ThisEFI_SMM_CPU_PROTOCOL instance
WidthThe number of bytes to read from the CPU save state.
RegisterSpecifies the CPU register to read form the save state.
CpuIndexSpecifies the zero-based index of the CPU save state.
BufferUpon return, this holds the CPU register value read from the save state.
Return values
EFI_SUCCESSThe register was read from Save State
EFI_NOT_FOUNDThe register is not defined for the Save State of Processor
EFI_INVALID_PARAMETERThis or Buffer is NULL.

Definition at line 217 of file PiSmmCpuCommon.c.

◆ SmmRelocationSemaphoreComplete()

VOID EFIAPI SmmRelocationSemaphoreComplete ( VOID  )

Semaphore operation for all processor relocate SMMBase.

◆ SmmSetMemoryAttributes()

EFI_STATUS SmmSetMemoryAttributes ( IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

This function sets the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to set for the memory region.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

This function sets the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to set for the memory region.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not supported for the memory resource range specified by BaseAddress and Length.

Definition at line 662 of file SmmCpuMemoryManagement.c.

◆ SmmSetMemoryAttributesEx()

EFI_STATUS SmmSetMemoryAttributesEx ( IN UINTN  PageTableBase,
IN PAGING_MODE  PagingMode,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

This function sets the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
[in]PageTableBaseThe page table base.
[in]PagingModeThe paging mode.
[in]BaseAddressThe physical address that is the start address of a memory region.
[in]LengthThe size in bytes of the memory region.
[in]AttributesThe bit mask of attributes to set for the memory region.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

Definition at line 566 of file SmmCpuMemoryManagement.c.

◆ SmmStartupThisAp()

EFI_STATUS EFIAPI SmmStartupThisAp ( IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  CpuIndex,
IN OUT VOID *ProcArguments  OPTIONAL 
)

Schedule a procedure to run on the specified CPU.

Parameters
ProcedureThe address of the procedure to run
CpuIndexTarget CPU number
ProcArgumentsThe parameter to pass to the procedure
Return values
EFI_INVALID_PARAMETERCpuNumber not valid
EFI_INVALID_PARAMETERCpuNumber specifying BSP
EFI_INVALID_PARAMETERThe AP specified by CpuNumber did not enter SMM
EFI_INVALID_PARAMETERThe AP specified by CpuNumber is busy
EFI_SUCCESS- The procedure has been successfully scheduled

Schedule a procedure to run on the specified CPU.

Parameters
ProcedureThe address of the procedure to run
CpuIndexTarget CPU Index
ProcArgumentsThe parameter to pass to the procedure
Return values
EFI_INVALID_PARAMETERCpuNumber not valid
EFI_INVALID_PARAMETERCpuNumber specifying BSP
EFI_INVALID_PARAMETERThe AP specified by CpuNumber did not enter SMM
EFI_INVALID_PARAMETERThe AP specified by CpuNumber is busy
EFI_SUCCESSThe procedure has been successfully scheduled

Definition at line 1434 of file MpService.c.

◆ SmmWaitForApArrival()

VOID SmmWaitForApArrival ( VOID  )

Insure when this function returns, no AP will execute normal mode code before entering SMM, except SMI disabled APs.

Given timeout constraint, wait for all APs to arrive, and insure when this function returns, no AP will execute normal mode code before entering SMM, except SMI disabled APs.

Definition at line 231 of file MpService.c.

◆ SmmWriteProtectReadOnlyPage()

VOID SmmWriteProtectReadOnlyPage ( IN BOOLEAN  WriteProtect)

Write protect read-only pages.

Parameters
[in]WriteProtectIf Cr0.Bits.WP should be enabled.

Definition at line 52 of file SmmCpuMemoryManagement.c.

◆ SmmWriteSaveState()

EFI_STATUS EFIAPI SmmWriteSaveState ( IN CONST EFI_SMM_CPU_PROTOCOL This,
IN UINTN  Width,
IN EFI_SMM_SAVE_STATE_REGISTER  Register,
IN UINTN  CpuIndex,
IN CONST VOID *  Buffer 
)

Write data to the CPU save state.

Parameters
ThisEFI_SMM_CPU_PROTOCOL instance
WidthThe number of bytes to read from the CPU save state.
RegisterSpecifies the CPU register to write to the save state.
CpuIndexSpecifies the zero-based index of the CPU save state
BufferUpon entry, this holds the new CPU register value.
Return values
EFI_SUCCESSThe register was written from Save State
EFI_NOT_FOUNDThe register is not defined for the Save State of Processor
EFI_INVALID_PARAMETERProcessorIndex or Width is not correct

Definition at line 289 of file PiSmmCpuCommon.c.

◆ SmmWriteUnprotectReadOnlyPage()

VOID SmmWriteUnprotectReadOnlyPage ( OUT BOOLEAN *  WriteProtect)

Write unprotect read-only pages if Cr0.Bits.WP is 1.

Parameters
[out]WriteProtectIf Cr0.Bits.WP is enabled.

Definition at line 31 of file SmmCpuMemoryManagement.c.

◆ StartSyncTimer()

UINT64 EFIAPI StartSyncTimer ( VOID  )

Start Timer for SMM AP Sync.

Definition at line 67 of file SyncTimer.c.

◆ UpdateUefiMemMapAttributes()

VOID UpdateUefiMemMapAttributes ( VOID  )

This function updates UEFI memory attribute according to UEFI memory map.

Definition at line 318 of file NonMmramMapDxeSmm.c.

Variable Documentation

◆ gPhyMask

UINT64 gPhyMask
extern

Definition at line 17 of file MpService.c.

◆ gSmmCpuPrivate

SMM_CPU_PRIVATE_DATA* gSmmCpuPrivate
extern

Definition at line 57 of file PiSmmCpuCommon.c.

◆ m5LevelPagingNeeded

BOOLEAN m5LevelPagingNeeded
extern

Definition at line 11 of file SmmCpuMemoryManagement.c.

◆ mAcpiS3Enable

BOOLEAN mAcpiS3Enable
extern

Definition at line 78 of file PiSmmCore.c.

◆ mAddressEncMask

UINT64 mAddressEncMask
extern

Definition at line 21 of file ScriptExecute.c.

◆ mBspApicId

UINT32 mBspApicId
extern

Definition at line 84 of file PiSmmCpuCommon.c.

◆ mCetSupported

BOOLEAN mCetSupported
extern

Definition at line 94 of file PiSmmCpuCommon.c.

◆ mConfigSmmCodeAccessCheckLock

SPIN_LOCK* mConfigSmmCodeAccessCheckLock
extern

Definition at line 117 of file PiSmmCpuCommon.c.

◆ mCpuHotPlugData

CPU_HOT_PLUG_DATA mCpuHotPlugData
extern

Definition at line 42 of file CpuHotplug.c.

◆ mGdtBuffer

EFI_PHYSICAL_ADDRESS mGdtBuffer
extern

Definition at line 13 of file SmmFuncsArch.c.

◆ mGdtBufferSize

UINTN mGdtBufferSize
extern

Definition at line 14 of file SmmFuncsArch.c.

◆ mIsStandaloneMm

const BOOLEAN mIsStandaloneMm
extern

Definition at line 19 of file PiSmmCpuDxeSmm.c.

◆ mMaxNumberOfCpus

UINTN mMaxNumberOfCpus
extern

Definition at line 16 of file SmmRelocationLib.c.

◆ mNumberOfCpus

UINTN mNumberOfCpus
extern

Definition at line 17 of file SmmRelocationLib.c.

◆ mPagingMode

PAGING_MODE mPagingMode
extern

Definition at line 12 of file SmmCpuMemoryManagement.c.

◆ mPatchCetSupported

X86_ASSEMBLY_PATCH_LABEL mPatchCetSupported

Definition at line 378 of file PiSmmCpuCommon.h.

◆ mPFLock

SPIN_LOCK* mPFLock
extern

Definition at line 22 of file MpService.c.

◆ mPhysicalAddressBits

UINT8 mPhysicalAddressBits
extern

Definition at line 125 of file PiSmmCpuCommon.c.

◆ mSemaphoreSize

UINTN mSemaphoreSize
extern

Definition at line 21 of file MpService.c.

◆ mSmmCodeAccessCheckEnable

BOOLEAN mSmmCodeAccessCheckEnable
extern

Definition at line 102 of file PiSmmCpuCommon.c.

◆ mSmmCpu

EFI_SMM_CPU_PROTOCOL mSmmCpu
extern

SMM CPU Protocol instance

Definition at line 67 of file PiSmmCpuCommon.c.

◆ mSmmCpuSemaphores

SMM_CPU_SEMAPHORES mSmmCpuSemaphores
extern

Definition at line 20 of file MpService.c.

◆ mSmmCpuService

EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService
extern

Definition at line 14 of file CpuService.c.

◆ mSmmCpuSmramRangeCount

UINTN mSmmCpuSmramRangeCount
extern

Definition at line 123 of file PiSmmCpuCommon.c.

◆ mSmmCpuSmramRanges

EFI_SMRAM_DESCRIPTOR* mSmmCpuSmramRanges
extern

Definition at line 122 of file PiSmmCpuCommon.c.

◆ mSmmDebugAgentSupport

BOOLEAN mSmmDebugAgentSupport
extern

Definition at line 107 of file PiSmmCpuCommon.c.

◆ mSmmInitialized

volatile BOOLEAN* mSmmInitialized
extern

Definition at line 83 of file PiSmmCpuCommon.c.

◆ mSmmMp

EFI_MM_MP_PROTOCOL mSmmMp
extern

SMM MP Protocol instance

Definition at line 16 of file SmmMp.c.

◆ mSmmMpSyncData

SMM_DISPATCHER_MP_SYNC_DATA* mSmmMpSyncData
extern

Definition at line 18 of file MpService.c.

◆ mSmmS3Flag

BOOLEAN mSmmS3Flag
extern

Definition at line 17 of file CpuS3.c.

◆ mSmmSaveStateRegisterLma

UINT8 mSmmSaveStateRegisterLma
extern

The mode of the CPU at the time an SMI occurs

Definition at line 26 of file AmdSmmCpuFeaturesLib.c.

◆ mSmmShadowStackSize

UINTN mSmmShadowStackSize
extern

Definition at line 93 of file PiSmmCpuCommon.c.

◆ mSmmStackArrayBase

UINTN mSmmStackArrayBase
extern

Definition at line 89 of file PiSmmCpuCommon.c.

◆ mSmmStackArrayEnd

UINTN mSmmStackArrayEnd
extern

Definition at line 90 of file PiSmmCpuCommon.c.

◆ mSmmStackSize

UINTN mSmmStackSize
extern

Definition at line 91 of file PiSmmCpuCommon.c.

◆ mTimeoutTicker

UINT64 mTimeoutTicker
extern

Definition at line 11 of file SyncTimer.c.

◆ mTimeoutTicker2

UINT64 mTimeoutTicker2
extern

Definition at line 13 of file SyncTimer.c.