From patchwork Mon Feb 26 12:36:04 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: 129642 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp160051lja; Mon, 26 Feb 2018 04:45:41 -0800 (PST) X-Google-Smtp-Source: AH8x225GyDI4DDT03bCAtrliSwrNAgk0RBOvDjj3wayRnZHZq4VCF8S5tHG2Rl9FoYRoaiDyhnKG X-Received: by 10.80.177.210 with SMTP id n18mr14462982edd.108.1519649141416; Mon, 26 Feb 2018 04:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519649141; cv=none; d=google.com; s=arc-20160816; b=1BMt7C8vF6E+dlK4D7bOK9Aj26eEPtQxaYjMr0Z+XQYQflR+CSrcYJCeONBzDbN8pk 4vbzBc1GiikishlRK7jELQC88Dc+nrTboY4L1hrfo/PcjBjdrfddeBEt9V9gVHhydwVg LD/oXkC8RfW11VIgc9mrbYO3/1cmEAf9eobGr/XTIVvgNnpicWrYT/pq0XnF5tVF179Z TQM0XE7SMpccl0XlH2IBgQsrNvO3WjbaEbSvUXXGr/V8YAyRy74J7Tk676rksU0AVs4P 7WhuUGYs+zOUkIssZM37+1pc5VHmL2jH7HaHiyjNlBV8KCZvPrlPAY9gpPhXly2bwQzF nX5A== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:arc-authentication-results; bh=k2G4x2/VptXi91LLzWj2/3r5duQgFPomWnrH9Y5Gw18=; b=zTuFpeeUWopZh2n/vLJoCSj6Fq0fjwCQwVrtrwNHsDkCw93QY6r39rFenEu/s93VZ5 n8AbB/c6P6sIzibYQHsyMtpUbmbGeCqXZatJb7caJuf6+FPNsgXvtGMHO4G9XiPzIeW9 YSfnePcl0D4nNZ0uf5Xz8N++NOj8ifbq/g7LDdio9KgR1C2VVA6a6flwT5e2Q+3y6/lD LmGiaFsOfkYe3cQ3HkmoLin3el3kMpHBz07PNOHaFlwIysiTl7s6gIz71fVY9OmdbMLb gfZUKE3bAwprCBl0kFZklHm5zGl/86PZ0iTKUJPrUtIpeBgJpxEA3OmHclbcLLzvlgjJ kwFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hOXEmnOf; 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 g31si8339100edd.241.2018.02.26.04.45.41; Mon, 26 Feb 2018 04:45:41 -0800 (PST) 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=hOXEmnOf; 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 12D8EC220EA; Mon, 26 Feb 2018 12:39:56 +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_H3, RCVD_IN_MSPIKE_WL, 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 A8393C22128; Mon, 26 Feb 2018 12:37:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 88933C220E6; Mon, 26 Feb 2018 12:36:24 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id 4E833C220E3 for ; Mon, 26 Feb 2018 12:36:20 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id w128so11161647wmw.0 for ; Mon, 26 Feb 2018 04:36:20 -0800 (PST) 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=hOXEmnOfxsEoL3jpSMo4k8sPxTTR0/Imv9/THuMs1ZEU+8rKMi/Cn4lHZA4BnMRK65 fN+iyuT+oi1JRf4vZJI0iNWJAn0X7bHVjipoAeN2kvDq3jADG+Sv5IXqGD9/IpuEtQWI TgxkVTMwYwul1f4v71hAdObqyCQMgs/XlL5OI= 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=SoA5vwKgAMGsMn+PWpvORvltAEKyDlwQ7gyahQ1fsnnCFQUvYsPV5Os4bqRj7mb5Ki KgZ+Ri+6u/4EwzzW8sskR/clhO69UXHTshsCF9BrCXgYwJQl8wwjJtetjFG/THxNicag F+25UUEMtfYwYCms3E6ysyeRghuF8OMEZSby61QLm0anxrJPWxStj8RV1r6bphzbKOJ0 2+RNTbbhBp68g5W/9ujx9LFLh3wZCRLR9KFqv9e7aAwzqdqfiRzkbeebVgeoq1Ti4I0N B7k1tNmhZ7P+b7ml4X6B2COEFlScNIyBPO62mskmjYug/Smog1xj4r7+2x8Gmm+W5h07 w7/Q== X-Gm-Message-State: APf1xPC8Kp2gHOrDtC7vMRGPkwf0EplHqNP5FECqNYhHGpOCWBtOmBsd nIL1T5RzXoXiuU1YYrajMpZOqMrZ5Zw= X-Received: by 10.80.241.25 with SMTP id w25mr14410266edl.62.1519648579730; Mon, 26 Feb 2018 04:36:19 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id f6sm2493967edn.45.2018.02.26.04.36.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 04:36:19 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, trini@konsulko.com, harinarayan@ti.com, afd@ti.com, kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, peng.fan@nxp.com Date: Mon, 26 Feb 2018 12:36:04 +0000 Message-Id: <1519648566-12061-11-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519648566-12061-1-git-send-email-bryan.odonoghue@linaro.org> References: <1519648566-12061-1-git-send-email-bryan.odonoghue@linaro.org> Subject: [U-Boot] [PATCH v4 10/12] 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; }