From patchwork Sat Dec 30 01:08:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 122970 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5316211qgn; Fri, 29 Dec 2017 17:12:26 -0800 (PST) X-Google-Smtp-Source: ACJfBot+HpF9XE4oOxAAGfU8iLGRS0YL8EzaXm5oabUPqyCX0qat8MvS/tj8U9uBYdOqJEOvJ4FG X-Received: by 10.80.205.218 with SMTP id h26mr46467576edj.157.1514596346781; Fri, 29 Dec 2017 17:12:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514596346; cv=none; d=google.com; s=arc-20160816; b=JrWEs7x1D9poPd2fVnXFRevzI57Pnn+7RgCzzSlKt6e9z2sFv9R/cdKxsEclmuo5eT rUxhReuXMRTpOUTj8BvR1S3+PFCmng+M37fQoJeFhzlNf4COnVS1q49PQ7nJbye984Rz u2MiGo5p35gahdOgGvxgIpjnPjrR+7//9b+ywUY8AUwX73WmOQ6/vrSFU2nSKnlFnpkc tlBiwWoYi/vyvWuUb5oC71nSOTqYcDHX136KZRpKJyrx1KExAVeiDCjxSv5qyjQEWpby Vrv5gb/tdZ5A+k5Ueo8wDgjp25UXLUy9F0A0WAHS+qJJMw7bkItIrM3/Rrx8aLDCGyJ5 k7lg== 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=rHJ9/QY5qb5XA3eZSsVELR4G9CQd39u1ezozHIDIsGQ=; b=oef0igI2stcMUSsNZOKYNKC9ksM16JU+MuMZwxddoRy0M3pT+w2knTRxw9KyGHIWAZ HQ5WRQiK02mzw2FTMH2KhNMIU6x52ZYoBt8ShqeVhHZr/pZuCU6uIA3hzy8OgEb+EO1A 3ReTqLwZO/mez4AhZ5YHLebo9UKLjNKVZ0TFbHKbdSy5ESoaMkzaLEL146QrxTjM9XQP 3WPa9lmL0ORIjNyHV9QDxJgE3l3mKMGf0UDioU/mhcPyoZKOfLfAE5FGRAwvst9uQkhk c/OOAQhn8oaWf9Oj5kVL1Tt+nmk7WatoqiQ4warF1ksrZ/N7doldM0OUP+mu5x/vFaiK HSqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V5jJJ3D4; 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 g3si669349edi.167.2017.12.29.17.12.26; Fri, 29 Dec 2017 17:12:26 -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=V5jJJ3D4; 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 1DBE4C21D56; Sat, 30 Dec 2017 01:09:47 +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 7F70AC21DAB; Sat, 30 Dec 2017 01:09:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6FCD5C21DE4; Sat, 30 Dec 2017 01:09:07 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id 7D378C21C34 for ; Sat, 30 Dec 2017 01:09:06 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id r78so50730146wme.5 for ; Fri, 29 Dec 2017 17:09:06 -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=TwZ+1qIB7/yAjZU3U+qR5EWeNMJDqcVtGrJ+SK9DAU4=; b=V5jJJ3D4XRdEC7xLH+5ow3PWIo15D2wSTnTJaYNczFhkUScmK1fKSOdTh7JOgQbFtN Sg4ivCsr6SGIzH61M3UhpFf33VxKVjTvlSt124FRfjmjcJE393TNq2Pozq54O3+v2hhc xCqyTSRKdGTV0qC2F/jSspRS7DJU7dDqfQBOs= 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=TwZ+1qIB7/yAjZU3U+qR5EWeNMJDqcVtGrJ+SK9DAU4=; b=R83sVHoICV4LEKRGTUd7RWWyU9dyprGe9ns4GlaM9XzoNEDSKbmcPPk7SWCS2LM3yK bvKK9ENO8L8Pc+hGo7s4HtJ2n01LXrIOUEyS2cvnHYEOb3ipAxz9WSlfvM/nV5yqEyya 6zpmlt43/JRJP7pKFHNA6zWKKn2/TEwapYnUszaoJhreZLhkv3jOwTffatHLhd4jICgk j+m0LlL57Q+In1CkZIz0MBQDHx3o2pbl+8lhGeIyf1SxaY+/taYVcCk/NDYaVhuBhY8Y j1QN0SZdEiSo/J8QMtO5Wfn7nzv3vsBPjnqBbqUR7QbHcW9AyHSgxFhXPJvM5A3Ek7Hv yywQ== X-Gm-Message-State: AKGB3mJG+LGuyiUbmj0cW3zfTLneK4ztTrU1q8grwtJ1+0mb8VtgWqob Qg320Qcl9v/pkTMzPTibXLOupg8ERM0= X-Received: by 10.80.231.151 with SMTP id b23mr47333559edn.94.1514596145899; Fri, 29 Dec 2017 17:09:05 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id f9sm26484148edm.83.2017.12.29.17.09.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 17:09:05 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Sat, 30 Dec 2017 01:08:31 +0000 Message-Id: <1514596142-22050-3-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514596142-22050-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514596142-22050-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v3 02/25] arm: imx: hab: Fix authenticate_image result code 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" authenticate_image returns 1 for success and 0 for failure. That result code is mapped directly to the result code for the command line function hab_auth_img - which means when hab_auth_img succeeds it is returning CMD_RET_FAILURE (1) instead of CMD_RET_SUCCESS (0). This patch fixes this behaviour by making authenticate_image() return 0 for success and 1 for failure. Both users of authenticate_image() as a result have some minimal churn. The upshot is once done when hab_auth_img is called from the command line we set $? in the standard way for scripting functions to act on. Fixes: 36c1ca4d46ef ("imx: Support i.MX6 High Assurance Boot authentication") Signed-off-by: Bryan O'Donoghue Cc: Stefano Babic Cc: Fabio Estevam Cc: Peng Fan Cc: Albert Aribaud Cc: Sven Ebenfeld Cc: George McCollister Cc: Breno Matheus Lima --- arch/arm/mach-imx/hab.c | 9 ++++++--- arch/arm/mach-imx/spl.c | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 09892a6..9fe6d43 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -373,7 +373,10 @@ static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc, ivt_offset = simple_strtoul(argv[2], NULL, 16); rcode = authenticate_image(addr, ivt_offset); - + if (rcode == 0) + rcode = CMD_RET_SUCCESS; + else + rcode = CMD_RET_FAILURE; return rcode; } @@ -415,7 +418,7 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size) uint32_t load_addr = 0; size_t bytes; ptrdiff_t ivt_offset = 0; - int result = 0; + int result = 1; ulong start; hab_rvt_authenticate_image_t *hab_rvt_authenticate_image; hab_rvt_entry_t *hab_rvt_entry; @@ -510,7 +513,7 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size) } if ((!is_hab_enabled()) || (load_addr != 0)) - result = 1; + result = 0; return result; } diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index d0d1b73..6e930b3 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -163,8 +163,8 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) /* HAB looks for the CSF at the end of the authenticated data therefore, * we need to subtract the size of the CSF from the actual filesize */ - if (authenticate_image(spl_image->load_addr, - spl_image->size - CONFIG_CSF_SIZE)) { + if (!authenticate_image(spl_image->load_addr, + spl_image->size - CONFIG_CSF_SIZE)) { image_entry(); } else { puts("spl: ERROR: image authentication unsuccessful\n");