summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c b/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c
index b2cfdba..2e39ce0 100644
--- a/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c
+++ b/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c
@@ -147,11 +147,18 @@ FillTranslationTable (
{
UINT32 *SectionEntry;
UINT32 Attributes;
- UINT32 PhysicalBase = MemoryRegion->PhysicalBase;
- UINT32 RemainLength = MemoryRegion->Length;
+ UINT32 PhysicalBase;
+ UINT32 RemainLength;
ASSERT(MemoryRegion->Length > 0);
+ if (MemoryRegion->PhysicalBase >= SIZE_4GB) {
+ return;
+ }
+
+ PhysicalBase = MemoryRegion->PhysicalBase;
+ RemainLength = MIN(MemoryRegion->Length, SIZE_4GB - PhysicalBase);
+
switch (MemoryRegion->Attributes) {
case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK:
Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0);