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
ASSERT ((*BlockEntrySize & (SIZE_4KB - 1)) == 0);\r
\r
//\r
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
//\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
\r
// If the start address is 0x0 then we use the size of the region to identify the alignment\r
if (RegionStart == 0) {\r
BlockEntry = (UINT64*)TT_GET_ENTRY_FOR_ADDRESS (TranslationTable, IndexLevel + 1, RegionStart);\r
\r
// Set the last block for this new table\r
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
}\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
\r
// Fill the new BlockEntry with the TranslationTable\r
*BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY;\r
\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
\r
// Populate the newly created lower level table\r
BlockEntry = TranslationTable;\r