From patchwork Thu Dec 28 18:49:21 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: 853515 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="R4QtYZRa"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3z6zVS6hxGz9s71 for ; Fri, 29 Dec 2017 05:57:20 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 97FB6C21DBA; Thu, 28 Dec 2017 18:50:30 +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 E5015C21DB2; Thu, 28 Dec 2017 18:49:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2C577C21CB1; Thu, 28 Dec 2017 18:49:47 +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 C6A6AC21C34 for ; Thu, 28 Dec 2017 18:49:46 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id y82so2846625wmg.1 for ; Thu, 28 Dec 2017 10:49:46 -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=R4QtYZRaQeStY3LBGZpvej4Mc5LWya2qhuWEGsV7mqJehriFa2Jotx1wTqRqcet3bQ Dh2m73z+1Viokk1bEYatoNHu7Wk3cq3FwVWgbvcuSfavXCO6A7Xgi6srNVAhkkDMrnGf APxwK1Yr6EPEB1MC2kxnA+4Ry22UlwhRdeetg= 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=quWJd+l/TiZhJqoGE1Xx6109FDI+lvp6rP65x8y6VSZu3LZaHJyI1FohyVyuvlUO2g kcuf4FQwo29Nwy5RGpc5gcLwSYeOFW4SO73ybocaCkIGnsPe19TlWdnQyfnOg2XhpTO/ 9iyFMc51jp3H9j6mQMmofFr6CMx3Tq8r81H1szAW4lv+uGlUY65DSZN1dzxwnVBcvrwV ZuRUJCmd9TOp0hdY+b9G3+dBpAmLghLUcKtXjS1TqfRHzTvrTnUM82RmkIWPPQ+xogFV /mhaHwDtV+R32LfSmJ89Gznqx4YxqGFkApLz8YlIf4GVbkLK5UsKVs5aJfjvq+2L1wq2 /L5g== X-Gm-Message-State: AKGB3mLD0KL9PuS4QSD2pubcPG5n1Uo/FF+WYCCAVKWq1eV83yxBg3lz bhcotOSaazaNhJtbikzAaijFv061y4I= X-Google-Smtp-Source: ACJfBouDGC7KGwPCdA0vJMX8/nlxzY0x7Uv265V5qza32/IFqgcN6OcmU5w/7PXvRl/g0UaROcfZUw== X-Received: by 10.80.144.112 with SMTP id z45mr40321618edz.185.1514486986191; Thu, 28 Dec 2017 10:49:46 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id x28sm35246579edd.0.2017.12.28.10.49.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Dec 2017 10:49:45 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Thu, 28 Dec 2017 18:49:21 +0000 Message-Id: <1514486982-19059-3-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514486982-19059-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514486982-19059-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v2 02/23] 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");