From patchwork Fri Mar 9 16:55:29 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: 131174 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1217904lja; Fri, 9 Mar 2018 09:01:23 -0800 (PST) X-Google-Smtp-Source: AG47ELuXgcE8iD18tg30WQK4v3315Pg/f67lHO7KmUJoazB54Gfrb4z9Tq+ioq2iDuq2DodU13EZ X-Received: by 10.80.241.83 with SMTP id z19mr38528156edl.104.1520614883631; Fri, 09 Mar 2018 09:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520614883; cv=none; d=google.com; s=arc-20160816; b=yNpw8bOl3WV/NcqjGizMuBoU3EygX+ErrBEEw39C93x2FVcJoBaTVeMUfgsgYWFaVg Jr9aDrVZigeKHLuDlCYdEvdqudK95I3XswYriPjehH6YO/AcUrOfRMoc3mmNM0SXPxgA jUeNwipCB9nvkPQfrhi+l478aEBHWJ0ITTDTn5+uZqIvF9No7t5112RZYMlFeD5l28I8 IHibgEK9lz1M16vCKkRdRfxKGY0tMlLKckGosDpidIYrHm2Jz2NXvGZPHHj5+EzHyrnn FAJD6viFULUlpgK08eYeUr7F7/xA944iNhZZJl/pHZg7PKcNREN9VadeIizlzCGwCkH8 8/Kg== 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=ceJIkA8oDbzIRflbYIvkMmjX6H9RhM52jmfA1GXNx6h45LgLspSayfyJK/XD5L0RHR Z9k29L/j3+taAxGkm8VFeQaIWAne+geb+r8046wpN1am/PO6PLEPfGQEu9KMfNOrsQGY iczCaZiQwmyFOVSnC0gOeMkac2jyqtCxHv32HZ+7/RNwm7mLE0yxoz174fspRNuu0oTW jI8jX5mkfCbVRmI168IZAxxKQVuuM6Cw5NVObojR6FsotG/6uVWQL0BbAWTsTcqb/Omw wEGhvPJnyDv6SAMaI9rijh/N0eSVKVXEpaMq4F+jGEzC7hMIwYyK0P4h8FFyimdBJvWY ttSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FgXkvf86; 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 n21si1459046eda.281.2018.03.09.09.01.22; Fri, 09 Mar 2018 09:01:23 -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=FgXkvf86; 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 D44ECC21DFD; Fri, 9 Mar 2018 16:58:39 +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_DNSWL_BLOCKED, 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 B9824C21E44; Fri, 9 Mar 2018 16:56:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 049C3C21E3B; Fri, 9 Mar 2018 16:55:47 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 3EF14C21DD9 for ; Fri, 9 Mar 2018 16:55:43 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id 139so5091134wmn.2 for ; Fri, 09 Mar 2018 08:55:43 -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=FgXkvf86UVtesaakVTGB9ndvVM684fu3AzYMCqxvUxGtX+CbjioipyouPy8E1UxyJA uNb3/IsVWRee5zOOaJbZ68PycjhBUxC9CJ5Cd9gHswGXiN1G6UNcwbhzh7fi/X5W66W+ 3Dvw0gIQAA/rBneCBuvZDwKs53NKw/UWmWXwc= 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=tjie2MWDrAwOY3lr1B+reVfCp64yUxfm3zkOM4qd/dsa0Ja7pRZYNF4QIIlb3zeve/ 5fy7T+pdSs3sWUBdvsX0eAmV/mZefnmF4r9uz6GN8e3uDuV7aFKTyQL72gn998Kp1H/6 8wKr7B5DOPunsSl1G4f2mz6As0CmhQbF9ZguSFIOE6y8+AnfTJ9UNYFbVY94bBDkZVHR Fud8Eqa4f2XwCgULyT9IXxbssU/tcHM2tCzCeTxg48mk4lG7yw2YHEYyNXoNbL6V6XJ8 UHUoNGop7UOFwUixl2SzzdXyAWTbB9bOzN2dAH1R1/aQkDyMu0yBd+AP1tVzhuTQlJn/ sTVA== X-Gm-Message-State: APf1xPB246yDuKeNxdnFsbIG1greaFjGqpulktgu4IZ7nDGcCF4/oBzu zJVgyVGcdHU+zzAfonLcewb6u6YGgkY= X-Received: by 10.80.157.130 with SMTP id w2mr38751468ede.123.1520614542772; Fri, 09 Mar 2018 08:55:42 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id e40sm960335ede.15.2018.03.09.08.55.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 08:55:42 -0800 (PST) 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: Fri, 9 Mar 2018 16:55:29 +0000 Message-Id: <1520614531-2164-9-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520614531-2164-1-git-send-email-bryan.odonoghue@linaro.org> References: <1520614531-2164-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Harinarayan Bhatta Subject: [U-Boot] [PATCH v5 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; }