]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmMmuLib: base page table VA size on GCD memory map size
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 9 Sep 2016 08:01:56 +0000 (09:01 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 13 Sep 2016 12:43:34 +0000 (13:43 +0100)
As reported by Eugene, the practice of sizing the address space in the
virtual memory system based on the maximum address in the table passed
to ArmConfigureMmu() is problematic, since it fails to take into account
the fact that the GCD memory space may be extended at a later time, both
for memory and for MMIO. So instead, choose the VA size identical to the
GCD memory map size, which is based on PcdPrePiCpuMemorySize on ARM
systems.

Reported-by: Eugene Cohen <eugene@hp.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Eugene Cohen <eugene@hp.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf

index 57e789f68b3b7527e495fc6d81be4dfa4153ca50..1fb3bbec6347852bdf2e3c5d392e6e98f77dc463 100644 (file)
@@ -555,9 +555,7 @@ ArmConfigureMmu (
   VOID*                         TranslationTable;\r
   VOID*                         TranslationTableBuffer;\r
   UINT32                        TranslationTableAttribute;\r
-  ARM_MEMORY_REGION_DESCRIPTOR *MemoryTableEntry;\r
   UINT64                        MaxAddress;\r
-  UINT64                        TopAddress;\r
   UINTN                         T0SZ;\r
   UINTN                         RootTableEntryCount;\r
   UINTN                         RootTableEntrySize;\r
@@ -569,16 +567,8 @@ ArmConfigureMmu (
     return RETURN_INVALID_PARAMETER;\r
   }\r
 \r
-  // Identify the highest address of the memory table\r
-  MaxAddress = MemoryTable->PhysicalBase + MemoryTable->Length - 1;\r
-  MemoryTableEntry = MemoryTable;\r
-  while (MemoryTableEntry->Length != 0) {\r
-    TopAddress = MemoryTableEntry->PhysicalBase + MemoryTableEntry->Length - 1;\r
-    if (TopAddress > MaxAddress) {\r
-      MaxAddress = TopAddress;\r
-    }\r
-    MemoryTableEntry++;\r
-  }\r
+  // Cover the entire GCD memory space\r
+  MaxAddress = (1UL << PcdGet8 (PcdPrePiCpuMemorySize)) - 1;\r
 \r
   // Lookup the Table Level to get the information\r
   LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount);\r
index 1533c2944e8e6cfdac3ca77d14e5f578a2c5573c..b9f264de8d26975d00f0e12b7d8622572120ef64 100644 (file)
@@ -32,6 +32,7 @@
 \r
 [Packages]\r
   ArmPkg/ArmPkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
   MdePkg/MdePkg.dec\r
 \r
 [LibraryClasses]\r
@@ -39,5 +40,8 @@
   CacheMaintenanceLib\r
   MemoryAllocationLib\r
 \r
+[Pcd.AARCH64]\r
+  gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize\r
+\r
 [Pcd.ARM]\r
   gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride\r
index 14ebf8de673dd61b9acee528bcd45d8ecbc29c49..ecf13f790734fda49a448362f8e407e63d2eede5 100644 (file)
 \r
 [Packages]\r
   ArmPkg/ArmPkg.dec\r
+  EmbeddedPkg/EmbeddedPkg.dec\r
   MdePkg/MdePkg.dec\r
 \r
 [LibraryClasses]\r
   ArmLib\r
   CacheMaintenanceLib\r
   MemoryAllocationLib\r
+\r
+[Pcd.AARCH64]\r
+  gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize\r