diff mbox series

[edk2,1/3] ArmVirtPkg/FdtClientDxe: take DT memory node 'status' property into account

Message ID 20170404132409.20422-2-ard.biesheuvel@linaro.org
State Accepted
Commit d014044395b5ac2d37efb65f889dd8910869a332
Headers show
Series ArmVirtPkg: ignore DT nodes with a status != 'okay' | expand

Commit Message

Ard Biesheuvel April 4, 2017, 1:24 p.m. UTC
In some cases, (e.g., when running QEMU with TrustZone emulation), the
DT may contain memory nodes whose status is set to 'secure'. Similarly,
the status may be set to 'disabled' if the consumer of the DT image is
expected to treat it as if it weren't there.

So check whether a 'status' property is present, and if so, ignore the
node if the status is not 'okay'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 8 ++++++++
 1 file changed, 8 insertions(+)

-- 
2.9.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
index 2d867b16fda8..fb6e0aeb9215 100644
--- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
+++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
@@ -210,6 +210,7 @@  FindNextMemoryNodeReg (
 {
   INT32          Prev, Next;
   CONST CHAR8    *DeviceType;
+  CONST CHAR8    *NodeStatus;
   INT32          Len;
   EFI_STATUS     Status;
 
@@ -222,6 +223,13 @@  FindNextMemoryNodeReg (
       break;
     }
 
+    NodeStatus = fdt_getprop (mDeviceTreeBase, Next, "status", &Len);
+    if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {
+      DEBUG ((DEBUG_WARN, "%a: ignoring memory node with status \"%a\"\n",
+        __FUNCTION__, NodeStatus));
+      continue;
+    }
+
     DeviceType = fdt_getprop (mDeviceTreeBase, Next, "device_type", &Len);
     if (DeviceType != NULL && AsciiStrCmp (DeviceType, "memory") == 0) {
       //