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