]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/MpLib: add support to register GHCB GPA when SEV-SNP is enabled
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / MpLib.h
1 /** @file
2 Common header file for MP Initialize Library.
3
4 Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2020, AMD Inc. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef _MP_LIB_H_
12 #define _MP_LIB_H_
13
14 #include <PiPei.h>
15
16 #include <Register/Intel/Cpuid.h>
17 #include <Register/Amd/Cpuid.h>
18 #include <Register/Intel/Msr.h>
19 #include <Register/Intel/LocalApic.h>
20 #include <Register/Intel/Microcode.h>
21
22 #include <Library/MpInitLib.h>
23 #include <Library/BaseLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/MemoryAllocationLib.h>
26 #include <Library/DebugLib.h>
27 #include <Library/LocalApicLib.h>
28 #include <Library/CpuLib.h>
29 #include <Library/UefiCpuLib.h>
30 #include <Library/TimerLib.h>
31 #include <Library/SynchronizationLib.h>
32 #include <Library/MtrrLib.h>
33 #include <Library/HobLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/MicrocodeLib.h>
36 #include <ConfidentialComputingGuestAttr.h>
37
38 #include <Register/Amd/Fam17Msr.h>
39 #include <Register/Amd/Ghcb.h>
40
41 #include <Guid/MicrocodePatchHob.h>
42
43 #define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')
44
45 #define CPU_INIT_MP_LIB_HOB_GUID \
46 { \
47 0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \
48 }
49
50 //
51 // The MP data for switch BSP
52 //
53 #define CPU_SWITCH_STATE_IDLE 0
54 #define CPU_SWITCH_STATE_STORED 1
55 #define CPU_SWITCH_STATE_LOADED 2
56
57 //
58 // Default maximum number of entries to store the microcode patches information
59 //
60 #define DEFAULT_MAX_MICROCODE_PATCH_NUM 8
61
62 //
63 // Data structure for microcode patch information
64 //
65 typedef struct {
66 UINTN Address;
67 UINTN Size;
68 } MICROCODE_PATCH_INFO;
69
70 //
71 // CPU exchange information for switch BSP
72 //
73 typedef struct {
74 UINT8 State; // offset 0
75 UINTN StackPointer; // offset 4 / 8
76 IA32_DESCRIPTOR Gdtr; // offset 8 / 16
77 IA32_DESCRIPTOR Idtr; // offset 14 / 26
78 } CPU_EXCHANGE_ROLE_INFO;
79
80 //
81 // AP loop state when APs are in idle state
82 // It's value is the same with PcdCpuApLoopMode
83 //
84 typedef enum {
85 ApInHltLoop = 1,
86 ApInMwaitLoop = 2,
87 ApInRunLoop = 3
88 } AP_LOOP_MODE;
89
90 //
91 // AP initialization state during APs wakeup
92 //
93 typedef enum {
94 ApInitConfig = 1,
95 ApInitReconfig = 2,
96 ApInitDone = 3
97 } AP_INIT_STATE;
98
99 //
100 // AP state
101 //
102 // The state transitions for an AP when it process a procedure are:
103 // Idle ----> Ready ----> Busy ----> Idle
104 // [BSP] [AP] [AP]
105 //
106 typedef enum {
107 CpuStateIdle,
108 CpuStateReady,
109 CpuStateBusy,
110 CpuStateFinished,
111 CpuStateDisabled
112 } CPU_STATE;
113
114 //
115 // CPU volatile registers around INIT-SIPI-SIPI
116 //
117 typedef struct {
118 UINTN Cr0;
119 UINTN Cr3;
120 UINTN Cr4;
121 UINTN Dr0;
122 UINTN Dr1;
123 UINTN Dr2;
124 UINTN Dr3;
125 UINTN Dr6;
126 UINTN Dr7;
127 IA32_DESCRIPTOR Gdtr;
128 IA32_DESCRIPTOR Idtr;
129 UINT16 Tr;
130 } CPU_VOLATILE_REGISTERS;
131
132 //
133 // AP related data
134 //
135 typedef struct {
136 SPIN_LOCK ApLock;
137 volatile UINT32 *StartupApSignal;
138 volatile UINTN ApFunction;
139 volatile UINTN ApFunctionArgument;
140 BOOLEAN CpuHealthy;
141 volatile CPU_STATE State;
142 CPU_VOLATILE_REGISTERS VolatileRegisters;
143 BOOLEAN Waiting;
144 BOOLEAN *Finished;
145 UINT64 ExpectedTime;
146 UINT64 CurrentTime;
147 UINT64 TotalTime;
148 EFI_EVENT WaitEvent;
149 UINT32 ProcessorSignature;
150 UINT8 PlatformId;
151 UINT64 MicrocodeEntryAddr;
152 UINT32 MicrocodeRevision;
153 } CPU_AP_DATA;
154
155 //
156 // Basic CPU information saved in Guided HOB.
157 // Because the contents will be shard between PEI and DXE,
158 // we need to make sure the each fields offset same in different
159 // architecture.
160 //
161 #pragma pack (1)
162 typedef struct {
163 UINT32 InitialApicId;
164 UINT32 ApicId;
165 UINT32 Health;
166 UINT64 ApTopOfStack;
167 } CPU_INFO_IN_HOB;
168 #pragma pack ()
169
170 //
171 // AP reset code information including code address and size,
172 // this structure will be shared be C code and assembly code.
173 // It is natural aligned by design.
174 //
175 typedef struct {
176 UINT8 *RendezvousFunnelAddress;
177 UINTN ModeEntryOffset;
178 UINTN RendezvousFunnelSize;
179 UINT8 *RelocateApLoopFuncAddress;
180 UINTN RelocateApLoopFuncSize;
181 UINTN ModeTransitionOffset;
182 UINTN SwitchToRealSize;
183 UINTN SwitchToRealOffset;
184 UINTN SwitchToRealNoNxOffset;
185 UINTN SwitchToRealPM16ModeOffset;
186 UINTN SwitchToRealPM16ModeSize;
187 } MP_ASSEMBLY_ADDRESS_MAP;
188
189 typedef struct _CPU_MP_DATA CPU_MP_DATA;
190
191 #pragma pack(1)
192
193 //
194 // MP CPU exchange information for AP reset code
195 // This structure is required to be packed because fixed field offsets
196 // into this structure are used in assembly code in this module
197 //
198 typedef struct {
199 UINTN StackStart;
200 UINTN StackSize;
201 UINTN CFunction;
202 IA32_DESCRIPTOR GdtrProfile;
203 IA32_DESCRIPTOR IdtrProfile;
204 UINTN BufferStart;
205 UINTN ModeOffset;
206 UINTN ApIndex;
207 UINTN CodeSegment;
208 UINTN DataSegment;
209 UINTN EnableExecuteDisable;
210 UINTN Cr3;
211 UINTN InitFlag;
212 CPU_INFO_IN_HOB *CpuInfo;
213 UINTN NumApsExecuting;
214 CPU_MP_DATA *CpuMpData;
215 UINTN InitializeFloatingPointUnitsAddress;
216 UINT32 ModeTransitionMemory;
217 UINT16 ModeTransitionSegment;
218 UINT32 ModeHighMemory;
219 UINT16 ModeHighSegment;
220 //
221 // Enable5LevelPaging indicates whether 5-level paging is enabled in long mode.
222 //
223 BOOLEAN Enable5LevelPaging;
224 BOOLEAN SevEsIsEnabled;
225 BOOLEAN SevSnpIsEnabled;
226 UINTN GhcbBase;
227 } MP_CPU_EXCHANGE_INFO;
228
229 #pragma pack()
230
231 //
232 // CPU MP Data save in memory
233 //
234 struct _CPU_MP_DATA {
235 UINT64 CpuInfoInHob;
236 UINT32 CpuCount;
237 UINT32 BspNumber;
238 //
239 // The above fields data will be passed from PEI to DXE
240 // Please make sure the fields offset same in the different
241 // architecture.
242 //
243 SPIN_LOCK MpLock;
244 UINTN Buffer;
245 UINTN CpuApStackSize;
246 MP_ASSEMBLY_ADDRESS_MAP AddressMap;
247 UINTN WakeupBuffer;
248 UINTN WakeupBufferHigh;
249 UINTN BackupBuffer;
250 UINTN BackupBufferSize;
251
252 volatile UINT32 FinishedCount;
253 UINT32 RunningCount;
254 BOOLEAN SingleThread;
255 EFI_AP_PROCEDURE Procedure;
256 VOID *ProcArguments;
257 BOOLEAN *Finished;
258 UINT64 ExpectedTime;
259 UINT64 CurrentTime;
260 UINT64 TotalTime;
261 EFI_EVENT WaitEvent;
262 UINTN **FailedCpuList;
263
264 AP_INIT_STATE InitFlag;
265 BOOLEAN SwitchBspFlag;
266 UINTN NewBspNumber;
267 CPU_EXCHANGE_ROLE_INFO BSPInfo;
268 CPU_EXCHANGE_ROLE_INFO APInfo;
269 MTRR_SETTINGS MtrrTable;
270 UINT8 ApLoopMode;
271 UINT8 ApTargetCState;
272 UINT16 PmCodeSegment;
273 UINT16 Pm16CodeSegment;
274 CPU_AP_DATA *CpuData;
275 volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo;
276
277 UINT32 CurrentTimerCount;
278 UINTN DivideValue;
279 UINT8 Vector;
280 BOOLEAN PeriodicMode;
281 BOOLEAN TimerInterruptState;
282 UINT64 MicrocodePatchAddress;
283 UINT64 MicrocodePatchRegionSize;
284
285 //
286 // Whether need to use Init-Sipi-Sipi to wake up the APs.
287 // Two cases need to set this value to TRUE. One is in HLT
288 // loop mode, the other is resume from S3 which loop mode
289 // will be hardcode change to HLT mode by PiSmmCpuDxeSmm
290 // driver.
291 //
292 BOOLEAN WakeUpByInitSipiSipi;
293
294 BOOLEAN SevEsIsEnabled;
295 BOOLEAN SevSnpIsEnabled;
296 UINTN SevEsAPBuffer;
297 UINTN SevEsAPResetStackStart;
298 CPU_MP_DATA *NewCpuMpData;
299
300 UINT64 GhcbBase;
301 };
302
303 #define AP_SAFE_STACK_SIZE 128
304 #define AP_RESET_STACK_SIZE AP_SAFE_STACK_SIZE
305
306 #pragma pack(1)
307
308 typedef struct {
309 UINT8 InsnBuffer[8];
310 UINT16 Rip;
311 UINT16 Segment;
312 } SEV_ES_AP_JMP_FAR;
313
314 #pragma pack()
315
316 /**
317 Assembly code to move an AP from long mode to real mode.
318
319 Move an AP from long mode to real mode in preparation to invoking
320 the reset vector. This is used for SEV-ES guests where a hypervisor
321 is not allowed to set the CS and RIP to point to the reset vector.
322
323 @param[in] BufferStart The reset vector target.
324 @param[in] Code16 16-bit protected mode code segment value.
325 @param[in] Code32 32-bit protected mode code segment value.
326 @param[in] StackStart The start of a stack to be used for transitioning
327 from long mode to real mode.
328 **/
329 typedef
330 VOID
331 (EFIAPI AP_RESET)(
332 IN UINTN BufferStart,
333 IN UINT16 Code16,
334 IN UINT16 Code32,
335 IN UINTN StackStart
336 );
337
338 extern EFI_GUID mCpuInitMpLibHobGuid;
339
340 /**
341 Assembly code to place AP into safe loop mode.
342
343 Place AP into targeted C-State if MONITOR is supported, otherwise
344 place AP into hlt state.
345 Place AP in protected mode if the current is long mode. Due to AP maybe
346 wakeup by some hardware event. It could avoid accessing page table that
347 may not available during booting to OS.
348
349 @param[in] MwaitSupport TRUE indicates MONITOR is supported.
350 FALSE indicates MONITOR is not supported.
351 @param[in] ApTargetCState Target C-State value.
352 @param[in] PmCodeSegment Protected mode code segment value.
353 **/
354 typedef
355 VOID
356 (EFIAPI *ASM_RELOCATE_AP_LOOP)(
357 IN BOOLEAN MwaitSupport,
358 IN UINTN ApTargetCState,
359 IN UINTN PmCodeSegment,
360 IN UINTN TopOfApStack,
361 IN UINTN NumberToFinish,
362 IN UINTN Pm16CodeSegment,
363 IN UINTN SevEsAPJumpTable,
364 IN UINTN WakeupBuffer
365 );
366
367 /**
368 Assembly code to get starting address and size of the rendezvous entry for APs.
369 Information for fixing a jump instruction in the code is also returned.
370
371 @param[out] AddressMap Output buffer for address map information.
372 **/
373 VOID
374 EFIAPI
375 AsmGetAddressMap (
376 OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap
377 );
378
379 /**
380 This function is called by both the BSP and the AP which is to become the BSP to
381 Exchange execution context including stack between them. After return from this
382 function, the BSP becomes AP and the AP becomes the BSP.
383
384 @param[in] MyInfo Pointer to buffer holding the exchanging information for the executing processor.
385 @param[in] OthersInfo Pointer to buffer holding the exchanging information for the peer.
386
387 **/
388 VOID
389 EFIAPI
390 AsmExchangeRole (
391 IN CPU_EXCHANGE_ROLE_INFO *MyInfo,
392 IN CPU_EXCHANGE_ROLE_INFO *OthersInfo
393 );
394
395 /**
396 Get the pointer to CPU MP Data structure.
397
398 @return The pointer to CPU MP Data structure.
399 **/
400 CPU_MP_DATA *
401 GetCpuMpData (
402 VOID
403 );
404
405 /**
406 Save the pointer to CPU MP Data structure.
407
408 @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.
409 **/
410 VOID
411 SaveCpuMpData (
412 IN CPU_MP_DATA *CpuMpData
413 );
414
415 /**
416 Get available system memory below 1MB by specified size.
417
418 @param[in] WakeupBufferSize Wakeup buffer size required
419
420 @retval other Return wakeup buffer address below 1MB.
421 @retval -1 Cannot find free memory below 1MB.
422 **/
423 UINTN
424 GetWakeupBuffer (
425 IN UINTN WakeupBufferSize
426 );
427
428 /**
429 Get available EfiBootServicesCode memory below 4GB by specified size.
430
431 This buffer is required to safely transfer AP from real address mode to
432 protected mode or long mode, due to the fact that the buffer returned by
433 GetWakeupBuffer() may be marked as non-executable.
434
435 @param[in] BufferSize Wakeup transition buffer size.
436
437 @retval other Return wakeup transition buffer address below 4GB.
438 @retval 0 Cannot find free memory below 4GB.
439 **/
440 UINTN
441 GetModeTransitionBuffer (
442 IN UINTN BufferSize
443 );
444
445 /**
446 Return the address of the SEV-ES AP jump table.
447
448 This buffer is required in order for an SEV-ES guest to transition from
449 UEFI into an OS.
450
451 @return Return SEV-ES AP jump table buffer
452 **/
453 UINTN
454 GetSevEsAPMemory (
455 VOID
456 );
457
458 /**
459 This function will be called by BSP to wakeup AP.
460
461 @param[in] CpuMpData Pointer to CPU MP Data
462 @param[in] Broadcast TRUE: Send broadcast IPI to all APs
463 FALSE: Send IPI to AP by ApicId
464 @param[in] ProcessorNumber The handle number of specified processor
465 @param[in] Procedure The function to be invoked by AP
466 @param[in] ProcedureArgument The argument to be passed into AP function
467 @param[in] WakeUpDisabledAps Whether need to wake up disabled APs in broadcast mode.
468 **/
469 VOID
470 WakeUpAP (
471 IN CPU_MP_DATA *CpuMpData,
472 IN BOOLEAN Broadcast,
473 IN UINTN ProcessorNumber,
474 IN EFI_AP_PROCEDURE Procedure OPTIONAL,
475 IN VOID *ProcedureArgument OPTIONAL,
476 IN BOOLEAN WakeUpDisabledAps OPTIONAL
477 );
478
479 /**
480 Initialize global data for MP support.
481
482 @param[in] CpuMpData The pointer to CPU MP Data structure.
483 **/
484 VOID
485 InitMpGlobalData (
486 IN CPU_MP_DATA *CpuMpData
487 );
488
489 /**
490 Worker function to execute a caller provided function on all enabled APs.
491
492 @param[in] Procedure A pointer to the function to be run on
493 enabled APs of the system.
494 @param[in] SingleThread If TRUE, then all the enabled APs execute
495 the function specified by Procedure one by
496 one, in ascending order of processor handle
497 number. If FALSE, then all the enabled APs
498 execute the function specified by Procedure
499 simultaneously.
500 @param[in] ExcludeBsp Whether let BSP also trig this task.
501 @param[in] WaitEvent The event created by the caller with CreateEvent()
502 service.
503 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
504 APs to return from Procedure, either for
505 blocking or non-blocking mode.
506 @param[in] ProcedureArgument The parameter passed into Procedure for
507 all APs.
508 @param[out] FailedCpuList If all APs finish successfully, then its
509 content is set to NULL. If not all APs
510 finish before timeout expires, then its
511 content is set to address of the buffer
512 holding handle numbers of the failed APs.
513
514 @retval EFI_SUCCESS In blocking mode, all APs have finished before
515 the timeout expired.
516 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
517 to all enabled APs.
518 @retval others Failed to Startup all APs.
519
520 **/
521 EFI_STATUS
522 StartupAllCPUsWorker (
523 IN EFI_AP_PROCEDURE Procedure,
524 IN BOOLEAN SingleThread,
525 IN BOOLEAN ExcludeBsp,
526 IN EFI_EVENT WaitEvent OPTIONAL,
527 IN UINTN TimeoutInMicroseconds,
528 IN VOID *ProcedureArgument OPTIONAL,
529 OUT UINTN **FailedCpuList OPTIONAL
530 );
531
532 /**
533 Worker function to let the caller get one enabled AP to execute a caller-provided
534 function.
535
536 @param[in] Procedure A pointer to the function to be run on
537 enabled APs of the system.
538 @param[in] ProcessorNumber The handle number of the AP.
539 @param[in] WaitEvent The event created by the caller with CreateEvent()
540 service.
541 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
542 APs to return from Procedure, either for
543 blocking or non-blocking mode.
544 @param[in] ProcedureArgument The parameter passed into Procedure for
545 all APs.
546 @param[out] Finished If AP returns from Procedure before the
547 timeout expires, its content is set to TRUE.
548 Otherwise, the value is set to FALSE.
549
550 @retval EFI_SUCCESS In blocking mode, specified AP finished before
551 the timeout expires.
552 @retval others Failed to Startup AP.
553
554 **/
555 EFI_STATUS
556 StartupThisAPWorker (
557 IN EFI_AP_PROCEDURE Procedure,
558 IN UINTN ProcessorNumber,
559 IN EFI_EVENT WaitEvent OPTIONAL,
560 IN UINTN TimeoutInMicroseconds,
561 IN VOID *ProcedureArgument OPTIONAL,
562 OUT BOOLEAN *Finished OPTIONAL
563 );
564
565 /**
566 Worker function to switch the requested AP to be the BSP from that point onward.
567
568 @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
569 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
570 enabled AP. Otherwise, it will be disabled.
571
572 @retval EFI_SUCCESS BSP successfully switched.
573 @retval others Failed to switch BSP.
574
575 **/
576 EFI_STATUS
577 SwitchBSPWorker (
578 IN UINTN ProcessorNumber,
579 IN BOOLEAN EnableOldBSP
580 );
581
582 /**
583 Worker function to let the caller enable or disable an AP from this point onward.
584 This service may only be called from the BSP.
585
586 @param[in] ProcessorNumber The handle number of AP.
587 @param[in] EnableAP Specifies the new state for the processor for
588 enabled, FALSE for disabled.
589 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
590 the new health status of the AP.
591
592 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
593 @retval others Failed to Enable/Disable AP.
594
595 **/
596 EFI_STATUS
597 EnableDisableApWorker (
598 IN UINTN ProcessorNumber,
599 IN BOOLEAN EnableAP,
600 IN UINT32 *HealthFlag OPTIONAL
601 );
602
603 /**
604 Get pointer to CPU MP Data structure from GUIDed HOB.
605
606 @return The pointer to CPU MP Data structure.
607 **/
608 CPU_MP_DATA *
609 GetCpuMpDataFromGuidedHob (
610 VOID
611 );
612
613 /** Checks status of specified AP.
614
615 This function checks whether the specified AP has finished the task assigned
616 by StartupThisAP(), and whether timeout expires.
617
618 @param[in] ProcessorNumber The handle number of processor.
619
620 @retval EFI_SUCCESS Specified AP has finished task assigned by StartupThisAPs().
621 @retval EFI_TIMEOUT The timeout expires.
622 @retval EFI_NOT_READY Specified AP has not finished task and timeout has not expired.
623 **/
624 EFI_STATUS
625 CheckThisAP (
626 IN UINTN ProcessorNumber
627 );
628
629 /**
630 Checks status of all APs.
631
632 This function checks whether all APs have finished task assigned by StartupAllAPs(),
633 and whether timeout expires.
634
635 @retval EFI_SUCCESS All APs have finished task assigned by StartupAllAPs().
636 @retval EFI_TIMEOUT The timeout expires.
637 @retval EFI_NOT_READY APs have not finished task and timeout has not expired.
638 **/
639 EFI_STATUS
640 CheckAllAPs (
641 VOID
642 );
643
644 /**
645 Checks APs status and updates APs status if needed.
646
647 **/
648 VOID
649 CheckAndUpdateApsStatus (
650 VOID
651 );
652
653 /**
654 Detect whether specified processor can find matching microcode patch and load it.
655
656 @param[in] CpuMpData The pointer to CPU MP Data structure.
657 @param[in] ProcessorNumber The handle number of the processor. The range is
658 from 0 to the total number of logical processors
659 minus 1.
660 **/
661 VOID
662 MicrocodeDetect (
663 IN CPU_MP_DATA *CpuMpData,
664 IN UINTN ProcessorNumber
665 );
666
667 /**
668 Shadow the required microcode patches data into memory.
669
670 @param[in, out] CpuMpData The pointer to CPU MP Data structure.
671 **/
672 VOID
673 ShadowMicrocodeUpdatePatch (
674 IN OUT CPU_MP_DATA *CpuMpData
675 );
676
677 /**
678 Get the cached microcode patch base address and size from the microcode patch
679 information cache HOB.
680
681 @param[out] Address Base address of the microcode patches data.
682 It will be updated if the microcode patch
683 information cache HOB is found.
684 @param[out] RegionSize Size of the microcode patches data.
685 It will be updated if the microcode patch
686 information cache HOB is found.
687
688 @retval TRUE The microcode patch information cache HOB is found.
689 @retval FALSE The microcode patch information cache HOB is not found.
690
691 **/
692 BOOLEAN
693 GetMicrocodePatchInfoFromHob (
694 UINT64 *Address,
695 UINT64 *RegionSize
696 );
697
698 /**
699 Detect whether Mwait-monitor feature is supported.
700
701 @retval TRUE Mwait-monitor feature is supported.
702 @retval FALSE Mwait-monitor feature is not supported.
703 **/
704 BOOLEAN
705 IsMwaitSupport (
706 VOID
707 );
708
709 /**
710 Enable Debug Agent to support source debugging on AP function.
711
712 **/
713 VOID
714 EnableDebugAgent (
715 VOID
716 );
717
718 /**
719 Find the current Processor number by APIC ID.
720
721 @param[in] CpuMpData Pointer to PEI CPU MP Data
722 @param[out] ProcessorNumber Return the pocessor number found
723
724 @retval EFI_SUCCESS ProcessorNumber is found and returned.
725 @retval EFI_NOT_FOUND ProcessorNumber is not found.
726 **/
727 EFI_STATUS
728 GetProcessorNumber (
729 IN CPU_MP_DATA *CpuMpData,
730 OUT UINTN *ProcessorNumber
731 );
732
733 /**
734 This funtion will try to invoke platform specific microcode shadow logic to
735 relocate microcode update patches into memory.
736
737 @param[in, out] CpuMpData The pointer to CPU MP Data structure.
738
739 @retval EFI_SUCCESS Shadow microcode success.
740 @retval EFI_OUT_OF_RESOURCES No enough resource to complete the operation.
741 @retval EFI_UNSUPPORTED Can't find platform specific microcode shadow
742 PPI/Protocol.
743 **/
744 EFI_STATUS
745 PlatformShadowMicrocode (
746 IN OUT CPU_MP_DATA *CpuMpData
747 );
748
749 /**
750 Allocate the SEV-ES AP jump table buffer.
751
752 @param[in, out] CpuMpData The pointer to CPU MP Data structure.
753 **/
754 VOID
755 AllocateSevEsAPMemory (
756 IN OUT CPU_MP_DATA *CpuMpData
757 );
758
759 /**
760 Program the SEV-ES AP jump table buffer.
761
762 @param[in] SipiVector The SIPI vector used for the AP Reset
763 **/
764 VOID
765 SetSevEsJumpTable (
766 IN UINTN SipiVector
767 );
768
769 /**
770 The function puts the AP in halt loop.
771
772 @param[in] CpuMpData The pointer to CPU MP Data structure.
773 **/
774 VOID
775 SevEsPlaceApHlt (
776 CPU_MP_DATA *CpuMpData
777 );
778
779 /**
780 Check if the specified confidential computing attribute is active.
781
782 @retval TRUE The specified Attr is active.
783 @retval FALSE The specified Attr is not active.
784 **/
785 BOOLEAN
786 EFIAPI
787 ConfidentialComputingGuestHas (
788 CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr
789 );
790
791 #endif