summaryrefslogtreecommitdiff
path: root/ArmPkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-09-09 11:19:18 +0100
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2016-09-13 13:43:08 +0100
commit674e127ef64b07a1e6e6bcc5ecbaead50ea81134 (patch)
tree12b148e154cece8dd350a5b4f16a8569c4e1cd33 /ArmPkg
parente93cb72e597df7b37aad7910787b8ecaeac31382 (diff)
downloadedk2-674e127ef64b07a1e6e6bcc5ecbaead50ea81134.zip
edk2-674e127ef64b07a1e6e6bcc5ecbaead50ea81134.tar.gz
edk2-674e127ef64b07a1e6e6bcc5ecbaead50ea81134.tar.bz2
ArmPkg/ArmMmuLib: remove bogus alignment of page allocations
In commit 7d189f99d81c ("ArmPkg/Mmu: Fix bug of aligning new allocated page table"), we fixed a flaw in the logic regarding alignment of newly allocated translation table pages. However, we all failed to spot that aligning page based allocations to page size is rather pointless to begin with, so simply allocate a single page each time we add new pages to the translation tables. Also, drop the unnecessary cast. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPkg')
-rw-r--r--ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
index 84a689a..1ff584e 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
@@ -298,7 +298,7 @@ GetBlockEntryListFromAddress (
}
// Create a new translation table
- TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);
+ TranslationTable = AllocatePages (1);
if (TranslationTable == NULL) {
return NULL;
}
@@ -321,7 +321,7 @@ GetBlockEntryListFromAddress (
//
// Create a new translation table
- TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);
+ TranslationTable = AllocatePages (1);
if (TranslationTable == NULL) {
return NULL;
}
@@ -553,7 +553,6 @@ ArmConfigureMmu (
)
{
VOID* TranslationTable;
- UINTN TranslationTablePageCount;
UINT32 TranslationTableAttribute;
ARM_MEMORY_REGION_DESCRIPTOR *MemoryTableEntry;
UINT64 MaxAddress;
@@ -640,8 +639,7 @@ ArmConfigureMmu (
ArmSetTCR (TCR);
// Allocate pages for translation table
- TranslationTablePageCount = EFI_SIZE_TO_PAGES(RootTableEntryCount * sizeof(UINT64));
- TranslationTable = (UINT64*)AllocateAlignedPages (TranslationTablePageCount, TT_ALIGNMENT_DESCRIPTION_TABLE);
+ TranslationTable = AllocatePages (1);
if (TranslationTable == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
@@ -718,7 +716,7 @@ ArmConfigureMmu (
return RETURN_SUCCESS;
FREE_TRANSLATION_TABLE:
- FreePages (TranslationTable, TranslationTablePageCount);
+ FreePages (TranslationTable, 1);
return Status;
}