Revision: 18421
          http://sourceforge.net/p/edk2/code/18421
Author:   abiesheuvel
Date:     2015-09-09 13:37:13 +0000 (Wed, 09 Sep 2015)
Log Message:
-----------
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 <[email protected]>
Cc: Leif Lindholm <[email protected]>
Reviewed-by: Ard Biesheuvel <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

Modified: trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c       2015-09-09 
07:50:09 UTC (rev 18420)
+++ trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c       2015-09-09 
13:37:13 UTC (rev 18421)
@@ -377,11 +377,10 @@
         }
 
         // 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 @@
         //
 
         // 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 @@
   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.


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to