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>
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
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
\r
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
(VOID **)&FdtClient);\r
}\r
RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);\r
\r
}\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
Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase,\r
CurSize, EFI_MEMORY_WB);\r
\r
gFdtClientProtocolGuid ## CONSUMES\r
\r
[Pcd]\r
gFdtClientProtocolGuid ## CONSUMES\r
\r
[Pcd]\r
- gArmTokenSpaceGuid.PcdSystemMemoryBase\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy\r
\r
[Depex]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy\r
\r
[Depex]\r