diff options
author | Olivier Martin <olivier.martin@arm.com> | 2013-07-24 11:50:31 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-07-24 11:50:31 +0000 |
commit | 383070d333bf53ce2612b1f7479909fdae25c83f (patch) | |
tree | 31dd7f90aa136f8d4f73d1d38183c9d67abebc62 | |
parent | 6ba46a920946ee510567fa515ce9e6b50ce7158b (diff) | |
download | edk2-383070d333bf53ce2612b1f7479909fdae25c83f.zip edk2-383070d333bf53ce2612b1f7479909fdae25c83f.tar.gz edk2-383070d333bf53ce2612b1f7479909fdae25c83f.tar.bz2 |
ArmPkg/ArmLib/AArch64: Fixed the calculation of the last entry in the Translation Table
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
-rw-r--r-- | ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c index 8abc73a..05b2a19 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c @@ -273,13 +273,13 @@ GetBlockEntryListFromAddress ( ASSERT ((*BlockEntrySize & (SIZE_4KB - 1)) == 0);
//
- // Calculate LastBlockEntry from T0SZ
+ // Calculate LastBlockEntry from T0SZ - this is the last block entry of the root Translation table
//
T0SZ = ArmGetTCR () & TCR_T0SZ_MASK;
// Get the Table info from T0SZ
GetRootTranslationTableInfo (T0SZ, &RootTableLevel, &RootTableEntryCount);
// The last block of the root table depends on the number of entry in this table
- *LastBlockEntry = (UINT64*)((UINTN)RootTable + (RootTableEntryCount * sizeof(UINT64)));
+ *LastBlockEntry = (UINT64*)((UINTN)RootTable + ((RootTableEntryCount - 1) * sizeof(UINT64)));
// If the start address is 0x0 then we use the size of the region to identify the alignment
if (RegionStart == 0) {
@@ -331,7 +331,7 @@ GetBlockEntryListFromAddress ( BlockEntry = (UINT64*)TT_GET_ENTRY_FOR_ADDRESS (TranslationTable, IndexLevel + 1, RegionStart);
// Set the last block for this new table
- *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + (TT_ENTRY_COUNT * sizeof(UINT64)));
+ *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));
}
} else if ((*BlockEntry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) {
// If we are not at the last level then we need to split this BlockEntry
@@ -373,6 +373,8 @@ GetBlockEntryListFromAddress ( // Fill the new BlockEntry with the TranslationTable
*BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY;
+ // Update the last block entry with the newly created translation table
+ *LastBlockEntry = (UINT64*)((UINTN)TranslationTable + ((TT_ENTRY_COUNT - 1) * sizeof(UINT64)));
// Populate the newly created lower level table
BlockEntry = TranslationTable;
|