]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/Mmu: Fix page level calculation bug
authorHeyi Guo <heyi.guo@linaro.org>
Wed, 9 Sep 2015 13:37:22 +0000 (13:37 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Wed, 9 Sep 2015 13:37:22 +0000 (13:37 +0000)
The bug can be triggered when alignment of Base is larger than Length
by 2 level of page granularity, e.g.

Base is 0x4000_0000, Length is 0x1000

The original code will change 2MB page level and we will get a
negative remaining length.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18422 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

index a7f374531a25d34a8f8149d8f97c8a52fc2f4e53..5b6c4537b552b3dc775d937bbc46078c0bb84f37 100644 (file)
@@ -314,7 +314,7 @@ GetBlockEntryListFromAddress (
   // If the required size is smaller than the current block size then we need to go to the page below.\r
   // The PageLevel was calculated on the Base Address alignment but did not take in account the alignment\r
   // of the allocation size\r
-  if (*BlockEntrySize < TT_BLOCK_ENTRY_SIZE_AT_LEVEL (PageLevel)) {\r
+  while (*BlockEntrySize < TT_BLOCK_ENTRY_SIZE_AT_LEVEL (PageLevel)) {\r
     // It does not fit so we need to go a page level above\r
     PageLevel++;\r
   }\r