@@ -156,17 +156,22 @@ DeclareDram (
DramDescriptor = *VirtualMemoryTable + ARRAY_SIZE (mVirtualMemoryTable);
- for (Idx = 0; Idx < RegionCount; Idx++, DramDescriptor++) {
+ for (Idx = 0; Idx < RegionCount; Idx++) {
Status = DramInfo->GetRegion (Idx, &Base, &Size);
ASSERT_EFI_ERROR (Status);
BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY,
mDramResourceAttributes, Base, Size);
+ if (Base > MAX_ALLOC_ADDRESS - Size + 1) {
+ continue;
+ }
+
DramDescriptor->PhysicalBase = Base;
DramDescriptor->VirtualBase = Base;
- DramDescriptor->Length = Size;
+ DramDescriptor->Length = MIN (Size, MAX_ALLOC_ADDRESS - Base + 1);
DramDescriptor->Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+ DramDescriptor++;
}
DramDescriptor->PhysicalBase = 0;
When encountering memory that is above the threshold of what we can map, don't add it to the virtual memory table. This table is only used by the early MMU code that creates the 1:1 mapping, and since it cannot be mapped in the first place, there is no point. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- Silicon/Socionext/SynQuacer/Library/SynQuacerMemoryInitPeiLib/SynQuacerMemoryInitPeiLib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel