summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Library/ArmMmuLib
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2019-01-28 17:23:32 +0100
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2019-01-28 20:01:45 +0100
commit66509f90fc6636f22e4ea9d6d11655b2f9268b91 (patch)
tree9620259bb445faf0e45849881001d9dcb0c8eb80 /ArmPkg/Library/ArmMmuLib
parent9a00a7164a39467efe7e934e2777377714655e13 (diff)
downloadedk2-66509f90fc6636f22e4ea9d6d11655b2f9268b91.tar.gz
edk2-66509f90fc6636f22e4ea9d6d11655b2f9268b91.tar.bz2
edk2-66509f90fc6636f22e4ea9d6d11655b2f9268b91.zip
ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them
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>
Diffstat (limited to 'ArmPkg/Library/ArmMmuLib')
-rw-r--r--ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
index bffab83d4f..baa085c384 100644
--- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c
@@ -744,10 +744,11 @@ ArmSetMemoryAttributes (
UINT64 ChunkLength;
BOOLEAN FlushTlbs;
- if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) {
+ if (BaseAddress > (UINT64)MAX_ADDRESS) {
return EFI_UNSUPPORTED;
}
+ Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1);
if (Length == 0) {
return EFI_SUCCESS;
}