From patchwork Tue Mar 13 16:50:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 131514 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp972070ljb; Tue, 13 Mar 2018 09:54:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELtngcFh9hW7iZ6oY17UrG31z1C5XBuCBOZIZyfnwp/QK6VqtaS4FPq0CkROkmbBSyRRZWRY X-Received: by 10.80.137.215 with SMTP id h23mr1592707edh.302.1520960071511; Tue, 13 Mar 2018 09:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960071; cv=none; d=google.com; s=arc-20160816; b=WuI5MG8w63RRdQrGT4vNND/DjeI/PylqZgaf4tdWURFLRKb1qOtIditrucqwJZOlBJ gjRRSIh2y/oQkgZiGR3ffBk0QUeXVvEHcldf/i2QjHTQD4RSrtOuK03TjQ8/7FfPyn6W nLIHyVlyGyJnvXPL5ieTWabrETVMWiB5ucPoiEeWHPOcunBcwIJjhJt2GUUkPgNe7oiC 2SrLKLC8UF4SJahxI8dN5Il9Q3NFpmx3JITsLzSJGiEa8oQc9rQSBxpjx/YNshYYy0lb ypRddmYDmq8Yd9OmEF7W38sPCeNZG8MEKNvL2C0yh2BA5JM78ncTdW0x1B0X6xy+LFYK WzNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=k2G4x2/VptXi91LLzWj2/3r5duQgFPomWnrH9Y5Gw18=; b=zhHqTvGBa7WmaAQo6Zp5RRkUHg42MW1IaGB0rqNZxrY8DuukHBMnGVcFDgFoinHZ9b plEz0F49UVgv6t0/9paX3LZea3KC6jmxw5H8uoa3n9GedkKBHq+bGJFrfOWa8hcM7Wd8 61VJhaTvHlI3Ha8kGlHa8tY8ioz8BcD/OATCNuUxIya8crq0PkPHkQolcjbkP88ucK50 hpMfqz67BHF5Dv1GpoNvPmdkqbSnK+nt15Lm5DnWxszEewOf/wY+mdAnxE9VyIDxU1y7 1ppQYXlCDh4pUWfXeC9bqMKlkegZaxeaEYcArOtmOKU522gmLjUA/6esSpx3vwi+TutT k/Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CF1Ptu88; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 30si388665eds.58.2018.03.13.09.54.31; Tue, 13 Mar 2018 09:54:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CF1Ptu88; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 22BE9C21E02; Tue, 13 Mar 2018 16:52:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 101B2C21E44; Tue, 13 Mar 2018 16:51:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5E5D1C21E49; Tue, 13 Mar 2018 16:50:57 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by lists.denx.de (Postfix) with ESMTPS id 025F7C21E2F for ; Tue, 13 Mar 2018 16:50:53 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id m4so773773wrb.7 for ; Tue, 13 Mar 2018 09:50:53 -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=9l4y29YT9GA9C87v2s0KMfjVt7b/wQv5HyUsRKb+Koc=; b=CF1Ptu88gr9T3MP4GQWcBM1ZcAsXQz54VK5GTP3KMTmVS1QbGI9cO+QmZtJKZ7TvWr An1mgQfAKi8/kaChMC0mfTk+5yY6fpW5e/7qeOVq2Jqy6/C/AagbN7GkhSL38sHmsP4r 0MSiV94w3c7KwLTQNBUvqQfkIMUDD7e/rMhyg= 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=9l4y29YT9GA9C87v2s0KMfjVt7b/wQv5HyUsRKb+Koc=; b=E4gwoxQaml+10xplvqNDt0h8kPGiJstFI5OU1Vjh6gR4YfiPSfmnxaNEfQy1rcB+pN Sxn/d/vAsorCBeMFEgjg44129RcEadMeb2wDpj5ZIG948Rqbq1zCyznCyMUe+n0M1H+H T6SL1PqZVUfRd5jFbSLnF8cGNwTrPnGRgoH/2GmjmAG7i9qG+UKdj388kQe2+QlBNG/5 ZOgPShQ+s/d8HDEOghiBRqf4v6hKGwU70vFN40rdSbAzxn1HTA2+6mrpMTqiaxCMbH0Z Rssro2QLv8xPjq/Ppmf3ujEiyCvKRdT3015RvkDFBqX1Gy2YsnHc9MwqQsHiV/+l0slN Kulg== X-Gm-Message-State: AElRT7FB865WyKrpMdxgLVhiKBuhioFs2+2EZSws4NuRfyIY8n9gKd8A zIl3zK5C8tNTccjuUbbHg1knfxvlWlQ= X-Received: by 10.80.164.82 with SMTP id v18mr1538741edb.115.1520959852504; Tue, 13 Mar 2018 09:50:52 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id 33sm476671edz.37.2018.03.13.09.50.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Mar 2018 09:50:51 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de, trini@konsulko.com, afd@ti.com, kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, peng.fan@nxp.com Date: Tue, 13 Mar 2018 16:50:34 +0000 Message-Id: <1520959836-16105-9-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520959836-16105-1-git-send-email-bryan.odonoghue@linaro.org> References: <1520959836-16105-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Harinarayan Bhatta Subject: [U-Boot] [PATCH v6 08/10] optee: Add error printout X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When encountering an error in OPTEE verification print out various details of the OPTEE header to aid in further debugging of encountered errors. Signed-off-by: Bryan O'Donoghue Cc: Harinarayan Bhatta Cc: Andrew F. Davis Cc: Tom Rini Cc: Kever Yang Cc: Philipp Tomsich Cc: Peng Fan Tested-by: Peng Fan --- lib/optee/optee.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/optee/optee.c b/lib/optee/optee.c index 365c078..78a15e8 100644 --- a/lib/optee/optee.c +++ b/lib/optee/optee.c @@ -8,6 +8,12 @@ #include #include +#define optee_hdr_err_msg \ + "OPTEE verification error:" \ + "\n\thdr=%p image=0x%08lx magic=0x%08x tzdram 0x%08lx-0x%08lx " \ + "\n\theader lo=0x%08x hi=0x%08x size=0x%08lx arch=0x%08x" \ + "\n\tuimage params 0x%08lx-0x%08lx\n" + int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start, unsigned long tzdram_len, unsigned long image_len) { @@ -42,10 +48,19 @@ int optee_verify_bootm_image(unsigned long image_addr, ret = optee_verify_image(hdr, tzdram_start, tzdram_len, image_len); if (ret) - return ret; + goto error; - if (image_load_addr + sizeof(*hdr) != hdr->init_load_addr_lo) + if (image_load_addr + sizeof(*hdr) != hdr->init_load_addr_lo) { ret = -EINVAL; + goto error; + } + + return ret; +error: + printf(optee_hdr_err_msg, hdr, image_addr, hdr->magic, tzdram_start, + tzdram_start + tzdram_len, hdr->init_load_addr_lo, + hdr->init_load_addr_hi, image_len, hdr->arch, image_load_addr, + image_load_addr + image_len); return ret; }