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

UefiCpuPkg/PiSmmCpuDxeSmm:Check resource HOB range before mapping #6431

Merged
merged 2 commits into from
Nov 25, 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
10 changes: 10 additions & 0 deletions UefiCpuPkg/PiSmmCpuDxeSmm/NonMmramMapStandaloneMm.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ BuildMemoryMapFromResDescHobs (
EFI_PEI_HOB_POINTERS Hob;
UINTN Count;
UINTN Index;
EFI_PHYSICAL_ADDRESS MaxPhysicalAddress;
EFI_PHYSICAL_ADDRESS ResourceHobEnd;

ASSERT (MemoryRegion != NULL && MemoryRegionCount != NULL);

*MemoryRegion = NULL;
*MemoryRegionCount = 0;
MaxPhysicalAddress = LShiftU64 (1, mPhysicalAddressBits);

//
// Get the count.
Expand All @@ -138,6 +141,13 @@ BuildMemoryMapFromResDescHobs (
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);
while (Hob.Raw != NULL) {
if ((Hob.ResourceDescriptor->ResourceAttribute & MM_RESOURCE_ATTRIBUTE_LOGGING) == 0) {
ResourceHobEnd = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength;

ASSERT (ResourceHobEnd <= MaxPhysicalAddress);
if (ResourceHobEnd > MaxPhysicalAddress) {
CpuDeadLoop ();
}

//
// Resource HOBs describe all accessible non-smram regions.
// Logging attribute range is treated as not present. Not-present ranges are not included in this memory map.
Expand Down
Loading