UefiCpuPkg/PiSmmCpuDxeSmm:Check resource HOB range before mapping

This commit is to check if the resource HOB range does not
exceed the max supported physical address.
The function BuildMemoryMapFromResDescHobs is to build Memory
Region from resource HOBs. Then the memory maps will be used
during creating or modifying SMM page table. If the resource
HOB range exceeds the max supported physical address, then
subsequent calling of PageTableMap() will fail.

Signed-off-by: Dun Tan <dun.tan@intel.com>
This commit is contained in:
Dun Tan 2024-11-22 11:17:35 +08:00 committed by mergify[bot]
parent 065df32de3
commit 468b3d9589
1 changed files with 10 additions and 0 deletions

View File

@ -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.
@ -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.