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