From 55df704dd24928b60b10bbb9dec5bfa7682910de Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 18 Nov 2015 16:18:40 +0000 Subject: ArmPkg/ArmV7Mmu: handle memory regions over 4 GB correctly The ARM_MEMORY_REGION_DESCRIPTOR array provided by the platform may contain entries that extend beyond the 4 GB boundary, above which we can't map anything on 32-bit ARM. If this is the case, map only the 1:1 addressable part. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18900 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c | 11 +++++++++-- 1 file 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); -- cgit v1.1