summaryrefslogtreecommitdiff
path: root/ArmPkg
diff options
context:
space:
mode:
authorHeyi Guo <heyi.guo@linaro.org>2015-09-09 13:37:13 +0000
committerabiesheuvel <abiesheuvel@Edk2>2015-09-09 13:37:13 +0000
commit7d189f99d81cd136a33074c66cdabb8ce66118ce (patch)
treee950e9e33d0189affed05d1bc7eb23e90141cfdb /ArmPkg
parentddd097e33f6e6829dc0413820e9971f3bf025f87 (diff)
downloadedk2-7d189f99d81cd136a33074c66cdabb8ce66118ce.zip
edk2-7d189f99d81cd136a33074c66cdabb8ce66118ce.tar.gz
edk2-7d189f99d81cd136a33074c66cdabb8ce66118ce.tar.bz2
ArmPkg/Mmu: Fix bug of aligning new allocated page table
The code has a simple bug on calculating aligned page table address. We can just use AllocateAlignedPages in MemoryAllocationLib instead. 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@18421 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg')
-rw-r--r--ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
index f215fe9..a7f3745 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
@@ -377,11 +377,10 @@ GetBlockEntryListFromAddress (
}
// Create a new translation table
- TranslationTable = (UINT64*)AllocatePages (EFI_SIZE_TO_PAGES((TT_ENTRY_COUNT * sizeof(UINT64)) + TT_ALIGNMENT_DESCRIPTION_TABLE));
+ TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);
if (TranslationTable == NULL) {
return NULL;
}
- TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);
// Populate the newly created lower level table
SubTableBlockEntry = TranslationTable;
@@ -405,11 +404,10 @@ GetBlockEntryListFromAddress (
//
// Create a new translation table
- TranslationTable = (UINT64*)AllocatePages (EFI_SIZE_TO_PAGES((TT_ENTRY_COUNT * sizeof(UINT64)) + TT_ALIGNMENT_DESCRIPTION_TABLE));
+ TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);
if (TranslationTable == NULL) {
return NULL;
}
- TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);
ZeroMem (TranslationTable, TT_ENTRY_COUNT * sizeof(UINT64));
@@ -617,12 +615,11 @@ ArmConfigureMmu (
ArmSetTCR (TCR);
// Allocate pages for translation table
- TranslationTablePageCount = EFI_SIZE_TO_PAGES((RootTableEntryCount * sizeof(UINT64)) + TT_ALIGNMENT_DESCRIPTION_TABLE);
- TranslationTable = AllocatePages (TranslationTablePageCount);
+ TranslationTablePageCount = EFI_SIZE_TO_PAGES(RootTableEntryCount * sizeof(UINT64));
+ TranslationTable = (UINT64*)AllocateAlignedPages (TranslationTablePageCount, TT_ALIGNMENT_DESCRIPTION_TABLE);
if (TranslationTable == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
- TranslationTable = (VOID*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);
// We set TTBR0 just after allocating the table to retrieve its location from the subsequent
// functions without needing to pass this value across the functions. The MMU is only enabled
// after the translation tables are populated.