From patchwork Tue Apr 4 13:24:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96728 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp192789qgd; Tue, 4 Apr 2017 06:24:22 -0700 (PDT) X-Received: by 10.99.164.26 with SMTP id c26mr24140508pgf.89.1491312262819; Tue, 04 Apr 2017 06:24:22 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id u10si17531708plu.58.2017.04.04.06.24.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D68342050A8A7; Tue, 4 Apr 2017 06:24:21 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-lf0-x234.google.com (mail-lf0-x234.google.com [IPv6:2a00:1450:4010:c07::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1D84221939316 for ; Tue, 4 Apr 2017 06:24:20 -0700 (PDT) Received: by mail-lf0-x234.google.com with SMTP id h125so92849641lfe.0 for ; Tue, 04 Apr 2017 06:24:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aMlPIe03HJfx1J4NCyrXnJw3s0w++wWCHV0yjHvz3+0=; b=KgtNMGnGdW3Ixnlhehs42m4OHRaDrP64ibLQL5MvrPRi7swFTEmYw5iGyIcyNX0ZKg lOfKD8GQ9QM33scRz8X0UfgdyUFY4zGodHyZLo935nlv/6GShmomxq8SVEVvrXnGtlxE 5dbJkMNF3iN7wShpqghXrg8LtcxvqSL7OElEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aMlPIe03HJfx1J4NCyrXnJw3s0w++wWCHV0yjHvz3+0=; b=UObv2c9ltP/sr2pqEmDtXXn89nImxxAlzFjnrpx9bzUD6MveVX8jWtJyLXX1VhZfyc 9jQgJhVnJmCnXqewP1U8IDrw8sg5rt0yhpYdrgeGDzYycbu/ziZVAAm/Uk4p67cwFKtR 1FtJAUgUnyKjIfEOK4DM+VHyDGwqbeYhI4GCP0M2f0gVXJfWHByy7tG732RdFPBF/A/P xJr+5mS7juTeEVs1TvAy3YGgvLUtul/jHXal07jor8UAKic6PTuRDKPWn6RUZ5MOYuZp WePkwWh18B3mlphPTyeEKdOOgMIV+Av6G6jmbRgzedFc2v8JzA52gA1DtRQ1iNIgdXGy iCMw== X-Gm-Message-State: AFeK/H2breUUwKOiGQ6BZ1dEPIBi6zDvkWqvoiFrp3XGqVXmjfFtTbgR4vNnt2v+ua3YCvp3 X-Received: by 10.28.109.214 with SMTP id b83mr15060163wmi.21.1491312258360; Tue, 04 Apr 2017 06:24:18 -0700 (PDT) Received: from localhost.localdomain ([160.163.145.113]) by smtp.gmail.com with ESMTPSA id g10sm13773778wrb.56.2017.04.04.06.24.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:17 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Tue, 4 Apr 2017 14:24:07 +0100 Message-Id: <20170404132409.20422-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404132409.20422-1-ard.biesheuvel@linaro.org> References: <20170404132409.20422-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/3] ArmVirtPkg/FdtClientDxe: take DT memory node 'status' property into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jens.wiklander@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- 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 --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) { // From patchwork Tue Apr 4 13:24:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96729 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp192804qgd; Tue, 4 Apr 2017 06:24:25 -0700 (PDT) X-Received: by 10.99.65.1 with SMTP id o1mr24166263pga.93.1491312265039; Tue, 04 Apr 2017 06:24:25 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 198si17483494pgd.114.2017.04.04.06.24.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 16CD021939316; Tue, 4 Apr 2017 06:24:23 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x234.google.com (mail-wr0-x234.google.com [IPv6:2a00:1450:400c:c0c::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C550D21939316 for ; Tue, 4 Apr 2017 06:24:21 -0700 (PDT) Received: by mail-wr0-x234.google.com with SMTP id t20so10674103wra.1 for ; Tue, 04 Apr 2017 06:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qghrqmGM63wTX0DSrePZT1WDzXWlchpX49dK9BLqLbw=; b=WPyUX8sEt83lzbCZwiZ2f/8YIfMiPpcOToidCroTDzdk3Uvi4SFkpNETZwv9S1NGj/ v+U0PnAc9MVh4YHXEIFtW0a3qiMPXi/hj2jiTPdc0FYjLd6QIgyrghnt0DE+uJdC4WbI QHX5QBIVEJxw0ZJJPRkl7oULST7+QkelvgqO0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qghrqmGM63wTX0DSrePZT1WDzXWlchpX49dK9BLqLbw=; b=DdDAAVzqbZ4IdHUbaWVOUHeAYZbu3vBfuladPk6ooKWmAr/cu/tTag4bhfWnPgJ1E2 pFyHXU4+bPfPcUMURu1yycHvGXg2s/BVRTh2xdfRpLMVdDn+8zcng2BQ1PbDYdQC/oWj K5SkXVRh0IBjf+OZz5Z2kZscJ2tFSsUhlpMUlrInzSxmiTuDj8XSLbkORv22T/Lf+KEJ OoIZzsJK7YPCKOrmmazNnoaqrpX935DttELbzGLyw6uTp9+JOFryL7tlAyDcOJeYiZYx 1a90/1RGYKnp+fQoApVohC/dsmbmQNZESD1JYPDBOFBNG3pXBPR3MVylXxB3dxt9ZFzz AOmA== X-Gm-Message-State: AFeK/H1J/GL2hToGP4GfIsnniR5uJFyWGl3K8Dm4+0ykGuxOQf3hVZBUl3VBVMiWzSnhShqH X-Received: by 10.28.20.85 with SMTP id 82mr9333205wmu.59.1491312260261; Tue, 04 Apr 2017 06:24:20 -0700 (PDT) Received: from localhost.localdomain ([160.163.145.113]) by smtp.gmail.com with ESMTPSA id g10sm13773778wrb.56.2017.04.04.06.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:19 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Tue, 4 Apr 2017 14:24:08 +0100 Message-Id: <20170404132409.20422-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404132409.20422-1-ard.biesheuvel@linaro.org> References: <20170404132409.20422-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/3] ArmVirtPkg/FdtPL011SerialPortLib: take DT node 'status' property into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jens.wiklander@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In some cases, (e.g., when running QEMU with TrustZone emulation), the DT may contain DT 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 --- ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c index c458abb622d9..e28750f3b4c4 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c @@ -66,6 +66,7 @@ SerialPortGetBaseAddress ( INT32 Node, Prev; INT32 Len; CONST CHAR8 *Compatible; + CONST CHAR8 *NodeStatus; CONST CHAR8 *CompatibleItem; CONST UINT64 *RegProperty; UINTN UartBase; @@ -98,6 +99,11 @@ SerialPortGetBaseAddress ( CompatibleItem += 1 + AsciiStrLen (CompatibleItem)) { if (AsciiStrCmp (CompatibleItem, "arm,pl011") == 0) { + NodeStatus = fdt_getprop (DeviceTreeBase, Node, "status", &Len); + if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) { + continue; + } + RegProperty = fdt_getprop (DeviceTreeBase, Node, "reg", &Len); if (Len != 16) { return 0; From patchwork Tue Apr 4 13:24:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96730 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp192831qgd; Tue, 4 Apr 2017 06:24:27 -0700 (PDT) X-Received: by 10.99.45.197 with SMTP id t188mr23942496pgt.209.1491312267645; Tue, 04 Apr 2017 06:24:27 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id s79si17544895pfj.189.2017.04.04.06.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 48AA72050A8B0; Tue, 4 Apr 2017 06:24:26 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x22b.google.com (mail-wr0-x22b.google.com [IPv6:2a00:1450:400c:c0c::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3E37121939317 for ; Tue, 4 Apr 2017 06:24:24 -0700 (PDT) Received: by mail-wr0-x22b.google.com with SMTP id w11so213100656wrc.3 for ; Tue, 04 Apr 2017 06:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a/g2tRzhOk+EOcTc80xL+b/lb5M7bN469eVd7A7iaN8=; b=BHVrLZi6lrHiB5NRr1c9lQFRMmQ209LYij4nH10Nle5GJcAfJhA+CWSFyqLIQovFze z4/J/BvrEUYiXsDJsBAfaiGJMtKk1juEF+ebYQnTDemQsdR61l4jjhJ0G1RJoZvOcj4b YZsUyon3F5NFfTc9TgVonI+pD8Wl3w3bDwFp4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a/g2tRzhOk+EOcTc80xL+b/lb5M7bN469eVd7A7iaN8=; b=V8+H+w2R9XxaTIqmcT9O+ILsvKKbUwxANmLTfvMdSarfLuQ9i9BWRhwPpo9AZHYdCy 29WBZKrT9MCU42sn1FRvY4DlM7GZ3gVcsbShJimg3BIYOYKOM2iFbACYN1GQCV9Lj9pw YgBW+3AShMacjmPZoLzsO7FWio4160i6VYnhSDSWcX/A2KKAqNzVJPPY2c6qQBuxecf2 ihHhO0vjgLU63ivy+Vn+gI5HAyjXcx7Q3wt6uZX+YasKRUN2Kmiv2u/SwWDEbGK81QVS 0LcU+4pM8wATQkTj+wOPGqBbzdw2ImGZq1sYVot9m/eUjrOy7J44Ls3FszhRtbY3s4f3 3dkw== X-Gm-Message-State: AFeK/H1f9Yf2Vwn/hP6SXaWQmn/09eMyXRZ9Z4A67Iamwt4bSE7nmxmlsPkl2j7BdcTTkk9X X-Received: by 10.28.9.15 with SMTP id 15mr15457191wmj.83.1491312262085; Tue, 04 Apr 2017 06:24:22 -0700 (PDT) Received: from localhost.localdomain ([160.163.145.113]) by smtp.gmail.com with ESMTPSA id g10sm13773778wrb.56.2017.04.04.06.24.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Tue, 4 Apr 2017 14:24:09 +0100 Message-Id: <20170404132409.20422-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404132409.20422-1-ard.biesheuvel@linaro.org> References: <20170404132409.20422-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 3/3] ArmVirtPkg/PlatformPeiLib: take DT node 'status' property into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jens.wiklander@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In some cases, (e.g., when running QEMU with TrustZone emulation), the DT may contain DT 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 --- ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c index bdf2b57fcb1e..df52d3653360 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -39,7 +39,9 @@ PlatformPeim ( INT32 Node, Prev; CONST CHAR8 *Compatible; CONST CHAR8 *CompItem; + CONST CHAR8 *NodeStatus; INT32 Len; + INT32 StatusLen; CONST UINT64 *RegProp; UINT64 UartBase; @@ -83,6 +85,11 @@ PlatformPeim ( CompItem += 1 + AsciiStrLen (CompItem)) { if (AsciiStrCmp (CompItem, "arm,pl011") == 0) { + NodeStatus = fdt_getprop (Base, Node, "status", &StatusLen); + if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) { + continue; + } + RegProp = fdt_getprop (Base, Node, "reg", &Len); ASSERT (Len == 16);