]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib/AArch64: Initialize the new N+1-level page table before registering it
authorOlivier Martin <olivier.martin@arm.com>
Fri, 10 Oct 2014 11:25:04 +0000 (11:25 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Oct 2014 11:25:04 +0000 (11:25 +0000)
Prior to this change, when a new page table was created at level N+1,
the reference to the table was added to the level N translation table,
before being initialized.
It means if virtual addresses were in the address range defined by
this new table the CPU would crash as the address range was not
initialized.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16206 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

index f0d2bff1a3a465d3c82a9b2dba354207db4ab8e8..f215fe9275efb686fcc8e0638f9884ba81d43a72 100644 (file)
@@ -251,6 +251,7 @@ GetBlockEntryListFromAddress (
   UINTN   RootTableEntryCount;\r
   UINT64 *TranslationTable;\r
   UINT64 *BlockEntry;\r
+  UINT64 *SubTableBlockEntry;\r
   UINT64  BlockEntryAddress;\r
   UINTN   BaseAddressAlignment;\r
   UINTN   PageLevel;\r
@@ -382,17 +383,18 @@ GetBlockEntryListFromAddress (
         }\r
         TranslationTable = (UINT64*)((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE);\r
 \r
+        // Populate the newly created lower level table\r
+        SubTableBlockEntry = TranslationTable;\r
+        for (Index = 0; Index < TT_ENTRY_COUNT; Index++) {\r
+          *SubTableBlockEntry = Attributes | (BlockEntryAddress + (Index << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel + 1)));\r
+          SubTableBlockEntry++;\r
+        }\r
+\r
         // Fill the BlockEntry with the new TranslationTable\r
         *BlockEntry = ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY;\r
         // Update the last block entry with the newly created translation table\r
         *LastBlockEntry = TT_LAST_BLOCK_ADDRESS(TranslationTable, TT_ENTRY_COUNT);\r
 \r
-        // Populate the newly created lower level table\r
-        BlockEntry = TranslationTable;\r
-        for (Index = 0; Index < TT_ENTRY_COUNT; Index++) {\r
-          *BlockEntry = Attributes | (BlockEntryAddress + (Index << TT_ADDRESS_OFFSET_AT_LEVEL(IndexLevel + 1)));\r
-          BlockEntry++;\r
-        }\r
         // Block Entry points at the beginning of the Translation Table\r
         BlockEntry = TranslationTable;\r
       }\r