mirror of https://github.com/acidanthera/audk.git
OvmfPkg: Update PlatformPei to support Tdx guest
RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 OvmfPkg/PlatformPei is updated to support Tdx guest. There are below major changes. - Set Tdx related PCDs - Publish Tdx RamRegions In this patch there is another new function BuildPlatformInfoHob (). This function builds EFI_HOB_PLATFORM_INFO which contains the HostBridgeDevId. The hob is built in both Td guest and Non-Td guest. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
This commit is contained in:
parent
e23f8f52fd
commit
cf17156d7d
|
@ -133,6 +133,7 @@
|
|||
gGrubFileGuid = {0xb5ae312c, 0xbc8a, 0x43b1, {0x9c, 0x62, 0xeb, 0xb8, 0x26, 0xdd, 0x5d, 0x07}}
|
||||
gConfidentialComputingSecretGuid = {0xadf956ad, 0xe98c, 0x484c, {0xae, 0x11, 0xb5, 0x1c, 0x7d, 0x33, 0x64, 0x47}}
|
||||
gConfidentialComputingSevSnpBlobGuid = {0x067b1f5f, 0xcf26, 0x44c5, {0x85, 0x54, 0x93, 0xd7, 0x77, 0x91, 0x2d, 0x42}}
|
||||
gUefiOvmfPkgPlatformInfoGuid = {0xdec9b486, 0x1f16, 0x47c7, {0x8f, 0x68, 0xdf, 0x1a, 0x41, 0x88, 0x8b, 0xa5}}
|
||||
|
||||
[Ppis]
|
||||
# PPI whose presence in the PPI database signals that the TPM base address
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <Library/QemuFwCfgLib.h>
|
||||
#include <Ppi/MpServices.h>
|
||||
#include <Register/ArchitecturalMsr.h>
|
||||
#include <IndustryStandard/Tdx.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -37,7 +38,11 @@ WriteFeatureControl (
|
|||
IN OUT VOID *WorkSpace
|
||||
)
|
||||
{
|
||||
AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, mFeatureControlValue);
|
||||
if (TdIsEnabled ()) {
|
||||
TdVmCall (TDVMCALL_WRMSR, (UINT64)MSR_IA32_FEATURE_CONTROL, mFeatureControlValue, 0, 0, 0);
|
||||
} else {
|
||||
AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, mFeatureControlValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/** @file
|
||||
Initialize Intel TDX support.
|
||||
|
||||
Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <IndustryStandard/Tdx.h>
|
||||
#include <IndustryStandard/QemuFwCfg.h>
|
||||
#include <Library/QemuFwCfgLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/TdxLib.h>
|
||||
#include <Library/PlatformInitLib.h>
|
||||
#include <WorkArea.h>
|
||||
#include <ConfidentialComputingGuestAttr.h>
|
||||
#include "Platform.h"
|
||||
|
||||
/**
|
||||
This Function checks if TDX is available, if present then it sets
|
||||
the dynamic PCDs for Tdx guest.
|
||||
**/
|
||||
VOID
|
||||
IntelTdxInitialize (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
#ifdef MDE_CPU_X64
|
||||
RETURN_STATUS PcdStatus;
|
||||
|
||||
if (!TdIsEnabled ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrIntelTdx);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
PcdStatus = PcdSet64S (PcdTdxSharedBitMask, TdSharedPageMask ());
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
PcdStatus = PcdSetBoolS (PcdSetNxForStack, TRUE);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
#endif
|
||||
}
|
|
@ -37,7 +37,6 @@ Module Name:
|
|||
|
||||
#include <Library/QemuFwCfgLib.h>
|
||||
#include <Library/QemuFwCfgSimpleParserLib.h>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
VOID
|
||||
|
@ -231,7 +230,12 @@ GetPeiMemoryCap (
|
|||
PdpEntries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 30);
|
||||
ASSERT (PdpEntries <= 0x200);
|
||||
} else {
|
||||
Pml4Entries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 39);
|
||||
if (mPlatformInfoHob.PhysMemAddressWidth > 48) {
|
||||
Pml4Entries = 0x200;
|
||||
} else {
|
||||
Pml4Entries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 39);
|
||||
}
|
||||
|
||||
ASSERT (Pml4Entries <= 0x200);
|
||||
PdpEntries = 512;
|
||||
}
|
||||
|
@ -354,6 +358,11 @@ InitializeRamRegions (
|
|||
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||
)
|
||||
{
|
||||
if (TdIsEnabled ()) {
|
||||
PlatformTdxPublishRamRegions ();
|
||||
return;
|
||||
}
|
||||
|
||||
PlatformQemuInitializeRam (PlatformInfoHob);
|
||||
|
||||
SevInitializeRam ();
|
||||
|
|
|
@ -310,6 +310,17 @@ MaxCpuCountInitialization (
|
|||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Builds PlatformInfo Hob
|
||||
*/
|
||||
VOID
|
||||
BuildPlatformInfoHob (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &mPlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO));
|
||||
}
|
||||
|
||||
/**
|
||||
Perform Platform PEI initialization.
|
||||
|
||||
|
@ -386,7 +397,9 @@ InitializePlatform (
|
|||
MiscInitialization (&mPlatformInfoHob);
|
||||
}
|
||||
|
||||
IntelTdxInitialize ();
|
||||
InstallFeatureControlCallback ();
|
||||
BuildPlatformInfoHob ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <IndustryStandard/E820.h>
|
||||
#include <Library/PlatformInitLib.h>
|
||||
#include <IndustryStandard/IntelTdx.h>
|
||||
|
||||
extern EFI_HOB_PLATFORM_INFO mPlatformInfoHob;
|
||||
|
||||
|
@ -84,6 +85,24 @@ AmdSevInitialize (
|
|||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
This Function checks if TDX is available, if present then it sets
|
||||
the dynamic PCDs for Tdx guest. It also builds Guid hob which contains
|
||||
the Host Bridge DevId.
|
||||
**/
|
||||
VOID
|
||||
IntelTdxInitialize (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Builds PlatformInfo Hob
|
||||
*/
|
||||
VOID
|
||||
BuildPlatformInfoHob (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
SevInitializeRam (
|
||||
VOID
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
MemTypeInfo.c
|
||||
Platform.c
|
||||
Platform.h
|
||||
IntelTdx.c
|
||||
|
||||
[Packages]
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
|
@ -43,6 +44,7 @@
|
|||
[Guids]
|
||||
gEfiMemoryTypeInformationGuid
|
||||
gFdtHobGuid
|
||||
gUefiOvmfPkgPlatformInfoGuid
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
|
@ -111,6 +113,7 @@
|
|||
gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled
|
||||
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr
|
||||
gUefiCpuPkgTokenSpaceGuid.PcdGhcbHypervisorFeatures
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdTdxSharedBitMask
|
||||
|
||||
[FixedPcd]
|
||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfCpuidBase
|
||||
|
|
Loading…
Reference in New Issue