From patchwork Fri Jan 12 12:39:56 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: 124312 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2014073qgn; Fri, 12 Jan 2018 04:41:57 -0800 (PST) X-Google-Smtp-Source: ACJfBotZLLZN4Hu19ek7ZC0zldM4xeMQlUAZeLgQ8/kNYU/RooW0C3HoviYXQx8WofF9Tl1Xmpea X-Received: by 10.80.240.86 with SMTP id u22mr5925025edl.276.1515760917305; Fri, 12 Jan 2018 04:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515760917; cv=none; d=google.com; s=arc-20160816; b=RXl6aYNo8gg8N4WGtejH0xefBUElv0gMlB/5d8JBnXvmRESzpb2D2ITKlzfx20cIAr lXi7oEwzrc4WPdtvH4clOHKyuWBgP2agNBEFtcgKQDJP+pqiO8MWJhDhNikFGpWwCFxE ikzbAVQgofmpAvDwpIk9dEu3LAiavJaXK/ZE/mIaLQgrOSEMfHDq75NUXBlqK+TGYw/4 iDXNCVR8MKyUIDVQ25ho8YS4UiOeDMbS8heUGBoJGsz/CJ+FaGYQL0MZgHokyyWtdcDe s0LKy+sUEwLJJFfcpjANh3/uIAQAh5EsWvbHREPzHw9h9O3Ft/pEe5VrEpZB+PPRc+CJ 513w== 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=YR6zb3s73Lwsg26QNHJM+OQB6FiZzHCxsFKv4cdiQkA=; b=KXA+Zx8s4YUoVxxVKEfQ1ExF7lIXiSY4IpVlL/grPuB8R0AOttZNPvBusIx95+gHqC kRGNdxH9pvnFVqoaXl1M79SRr0sAb9RdH8VnH5hME3jDFmV5iaf7URyKFKM7kwMNoM74 YbaxsHUXzWv14IeHvyADcaYla5wDE5dJ82cYtLx9D4+yjTqop19jhwgXtoRlyEThlcke VGPW9YVpqxAquRydlncNVzNddYj2sUAuIJMncVlCVam1ZILOAyMno9qEvpo3419UhgBk MS0zbtE/vGw1JvGCNyuUB0EFb3iSISr2wGbgvxqem2R4pnCubPYfUnSxUG63/rDirzdZ 1skQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V3YOpAzs; 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 l30si2901880edl.217.2018.01.12.04.41.57; Fri, 12 Jan 2018 04:41:57 -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=V3YOpAzs; 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 C7BA3C22157; Fri, 12 Jan 2018 12:41:07 +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 98CDEC220B8; Fri, 12 Jan 2018 12:40:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B7D20C220BE; Fri, 12 Jan 2018 12:40:25 +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 62E0BC220AD for ; Fri, 12 Jan 2018 12:40:25 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id f140so11509922wmd.2 for ; Fri, 12 Jan 2018 04:40:25 -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=ySFxBv/ByuxpRjbsAntbGNOEdsIMEzEt6so7xbNEWt4=; b=V3YOpAzsRwG5TLFJf2rju3gcSeWbxceZDT4z+CiOYOOwMfsAyweBs6iDQ14t4eHEvE dwQL89dwnhQGsKyznqtqjybAcqItS4sqYZm/BJdgGgR4NWzDOwmunMywEq3vWTNMHtst zf4a1bbipjS6NhZMETDjBAmCECc0AkQTxezWM= 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=ySFxBv/ByuxpRjbsAntbGNOEdsIMEzEt6so7xbNEWt4=; b=tszeNTZ8EwFP3QDpd695xYE4YEQjNaU0pWUxvak27nJBeThMEJFMu1yZMptyYfMoUL wc6ZcqwxE35qeCBtz1rpnr7CKLggmchNM+YNvu3Vhmt6cE9VBFoEwO2XSi+ZPBdAeqmL 2aTYhiBP5dStoKuxl0HjfTCoWWqZob1MOv9tfdd9pFHfvqQngjjxDD35ovAsl6BQYQns trGnALeE4BRIwHy6NbljiHjX2I/AKQ8m8YGYcOiY7b6SofLGFoZxwLZGVyWHLGFKDlI0 rf/+LO5i+ifVkku/P0/4V+Pk/3jss2yLjiqbfDkrhjaQMUCcOPDKk6yjLJzgQN9aB0ZV eczg== X-Gm-Message-State: AKGB3mIpBZ/15Brw4aijyivxVRu6LLKJB4ekwuvdnQ6PbfXvVxxsa4fe 00MxR5JpbCVU6LqDn5Dc/88SvV5hVXI= X-Received: by 10.80.214.136 with SMTP id r8mr35236425edi.288.1515760824781; Fri, 12 Jan 2018 04:40:24 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id w2sm13893585edb.4.2018.01.12.04.40.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 04:40:23 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Fri, 12 Jan 2018 12:39:56 +0000 Message-Id: <1515760819-15116-3-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515760819-15116-1-git-send-email-bryan.odonoghue@linaro.org> References: <1515760819-15116-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v6 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 Tested-by: Breno Lima Reviewed-by: Fabio Estevam --- 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");