2022-01-20 04:04:17 +01:00
|
|
|
/** @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>
|
2023-02-03 04:31:46 +01:00
|
|
|
#include <Library/TdxHelperLib.h>
|
2022-01-20 04:04:17 +01:00
|
|
|
#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 (
|
2024-07-01 11:49:03 +02:00
|
|
|
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
2022-01-20 04:04:17 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
#ifdef MDE_CPU_X64
|
|
|
|
RETURN_STATUS PcdStatus;
|
2024-07-01 11:49:03 +02:00
|
|
|
UINT64 PageMask;
|
2022-01-20 04:04:17 +01:00
|
|
|
|
|
|
|
if (!TdIsEnabled ()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-03 04:31:46 +01:00
|
|
|
TdxHelperBuildGuidHobForTdxMeasurement ();
|
|
|
|
|
2022-01-20 04:04:17 +01:00
|
|
|
PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, CCAttrIntelTdx);
|
|
|
|
ASSERT_RETURN_ERROR (PcdStatus);
|
|
|
|
|
2024-07-01 11:49:03 +02:00
|
|
|
PlatformInfoHob->PcdConfidentialComputingGuestAttr = CCAttrIntelTdx;
|
|
|
|
|
|
|
|
PageMask = TdSharedPageMask ();
|
|
|
|
PcdStatus = PcdSet64S (PcdTdxSharedBitMask, PageMask);
|
2022-01-20 04:04:17 +01:00
|
|
|
ASSERT_RETURN_ERROR (PcdStatus);
|
|
|
|
|
2024-07-01 11:49:03 +02:00
|
|
|
PlatformInfoHob->PcdTdxSharedBitMask = PageMask;
|
|
|
|
|
2022-01-20 04:04:17 +01:00
|
|
|
PcdStatus = PcdSetBoolS (PcdSetNxForStack, TRUE);
|
|
|
|
ASSERT_RETURN_ERROR (PcdStatus);
|
|
|
|
#endif
|
|
|
|
}
|