TianoCore EDK2 master
Loading...
Searching...
No Matches
MpLib.h File Reference

Go to the source code of this file.

Data Structures

struct  MICROCODE_PATCH_INFO
 
struct  CPU_VOLATILE_REGISTERS
 
struct  CPU_EXCHANGE_ROLE_INFO
 
struct  CPU_AP_DATA
 
struct  CPU_INFO_IN_HOB
 
struct  MP_ASSEMBLY_ADDRESS_MAP
 
struct  MP_CPU_EXCHANGE_INFO
 
struct  _CPU_MP_DATA
 
struct  AP_STACK_DATA
 
struct  SEV_ES_AP_JMP_FAR
 
union  RELOCATE_AP_LOOP_ENTRY
 

Macros

#define WAKEUP_AP_SIGNAL   SIGNATURE_32 ('S', 'T', 'A', 'P')
 
#define MP_HAND_OFF_SIGNAL   SIGNATURE_32 ('M', 'P', 'H', 'O')
 
#define CPU_INIT_MP_LIB_HOB_GUID
 
#define CPU_SWITCH_STATE_IDLE   0
 
#define CPU_SWITCH_STATE_STORED   1
 
#define CPU_SWITCH_STATE_LOADED   2
 
#define DEFAULT_MAX_MICROCODE_PATCH_NUM   8
 
#define PAGING_4K_ADDRESS_MASK_64   0x000FFFFFFFFFF000ull
 
#define AP_SAFE_STACK_SIZE   128
 
#define AP_RESET_STACK_SIZE   AP_SAFE_STACK_SIZE
 

Typedefs

typedef struct _CPU_MP_DATA CPU_MP_DATA
 
typedef IN UINT16 Code16
 
typedef IN UINT16 IN UINT16 Code32
 
typedef IN UINT16 IN UINT16 IN UINTN StackStart
 
typedef VOID(EFIAPI * ASM_RELOCATE_AP_LOOP_GENERIC) (IN BOOLEAN MwaitSupport, IN UINTN ApTargetCState, IN UINTN TopOfApStack, IN UINTN NumberToFinish, IN UINTN Cr3)
 
typedef VOID(EFIAPI * ASM_RELOCATE_AP_LOOP_AMDSEV) (IN BOOLEAN MwaitSupport, IN UINTN ApTargetCState, IN UINTN PmCodeSegment, IN UINTN TopOfApStack, IN UINTN NumberToFinish, IN UINTN Pm16CodeSegment, IN UINTN SevEsAPJumpTable, IN UINTN WakeupBuffer)
 

Enumerations

enum  AP_LOOP_MODE {
  ApInHltLoop = 1 , ApInRunLoop = 2 , ApInHltLoop = 1 , ApInMwaitLoop = 2 ,
  ApInRunLoop = 3
}
 
enum  AP_INIT_STATE {
  ApInitConfig = 1 , ApInitReconfig = 2 , ApInitDone = 3 , ApInitConfig = 1 ,
  ApInitDone = 2
}
 
enum  CPU_STATE {
  CpuStateIdle , CpuStateReady , CpuStateBlocked , CpuStateBusy ,
  CpuStateFinished , CpuStateDisabled , CpuStateIdle , CpuStateReady ,
  CpuStateBusy , CpuStateFinished , CpuStateDisabled , CpuStateIdle ,
  CpuStateReady , CpuStateBusy , CpuStateFinished , CpuStateDisabled
}
 

Functions

 STATIC_ASSERT ((AP_SAFE_STACK_SIZE &(CPU_STACK_ALIGNMENT - 1))==0, "AP_SAFE_STACK_SIZE is not aligned with CPU_STACK_ALIGNMENT")
 
