mirror of
https://github.com/acidanthera/audk.git
synced 2025-09-25 18:48:42 +02:00
UefiCpuPkg, OvmfPkg: Eliminated dependencies of PeiMpInitLib, DxeMpInitLib
from DynamicPcds: PcdCpuMaxLogicalProcessorNumber, PcdCpuBootLogicalProcessorNumber, PcdGhcbBase, PcdConfidentialComputingGuestAttr. This information is now obtained from EFI_HOB_PLATFORM_INFO directly.
This commit is contained in:
parent
c810b25601
commit
28743ca0ee
@ -55,6 +55,8 @@ typedef struct {
|
||||
BOOLEAN QemuFwCfgChecked;
|
||||
BOOLEAN QemuFwCfgSupported;
|
||||
BOOLEAN QemuFwCfgDmaSupported;
|
||||
|
||||
UINT64 GhcbBase;
|
||||
} EFI_HOB_PLATFORM_INFO;
|
||||
#pragma pack()
|
||||
|
||||
|
@ -258,6 +258,9 @@ AmdSevEsInitialize (
|
||||
|
||||
Status = PcdSet64S (PcdGhcbBase, GhcbBasePa);
|
||||
ASSERT_RETURN_ERROR (Status);
|
||||
|
||||
PlatformInfoHob->GhcbBase = GhcbBasePa;
|
||||
|
||||
Status = PcdSet64S (PcdGhcbSize, EFI_PAGES_TO_SIZE (GhcbPageCount));
|
||||
ASSERT_RETURN_ERROR (Status);
|
||||
|
||||
@ -428,10 +431,13 @@ AmdSevInitialize (
|
||||
//
|
||||
if (MemEncryptSevSnpIsEnabled ()) {
|
||||
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrAmdSevSnp);
|
||||
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrAmdSevSnp;
|
||||
} else if (MemEncryptSevEsIsEnabled ()) {
|
||||
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrAmdSevEs);
|
||||
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrAmdSevEs;
|
||||
} else {
|
||||
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrAmdSev);
|
||||
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrAmdSev;
|
||||
}
|
||||
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
@ -30,7 +30,7 @@
|
||||
**/
|
||||
VOID
|
||||
IntelTdxInitialize (
|
||||
VOID
|
||||
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||
)
|
||||
{
|
||||
#ifdef MDE_CPU_X64
|
||||
@ -45,6 +45,8 @@ IntelTdxInitialize (
|
||||
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrIntelTdx);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrIntelTdx;
|
||||
|
||||
PcdStatus = PcdSet64S (PcdTdxSharedBitMask, TdSharedPageMask ());
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
|
@ -395,7 +395,7 @@ InitializePlatform (
|
||||
MiscInitialization (PlatformInfoHob);
|
||||
}
|
||||
|
||||
IntelTdxInitialize ();
|
||||
IntelTdxInitialize (PlatformInfoHob);
|
||||
InstallFeatureControlCallback (PlatformInfoHob);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -90,7 +90,7 @@ AmdSevInitialize (
|
||||
**/
|
||||
VOID
|
||||
IntelTdxInitialize (
|
||||
VOID
|
||||
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,7 @@
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
OvmfPkg/OvmfPkg.dec
|
||||
UefiCpuPkg/UefiCpuPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
@ -64,10 +65,9 @@
|
||||
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
|
||||
gEfiEventLegacyBootGuid ## SOMETIMES_CONSUMES ## Event
|
||||
gEdkiiMicrocodePatchHobGuid ## SOMETIMES_CONSUMES ## HOB
|
||||
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES ## HOB
|
||||
|
||||
[Pcd]
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOMETIMES_CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES
|
||||
@ -78,5 +78,3 @@
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase ## SOMETIMES_CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr ## CONSUMES
|
||||
|
@ -9,11 +9,15 @@
|
||||
**/
|
||||
|
||||
#include "MpLib.h"
|
||||
|
||||
#include <Library/CcExitLib.h>
|
||||
#include <Library/PlatformInitLib.h>
|
||||
|
||||
#include <Register/Amd/Fam17Msr.h>
|
||||
#include <Register/Amd/Ghcb.h>
|
||||
|
||||
EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;
|
||||
EFI_HOB_PLATFORM_INFO *mPlatformInfoHob = NULL;
|
||||
|
||||
/**
|
||||
Save the volatile registers required to be restored following INIT IPI.
|
||||
@ -521,7 +525,7 @@ CollectProcessorCount (
|
||||
// FinishedCount is the number of check-in APs.
|
||||
//
|
||||
CpuMpData->CpuCount = CpuMpData->FinishedCount + 1;
|
||||
ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
|
||||
ASSERT (CpuMpData->CpuCount <= mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber);
|
||||
|
||||
//
|
||||
// Enable x2APIC mode if
|
||||
@ -1093,7 +1097,7 @@ AllocateResetVectorBelow1Mb (
|
||||
// of processors for calculating the total stack area.
|
||||
//
|
||||
ApResetStackSize = (AP_RESET_STACK_SIZE *
|
||||
PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
|
||||
mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber);
|
||||
|
||||
//
|
||||
// Invoke GetWakeupBuffer a second time to allocate the stack area
|
||||
@ -1238,7 +1242,7 @@ WakeUpAP (
|
||||
}
|
||||
|
||||
if (CpuMpData->InitFlag == ApInitConfig) {
|
||||
if (PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) {
|
||||
if (mPlatformInfoHob->PcdCpuBootLogicalProcessorNumber > 0) {
|
||||
//
|
||||
// The AP enumeration algorithm below is suitable only when the
|
||||
// platform can tell us the *exact* boot CPU count in advance.
|
||||
@ -1254,7 +1258,7 @@ WakeUpAP (
|
||||
//
|
||||
TimedWaitForApFinish (
|
||||
CpuMpData,
|
||||
PcdGet32 (PcdCpuBootLogicalProcessorNumber) - 1,
|
||||
mPlatformInfoHob->PcdCpuBootLogicalProcessorNumber - 1,
|
||||
MAX_UINT32 // approx. 71 minutes
|
||||
);
|
||||
} else {
|
||||
@ -1292,7 +1296,7 @@ WakeUpAP (
|
||||
//
|
||||
TimedWaitForApFinish (
|
||||
CpuMpData,
|
||||
PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,
|
||||
mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber - 1,
|
||||
PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)
|
||||
);
|
||||
|
||||
@ -1821,10 +1825,16 @@ MpInitLibInitialize (
|
||||
UINTN ApResetVectorSizeAbove1Mb;
|
||||
UINTN BackupBufferAddr;
|
||||
UINTN ApIdtBase;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
|
||||
GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
|
||||
if (GuidHob != NULL) {
|
||||
mPlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)(GET_GUID_HOB_DATA (GuidHob));
|
||||
}
|
||||
|
||||
OldCpuMpData = GetCpuMpDataFromGuidedHob ();
|
||||
if (OldCpuMpData == NULL) {
|
||||
MaxLogicalProcessorNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
|
||||
MaxLogicalProcessorNumber = mPlatformInfoHob->PcdCpuMaxLogicalProcessorNumber;
|
||||
} else {
|
||||
MaxLogicalProcessorNumber = OldCpuMpData->CpuCount;
|
||||
}
|
||||
@ -1901,7 +1911,7 @@ MpInitLibInitialize (
|
||||
CpuMpData->SevEsIsEnabled = ConfidentialComputingGuestHas (CCAttrAmdSevEs);
|
||||
CpuMpData->SevSnpIsEnabled = ConfidentialComputingGuestHas (CCAttrAmdSevSnp);
|
||||
CpuMpData->SevEsAPBuffer = (UINTN)-1;
|
||||
CpuMpData->GhcbBase = PcdGet64 (PcdGhcbBase);
|
||||
CpuMpData->GhcbBase = mPlatformInfoHob->GhcbBase;
|
||||
CpuMpData->UseSevEsAPMethod = CpuMpData->SevEsIsEnabled && !CpuMpData->SevSnpIsEnabled;
|
||||
|
||||
if (CpuMpData->SevSnpIsEnabled) {
|
||||
@ -2887,7 +2897,7 @@ ConfidentialComputingGuestHas (
|
||||
//
|
||||
// Get the current CC attribute.
|
||||
//
|
||||
CurrentAttr = PcdGet64 (PcdConfidentialComputingGuestAttr);
|
||||
CurrentAttr = mPlatformInfoHob->PcdConfidentialComputingGuestAttr;
|
||||
|
||||
//
|
||||
// If attr is for the AMD group then call AMD specific checks.
|
||||
|
@ -39,8 +39,9 @@
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
UefiCpuPkg/UefiCpuPkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
OvmfPkg/OvmfPkg.dec
|
||||
UefiCpuPkg/UefiCpuPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
@ -57,8 +58,6 @@
|
||||
MicrocodeLib
|
||||
|
||||
[Pcd]
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOMETIMES_CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONSUMES
|
||||
@ -67,8 +66,6 @@
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## SOMETIMES_CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase ## SOMETIMES_CONSUMES
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures ## CONSUMES
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ## CONSUMES
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr ## CONSUMES
|
||||
|
||||
[Ppis]
|
||||
gEdkiiPeiShadowMicrocodePpiGuid ## SOMETIMES_CONSUMES
|
||||
@ -76,3 +73,4 @@
|
||||
[Guids]
|
||||
gEdkiiS3SmmInitDoneGuid
|
||||
gEdkiiMicrocodePatchHobGuid
|
||||
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES ## HOB
|
||||
|
Loading…
x
Reference in New Issue
Block a user