]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/HighMemDxe: check new regions against GCD memory space map
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 21 Mar 2017 09:12:56 +0000 (09:12 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 21 Mar 2017 10:41:25 +0000 (10:41 +0000)
Instead of looking at the PCD gArmTokenSpaceGuid.PcdSystemMemoryBase
to decide which DT node covers the memory we are already using, query
the GCD memory space map, which is the authoritative source for this
kind of information

This fixes a problem observed by Michael on platforms where this PCD
is of the 'Patchable' type, which means updates to its value do not
propagate to other modules.

Reported-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
ArmVirtPkg/HighMemDxe/HighMemDxe.c
ArmVirtPkg/HighMemDxe/HighMemDxe.inf

index 4e41120deff3a198b83739d9f1b869ff8ed72cf6..aa3f5f6d8956c4d8ca28ef1b6dcc9cb9973a9d65 100644 (file)
@@ -30,16 +30,17 @@ InitializeHighMemDxe (
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
-  FDT_CLIENT_PROTOCOL   *FdtClient;\r
-  EFI_CPU_ARCH_PROTOCOL *Cpu;\r
-  EFI_STATUS            Status, FindNodeStatus;\r
-  INT32                 Node;\r
-  CONST UINT32          *Reg;\r
-  UINT32                RegSize;\r
-  UINTN                 AddressCells, SizeCells;\r
-  UINT64                CurBase;\r
-  UINT64                CurSize;\r
-  UINT64                Attributes;\r
+  FDT_CLIENT_PROTOCOL               *FdtClient;\r
+  EFI_CPU_ARCH_PROTOCOL             *Cpu;\r
+  EFI_STATUS                        Status, FindNodeStatus;\r
+  INT32                             Node;\r
+  CONST UINT32                      *Reg;\r
+  UINT32                            RegSize;\r
+  UINTN                             AddressCells, SizeCells;\r
+  UINT64                            CurBase;\r
+  UINT64                            CurSize;\r
+  UINT64                            Attributes;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR   GcdDescriptor;\r
 \r
   Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
                   (VOID **)&FdtClient);\r
@@ -73,7 +74,14 @@ InitializeHighMemDxe (
       }\r
       RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);\r
 \r
-      if (PcdGet64 (PcdSystemMemoryBase) != CurBase) {\r
+      Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor);\r
+      if (EFI_ERROR (Status)) {\r
+        DEBUG ((DEBUG_WARN,\r
+          "%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n",\r
+          __FUNCTION__, CurBase, CurBase + CurSize - 1));\r
+          continue;\r
+      }\r
+      if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) {\r
         Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase,\r
                         CurSize, EFI_MEMORY_WB);\r
 \r
index ac1761974f5245146ec5df50617f4793ce8c1ba9..a7072e38d09d59c1736a6813ce82795da7923a25 100644 (file)
@@ -45,7 +45,6 @@
   gFdtClientProtocolGuid                  ## CONSUMES\r
 \r
 [Pcd]\r
-  gArmTokenSpaceGuid.PcdSystemMemoryBase\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy\r
 \r
 [Depex]\r