typedef VOID (EFIAPI AP_RESET)(IN UINTN BufferStart
 
VOID EFIAPI AsmGetAddressMap (OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap)
 
VOID EFIAPI AsmExchangeRole (IN CPU_EXCHANGE_ROLE_INFO *MyInfo, IN CPU_EXCHANGE_ROLE_INFO *OthersInfo)
 
CPU_MP_DATAGetCpuMpData (VOID)
 
VOID SaveCpuMpData (IN CPU_MP_DATA *CpuMpData)
 
UINTN GetWakeupBuffer (IN UINTN WakeupBufferSize)
 
VOID SwitchApContext (IN CONST MP_HAND_OFF_CONFIG *MpHandOffConfig, IN CONST MP_HAND_OFF *FirstMpHandOff)
 
MP_HAND_OFFGetNextMpHandOffHob (IN CONST MP_HAND_OFF *MpHandOff)
 
UINTN AllocateCodeBuffer (IN UINTN BufferSize)
 
UINTN GetSevEsAPMemory (VOID)
 
UINTN CreatePageTable (IN UINTN Address, IN UINTN Length)
 
VOID WakeUpAP (IN CPU_MP_DATA *CpuMpData, IN BOOLEAN Broadcast, IN UINTN ProcessorNumber, IN EFI_AP_PROCEDURE Procedure OPTIONAL, IN VOID *ProcedureArgument OPTIONAL, IN BOOLEAN WakeUpDisabledAps)
 
VOID InitMpGlobalData (IN CPU_MP_DATA *CpuMpData)
 
EFI_STATUS StartupAllCPUsWorker (IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN BOOLEAN ExcludeBsp, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT UINTN **FailedCpuList OPTIONAL)
 
EFI_STATUS StartupThisAPWorker (IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
 
EFI_STATUS SwitchBSPWorker (IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
 
EFI_STATUS EnableDisableApWorker (IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
 
CPU_MP_DATAGetCpuMpDataFromGuidedHob (VOID)
 
EFI_STATUS CheckThisAP (IN UINTN ProcessorNumber)
 
EFI_STATUS CheckAllAPs (VOID)
 
VOID CheckAndUpdateApsStatus (VOID)
 
VOID MicrocodeDetect (IN CPU_MP_DATA *CpuMpData, IN UINTN ProcessorNumber)
 
VOID ShadowMicrocodeUpdatePatch (IN OUT CPU_MP_DATA *CpuMpData)
 
BOOLEAN GetMicrocodePatchInfoFromHob (UINT64 *Address, UINT64 *RegionSize)
 
BOOLEAN IsMwaitSupport (VOID)
 
VOID EnableDebugAgent (VOID)
 
EFI_STATUS GetProcessorNumber (IN CPU_MP_DATA *CpuMpData, OUT UINTN *ProcessorNumber)
 
EFI_STATUS PlatformShadowMicrocode (IN OUT CPU_MP_DATA *CpuMpData)
 
VOID AllocateSevEsAPMemory (IN OUT CPU_MP_DATA *CpuMpData)
 
VOID SetSevEsJumpTable (IN UINTN SipiVector)
 
VOID SevEsPlaceApHlt (CPU_MP_DATA *CpuMpData)
 
BOOLEAN EFIAPI ConfidentialComputingGuestHas (CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr)
 
VOID FillExchangeInfoDataSevEs (IN volatile MP_CPU_EXCHANGE_INFO *ExchangeInfo)
 
VOID SevSnpCreateSaveArea (IN CPU_MP_DATA *CpuMpData, IN CPU_AP_DATA *CpuData, UINT32 ApicId)
 
VOID SevSnpCreateAP (IN CPU_MP_DATA *CpuMpData, IN INTN ProcessorNumber)
 
BOOLEAN CanUseSevSnpCreateAP (IN CPU_MP_DATA *CpuMpData)
 
VOID AmdSevUpdateCpuMpData (IN CPU_MP_DATA *CpuMpData)
 
VOID PrepareApLoopCode (IN CPU_MP_DATA *CpuMpData)
 
VOID EFIAPI RelocateApLoop (IN OUT VOID *Buffer)
 
VOID AllocateApLoopCodeBuffer (IN UINTN Pages, IN OUT EFI_PHYSICAL_ADDRESS *Address)
 
VOID RemoveNxprotection (IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINTN Length)
 

Variables

EFI_GUID mCpuInitMpLibHobGuid
 
volatile UINT32 mNumberToFinish
 

Detailed Description

Common header file for MP Initialize Library.

Copyright (c) 2016 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2020 - 2024, AMD Inc. All rights reserved.

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

Definition in file MpLib.h.

Macro Definition Documentation

◆ AP_RESET_STACK_SIZE

#define AP_RESET_STACK_SIZE   AP_SAFE_STACK_SIZE

Definition at line 340 of file MpLib.h.

◆ AP_SAFE_STACK_SIZE

#define AP_SAFE_STACK_SIZE   128

Definition at line 339 of file MpLib.h.

◆ CPU_INIT_MP_LIB_HOB_GUID

#define CPU_INIT_MP_LIB_HOB_GUID
Value:
{ \
0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \
}

Definition at line 56 of file MpLib.h.

◆ CPU_SWITCH_STATE_IDLE

#define CPU_SWITCH_STATE_IDLE   0

Definition at line 64 of file MpLib.h.

◆ CPU_SWITCH_STATE_LOADED

#define CPU_SWITCH_STATE_LOADED   2

Definition at line 66 of file MpLib.h.

◆ CPU_SWITCH_STATE_STORED

#define CPU_SWITCH_STATE_STORED   1

Definition at line 65 of file MpLib.h.

◆ DEFAULT_MAX_MICROCODE_PATCH_NUM

#define DEFAULT_MAX_MICROCODE_PATCH_NUM   8

Definition at line 71 of file MpLib.h.

◆ MP_HAND_OFF_SIGNAL

#define MP_HAND_OFF_SIGNAL   SIGNATURE_32 ('M', 'P', 'H', 'O')

Definition at line 54 of file MpLib.h.

◆ PAGING_4K_ADDRESS_MASK_64

#define PAGING_4K_ADDRESS_MASK_64   0x000FFFFFFFFFF000ull

Definition at line 73 of file MpLib.h.

◆ WAKEUP_AP_SIGNAL

#define WAKEUP_AP_SIGNAL   SIGNATURE_32 ('S', 'T', 'A', 'P')

Definition at line 46 of file MpLib.h.

Typedef Documentation

◆ ASM_RELOCATE_AP_LOOP_AMDSEV

typedef VOID(EFIAPI * ASM_RELOCATE_AP_LOOP_AMDSEV) (IN BOOLEAN MwaitSupport, IN UINTN ApTargetCState, IN UINTN PmCodeSegment, IN UINTN TopOfApStack, IN UINTN NumberToFinish, IN UINTN Pm16CodeSegment, IN UINTN SevEsAPJumpTable, IN UINTN WakeupBuffer)

Assembly code to place AP into safe loop mode for Amd processors with Sev enabled. Place AP into targeted C-State if MONITOR is supported, otherwise place AP into hlt state. Place AP in protected mode if the current is long mode. Due to AP maybe wakeup by some hardware event. It could avoid accessing page table that may not available during booting to OS.

Parameters
[in]MwaitSupportTRUE indicates MONITOR is supported. FALSE indicates MONITOR is not supported.
[in]ApTargetCStateTarget C-State value.
[in]PmCodeSegmentProtected mode code segment value.

Definition at line 416 of file MpLib.h.

◆ ASM_RELOCATE_AP_LOOP_GENERIC

typedef VOID(EFIAPI * ASM_RELOCATE_AP_LOOP_GENERIC) (IN BOOLEAN MwaitSupport, IN UINTN ApTargetCState, IN UINTN TopOfApStack, IN UINTN NumberToFinish, IN UINTN Cr3)

Assembly code to place AP into safe loop mode.

Place AP into targeted C-State if MONITOR is supported, otherwise place AP into hlt state. Place AP in protected mode if the current is long mode. Due to AP maybe wakeup by some hardware event. It could avoid accessing page table that may not available during booting to OS.

Parameters
[in]MwaitSupportTRUE indicates MONITOR is supported. FALSE indicates MONITOR is not supported.
[in]ApTargetCStateTarget C-State value.
[in]PmCodeSegmentProtected mode code segment value.

Definition at line 393 of file MpLib.h.

◆ Code16

typedef IN UINT16 Code16

Definition at line 370 of file MpLib.h.

◆ Code32

typedef IN UINT16 IN UINT16 Code32

Definition at line 371 of file MpLib.h.

◆ CPU_MP_DATA

typedef struct _CPU_MP_DATA CPU_MP_DATA

Definition at line 201 of file MpLib.h.

◆ StackStart

typedef IN UINT16 IN UINT16 IN UINTN StackStart

Definition at line 372 of file MpLib.h.

Enumeration Type Documentation

◆ AP_INIT_STATE

enum AP_INIT_STATE

Definition at line 123 of file MpLib.h.

◆ AP_LOOP_MODE

enum AP_LOOP_MODE

Definition at line 114 of file MpLib.h.

◆ CPU_STATE

enum CPU_STATE

Definition at line 135 of file MpLib.h.

Function Documentation

◆ AllocateApLoopCodeBuffer()

VOID AllocateApLoopCodeBuffer ( IN UINTN  Pages,
IN OUT EFI_PHYSICAL_ADDRESS Address 
)

Allocate buffer for ApLoopCode.

Parameters
[in]PagesNumber of pages to allocate.
[in,out]AddressPointer to the allocated buffer.

Definition at line 401 of file DxeMpLib.c.

◆ AllocateCodeBuffer()

UINTN AllocateCodeBuffer ( IN UINTN  BufferSize)

Get available EfiBootServicesCode memory below 4GB by specified size.

This buffer is required to safely transfer AP from real address mode to protected mode or long mode, due to the fact that the buffer returned by GetWakeupBuffer() may be marked as non-executable.

Parameters
[in]BufferSizeWakeup transition buffer size.
Return values
otherReturn wakeup transition buffer address below 4GB.
0Cannot find free memory below 4GB.

Definition at line 163 of file DxeMpLib.c.

◆ AllocateSevEsAPMemory()

VOID AllocateSevEsAPMemory ( IN OUT CPU_MP_DATA CpuMpData)

Allocate the SEV-ES AP jump table buffer.

Parameters
[in,out]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 158 of file AmdSev.c.

◆ AmdSevUpdateCpuMpData()

VOID AmdSevUpdateCpuMpData ( IN CPU_MP_DATA CpuMpData)

Get pointer to CPU MP Data structure from GUIDed HOB.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 304 of file AmdSev.c.

◆ AsmExchangeRole()

VOID EFIAPI AsmExchangeRole ( IN CPU_EXCHANGE_ROLE_INFO MyInfo,
IN CPU_EXCHANGE_ROLE_INFO OthersInfo 
)

This function is called by both the BSP and the AP which is to become the BSP to Exchange execution context including stack between them. After return from this function, the BSP becomes AP and the AP becomes the BSP.

Parameters
[in]MyInfoPointer to buffer holding the exchanging information for the executing processor.
[in]OthersInfoPointer to buffer holding the exchanging information for the peer.

◆ AsmGetAddressMap()

VOID EFIAPI AsmGetAddressMap ( OUT MP_ASSEMBLY_ADDRESS_MAP AddressMap)

Assembly code to get starting address and size of the rendezvous entry for APs. Information for fixing a jump instruction in the code is also returned.

Parameters
[out]AddressMapOutput buffer for address map information.

◆ CanUseSevSnpCreateAP()

BOOLEAN CanUseSevSnpCreateAP ( IN CPU_MP_DATA CpuMpData)

Determine if the SEV-SNP AP Create protocol should be used.

Parameters
[in]CpuMpDataPointer to CPU MP Data
Return values
TRUEUse SEV-SNP AP Create protocol
FALSEDo not use SEV-SNP AP Create protocol

Definition at line 61 of file AmdSev.c.

◆ CheckAllAPs()

EFI_STATUS CheckAllAPs ( VOID  )

Checks status of all APs.

This function checks whether all APs have finished task assigned by StartupAllAPs(), and whether timeout expires.

Return values
EFI_SUCCESSAll APs have finished task assigned by StartupAllAPs().
EFI_TIMEOUTThe timeout expires.
EFI_NOT_READYAPs have not finished task and timeout has not expired.

Definition at line 910 of file MpLib.c.

◆ CheckAndUpdateApsStatus()

VOID CheckAndUpdateApsStatus ( VOID  )

Checks APs status and updates APs status if needed.

Definition at line 235 of file DxeMpLib.c.

◆ CheckThisAP()

EFI_STATUS CheckThisAP ( IN UINTN  ProcessorNumber)

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]ProcessorNumberThe handle number of processor.
Return values
EFI_SUCCESSSpecified AP has finished task assigned by StartupThisAPs().
EFI_TIMEOUTThe timeout expires.
EFI_NOT_READYSpecified AP has not finished task and timeout has not expired.

Definition at line 863 of file MpLib.c.

◆ ConfidentialComputingGuestHas()

BOOLEAN EFIAPI ConfidentialComputingGuestHas ( CONFIDENTIAL_COMPUTING_GUEST_ATTR  Attr)

Check if the specified confidential computing attribute is active.

Return values
TRUEThe specified Attr is active.
FALSEThe specified Attr is not active.

◆ CreatePageTable()

UINTN CreatePageTable ( IN UINTN  Address,
IN UINTN  Length 
)

Create 1:1 mapping page table in reserved memory to map the specified address range.

Parameters
[in]LinearAddressThe start of the linear address range.
[in]LengthThe length of the linear address range.
Returns
The page table to be created.

Only create page table for x64, and leave the CreatePageTable empty for Ia32.

Parameters
[in]LinearAddressThe start of the linear address range.
[in]LengthThe length of the linear address range.
Returns
The page table to be created.

Definition at line 17 of file CreatePageTable.c.

◆ EnableDebugAgent()

VOID EnableDebugAgent ( VOID  )

Enable Debug Agent to support source debugging on AP function.

Definition at line 40 of file DxeMpLib.c.

◆ EnableDisableApWorker()

EFI_STATUS EnableDisableApWorker ( IN UINTN  ProcessorNumber,
IN BOOLEAN  EnableAP,
IN UINT32 *HealthFlag  OPTIONAL 
)

Worker function to let the caller enable or disable an AP from this point onward. This service may only be called from the BSP.

Parameters
[in]ProcessorNumberThe handle number of AP.
[in]EnableAPSpecifies the new state for the processor for enabled, FALSE for disabled.
[in]HealthFlagIf not NULL, a pointer to a value that specifies the new health status of the AP.
Return values
EFI_SUCCESSThe specified AP was enabled or disabled successfully.
othersFailed to Enable/Disable AP.

Definition at line 2745 of file MpLib.c.

◆ FillExchangeInfoDataSevEs()

VOID FillExchangeInfoDataSevEs ( IN volatile MP_CPU_EXCHANGE_INFO ExchangeInfo)

The function fills the exchange data for the AP.

Parameters
[in]ExchangeInfoThe pointer to CPU Exchange Data structure

Definition at line 276 of file AmdSev.c.

◆ GetCpuMpData()

CPU_MP_DATA * GetCpuMpData ( VOID  )

Get the pointer to CPU MP Data structure.

Returns
The pointer to CPU MP Data structure.

Get pointer to CPU MP Data structure.

Returns
The pointer to CPU MP Data structure.

Get pointer to CPU MP Data structure. For BSP, the pointer is retrieved from HOB. For AP, the structure is stored in the top of each AP's stack.

Returns
The pointer to CPU MP Data structure.

Definition at line 56 of file DxeMpLib.c.

◆ GetCpuMpDataFromGuidedHob()

CPU_MP_DATA * GetCpuMpDataFromGuidedHob ( VOID  )

Get pointer to CPU MP Data structure from GUIDed HOB.

Returns
The pointer to CPU MP Data structure.

Definition at line 1609 of file MpLib.c.

◆ GetMicrocodePatchInfoFromHob()

BOOLEAN GetMicrocodePatchInfoFromHob ( UINT64 *  Address,
UINT64 *  RegionSize 
)

Get the cached microcode patch base address and size from the microcode patch information cache HOB.

Parameters
[out]AddressBase address of the microcode patches data. It will be updated if the microcode patch information cache HOB is found.
[out]RegionSizeSize of the microcode patches data. It will be updated if the microcode patch information cache HOB is found.
Return values
TRUEThe microcode patch information cache HOB is found.
FALSEThe microcode patch information cache HOB is not found.

Definition at line 358 of file Microcode.c.

◆ GetNextMpHandOffHob()

MP_HAND_OFF * GetNextMpHandOffHob ( IN CONST MP_HAND_OFF MpHandOff)

Get pointer to next MP_HAND_OFF GUIDed HOB body.

Parameters
[in]MpHandOffPrevious HOB body. Pass NULL to get the first HOB.
Returns
The pointer to MP_HAND_OFF structure.

Definition at line 2011 of file MpLib.c.

◆ GetProcessorNumber()

EFI_STATUS GetProcessorNumber ( IN CPU_MP_DATA CpuMpData,
OUT UINTN ProcessorNumber 
)

Find the current Processor number by APIC ID.

Parameters
[in]CpuMpDataPointer to PEI CPU MP Data
[out]ProcessorNumberReturn the pocessor number found
Return values
EFI_SUCCESSProcessorNumber is found and returned.
EFI_NOT_FOUNDProcessorNumber is not found.

Definition at line 78 of file MpLib.c.

◆ GetSevEsAPMemory()

UINTN GetSevEsAPMemory ( VOID  )

Return the address of the SEV-ES AP jump table.

This buffer is required in order for an SEV-ES guest to transition from UEFI into an OS.

Returns
Return SEV-ES AP jump table buffer

Definition at line 193 of file DxeMpLib.c.

◆ GetWakeupBuffer()

UINTN GetWakeupBuffer ( IN UINTN  WakeupBufferSize)

Get available system memory below 1MB by specified size.

Parameters
[in]WakeupBufferSizeWakeup buffer size required
Return values
otherReturn wakeup buffer address below 1MB.
-1Cannot find free memory below 1MB.

Get available system memory below 0x88000 by specified size.

Parameters
[in]WakeupBufferSizeWakeup buffer size required
Return values
otherReturn wakeup buffer address below 1MB.
-1Cannot find free memory below 1MB.

Definition at line 86 of file DxeMpLib.c.

◆ InitMpGlobalData()

VOID InitMpGlobalData ( IN CPU_MP_DATA CpuMpData)

Initialize global data for MP support.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.

Install Notify

Definition at line 499 of file DxeMpLib.c.

◆ IsMwaitSupport()

BOOLEAN IsMwaitSupport ( VOID  )

Detect whether Mwait-monitor feature is supported.

Return values
TRUEMwait-monitor feature is supported.
FALSEMwait-monitor feature is not supported.

Definition at line 295 of file MpLib.c.

◆ MicrocodeDetect()

VOID MicrocodeDetect ( IN CPU_MP_DATA CpuMpData,
IN UINTN  ProcessorNumber 
)

Detect whether specified processor can find matching microcode patch and load it.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.
[in]ProcessorNumberThe handle number of the processor. The range is from 0 to the total number of logical processors minus 1.

Definition at line 20 of file Microcode.c.

◆ PlatformShadowMicrocode()

EFI_STATUS PlatformShadowMicrocode ( IN OUT CPU_MP_DATA CpuMpData)

This funtion will try to invoke platform specific microcode shadow logic to relocate microcode update patches into memory.

Parameters
[in,out]CpuMpDataThe pointer to CPU MP Data structure.
Return values
EFI_SUCCESSShadow microcode success.
EFI_OUT_OF_RESOURCESNo enough resource to complete the operation.
EFI_UNSUPPORTEDCan't find platform specific microcode shadow PPI/Protocol.

Definition at line 959 of file DxeMpLib.c.

◆ PrepareApLoopCode()

VOID PrepareApLoopCode ( IN CPU_MP_DATA CpuMpData)

Prepare ApLoopCode.

Parameters
[in]CpuMpDataPointer to CpuMpData.

Definition at line 3424 of file MpLib.c.

◆ RelocateApLoop()

VOID EFIAPI RelocateApLoop ( IN OUT VOID *  Buffer)

Do sync on APs.

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

Definition at line 3364 of file MpLib.c.

◆ RemoveNxprotection()

VOID RemoveNxprotection ( IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINTN  Length 
)

Remove Nx protection for the range specific by BaseAddress and Length.

The PEI implementation uses CpuPageTableLib to change the attribute. The DXE implementation uses gDS to change the attribute.

Parameters
[in]BaseAddressBaseAddress of the range.
[in]LengthLength of the range.

Definition at line 427 of file DxeMpLib.c.

◆ SaveCpuMpData()

VOID SaveCpuMpData ( IN CPU_MP_DATA CpuMpData)

Save the pointer to CPU MP Data structure.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure will be saved.

Definition at line 70 of file DxeMpLib.c.

◆ SetSevEsJumpTable()

VOID SetSevEsJumpTable ( IN UINTN  SipiVector)

Program the SEV-ES AP jump table buffer.

Parameters
[in]SipiVectorThe SIPI vector used for the AP Reset

Definition at line 174 of file AmdSev.c.

◆ SevEsPlaceApHlt()

VOID SevEsPlaceApHlt ( CPU_MP_DATA CpuMpData)

The function puts the AP in halt loop.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 223 of file AmdSev.c.

◆ SevSnpCreateAP()

VOID SevSnpCreateAP ( IN CPU_MP_DATA CpuMpData,
IN INTN  ProcessorNumber 
)

Create SEV-SNP APs.

Parameters
[in]CpuMpDataPointer to CPU MP Data
[in]ProcessorNumberThe handle number of specified processor (-1 for all APs)

Definition at line 41 of file AmdSev.c.

◆ SevSnpCreateSaveArea()

VOID SevSnpCreateSaveArea ( IN CPU_MP_DATA CpuMpData,
IN CPU_AP_DATA CpuData,
UINT32  ApicId 
)

Create an SEV-SNP AP save area (VMSA) for use in running the vCPU.

Parameters
[in]CpuMpDataPointer to CPU MP Data
[in]CpuDataPointer to CPU AP Data
[in]ApicIdAPIC ID of the vCPU

Definition at line 21 of file AmdSev.c.

◆ ShadowMicrocodeUpdatePatch()

VOID ShadowMicrocodeUpdatePatch ( IN OUT CPU_MP_DATA CpuMpData)

Shadow the required microcode patches data into memory.

Parameters
[in,out]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 330 of file Microcode.c.

◆ StartupAllCPUsWorker()

EFI_STATUS StartupAllCPUsWorker ( IN EFI_AP_PROCEDURE  Procedure,
IN BOOLEAN  SingleThread,
IN BOOLEAN  ExcludeBsp,
IN EFI_EVENT WaitEvent  OPTIONAL,
IN UINTN  TimeoutInMicroseconds,
IN VOID *ProcedureArgument  OPTIONAL,
OUT UINTN **FailedCpuList  OPTIONAL 
)

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]SingleThreadIf TRUE, then all the enabled APs execute the function specified by Procedure one by one, in ascending order of processor handle number. If FALSE, then all the enabled APs execute the function specified by Procedure simultaneously.
[in]ExcludeBspWhether let BSP also trig this task.
[in]WaitEventThe event created by the caller with CreateEvent() service.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for APs to return from Procedure, either for blocking or non-blocking mode.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
[out]FailedCpuListIf all APs finish successfully, then its content is set to NULL. If not all APs finish before timeout expires, then its content is set to address of the buffer holding handle numbers of the failed APs.
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 1019 of file MpLib.c.

◆ StartupThisAPWorker()

EFI_STATUS StartupThisAPWorker ( IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  ProcessorNumber,
IN EFI_EVENT WaitEvent  OPTIONAL,
IN UINTN  TimeoutInMicroseconds,
IN VOID *ProcedureArgument  OPTIONAL,
OUT BOOLEAN *Finished  OPTIONAL 
)

Worker function to let the caller get one enabled AP to execute a caller-provided function.

Parameters
[in]ProcedureA pointer to the function to be run on enabled APs of the system.
[in]ProcessorNumberThe handle number of the AP.
[in]WaitEventThe event created by the caller with CreateEvent() service.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for APs to return from Procedure, either for blocking or non-blocking mode.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
[out]FinishedIf AP returns from Procedure before the timeout expires, its content is set to TRUE. Otherwise, the value is set to FALSE.
Return values
EFI_SUCCESSIn blocking mode, specified AP finished before the timeout expires.
othersFailed to Startup AP.

Definition at line 1176 of file MpLib.c.

◆ SwitchApContext()

VOID SwitchApContext ( IN CONST MP_HAND_OFF_CONFIG MpHandOffConfig,
IN CONST MP_HAND_OFF FirstMpHandOff 
)

Switch Context for each AP.

This function is intended to be invoked by the BSP in order to wake up the AP. The BSP accomplishes this by triggering a start-up signal, which in turn causes any APs that are currently in a loop on the PEI-prepared memory to awaken and begin running the procedure called SwitchContextPerAp. This procedure allows the AP to switch to another section of memory and continue its loop there.

Parameters
[in]MpHandOffConfigPointer to MP hand-off config HOB body.
[in]FirstMpHandOffPointer to first MP hand-off HOB body.

Definition at line 1945 of file MpLib.c.

◆ SwitchBSPWorker()

EFI_STATUS SwitchBSPWorker ( IN UINTN  ProcessorNumber,
IN BOOLEAN  EnableOldBSP 
)

Worker function to switch the requested AP to be the BSP from that point onward.

Parameters
[in]ProcessorNumberThe handle number of AP that is to become the new BSP.
[in]EnableOldBSPIf TRUE, then the old BSP will be listed as an enabled AP. Otherwise, it will be disabled.
Return values
EFI_SUCCESSBSP successfully switched.
othersFailed to switch BSP.

Definition at line 2581 of file MpLib.c.

◆ VOID()

typedef VOID ( EFIAPI  AP_RESET)

Assembly code to move an AP from long mode to real mode.

Move an AP from long mode to real mode in preparation to invoking the reset vector. This is used for SEV-ES guests where a hypervisor is not allowed to set the CS and RIP to point to the reset vector.

Parameters
[in]BufferStartThe reset vector target.
[in]Code1616-bit protected mode code segment value.
[in]Code3232-bit protected mode code segment value.
[in]StackStartThe start of a stack to be used for transitioning from long mode to real mode.

◆ WakeUpAP()

VOID WakeUpAP ( IN CPU_MP_DATA CpuMpData,
IN BOOLEAN  Broadcast,
IN UINTN  ProcessorNumber,
IN EFI_AP_PROCEDURE Procedure  OPTIONAL,
IN VOID *ProcedureArgument  OPTIONAL,
IN BOOLEAN  WakeUpDisabledAps 
)

This function will be called by BSP to wakeup AP.

Parameters
[in]CpuMpDataPointer to CPU MP Data
[in]BroadcastTRUE: Send broadcast IPI to all APs FALSE: Send IPI to AP by ApicId
[in]ProcessorNumberThe handle number of specified processor
[in]ProcedureThe function to be invoked by AP
[in]ProcedureArgumentThe argument to be passed into AP function
[in]WakeUpDisabledApsWhether need to wake up disabled APs in broadcast mode.

This function will be called by BSP to wakeup AP.

Parameters
[in]CpuMpDataPointer to CPU MP Data
[in]BroadcastTRUE: Send broadcast IPI to all APs FALSE: Send IPI to AP by ApicId
[in]ProcessorNumberThe handle number of specified processor
[in]ProcedureThe function to be invoked by AP
[in]ProcedureArgumentThe argument to be passed into AP function
[in]WakeUpDisabledApsWhether need to wake up disabled APs in broadcast mode. Currently not used on LoongArch.

Definition at line 672 of file MpLib.c.

Variable Documentation

◆ mCpuInitMpLibHobGuid

EFI_GUID mCpuInitMpLibHobGuid
extern

Definition at line 17 of file MpLib.c.

◆ mNumberToFinish

volatile UINT32 mNumberToFinish
extern

Definition at line 22 of file MpLib.c.