]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib/AArch64: Fixed the calculation of the last entry in the Translation...
authorOlivier Martin <olivier.martin@arm.com>
Wed, 24 Jul 2013 11:50:31 +0000 (11:50 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 24 Jul 2013 11:50:31 +0000 (11:50 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14500 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

index 8abc73a2541ae457180c5940a0ebd2cb2e6ca0c8..05b2a197d5af59f247e9f58fad687b3cb698e54b 100644 (file)
@@ -273,13 +273,13 @@ GetBlockEntryListFromAddress (
   ASSERT ((*BlockEntrySize & (SIZE_4KB - 1)) == 0);\r
 \r
   //\r
-  // Calculate LastBlockEntry from T0SZ\r
+  // Calculate LastBlockEntry from T0SZ - this is the last block entry of the root Translation table\r
   //\r
   T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;\r
   // Get the Table info from T0SZ\r
   GetRootTranslationTableInfo (T0SZ, &RootTableLevel, &RootTableEntryCount);\r
   // The last block of the root table depends on the number of entry in this table\r
-  *LastBlockEntry = (UINT64*)((UINTN)RootTable + (RootTableEntryCount * sizeof(UINT64)));\r
+  *LastBlockEntry = (UINT64*)((UINTN)RootTable + ((RootTableEntryCount - 1) * sizeof(UINT64)));\r
 \r
   // If the start address is 0x0 then we use the size of the region to identify the alignment\r
   if (RegionStart == 0) {\r
@@ -331,7 +331,7 @@ GetBlockEntryListFromAddress (
         BlockEntry = (UINT64*)TT_GET_ENTRY_FOR_ADDRESS (TranslationTable, IndexLevel + 1, RegionStart);\r
 \r
         // Set the last block for this new table\r
-        *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + (TT_ENTRY_COUNT * sizeof(UINT64)));\r
+        *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));\r
       }\r
     } else if ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) {\r
       // If we are not at the last level then we need to split this BlockEntry\r
@@ -373,6 +373,8 @@ GetBlockEntryListFromAddress (
 \r
         // Fill the new BlockEntry with the TranslationTable\r
         *BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY;\r
+        // Update the last block entry with the newly created translation table\r
+        *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));\r
 \r
         // Populate the newly created lower level table\r
         BlockEntry = TranslationTable;\r