]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/Mmu: Fix bug of aligning new allocated page table
authorHeyi Guo <heyi.guo@linaro.org>
Wed, 9 Sep 2015 13:37:13 +0000 (13:37 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Wed, 9 Sep 2015 13:37:13 +0000 (13:37 +0000)
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

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

index f215fe9275efb686fcc8e0638f9884ba81d43a72..a7f374531a25d34a8f8149d8f97c8a52fc2f4e53 100644 (file)
@@ -377,11 +377,10 @@ GetBlockEntryListFromAddress (
         }\r
 \r
         // Create a new translation table\r
-        TranslationTable = (UINT64*)AllocatePages (EFI_SIZE_TO_PAGES((TT_ENTRY_COUNT * sizeof(UINT64)) + TT_ALIGNMENT_DESCRIPTION_TABLE));\r
+        TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);\r
         if (TranslationTable == NULL) {\r
           return NULL;\r
         }\r
-        TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);\r
 \r
         // Populate the newly created lower level table\r
         SubTableBlockEntry = TranslationTable;\r
@@ -405,11 +404,10 @@ GetBlockEntryListFromAddress (
         //\r
 \r
         // Create a new translation table\r
-        TranslationTable = (UINT64*)AllocatePages (EFI_SIZE_TO_PAGES((TT_ENTRY_COUNT * sizeof(UINT64)) + TT_ALIGNMENT_DESCRIPTION_TABLE));\r
+        TranslationTable = (UINT64*)AllocateAlignedPages (EFI_SIZE_TO_PAGES(TT_ENTRY_COUNT * sizeof(UINT64)), TT_ALIGNMENT_DESCRIPTION_TABLE);\r
         if (TranslationTable == NULL) {\r
           return NULL;\r
         }\r
-        TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);\r
 \r
         ZeroMem (TranslationTable, TT_ENTRY_COUNT * sizeof(UINT64));\r
 \r
@@ -617,12 +615,11 @@ ArmConfigureMmu (
   ArmSetTCR (TCR);\r
 \r
   // Allocate pages for translation table\r
-  TranslationTablePageCount = EFI_SIZE_TO_PAGES((RootTableEntryCount * sizeof(UINT64)) + TT_ALIGNMENT_DESCRIPTION_TABLE);\r
-  TranslationTable = AllocatePages (TranslationTablePageCount);\r
+  TranslationTablePageCount = EFI_SIZE_TO_PAGES(RootTableEntryCount * sizeof(UINT64));\r
+  TranslationTable = (UINT64*)AllocateAlignedPages (TranslationTablePageCount, TT_ALIGNMENT_DESCRIPTION_TABLE);\r
   if (TranslationTable == NULL) {\r
     return RETURN_OUT_OF_RESOURCES;\r
   }\r
-  TranslationTable = (VOID*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);\r
   // We set TTBR0 just after allocating the table to retrieve its location from the subsequent\r
   // functions without needing to pass this value across the functions. The MMU is only enabled\r
   // after the translation tables are populated.\r