#include <Library/HobLib.h>\r
#include <Protocol/Cpu.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
+#include <ConfidentialComputingGuestAttr.h>\r
#include <IndustryStandard/Tdx.h>\r
#include <Library/PlatformInitLib.h>\r
#include <Library/TdxLib.h>\r
#include <TdxAcpiTable.h>\r
#include <Library/MemEncryptTdxLib.h>\r
\r
+VOID\r
+SetPcdSettings (\r
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob\r
+ )\r
+{\r
+ RETURN_STATUS PcdStatus;\r
+\r
+ PcdStatus = PcdSet64S (PcdConfidentialComputingGuestAttr, PlatformInfoHob->PcdConfidentialComputingGuestAttr);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSetBoolS (PcdSetNxForStack, PlatformInfoHob->PcdSetNxForStack);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "HostBridgeDevId=0x%x, CCAttr=0x%x, SetNxForStack=%x\n",\r
+ PlatformInfoHob->HostBridgeDevId,\r
+ PlatformInfoHob->PcdConfidentialComputingGuestAttr,\r
+ PlatformInfoHob->PcdSetNxForStack\r
+ ));\r
+\r
+ PcdStatus = PcdSet32S (PcdCpuBootLogicalProcessorNumber, PlatformInfoHob->PcdCpuBootLogicalProcessorNumber);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet32S (PcdCpuMaxLogicalProcessorNumber, PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "MaxCpuCount=0x%x, BootCpuCount=0x%x\n",\r
+ PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber,\r
+ PlatformInfoHob->PcdCpuBootLogicalProcessorNumber\r
+ ));\r
+\r
+ if (TdIsEnabled ()) {\r
+ PcdStatus = PcdSet64S (PcdTdxSharedBitMask, TdSharedPageMask ());\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ DEBUG ((DEBUG_INFO, "TdxSharedBitMask=0x%llx\n", PcdGet64 (PcdTdxSharedBitMask)));\r
+ } else {\r
+ PcdStatus = PcdSet64S (PcdPciMmio64Base, PlatformInfoHob->PcdPciMmio64Base);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciMmio64Size, PlatformInfoHob->PcdPciMmio64Size);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciMmio32Base, PlatformInfoHob->PcdPciMmio32Base);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciMmio32Size, PlatformInfoHob->PcdPciMmio32Size);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciIoBase, PlatformInfoHob->PcdPciIoBase);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ PcdStatus = PcdSet64S (PcdPciIoSize, PlatformInfoHob->PcdPciIoSize);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
+ }\r
+}\r
+\r
/**\r
Location of resource hob matching type and starting address\r
\r
PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, PlatformInfo->HostBridgeDevId);\r
ASSERT_RETURN_ERROR (PcdStatus);\r
\r
+ #ifdef TDX_PEI_LESS_BOOT\r
+ //\r
+ // For Pei-less boot, PlatformInfo contains more information and\r
+ // need to set PCDs based on these information.\r
+ //\r
+ SetPcdSettings (PlatformInfo);\r
+ #endif\r
+\r
if (!TdIsEnabled ()) {\r
- return EFI_UNSUPPORTED;\r
+ //\r
+ // If it is Non-Td guest, we're done.\r
+ //\r
+ return EFI_SUCCESS;\r
}\r
\r
SetMmioSharedBit ();\r