VOID\r
);\r
\r
+/**\r
+ In Tdx guest, the system memory is passed in TdHob by host VMM. So\r
+ the major task of PlatformTdxPublishRamRegions is to walk thru the\r
+ TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob\r
+ to the hobs in DXE phase.\r
+\r
+ MemoryAllocationHob should also be created for Mailbox and Ovmf work area.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformTdxPublishRamRegions (\r
+ VOID\r
+ );\r
+\r
#endif // PLATFORM_INIT_LIB_H_\r
Hob.Raw = GET_NEXT_HOB (Hob);\r
}\r
}\r
+\r
+/**\r
+ In Tdx guest, the system memory is passed in TdHob by host VMM. So\r
+ the major task of PlatformTdxPublishRamRegions is to walk thru the\r
+ TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob\r
+ to the hobs in DXE phase.\r
+\r
+ MemoryAllocationHob should also be created for Mailbox and Ovmf work area.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformTdxPublishRamRegions (\r
+ VOID\r
+ )\r
+{\r
+ if (!TdIsEnabled ()) {\r
+ return;\r
+ }\r
+\r
+ TransferTdxHobList ();\r
+\r
+ //\r
+ // The memory region defined by PcdOvmfSecGhcbBackupBase is pre-allocated by\r
+ // host VMM and used as the td mailbox at the beginning of system boot.\r
+ //\r
+ BuildMemoryAllocationHob (\r
+ FixedPcdGet32 (PcdOvmfSecGhcbBackupBase),\r
+ FixedPcdGet32 (PcdOvmfSecGhcbBackupSize),\r
+ EfiACPIMemoryNVS\r
+ );\r
+\r
+ if (FixedPcdGet32 (PcdOvmfWorkAreaSize) != 0) {\r
+ //\r
+ // Reserve the work area.\r
+ //\r
+ // Since this memory range will be used by the Reset Vector on S3\r
+ // resume, it must be reserved as ACPI NVS.\r
+ //\r
+ // If S3 is unsupported, then various drivers might still write to the\r
+ // work area. We ought to prevent DXE from serving allocation requests\r
+ // such that they would overlap the work area.\r
+ //\r
+ BuildMemoryAllocationHob (\r
+ (EFI_PHYSICAL_ADDRESS)(UINTN)FixedPcdGet32 (PcdOvmfWorkAreaBase),\r
+ (UINT64)(UINTN)FixedPcdGet32 (PcdOvmfWorkAreaSize),\r
+ EfiBootServicesData\r
+ );\r
+ }\r
+}\r
{\r
return EFI_UNSUPPORTED;\r
}\r
+\r
+/**\r
+ In Tdx guest, the system memory is passed in TdHob by host VMM. So\r
+ the major task of PlatformTdxPublishRamRegions is to walk thru the\r
+ TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob\r
+ to the hobs in DXE phase.\r
+\r
+ MemoryAllocationHob should also be created for Mailbox and Ovmf work area.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformTdxPublishRamRegions (\r
+ VOID\r
+ )\r
+{\r
+}\r
#include <Library/MtrrLib.h>\r
#include <Library/QemuFwCfgLib.h>\r
#include <Library/QemuFwCfgSimpleParserLib.h>\r
+#include <Library/TdxLib.h>\r
+\r
#include <Library/PlatformInitLib.h>\r
\r
VOID\r
PhysMemAddressWidth = 36;\r
}\r
\r
+ #if defined (MDE_CPU_X64)\r
+ if (TdIsEnabled ()) {\r
+ if (TdSharedPageMask () == (1ULL << 47)) {\r
+ PhysMemAddressWidth = 48;\r
+ } else {\r
+ PhysMemAddressWidth = 52;\r
+ }\r
+ }\r
+\r
+ ASSERT (PhysMemAddressWidth <= 52);\r
+ #else\r
ASSERT (PhysMemAddressWidth <= 48);\r
+ #endif\r
\r
PlatformInfoHob->FirstNonAddress = FirstNonAddress;\r
PlatformInfoHob->PhysMemAddressWidth = PhysMemAddressWidth;\r
//\r
// Video memory + Legacy BIOS region\r
//\r
- PlatformAddIoMemoryRangeHob (0x0A0000, BASE_1MB);\r
+ if (!TdIsEnabled ()) {\r
+ PlatformAddIoMemoryRangeHob (0x0A0000, BASE_1MB);\r
+ }\r
\r
if (PlatformInfoHob->HostBridgeDevId == 0xffff /* microvm */) {\r
PlatformAddIoMemoryBaseSizeHob (MICROVM_GED_MMIO_BASE, SIZE_4KB);\r