]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmMmuLib: remove bogus alignment of page allocations
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 9 Sep 2016 10:19:18 +0000 (11:19 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 13 Sep 2016 12:43:08 +0000 (13:43 +0100)
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>
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c

index 84a689af7c8aef4f969d1a27c0084f6dfc5e9631..1ff584ec9eec69ebc62764b058cb60b9b75d60e5 100644 (file)
@@ -298,7 +298,7 @@ GetBlockEntryListFromAddress (
         }\r
 \r
         // Create a new translation table\r
-        TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);\r
+        TranslationTable = AllocatePages (1);\r
         if (TranslationTable == NULL) {\r
           return NULL;\r
         }\r
@@ -321,7 +321,7 @@ GetBlockEntryListFromAddress (
         //\r
 \r
         // Create a new translation table\r
-        TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);\r
+        TranslationTable = AllocatePages (1);\r
         if (TranslationTable == NULL) {\r
           return NULL;\r
         }\r
@@ -553,7 +553,6 @@ ArmConfigureMmu (
   )\r
 {\r
   VOID*                         TranslationTable;\r
-  UINTN                         TranslationTablePageCount;\r
   UINT32                        TranslationTableAttribute;\r
   ARM_MEMORY_REGION_DESCRIPTOR *MemoryTableEntry;\r
   UINT64                        MaxAddress;\r
@@ -640,8 +639,7 @@ ArmConfigureMmu (
   ArmSetTCR (TCR);\r
 \r
   // Allocate pages for translation table\r
-  TranslationTablePageCount = EFI_SIZE_TO_PAGES(RootTableEntryCount * sizeof(UINT64));\r
-  TranslationTable = (UINT64*)AllocateAlignedPages (TranslationTablePageCount, TT_ALIGNMENT_DESCRIPTION_TABLE);\r
+  TranslationTable = AllocatePages (1);\r
   if (TranslationTable == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
   }\r
@@ -718,7 +716,7 @@ ArmConfigureMmu (
   return RETURN_SUCCESS;\r
 \r
 FREE_TRANSLATION_TABLE:\r
-  FreePages (TranslationTable, TranslationTablePageCount);\r
+  FreePages (TranslationTable, 1);\r
   return Status;\r
 }\r
 \r