Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OvmfPkg: Use TdHob instead of e820tables to get memory info in TDVF #6114

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions OvmfPkg/Library/PlatformInitLib/MemDetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ typedef VOID (*E820_SCAN_CALLBACK) (
EFI_HOB_PLATFORM_INFO *PlatformInfoHob
);

STATIC
EFI_STATUS
PlatformScanE820Tdx (
IN E820_SCAN_CALLBACK Callback,
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
)
{
EFI_E820_ENTRY64 E820Entry;
EFI_PEI_HOB_POINTERS Hob;

Hob.Raw = (UINT8 *)(UINTN)FixedPcdGet32 (PcdOvmfSecGhcbBase);

while (!END_OF_HOB_LIST (Hob)) {
if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
if ((Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_MEMORY_UNACCEPTED) ||
(Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY))
{
E820Entry.BaseAddr = Hob.ResourceDescriptor->PhysicalStart;
E820Entry.Length = Hob.ResourceDescriptor->ResourceLength;
E820Entry.Type = EfiAcpiAddressRangeMemory;
Callback (&E820Entry, PlatformInfoHob);
}
}

Hob.Raw = (UINT8 *)(Hob.Raw + Hob.Header->HobLength);
}

return EFI_SUCCESS;
}

/**
Store first address not used by e820 RAM entries in
PlatformInfoHob->FirstNonAddress
Expand Down Expand Up @@ -347,6 +377,10 @@ PlatformScanE820 (
return PlatformScanE820Pvh (Callback, PlatformInfoHob);
}

if (TdIsEnabled ()) {
return PlatformScanE820Tdx (Callback, PlatformInfoHob);
}

Status = QemuFwCfgFindFile ("etc/e820", &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) {
return Status;
Expand Down
Loading