]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 28 Jan 2019 16:23:32 +0000 (17:23 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 28 Jan 2019 19:01:45 +0000 (20:01 +0100)
ArmSetMemoryAttributes() still chokes in some cases, i.e., when the
length of the region exceeds 4 GB, the subtraction overflows, which
results in the region being misidentified as being 32-bit addressable.

Let's update the logic to trim the length to what we can address with
32 bits. This fixes the issue, and also deals with the issue where an
entire region is disregarded if part of it exceeds beyond what we can
map with 32 bits.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c

index bffab83d4fd0bbe1571fbab9ca3ae0c879a6357b..baa085c3849a9279e175ca8443531a8597eda048 100644 (file)
@@ -744,10 +744,11 @@ ArmSetMemoryAttributes (
   UINT64        ChunkLength;\r
   BOOLEAN       FlushTlbs;\r
 \r
-  if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) {\r
+  if (BaseAddress > (UINT64)MAX_ADDRESS) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);\r
   if (Length == 0) {\r
     return EFI_SUCCESS;\r
   }\r