From patchwork Tue Jan 2 16:43:47 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: 123158 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9169731qgn; Tue, 2 Jan 2018 08:45:44 -0800 (PST) X-Google-Smtp-Source: ACJfBovNA7LumMaK2QiKjtJ6v71DCsCqwZlyK3iv78ut39J/r7imVwQSlVZ3tYOftxfwLWKDlZks X-Received: by 10.80.180.16 with SMTP id b16mr63143259edh.136.1514911544791; Tue, 02 Jan 2018 08:45:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911544; cv=none; d=google.com; s=arc-20160816; b=BqAmp/eEtOW4zIMCroV+eFlbk6tF65qZsj/wVE5M/BHrCbEcbFBF3x60ku0OUkF6RL wA0iIoc7CSF5ggvH1s66Oqmh9DFcjCh3JBnaqiPkiAeUijGCsiqCP01dtNvw3Ge+oRTm V5HiRAlBISL2diXYHiRO++0mCa4uUkEOAgP/ys3GoYJztkQJdPvOlMFb6gxLASSKa42y i9SRWpypwKEjEaAg7jH09aZUjWBSPUmZe8hb+dduZMl3moyDrlz67YqsuqDgv+hRt8xJ qRu8aEHcsl0Pw3d7qx7RfiJLvJZ532HPlgVxMmfYlr5kkbQNxkQS6PGiXozQnJba1XCo KPxQ== 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=HS7KCmC5EP3My/+W1w4nqOM20jbfY7ICfxQOJquCBzI=; b=C6otGfEeT7pvk1l9akNh2syGSeCTDoUvMdbk89JYc62iuJpFS9/mZdkFYS3Sj8w6Kn ii/EZdx3WJiiqSdwxOCYnTK0MsSaEHF0eOKoQKeZVSghOHS0PqMuz8nVD6SY5Lk3B1B3 B0bnTdWRq27bKo2KDdBeyhoNgAOw8mUEdF4SsCVhNSdjAvfT7QYK3JmycYCdps+sem/D ud9WtVbuLpMXTSOz3NcP9/xg1TFSpfD0kAvtH1b+/myEOIF1KiboGjQdPRHxxluQNSXf GbTdT5cY90NXUAJymF4Xx7CIopIAUHWGcw4tIqGaX5hmVBrq/0Nk8f/9Y4E6mk2nbpb9 VO0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=R+TottIh; 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 g26si8649672edg.138.2018.01.02.08.45.44; Tue, 02 Jan 2018 08:45:44 -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=R+TottIh; 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 0E5E6C21E5A; Tue, 2 Jan 2018 16:44:46 +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 31C96C21DA3; Tue, 2 Jan 2018 16:44:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2C58EC21C2B; Tue, 2 Jan 2018 16:44:25 +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 CBAEAC21C29 for ; Tue, 2 Jan 2018 16:44:24 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id g75so62446117wme.0 for ; Tue, 02 Jan 2018 08:44:24 -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=3YZdInYDxFuSNZyaa3f41D9mVUQyXzcYYtPmrUIIf60=; b=R+TottIh2v4Yf5VdpHsJfHfdk6uOZbHt4yh1fL730Qeo7KWRR4lBvjZ73N2OISfiK2 ZS+VKoVZwpNY8PwO1VcVyGSV8IYUeSU1AB87ix0iXgML12opT+YSqYqMOBXZa2LFDfIh 1eqkNgcRZYYjwWYgYQ4YLtQKqFzrWXN+s1/vo= 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=3YZdInYDxFuSNZyaa3f41D9mVUQyXzcYYtPmrUIIf60=; b=tGaEGoJucCLjAfDp6VSh7wZ/ES9HfFnJgKeNECrT6bUAG6fUzrVm/um0KEs/ph9zIE lQhhjPBvS1YsN4V80zEygAk0rqkxKrqJVVUX5ZNvA+MvG/xzhab4g6zxkguc/PlhrbI0 Vva/fkqcE3QqGmBQzuX4MAC2PJcqKA28w299Iur9MhqLhDuIcqOIMTtE12tjX1cGX4YY M2TtM8SU2P3n9xvvZdayQehaS+CiChX8j8lV22JbHpuUy6AvHC1xQvpcNpJ7Z6sIj4TM xSOqUfKAtGj4nKGyv5sxBgYQE8AULlwPG77Q5r8M3o/wmjzNy+Fp0VzgPe05ZQo/mGHA CG1w== X-Gm-Message-State: AKGB3mJjoRGw+B7rGE+HsNVRxGywWaQXw8AFc/ux0dQb51n4T+O91vZb HViwh/h2jpgW5/t/KqLZLUg9Q3SK6F8= X-Received: by 10.80.209.193 with SMTP id i1mr61834644edg.107.1514911464223; Tue, 02 Jan 2018 08:44:24 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:23 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:47 +0000 Message-Id: <1514911451-4520-2-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 01/25] arm: imx: hab: Make authenticate_image return int 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" Both usages of authenticate_image treat the result code as a simple binary. The command line usage of authenticate_image directly returns the result code of authenticate_image as a success/failure code. Right now when calling hab_auth_img and test the result code in a shell a passing hab_auth_img will appear to the shell as a fail. The first step in fixing this behaviour is to fix-up the result code return by authenticate_image() itself, subsequent patches fix the interpretation of authenticate_image so that zero will return CMD_RET_SUCCESS and non-zero will return CMD_RET_FAILURE. The first step is fixing the return type in authenticate_image() so do that now. 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/include/asm/mach-imx/hab.h | 2 +- arch/arm/mach-imx/hab.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index e0ff459..1b7a5e4 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -145,6 +145,6 @@ typedef void hapi_clock_init_t(void); /* ----------- end of HAB API updates ------------*/ -uint32_t authenticate_image(uint32_t ddr_start, uint32_t image_size); +int authenticate_image(uint32_t ddr_start, uint32_t image_size); #endif diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 02c7ae4..09892a6 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -410,7 +410,7 @@ static bool is_hab_enabled(void) return (reg & IS_HAB_ENABLED_BIT) == IS_HAB_ENABLED_BIT; } -uint32_t authenticate_image(uint32_t ddr_start, uint32_t image_size) +int authenticate_image(uint32_t ddr_start, uint32_t image_size) { uint32_t load_addr = 0; size_t bytes; From patchwork Tue Jan 2 16:43:48 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: 123160 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9170933qgn; Tue, 2 Jan 2018 08:46:56 -0800 (PST) X-Google-Smtp-Source: ACJfBounInhz8S1z4TqNDLGYZ4pKcMAuGUrvHl6RkxHxx1FVUtBP3pX7xTJRNbs5jY3S1Gb70Tf+ X-Received: by 10.80.214.74 with SMTP id c10mr61603990edj.271.1514911616841; Tue, 02 Jan 2018 08:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911616; cv=none; d=google.com; s=arc-20160816; b=yxOrvG3XY5xumm8mhqaqPDtH4cf+yAz8uA+Qfdbie6fbE4YAfgFsDeCqYIUjlwFI6J JqqUWk+eSsyEqG7rfOF4bYWojbGEtzzfgFUYWBUtCPTtiBoWHN6pdrfz/FMJ8tOpIzwt zyPknNxvz7joRbI9sWshjdFVqMkUNmFITg32Zxyzt1uhuIlpFfwLP9GgkL1KZwo2/9iK h5504EcUKW2PbFA5sriEyjoaM6bKkQBtGrwNoKtFs5hiGEf1Bqgvcn79w8/XSfInAPla 0YnKIgRJHd6R/ev9Ol4f7dVNep0BRB79rOr+iNF9KwOtiwiZGPJuBdxCNFq1FVl3P0xj xO9Q== 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=nOoFvocq0u5UAVTqAEAZMlw3pncPaKA+lpLfo4AkSYU5JmETG0YRsVBlp0+v//PLKS 3UjIj34h9z9gSSiIMkMq10TXZ9BBZkKoO+3gOllqAQ1VYO3POfT6VbeHLGBBethm5OJG Rpr7leS1dgJ6zn2rTqa0yxrQ2+MyFZAe1joczJEEplkKaTXUXvH0qzWgfFTZ2W3XDddN UUYwehT/92U5apLI2myLasRekanU5FOUR4j7SFFgKSm5F0sRqUUlZnufKxtSwpBtowQS 5JFpGpf+6WE4uKoJZyIknasNAJk+kw8og/g/qg1F2OKvLfn1tELk4zMgcmhH+2HiqTRC AwXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=d9xZMiFe; 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 r1si11990479edr.56.2018.01.02.08.46.56; Tue, 02 Jan 2018 08:46:56 -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=d9xZMiFe; 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 602E3C21E4C; Tue, 2 Jan 2018 16:45: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 0E56AC21DCE; Tue, 2 Jan 2018 16:44:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B42EBC21DB0; Tue, 2 Jan 2018 16:44:29 +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 08C22C21C29 for ; Tue, 2 Jan 2018 16:44:26 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id t8so62060330wmc.3 for ; Tue, 02 Jan 2018 08:44:26 -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=d9xZMiFeekmuDii0+t2aSagJnfqcrZKyeGpcf2gBJWpuqTmXnCEj6g/AyBwv2rIyRh UwrQ6fmSshBiTGvolS9iRlQpYIXkSQUsK5Uah2KEjyrV91+ry+slOU/nu0eT68DUfeBk LFgKwIFkIhO68DVU9bgBMjJcXgpo5g1DEUx6M= 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=jqZNv9ilNbsw5AS1+hD2+jXt9X4J8CfFCu87I2vvMwF0IlFJ1wNA3BoIofCowusQCI 1BoTXt9/gplgoY1GwZGoqQPv0Nmb+fGxCdyRiJP8b+iERcqK+jXYReVSXmD5mikHdQnS Sb0dIEqzsE1wgJN1+c3Kn9Xif/pLYXnHS/SWklnXXy3cp0pXUkeZkWKLunyfPkpfxiH/ pXd6yklYLVyWkp3Xb2jBriyna1IDGvf5IvsCHo6AyB5RjXjYGIhCycuiaDb+zH+5ZHbM /O9sMQwm87iy8IikvlsixNlr7xDbOZSU1J4YdVrUmoLJH/fFu3yU9dqcvT1TjlAnvOrF duBA== X-Gm-Message-State: AKGB3mIF8Rr4eMfA+/oehuRHlS4odlzMGzMgIsLDTxFJ+MyG5QV2pKqO 42wAHuV/YkBFTgtXvjQ4M8vfd/lryF4= X-Received: by 10.80.139.180 with SMTP id m49mr65035691edm.36.1514911465424; Tue, 02 Jan 2018 08:44:25 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:24 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:48 +0000 Message-Id: <1514911451-4520-3-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 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"); From patchwork Tue Jan 2 16:43:49 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: 123173 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9180153qgn; Tue, 2 Jan 2018 08:57:07 -0800 (PST) X-Google-Smtp-Source: ACJfBosJ2bly2tqFoeWOGrAdqV494pYrvrUgZmsfPMLjVE24nTNpt87qE3E+/9AVDbagH8Q/Viwn X-Received: by 10.80.176.194 with SMTP id j60mr63813306edd.254.1514912227626; Tue, 02 Jan 2018 08:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912227; cv=none; d=google.com; s=arc-20160816; b=HZRdc/V2TZgrHKZrXVw0EaTaVHUs0R7ieQkl35nBYuZmL38XFb++eZxcG8HhlmO9cb E+Om7XH2rr4D8DRpkh08BKPGZNLoNSzjGeiOMxCvZgVXI44X7yV0+L+i1Zn1lOnIbykj 5yxrxs19zxzQG9HaDz5zEhZ1tKcxheLhFg1grgFeqfqTZx7ydc7b/VCYXf38kq8ng+Tw 4eAot0A5kzMxPpr8oORrWHNujt6Hdib2PZiF3gW97Xi3BF6BhuDdnyxumHpQIVpgUKrK 4t9aZg+3wJMKvKjYOJZAjP72hBgeTYDJG0hF3mHgrluumXV03ZA3IbATQ9yjS8tT508U ffvA== 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=/WitLXfEnpiCLqcc5cbQcLmodoRowOstK7tA67Wctsk=; b=SEM8BsZQYipTsyFG+m+GyMNd3F7a88eA5thNbXqZlPBIAT/prqCKb8xJhAQerwOFcK RLVEsi6q5pocgp9haowXMRBbrloS7cLDm5tJhL+eUhH2shDOz1jM9wi8z2poTkYXTEV0 qsiE+Kqen2toRFGkeCyJn/U8BVyRZML3f2WXtzkHBsOZ6tjxeytFe61CFcEz9e7oo7Np lvzey3XcYqLV/idgpw5XvrED33KE4OwLjMy09uwk4Zw3B7zA5yEuPgfNZNsF0VCyDzDS Yl/AZX7Y0J/xrU0frcBzgyCK7n+Rdpj8f67UJ7AOdp/ST4fbMC0+KV0D6+H/iqkNNhzk nVRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LuHJ52FF; 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 o15si4630574edk.480.2018.01.02.08.57.07; Tue, 02 Jan 2018 08:57:07 -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=LuHJ52FF; 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 28596C21DE7; Tue, 2 Jan 2018 16:45:52 +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 2A6CBC21DF4; Tue, 2 Jan 2018 16:44:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F2C44C21C2B; Tue, 2 Jan 2018 16:44:31 +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 46DB4C21DD9 for ; Tue, 2 Jan 2018 16:44:27 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id 9so62082307wme.4 for ; Tue, 02 Jan 2018 08:44:27 -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=tEb+zxvqiXfooPFKqTTt4TM4oFUuaaywnnCJUJSankY=; b=LuHJ52FF7jNb3l6ECeqIXD7zaiePmyNUGO/mr63zVzdZwjROFxxsg5Iq669wbAC3v2 eb3FM2TsLw4XGI2laZIMQDfWAgt55kbBvv2JSsGszU2ghJPGLuSQCCSeDQJug7SVo3cd CmWOuMlGgH+y7SF2riZ4LOk9Xp5EUkQOi/vO0= 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=tEb+zxvqiXfooPFKqTTt4TM4oFUuaaywnnCJUJSankY=; b=rxt1hr+/EZ2xTbmYy/veKbNP3pCj9WxVwMR6GpzgiYqnLcNV0BWUVBIVY+qmWvRGcl mQWKXBcUZE7hTPiIYLNbnVZmHxHRYD/Kp3S8Cui9C6ayMCVZuCIRy2onCshgNQ8iBuNf FPbjywHp+7s6ZWVLEQMbFxoc6npEaQD53ud/WGCd0o6LBe49HcIUtvs1tfCq619/hY3R ToSGFEIODZhAuj8YMhXPeccNEbZDwFXs3180TILzxtL82NGTzjLx9C6DSOpPbr597yMG bGyYK9vaZr6hEYgVT7YfH0qgJJTsPZX4+wWWgKi2smmrZ3iO9kHqxkDvm5OW42nFFds1 3MxA== X-Gm-Message-State: AKGB3mIcL5ENOW1lsWOm+yVlrn1fFSle6la2dTfmD5OVk88J63XajwLz MVgOBF9MioRBTQfyd4RLR3JSZn+w55o= X-Received: by 10.80.170.207 with SMTP id r15mr65667626edc.220.1514911466663; Tue, 02 Jan 2018 08:44:26 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:25 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:49 +0000 Message-Id: <1514911451-4520-4-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 03/25] arm: imx: hab: Optimise flow of authenticate_image on is_enabled fail 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" There is no need to call is_enabled() twice in authenticate_image - it does nothing but add an additional layer of indentation. We can check for is_enabled() at the start of the function and return the result code directly. 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 | 138 ++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 9fe6d43..6f86c02 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -428,91 +428,91 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size) hab_rvt_entry = hab_rvt_entry_p; hab_rvt_exit = hab_rvt_exit_p; - if (is_hab_enabled()) { - printf("\nAuthenticate image from DDR location 0x%x...\n", - ddr_start); + if (!is_hab_enabled()) { + puts("hab fuse not enabled\n"); + return result; + } - hab_caam_clock_enable(1); + printf("\nAuthenticate image from DDR location 0x%x...\n", + ddr_start); - if (hab_rvt_entry() == HAB_SUCCESS) { - /* If not already aligned, Align to ALIGN_SIZE */ - ivt_offset = (image_size + ALIGN_SIZE - 1) & - ~(ALIGN_SIZE - 1); + hab_caam_clock_enable(1); - start = ddr_start; - bytes = ivt_offset + IVT_SIZE + CSF_PAD_SIZE; + if (hab_rvt_entry() == HAB_SUCCESS) { + /* If not already aligned, Align to ALIGN_SIZE */ + ivt_offset = (image_size + ALIGN_SIZE - 1) & + ~(ALIGN_SIZE - 1); + + start = ddr_start; + bytes = ivt_offset + IVT_SIZE + CSF_PAD_SIZE; #ifdef DEBUG - printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", - ivt_offset, ddr_start + ivt_offset); - puts("Dumping IVT\n"); - print_buffer(ddr_start + ivt_offset, - (void *)(ddr_start + ivt_offset), - 4, 0x8, 0); - - puts("Dumping CSF Header\n"); - print_buffer(ddr_start + ivt_offset+IVT_SIZE, - (void *)(ddr_start + ivt_offset+IVT_SIZE), - 4, 0x10, 0); + printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", + ivt_offset, ddr_start + ivt_offset); + puts("Dumping IVT\n"); + print_buffer(ddr_start + ivt_offset, + (void *)(ddr_start + ivt_offset), + 4, 0x8, 0); + + puts("Dumping CSF Header\n"); + print_buffer(ddr_start + ivt_offset + IVT_SIZE, + (void *)(ddr_start + ivt_offset + IVT_SIZE), + 4, 0x10, 0); #if !defined(CONFIG_SPL_BUILD) - get_hab_status(); + get_hab_status(); #endif - puts("\nCalling authenticate_image in ROM\n"); - printf("\tivt_offset = 0x%x\n", ivt_offset); - printf("\tstart = 0x%08lx\n", start); - printf("\tbytes = 0x%x\n", bytes); + puts("\nCalling authenticate_image in ROM\n"); + printf("\tivt_offset = 0x%x\n", ivt_offset); + printf("\tstart = 0x%08lx\n", start); + printf("\tbytes = 0x%x\n", bytes); #endif - /* - * If the MMU is enabled, we have to notify the ROM - * code, or it won't flush the caches when needed. - * This is done, by setting the "pu_irom_mmu_enabled" - * word to 1. You can find its address by looking in - * the ROM map. This is critical for - * authenticate_image(). If MMU is enabled, without - * setting this bit, authentication will fail and may - * crash. - */ - /* Check MMU enabled */ - if (is_soc_type(MXC_SOC_MX6) && get_cr() & CR_M) { - if (is_mx6dq()) { - /* - * This won't work on Rev 1.0.0 of - * i.MX6Q/D, since their ROM doesn't - * do cache flushes. don't think any - * exist, so we ignore them. - */ - if (!is_mx6dqp()) - writel(1, MX6DQ_PU_IROM_MMU_EN_VAR); - } else if (is_mx6sdl()) { - writel(1, MX6DLS_PU_IROM_MMU_EN_VAR); - } else if (is_mx6sl()) { - writel(1, MX6SL_PU_IROM_MMU_EN_VAR); - } + /* + * If the MMU is enabled, we have to notify the ROM + * code, or it won't flush the caches when needed. + * This is done, by setting the "pu_irom_mmu_enabled" + * word to 1. You can find its address by looking in + * the ROM map. This is critical for + * authenticate_image(). If MMU is enabled, without + * setting this bit, authentication will fail and may + * crash. + */ + /* Check MMU enabled */ + if (is_soc_type(MXC_SOC_MX6) && get_cr() & CR_M) { + if (is_mx6dq()) { + /* + * This won't work on Rev 1.0.0 of + * i.MX6Q/D, since their ROM doesn't + * do cache flushes. don't think any + * exist, so we ignore them. + */ + if (!is_mx6dqp()) + writel(1, MX6DQ_PU_IROM_MMU_EN_VAR); + } else if (is_mx6sdl()) { + writel(1, MX6DLS_PU_IROM_MMU_EN_VAR); + } else if (is_mx6sl()) { + writel(1, MX6SL_PU_IROM_MMU_EN_VAR); } + } - load_addr = (uint32_t)hab_rvt_authenticate_image( - HAB_CID_UBOOT, - ivt_offset, (void **)&start, - (size_t *)&bytes, NULL); - if (hab_rvt_exit() != HAB_SUCCESS) { - puts("hab exit function fail\n"); - load_addr = 0; - } - } else { - puts("hab entry function fail\n"); + load_addr = (uint32_t)hab_rvt_authenticate_image( + HAB_CID_UBOOT, + ivt_offset, (void **)&start, + (size_t *)&bytes, NULL); + if (hab_rvt_exit() != HAB_SUCCESS) { + puts("hab exit function fail\n"); + load_addr = 0; } + } else { + puts("hab entry function fail\n"); + } - hab_caam_clock_enable(0); + hab_caam_clock_enable(0); #if !defined(CONFIG_SPL_BUILD) - get_hab_status(); + get_hab_status(); #endif - } else { - puts("hab fuse not enabled\n"); - } - - if ((!is_hab_enabled()) || (load_addr != 0)) + if (load_addr != 0) result = 0; return result; From patchwork Tue Jan 2 16:43:50 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: 123159 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9170687qgn; Tue, 2 Jan 2018 08:46:43 -0800 (PST) X-Google-Smtp-Source: ACJfBouFVEEPZ8Kr6FLC8rMOEaLYnNeN93uANk4fQoN0LIxZJ0KbX8XczpUTNpDl0dbxdSE2NbOT X-Received: by 10.80.170.87 with SMTP id p23mr64758964edc.289.1514911602914; Tue, 02 Jan 2018 08:46:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911602; cv=none; d=google.com; s=arc-20160816; b=t04Fb5XzrWX7cMLEGVyC0Ew/kBfZJQbnc9dLDnLl832uHjTvLTmY0b86rQq0TZ0Df+ 80UObHvlbrMBm7onsaZQ5+sbzumQxSi5KwToguxuHmFK8kICFuMIEb17uJKxlqwQWHTI tw+pu2zAvWF/WBXnWvt5kEMxZtlDV/9Ce7E68t5FWHX5cXlUBgFHR3tI1KB68JMMsBhV LUBrNnEozPbFPyLlrhhmDwI7niY1en0A657X4Xh8k8BCoc7BUbg+rfD+MGYmBwFvu0IX PSrWvDy7WGkfatZ2g+7zuKIitR9kFNJoWhdQs7GO1Zul/grn9CLBn3/kpmoj02M11j+0 JhgA== 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=ltIxGxwbriNIdsJA8E5Tn2uUeswTayfs+quuAx+dYJY=; b=y49ItoXCvdykDkKT3lAy+vUsYC93qdAKeEV/M5HyEu0a+3gUi+fuCaDCPe+sTCnsER 7NZ/lZWV4fJNb87aZXvzBOw28G1TtL0I5BwGlHOuoSR8Pb+4IY7Un/dtBYuKpMy/lBei AQtmYg17NFrBjKoNWHBK2Tvep369tfaiJvZkr1OHksX+RNeJqyQ81V2bYpUW9UYaXp33 t30/c8dv8yr1W3IGPWp+vpdG4dBYwP3PQIqPWDto589AtpOdL0MUiM6NzosIaKtsG0U8 8STFrR7NqG0yiU8t2ocmN4aa2F0kjmNOIOc9/17zK/gUeVKixhxZn5/E/DfTGLE0qFCP aVHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=i6idi7gc; 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 i59si4351795edd.106.2018.01.02.08.46.42; Tue, 02 Jan 2018 08:46:42 -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=i6idi7gc; 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 76A32C21E10; Tue, 2 Jan 2018 16:45:28 +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 0B32CC21DC8; Tue, 2 Jan 2018 16:44:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 935A1C21DF0; Tue, 2 Jan 2018 16:44:32 +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 76E93C21DD0 for ; Tue, 2 Jan 2018 16:44:28 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id i11so61727670wmf.4 for ; Tue, 02 Jan 2018 08:44:28 -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=EH9nAsP2R6CcqdRJVaGDdlF3b/WA9xPFI4ki25Ui41g=; b=i6idi7gc0PhNHr1R/XVOaov9e2J/Zheg5ZlMhPZrzREge6d3SrsXkgH0T2NdorQMmy bwsK4IZQFjVK4AdQ3GGRyLp0JOpdvbNwJ+rhhC75KCgf9Sof7A42+pEVuIt1p7rrmGYL Fn9sJbehZ/JNZOzVX3Hq9yQVSitcXAqPdtKTE= 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=EH9nAsP2R6CcqdRJVaGDdlF3b/WA9xPFI4ki25Ui41g=; b=g6UkwCHFZG62I7xm+tx0PY4ZEGC/MOg4v/auIKqvp/ZTI4wia4FEvos9F6Aqajoik+ YM3SPj1WzFWPAVVPGpCOhEQC7+kE+P/U932IVF/OYQvDJ/H5Ebbh0fHYC7wYpVqH6ECF QD7+uj2pZKsrjEjq3OJuHGXEcKY2xWp1JZt+J/uEKlS3Dtnd8yotr+yYyrj77jHJJ0Zr IFekHKcGlkT42Kgp3iXsCc4BkfJ6AkuN6/LD6+zWHE9RqOQF81YAHvZ14lj9lnqiHMXF JyGPRIERwSIanR/mtzhgdlwXbbvbo7MMtK5tQrKzX6jCkRlVw0/gBh949aQhRhzbW9XU K4hg== X-Gm-Message-State: AKGB3mIwSxzUAjdgEagMO3dSAZ8BOhWBM4q0PfyoyfZPsBfnGv51Z4p/ SUoclDZ9IwdkomP3coi0F9N54j0F9Ok= X-Received: by 10.80.205.25 with SMTP id z25mr62153145edi.77.1514911467852; Tue, 02 Jan 2018 08:44:27 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:27 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:50 +0000 Message-Id: <1514911451-4520-5-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 04/25] arm: imx: hab: Optimise flow of authenticate_image on hab_entry fail 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" The current code disjoins an entire block of code on hab_entry pass/fail resulting in a large chunk of authenticate_image being offset to the right. Fix this by checking hab_entry() pass/failure and exiting the function directly if in an error state. 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 | 118 ++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 6f86c02..f878b7b 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -438,75 +438,77 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size) hab_caam_clock_enable(1); - if (hab_rvt_entry() == HAB_SUCCESS) { - /* If not already aligned, Align to ALIGN_SIZE */ - ivt_offset = (image_size + ALIGN_SIZE - 1) & - ~(ALIGN_SIZE - 1); + if (hab_rvt_entry() != HAB_SUCCESS) { + puts("hab entry function fail\n"); + goto hab_caam_clock_disable; + } - start = ddr_start; - bytes = ivt_offset + IVT_SIZE + CSF_PAD_SIZE; + /* If not already aligned, Align to ALIGN_SIZE */ + ivt_offset = (image_size + ALIGN_SIZE - 1) & + ~(ALIGN_SIZE - 1); + + start = ddr_start; + bytes = ivt_offset + IVT_SIZE + CSF_PAD_SIZE; #ifdef DEBUG - printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", - ivt_offset, ddr_start + ivt_offset); - puts("Dumping IVT\n"); - print_buffer(ddr_start + ivt_offset, - (void *)(ddr_start + ivt_offset), - 4, 0x8, 0); - - puts("Dumping CSF Header\n"); - print_buffer(ddr_start + ivt_offset + IVT_SIZE, - (void *)(ddr_start + ivt_offset + IVT_SIZE), - 4, 0x10, 0); + printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", + ivt_offset, ddr_start + ivt_offset); + puts("Dumping IVT\n"); + print_buffer(ddr_start + ivt_offset, + (void *)(ddr_start + ivt_offset), + 4, 0x8, 0); + + puts("Dumping CSF Header\n"); + print_buffer(ddr_start + ivt_offset + IVT_SIZE, + (void *)(ddr_start + ivt_offset + IVT_SIZE), + 4, 0x10, 0); #if !defined(CONFIG_SPL_BUILD) - get_hab_status(); + get_hab_status(); #endif - puts("\nCalling authenticate_image in ROM\n"); - printf("\tivt_offset = 0x%x\n", ivt_offset); - printf("\tstart = 0x%08lx\n", start); - printf("\tbytes = 0x%x\n", bytes); + puts("\nCalling authenticate_image in ROM\n"); + printf("\tivt_offset = 0x%x\n", ivt_offset); + printf("\tstart = 0x%08lx\n", start); + printf("\tbytes = 0x%x\n", bytes); #endif - /* - * If the MMU is enabled, we have to notify the ROM - * code, or it won't flush the caches when needed. - * This is done, by setting the "pu_irom_mmu_enabled" - * word to 1. You can find its address by looking in - * the ROM map. This is critical for - * authenticate_image(). If MMU is enabled, without - * setting this bit, authentication will fail and may - * crash. - */ - /* Check MMU enabled */ - if (is_soc_type(MXC_SOC_MX6) && get_cr() & CR_M) { - if (is_mx6dq()) { - /* - * This won't work on Rev 1.0.0 of - * i.MX6Q/D, since their ROM doesn't - * do cache flushes. don't think any - * exist, so we ignore them. - */ - if (!is_mx6dqp()) - writel(1, MX6DQ_PU_IROM_MMU_EN_VAR); - } else if (is_mx6sdl()) { - writel(1, MX6DLS_PU_IROM_MMU_EN_VAR); - } else if (is_mx6sl()) { - writel(1, MX6SL_PU_IROM_MMU_EN_VAR); - } + /* + * If the MMU is enabled, we have to notify the ROM + * code, or it won't flush the caches when needed. + * This is done, by setting the "pu_irom_mmu_enabled" + * word to 1. You can find its address by looking in + * the ROM map. This is critical for + * authenticate_image(). If MMU is enabled, without + * setting this bit, authentication will fail and may + * crash. + */ + /* Check MMU enabled */ + if (is_soc_type(MXC_SOC_MX6) && get_cr() & CR_M) { + if (is_mx6dq()) { + /* + * This won't work on Rev 1.0.0 of + * i.MX6Q/D, since their ROM doesn't + * do cache flushes. don't think any + * exist, so we ignore them. + */ + if (!is_mx6dqp()) + writel(1, MX6DQ_PU_IROM_MMU_EN_VAR); + } else if (is_mx6sdl()) { + writel(1, MX6DLS_PU_IROM_MMU_EN_VAR); + } else if (is_mx6sl()) { + writel(1, MX6SL_PU_IROM_MMU_EN_VAR); } + } - load_addr = (uint32_t)hab_rvt_authenticate_image( - HAB_CID_UBOOT, - ivt_offset, (void **)&start, - (size_t *)&bytes, NULL); - if (hab_rvt_exit() != HAB_SUCCESS) { - puts("hab exit function fail\n"); - load_addr = 0; - } - } else { - puts("hab entry function fail\n"); + load_addr = (uint32_t)hab_rvt_authenticate_image( + HAB_CID_UBOOT, + ivt_offset, (void **)&start, + (size_t *)&bytes, NULL); + if (hab_rvt_exit() != HAB_SUCCESS) { + puts("hab exit function fail\n"); + load_addr = 0; } +hab_caam_clock_disable: hab_caam_clock_enable(0); #if !defined(CONFIG_SPL_BUILD) From patchwork Tue Jan 2 16:43:51 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: 123169 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9177719qgn; Tue, 2 Jan 2018 08:54:20 -0800 (PST) X-Google-Smtp-Source: ACJfBosE+Y+Q9Oo4X6CNoYg2JMlZr3nhvaSOKhI+JT2hlTgKR9Hdg3xACXVoQgmLfC62v/xMTPGW X-Received: by 10.80.151.24 with SMTP id c24mr64932455edb.47.1514912060078; Tue, 02 Jan 2018 08:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912060; cv=none; d=google.com; s=arc-20160816; b=sOW7D57Yh33Hz+U30r0ZzDsxwvX0/GDugvlRBc1EYQcrCqmIvca+PtOUazfFxYEFUN kA2SwEQhgDnbBxxhhowNQn/b1ER4HkCpJbrMUXmNSeJ2H04hGMVAfQU1hh4fxBbPS0yY sC6bGu0M8tFvTAJceN7rlbkXpok3fRj/cKc35UEsUJJg5yU37BLavznlHpwE7hKAAJA7 8JBCZdzFw6bNLVPMoRMypkWX7/ahnyumYEtUffSFapDpOwGRgg0Gq5xxtrAW3nIvM+K4 cRCFHQS1Fn8JSwY66XuOfRqtS/m02kac62LHTRpVZdHAm0wCFnY0dxfmIFX3dXs2rv0c W/XA== 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=ikhStahDui4p/tFfHpF7zYtX8K+0lVPEu6TRgvewZ2w=; b=e+4Kmu2RcNPIl8f6TCGGUETNowCy8O8PVJQYYD14KP9dwkdsswMMeRP8rhn9SEqU3Y BASurO9CDUAuxAI506lJESt+BrVhjXKsyQ2LCINfXWqQV96tw5K9vRJgbJBTVOG3/po9 sh9KjsokxRIRx7sJozyzd7kmze7Xa4BawbZsjVqtoGuBMAVv+7wCOb527oJPkCzJP5NM lNZqohLh+lwtxBeD6CgHqY7WXQuaSQmEk6ItCYNX+vo2YdUZkxNLyx+SAtaZrUlOfPT2 V7vQP9yWr+tf9z4kh4LSQ1a1x8YlwxwO81FEacXMYRcJbehJrxMg86vd7Jv41ERElBeP bhxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EwCwptA7; 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 a39si2506843eda.495.2018.01.02.08.54.19; Tue, 02 Jan 2018 08:54:20 -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=EwCwptA7; 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 AFBFBC21C34; Tue, 2 Jan 2018 16:46:14 +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 5F88CC21DE7; Tue, 2 Jan 2018 16:44:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BEE0BC21E0A; Tue, 2 Jan 2018 16:44:33 +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 D8420C21DDB for ; Tue, 2 Jan 2018 16:44:29 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id t8so62060623wmc.3 for ; Tue, 02 Jan 2018 08:44:29 -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=5osmqO6RuGeR5rNp1YmiKz2CDqY4yTY8yMk3hzOQD9k=; b=EwCwptA7pl5nK5PUln4p6T1wF96vBApHDqoTbRIn6t+KWUc8UTOlddaYyjjkyKZL8e C2wCjdomlWzGp91/JGWtWBM7SgWzSvnUG1qqb+N8s0KgjLu43C4w2OgofLVch6stHdp3 ldvv9kTKYR8rdxuov644sE3a/ol0qCMBzRq90= 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=5osmqO6RuGeR5rNp1YmiKz2CDqY4yTY8yMk3hzOQD9k=; b=kSXhnME74mYbmxD/nbiLes+DK3HbJJdWMCIpLGZ20K697VEXx3In9yECKEezXnDfvr IsFXi4x1A1J06fg9xfsVexhTI7i53qnsqxUOMD2Zl4Csu3PAh1irbf1XR694USDZVe1H 4mgdsEitZ6GFSUCtkOEoUyHe7PyoXNQXBSo477ZTs1Eir37aIGDjkcGSqhd/4mfx4yc+ oMRLkdIHgJbPeUPEzoWZa+D+EngRZuNq5ObG+QVq1+sa1AvurG3knY5JEQUK3Dmcr0iN g801VPJHcohcED1aOVvfSBSbZb+hbquJ9IoEQTkiFm6nWzKGX2iv11qoRG2p5/fOPc89 kxnw== X-Gm-Message-State: AKGB3mJ1y1rQ0Jwod9JUOYgcOrsdH8uBWQlVe550x1O1F8u41nHZR8lZ oYdrRuQ3TThnu9CN9p9ETzHkBiO5CDU= X-Received: by 10.80.213.90 with SMTP id f26mr19682162edj.225.1514911469199; Tue, 02 Jan 2018 08:44:29 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:28 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:51 +0000 Message-Id: <1514911451-4520-6-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 05/25] arm: imx: hab: Move IVT_SIZE to hab.h 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" The size of the IVT header should be defined in hab.h move it there now. 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/include/asm/mach-imx/hab.h | 2 ++ arch/arm/mach-imx/hab.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 1b7a5e4..3c19d2e 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -143,6 +143,8 @@ typedef void hapi_clock_init_t(void); #define HAB_CID_ROM 0 /**< ROM Caller ID */ #define HAB_CID_UBOOT 1 /**< UBOOT Caller ID*/ +#define IVT_SIZE 0x20 + /* ----------- end of HAB API updates ------------*/ int authenticate_image(uint32_t ddr_start, uint32_t image_size); diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index f878b7b..6367562 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -70,7 +70,6 @@ ((hab_rvt_exit_t *)HAB_RVT_EXIT) \ ) -#define IVT_SIZE 0x20 #define ALIGN_SIZE 0x1000 #define CSF_PAD_SIZE 0x2000 #define MX6DQ_PU_IROM_MMU_EN_VAR 0x009024a8 From patchwork Tue Jan 2 16:43:52 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: 123163 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9175292qgn; Tue, 2 Jan 2018 08:51:44 -0800 (PST) X-Google-Smtp-Source: ACJfBouBZG3SliuJGYgeY3CrIGeY7Q6Jzj/O75gwv2m58uUHrx/OTLWbyWnyBkFqFvQxk3xAE9kq X-Received: by 10.80.221.73 with SMTP id u9mr60715804edk.162.1514911903953; Tue, 02 Jan 2018 08:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911903; cv=none; d=google.com; s=arc-20160816; b=z2OabBCIJ6KmKVFeJev4p4ChNpHvTeTkHrHM61p1D5duqS5Htwzusl68bZZPJ7dZbn 1xxD8mgFKdtd7anbJ0n1YjL8ST6pqqWiKD1BZXGontVG5SD3Eec9TNA6g+xfYzMzc4kR ljIC8Y9OH7d9aDtEeo9800YoVO0AgIwvN2StvJcsnU6fqLFSXAhLVgZH79DiO4i87CR8 W8gnmJgfleNXC6cBZ0x3euNlDKZnxnD83Vd2xmMT1myRlaHxCyzqDax2UXHbGHI86yGa sRM1XdilSEUYqurX5zIga0Q/drEQiMfHmwtB0w3is3S/ALH6yCrPnc/2C9hqmjn65Wh6 vRzA== 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=4A8H0JfHSw8vHNwupD9jh0knhRyZxPcxGbEsqQUu+Aw=; b=0EEyusjyDWLPm2eL0croHt/9epxW7E+1X4EhKu+n3iNL5ke8r+F06ZiaIwz67ZIQLW f6xl1ZnIm73R8q6NrUT3eCTExUw3+1DrMKlcr4QlE3TbgRpWOXELzGXD341bZhCzE0F1 nSgaZ9lupwVgOE4RGHRf4KE+BhpvuVDzFgtdfHmdl4E0QuWqoyqfiz4kQtzUo2oNpm4b 7g9SPUIv3vIihaNdqLYVEI/UmNazt3+LtvZouiN6eouJU6l6wFCrIPbGXJ/CiaX/C04d Ccoeg+tzSlMckaJBzB5m2w7v3qFb+aBv8WxqPXAwIkTJYij1ZKX/rhd/ZIXw8pyqO4cN A8ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=RJkHSWqh; 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 g26si8656104edg.138.2018.01.02.08.51.43; Tue, 02 Jan 2018 08:51:43 -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=RJkHSWqh; 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 7E6F9C21C4A; Tue, 2 Jan 2018 16:47: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_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 C4B96C21E09; Tue, 2 Jan 2018 16:45:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0F4CAC21D9F; Tue, 2 Jan 2018 16:44:36 +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 2DABDC21DB9 for ; Tue, 2 Jan 2018 16:44:31 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id g130so16992446wme.0 for ; Tue, 02 Jan 2018 08:44:31 -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=3LjNZTTYyCYseZYUKjInSqJMeBXflteglLGsqlXBjII=; b=RJkHSWqh+fb7stZAgQncujl1G5wY0DnAdjZJd6I6nYjN6qoZDeTsCH+ZWIGmxhs8fL BTQZ2+vMbgsJ/NJYSkE5r+D5tx1oQJSG03YEfUQPiH9X7OgBj2ITv4O/mD+TuUNMLEJ5 rkX6mSMS98BWQ3n4C8jWA6H6uXzIfFjKYkpJM= 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=3LjNZTTYyCYseZYUKjInSqJMeBXflteglLGsqlXBjII=; b=Y4rlowf/5joPhU0JrL9OeDTadi0TIK7XPmCKfUIWMPic5W7Ft8dXo4Je7WDUeZKVIb G32dgD/U4ywR1LFBRT+SCjY6OiKfMZYpV6JN/tNpHsiaheOfZh424mbavxZqzJyIGsjo OoIXVaYDXSVpVeO+pDRNkLW1aamPGTOB+vC9qIJ5hSHxN1TSQuu4Jzbihf0wMnScLPr1 LrtaIQQwrUT9scLRL8edtOcJvtXsvTcUnqmeg3MQXSg7k2+O9Oo2NWkC8mWpTrpC0bwK n5cX2mP0VFSZqcQAiWRwaN85VDDFzbwEPbucyZ48Qeq3fCjl2G3Ajvg6qUfUGcMy4Up1 Y1og== X-Gm-Message-State: AKGB3mKG6N73SeGqHIjckmjnKFwgqRZXECppD9I47hqKkLrxOanQv4Wz 8iMmSf+4mDbcChhqXZgQ9c/D0oZvzgM= X-Received: by 10.80.179.137 with SMTP id s9mr63223044edd.164.1514911470583; Tue, 02 Jan 2018 08:44:30 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:29 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:52 +0000 Message-Id: <1514911451-4520-7-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 06/25] arm: imx: hab: Move CSF_PAD_SIZE to hab.h 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" CSF_PAD_SIZE should be defined in hab.h, move it to that location now. 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/include/asm/mach-imx/hab.h | 1 + arch/arm/mach-imx/hab.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 3c19d2e..91dda42 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -144,6 +144,7 @@ typedef void hapi_clock_init_t(void); #define HAB_CID_UBOOT 1 /**< UBOOT Caller ID*/ #define IVT_SIZE 0x20 +#define CSF_PAD_SIZE 0x2000 /* ----------- end of HAB API updates ------------*/ diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 6367562..039a017 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -71,7 +71,6 @@ ) #define ALIGN_SIZE 0x1000 -#define CSF_PAD_SIZE 0x2000 #define MX6DQ_PU_IROM_MMU_EN_VAR 0x009024a8 #define MX6DLS_PU_IROM_MMU_EN_VAR 0x00901dd0 #define MX6SL_PU_IROM_MMU_EN_VAR 0x00900a18 From patchwork Tue Jan 2 16:43:53 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: 123162 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9175036qgn; Tue, 2 Jan 2018 08:51:25 -0800 (PST) X-Google-Smtp-Source: ACJfBovx1qxyFuRnn44FzM9barIK8OOWAIPt6ZG0NxAlcCByrTNHR8//795b1Al+YBL0cMzFsMZ+ X-Received: by 10.80.241.72 with SMTP id z8mr63767404edl.35.1514911885755; Tue, 02 Jan 2018 08:51:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911885; cv=none; d=google.com; s=arc-20160816; b=o56E6JMN+eHtzDuosnhGN7w/ZH98ufvQ/0Acg7L+wSACPQpQes91eIWP0T2TqyKwx5 VsH9Ot0kfSFmCcAzWi0yeVDiLi666Nzdg5udY/EEo35p81CDJOx3IT+nUH46YauwfZHa 6AOu7epHRbHoN7MMqdw1F1q2gxlXhhavIVnwF/LKgO55u/lEOjZfMKrL9KAXIIeR0HzR PejHIqHTiXtrPTODUXVXoriegqvAr/+gLHN07qCCuf8uSpAj8kaS57YK8ywkYMbA2/5H eGBZucDL8qxjf2sW7sX9cwwBrScO0jKFj+nlOWYKZXS5gOEzdMd1iKiRnuNan6FwW/ZO X22w== 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=/CFeAgyZ025Ytf/Ld84XKfOkYCNCLxgLRiwGO1exCQs=; b=gdqZ/e/zh5aU4G8SX9tT/4fRmce4UcejggYx9sqZBNd8DAOKmSxAPW578SSbnWyzli 82QcizhqPDZn+M99+REQX6c8aMGAEKXRp+1wypQcLH6EhO7kQR25JsRcfgY85LVlsEV7 4vdbNoTl0z9B9fVkvlTWsH66WdqK2LQr2UGikHlqP46tivJfiJiAJvjyVjTWnOTvJ80D henVK7GG5Ba6rFDwJCL8n0oR2eD9QYY7LxLww7uYvbvB/OA1vN5xkNMw874TvqQ2kPXq LomD2UwIAN40Ii4++Qu+MYlhDFvtVZ7g/ProjDb4GasedccRbOkZYYQe0OYIXPUvf2+r U0sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=b0IqYtCH; 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 a11si2964250edb.460.2018.01.02.08.51.25; Tue, 02 Jan 2018 08:51:25 -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=b0IqYtCH; 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 45CDFC21DA3; Tue, 2 Jan 2018 16:48:43 +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 70C3EC21E4D; Tue, 2 Jan 2018 16:45:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D5642C21E1E; Tue, 2 Jan 2018 16:44:36 +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 7A832C21DE4 for ; Tue, 2 Jan 2018 16:44:32 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id g75so62446705wme.0 for ; Tue, 02 Jan 2018 08:44:32 -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=EvOW9AnWvFja+KH57XFeHCqYmUyZa4E60vY9BoKFZBs=; b=b0IqYtCHbuC8LSsTan0FK3uj4LceoVBqRu0P5zuGYtR7TOVpnAr77Kh3hG8PtOhco5 lquxK+hd838qx6Y6hAcLk+2Zsgky2GmxOs/8ar9/hUEx8T9me63qnOgkTCeRA1zlZzRy jhmlqvIhAxjTKCQYjgnfdK48sZY3mgImcpL1Q= 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=EvOW9AnWvFja+KH57XFeHCqYmUyZa4E60vY9BoKFZBs=; b=X2FOz3mJlaKCWEznC49Vky3jvaufbBw+cFP/Ix4ns183H95fNR+gyFOKPqKVA9Lt7f s5Ab4uYm4hsBdPk04uoNRMgIJdDngH2MQv6zId+3JOPn7S3eWHUViVwwl7qCIIs9K0Z2 vF41Ip9z9BL+2XW95eXqtLj6PMsI73T2GI7GkNhgfaN69iKxWJ5xtuIhe1L6WzkRmZZt COC0AhrRLHviXMqTdtsvta9pr5WwWILXe6cpYPvhAsU0SXtYyh2kOYbQu3D7IyDqlvXp gHtfnf+P54r2/RVqId6nin9CPh+Mr042bm5GnhyVl0AOixy6zL5g4MXRurY0vY0T0cWK Fw4A== X-Gm-Message-State: AKGB3mIGFwDy/8kI28WeYswI1+S6RSONkaKSUBayGDCpLoagzdMo7crU CR2uHZkW7zChUu6HNzSOlL/ZUSutzm8= X-Received: by 10.80.166.34 with SMTP id d31mr62067319edc.96.1514911471780; Tue, 02 Jan 2018 08:44:31 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:31 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:53 +0000 Message-Id: <1514911451-4520-8-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 07/25] arm: imx: hab: Fix authenticate_image input parameters 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" u-boot command "hab_auth_img" tells a user that it takes - addr - image hex address - offset - hex offset of IVT in the image but in fact the callback hab_auth_img makes to authenticate_image treats the second 'offset' parameter as an image length. Furthermore existing code requires the IVT header to be appended to the end of the image which is not actually a requirement of HABv4. This patch fixes this situation by 1: Adding a new parameter to hab_auth_img - addr : image hex address - length : total length of the image - offset : offset of IVT from addr 2: Updates the existing call into authenticate_image() in arch/arm/mach-imx/spl.c:jump_to_image_no_args() to pass addr, length and IVT offset respectively. This allows then hab_auth_img to actually operate the way it was specified in the help text and should still allow existing code to work. It has the added advantage that the IVT header doesn't have to be appended to an image given to HAB - it can be prepended for example. Note prepending the IVT is what u-boot will do when making an IVT for the BootROM. It should be possible for u-boot properly authenticate images made by mkimage via HAB. This patch is the first step in making that happen subsequent patches will focus on removing hard-coded offsets to the IVT, which again is not mandated to live at the end of a .imx image. 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/include/asm/mach-imx/hab.h | 3 +- arch/arm/mach-imx/hab.c | 73 +++++++++++-------------------------- arch/arm/mach-imx/spl.c | 35 +++++++++++++++++- 3 files changed, 57 insertions(+), 54 deletions(-) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 91dda42..b2a8031 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -148,6 +148,7 @@ typedef void hapi_clock_init_t(void); /* ----------- end of HAB API updates ------------*/ -int authenticate_image(uint32_t ddr_start, uint32_t image_size); +int authenticate_image(uint32_t ddr_start, uint32_t image_size, + uint32_t ivt_offset); #endif diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 039a017..2a40d06 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -78,37 +78,6 @@ (is_soc_type(MXC_SOC_MX7ULP) ? 0x80000000 : \ (is_soc_type(MXC_SOC_MX7) ? 0x2000000 : 0x2)) -/* - * +------------+ 0x0 (DDR_UIMAGE_START) - - * | Header | | - * +------------+ 0x40 | - * | | | - * | | | - * | | | - * | | | - * | Image Data | | - * . | | - * . | > Stuff to be authenticated ----+ - * . | | | - * | | | | - * | | | | - * +------------+ | | - * | | | | - * | Fill Data | | | - * | | | | - * +------------+ Align to ALIGN_SIZE | | - * | IVT | | | - * +------------+ + IVT_SIZE - | - * | | | - * | CSF DATA | <---------------------------------------------------------+ - * | | - * +------------+ - * | | - * | Fill Data | - * | | - * +------------+ + CSF_PAD_SIZE - */ - static bool is_hab_enabled(void); #if !defined(CONFIG_SPL_BUILD) @@ -361,20 +330,22 @@ int do_hab_status(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - ulong addr, ivt_offset; + ulong addr, length, ivt_offset; int rcode = 0; - if (argc < 3) + if (argc < 4) return CMD_RET_USAGE; addr = simple_strtoul(argv[1], NULL, 16); - ivt_offset = simple_strtoul(argv[2], NULL, 16); + length = simple_strtoul(argv[2], NULL, 16); + ivt_offset = simple_strtoul(argv[3], NULL, 16); - rcode = authenticate_image(addr, ivt_offset); + rcode = authenticate_image(addr, length, ivt_offset); if (rcode == 0) rcode = CMD_RET_SUCCESS; else rcode = CMD_RET_FAILURE; + return rcode; } @@ -385,10 +356,11 @@ U_BOOT_CMD( ); U_BOOT_CMD( - hab_auth_img, 3, 0, do_authenticate_image, + hab_auth_img, 4, 0, do_authenticate_image, "authenticate image via HAB", - "addr ivt_offset\n" + "addr length ivt_offset\n" "addr - image hex address\n" + "length - image hex length\n" "ivt_offset - hex offset of IVT in the image" ); @@ -411,11 +383,12 @@ static bool is_hab_enabled(void) return (reg & IS_HAB_ENABLED_BIT) == IS_HAB_ENABLED_BIT; } -int authenticate_image(uint32_t ddr_start, uint32_t image_size) +int authenticate_image(uint32_t ddr_start, uint32_t image_size, + uint32_t ivt_offset) { uint32_t load_addr = 0; size_t bytes; - ptrdiff_t ivt_offset = 0; + uint32_t ivt_addr = 0; int result = 1; ulong start; hab_rvt_authenticate_image_t *hab_rvt_authenticate_image; @@ -441,24 +414,18 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size) goto hab_caam_clock_disable; } - /* If not already aligned, Align to ALIGN_SIZE */ - ivt_offset = (image_size + ALIGN_SIZE - 1) & - ~(ALIGN_SIZE - 1); - + /* Calculate IVT address header */ + ivt_addr = ddr_start + ivt_offset; start = ddr_start; - bytes = ivt_offset + IVT_SIZE + CSF_PAD_SIZE; + bytes = image_size; #ifdef DEBUG - printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", - ivt_offset, ddr_start + ivt_offset); + printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", ivt_offset, ivt_addr); puts("Dumping IVT\n"); - print_buffer(ddr_start + ivt_offset, - (void *)(ddr_start + ivt_offset), - 4, 0x8, 0); + print_buffer(ivt_addr, (void *)(ivt_addr), 4, 0x8, 0); puts("Dumping CSF Header\n"); - print_buffer(ddr_start + ivt_offset + IVT_SIZE, - (void *)(ddr_start + ivt_offset + IVT_SIZE), - 4, 0x10, 0); + print_buffer(ivt_addr + IVT_SIZE, (void *)(ivt_addr + IVT_SIZE), 4, + 0x10, 0); #if !defined(CONFIG_SPL_BUILD) get_hab_status(); @@ -468,6 +435,8 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size) printf("\tivt_offset = 0x%x\n", ivt_offset); printf("\tstart = 0x%08lx\n", start); printf("\tbytes = 0x%x\n", bytes); +#else + (void)ivt_addr; #endif /* * If the MMU is enabled, we have to notify the ROM diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index 6e930b3..e5d0c35 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -152,9 +152,41 @@ u32 spl_boot_mode(const u32 boot_device) #if defined(CONFIG_SECURE_BOOT) +/* + * +------------+ 0x0 (DDR_UIMAGE_START) - + * | Header | | + * +------------+ 0x40 | + * | | | + * | | | + * | | | + * | | | + * | Image Data | | + * . | | + * . | > Stuff to be authenticated ----+ + * . | | | + * | | | | + * | | | | + * +------------+ | | + * | | | | + * | Fill Data | | | + * | | | | + * +------------+ Align to ALIGN_SIZE | | + * | IVT | | | + * +------------+ + IVT_SIZE - | + * | | | + * | CSF DATA | <---------------------------------------------------------+ + * | | + * +------------+ + * | | + * | Fill Data | + * | | + * +------------+ + CSF_PAD_SIZE + */ + __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { typedef void __noreturn (*image_entry_noargs_t)(void); + uint32_t offset; image_entry_noargs_t image_entry = (image_entry_noargs_t)(unsigned long)spl_image->entry_point; @@ -163,8 +195,9 @@ __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 */ + offset = spl_image->size - CONFIG_CSF_SIZE; if (!authenticate_image(spl_image->load_addr, - spl_image->size - CONFIG_CSF_SIZE)) { + offset + IVT_SIZE + CSF_PAD_SIZE, offset)) { image_entry(); } else { puts("spl: ERROR: image authentication unsuccessful\n"); From patchwork Tue Jan 2 16:43:54 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: 123170 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9177744qgn; Tue, 2 Jan 2018 08:54:22 -0800 (PST) X-Google-Smtp-Source: ACJfBosH93PLkm7LaBNv5mwlIDAPtk4iNLeAI2jMHkaPKQK+u+R/SRc7jsXd+xTbp0kSLwkpi98f X-Received: by 10.80.134.108 with SMTP id 41mr64373609edt.69.1514912062377; Tue, 02 Jan 2018 08:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912062; cv=none; d=google.com; s=arc-20160816; b=ImE9uZkudXHZb1I4/hgvG1CC/weeqe/HtHcN7PbfTTayNjc+3o1jautIAJpTtwkcKV 0/VrnCIdsHe6ko7X7hj4Tlv2nY/RvUI2Yfl6yie+/0FRrp6aiHggi+f5tRt0LYLNZxYJ SRc2B0Kv6qJknLI71YFSLaHgAt83Zv2+g6cdTqrzL6KlMKafYIEPK4rnszM2KEIR8PhW T+iPkLcMuUgmo3w3MrycMCgnfWQkFcNo+R4+O0Jg5/2gsSgCzKYKYsNoKKQ573rJEOQL 8NJKB9giZkGnA3CR5ibhaGVzx5rCnJUGBwc807+c50LcEzxDg70rlZwz8jGVpYxeniyx e7Pg== 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=N9cjxq1JSXJ8z95cc24viTXrcEeJuNQ7EWQtfvf+sFU=; b=djXGts0/hXbKsYbmoGIe/lV+tYIbkMtg6+C4fucUz3BPWG38JJZ5q/C0XZHJPWprDJ 0J9f48RX6PZZqr75yx9jcQpFoBLmLbNUE8CW+O5TLayoTAVznprGlR29SLdDUEg9PXJb 6TPxDcIKhRdmqiv7PJ04wLR/X21BxYMfcG1FAa06sHZMBixtxRrKYr4gNiLWaRLWDYBs z1yMkRg6KYZetfF7HHKaEnL95MWmm+WNnJy7Nc9yDOJcYkikgu/aTi6WXM8zEaLzsGAI ub/XTBWOh5ttGDm0RK4nJCjHPfCjKm+/Dglpc2JzJavZ+SZ8Pzhfw+byShjHPB96NM9/ gAfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SG+QcS/S; 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 5si523705edm.313.2018.01.02.08.54.22; Tue, 02 Jan 2018 08:54:22 -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=SG+QcS/S; 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 F0E7DC21C34; Tue, 2 Jan 2018 16:46:52 +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 7A8B7C21E14; Tue, 2 Jan 2018 16:44:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AD798C21CB6; Tue, 2 Jan 2018 16:44:38 +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 4693FC21DAB for ; Tue, 2 Jan 2018 16:44:34 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id y82so16940536wmg.1 for ; Tue, 02 Jan 2018 08:44:34 -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=uTnjN80vRz9KsccagZjGfzkJcvaXHUA7tSlukwiRk1s=; b=SG+QcS/SrMV6C7AOn0kgpKVOh8VlrlJFeLFBnAZFWKisK/4bA2O9XjGTpO/QIKuqD/ zzttlQTX9x1smQo83X9xNRzklqUs3cRH5D3GQzat6SnVl/nb3KvBTETtHtOjcJggAh2t nHaC+WbzLaJqEDeZvcvXXSmsLgU2DG2kTPZZ8= 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=uTnjN80vRz9KsccagZjGfzkJcvaXHUA7tSlukwiRk1s=; b=RInDWyr024wbiDuHP8eAyaw3WcedqxEBc8rDVU/gcLAJ54cLF/KZ5bpV5JBnNc/vIU flOrqhd4e9nx9j64TrWJ0lfQlb7g3U7kqEB33T6Malh3Kaq95jr6AP6CMZTHKS9uLBWA y92TSCZyBdIPmnTESx5ayB4cDH7PZzereigsKHMR37U7heK508Cxj0QeFbm0LlYX/Szb ndA4ifVr1Mx9KTLQ42wifdfdRJ8LnTZ+0ead/NHCtlcLeR2Zt+g1GzCBnU28YjUVRP+v SCfwJ6DD2UJp9DjYNatQ7/SW3Y6XZ5qBPgfElpOfisgsjtmL/l4VhGz9zJD0R7ynfc1T maDA== X-Gm-Message-State: AKGB3mI1aTgOnnmFOYPbDYbSdoZbhINOVSXOjkt0av/ZvFyzPza9Br9f Y2Zy71nm7cfvxJCca5j88XNK0D9Oaq0= X-Received: by 10.80.165.139 with SMTP id a11mr63786561edc.95.1514911473610; Tue, 02 Jan 2018 08:44:33 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:32 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:54 +0000 Message-Id: <1514911451-4520-9-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 08/25] arm: imx: hab: Fix authenticate image lockup on MX7 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" The i.MX6 has some pretty explicit code associated with informing the IROM about flushing caches during authenticate_image(). Looking at various pieces of documentation its pretty clear the i.MX6 IROM registers are not documented and absent similar documentation on the i.MX7 the next-best fix is to disabled the dcache while making an authenticate_image() callback. This patch therefore disables dcache temporarily while doing an IROM authenticate_image() callback, thus resolving a lockup encountered in a complex set of authenticate-image calls observed. Note there is no appreciable performance impact with dcache switched off so this fix is relatively pain-free. 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 2a40d06..1d7b069 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -466,10 +466,25 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, } } + /* + * FIXME: Need to disable dcache on MX7 is there an IROM + * register like on MX6 above ? Certain images called in certain + * orders with the dcache switched on will cause + * authenticate_image() to lockup. Switching off the dcache + * resolves the issue. + * https://community.nxp.com/message/953261 + */ + if (is_soc_type(MXC_SOC_MX7)) + dcache_disable(); + load_addr = (uint32_t)hab_rvt_authenticate_image( HAB_CID_UBOOT, ivt_offset, (void **)&start, (size_t *)&bytes, NULL); + + if (is_soc_type(MXC_SOC_MX7)) + dcache_enable(); + if (hab_rvt_exit() != HAB_SUCCESS) { puts("hab exit function fail\n"); load_addr = 0; From patchwork Tue Jan 2 16:43:55 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: 123168 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9177572qgn; Tue, 2 Jan 2018 08:54:10 -0800 (PST) X-Google-Smtp-Source: ACJfBouTuNYB3mY9Sc4nh299IAQL6Lc/Z1EJB84sGTBq1pfKHkQBZJFITSxETTi4kYH6IK2CGw2w X-Received: by 10.80.214.139 with SMTP id r11mr63560451edi.17.1514912049975; Tue, 02 Jan 2018 08:54:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912049; cv=none; d=google.com; s=arc-20160816; b=qQFm1Xk8YDkfuzny/bAZAAuN/O/t5G+b0NpacFKBtfB+0XZhbCrKCFHGM2Nv/RnAVE iPrLD0/3jLeDqiuzK2HkrOccL8Zeev5qM8CGPhpWKIJLFSyONq0hzxHdFDFXrYqYQLPX KWI/DLgINSHPwkngbIB/s7x8hEUUeqWi7B9JD521hA7CBI7q0tH/vEIeRq3Gc2RcmRNv MBzs/zp6BmmZK45I6qfx+q2XWUd/qqt/0yAHkUeD0csUOyajdRHtcr0wDQ0b1/wOrnOa B2MQmacpcZ/fcGBKKPqDDoxHd/LWP0x05Yhnme6woOFddIhabcr1uOR0gXEXfIsgev0f Z+uA== 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=wMUOic2TFDmrDvyogVjf9hvh3SaCoaZsPmQv9SLgU/M=; b=hhesK6zN2MaGAlr6wPHyTU/mtP2IOGPUeY8owosKYL90cH207Lj2ZchrJ3TOseogoZ 6ZmukZEcOsPOfPLmkyRxt/RDBN9h2nux7LDrq9seu1JjaVQMdSX2aGfyXDKzwWbJ2+sI JixIAQvdIaSg/NnfBN5VJ7BGwR4fLYAyJZtKYzbtpjdkkPrI3FjIBT/NsuslfL01bk1G vTUrtFhsBGaL5nkmWiONmdHT41Hrx05jAjYYRvDnkh+N/6X5XPjLhcTKH46b4v653eHl eBw33ab6EW1GxOkCrOFoxzURpsTrEViZT1V0cQgJeXImxljnLPE5imDdWopSMm8cHN4J mETw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=C65kkx8O; 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 x31si115705ede.181.2018.01.02.08.54.09; Tue, 02 Jan 2018 08:54:09 -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=C65kkx8O; 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 7824BC21DBB; Tue, 2 Jan 2018 16:47:48 +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 08853C21E13; Tue, 2 Jan 2018 16:45:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A6893C21DCE; Tue, 2 Jan 2018 16:44:39 +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 F385BC21DA9 for ; Tue, 2 Jan 2018 16:44:35 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id n138so62060431wmg.2 for ; Tue, 02 Jan 2018 08:44:35 -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=W3aaLbqI/MaiX5sYMhnL4aKeCAri3WIVr9Implx4W6o=; b=C65kkx8Op2EuLhhxSuUrHh/j+mTtXCHFCg+8EcUXerpgnOOIHv0vBhZcOBbtTeHBv/ KvT8FO2M3Rdg2fe0MUycAN4t3oRSmauFftlz6YLJbBo1AJW0SaycZo93mURgLL/HGb05 LVEXmshG0j+CCbyQHmJpAxlxsqS8MiH5Zt184= 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=W3aaLbqI/MaiX5sYMhnL4aKeCAri3WIVr9Implx4W6o=; b=e9JX9kNzxlwMjgNkZ21sWC9U0//QkGiRq7LRMVAd4YalH9Lb9XVBarIdaEItU8f3lM JgVWLPrHFTvY85wYKImXZNxc94yuzOp6lWjBu+Tdgjp4Kscq1EMhEYlYPx/PhiVCU8ds CIN8TFa4nae3gEd1UnBjFEJlmRDRdYiNUpWBP9vDJ3rq7T+a+lxhuuwcTwLkZIgeOg+Y 3SES8QNGveSzXOsPCKXQBBBzOHhlnk40+K7aUrD0innpXsZW40XgF0DjPlmUy/WswyCO eazbND6rHc9ELQOGCB7VLrZ8RY1Uc/KsM1tKMhoicJzqjURfd1DWEb0sB8BxO1N2eAmA myKQ== X-Gm-Message-State: AKGB3mI6zoQ0/ROZ9xufkO2MwelzvaMI2kCSD2ijhMvxW+c4Ig3dF9Il mXSlsbD6DOg7YPBgqxkNLxuNx47dbuI= X-Received: by 10.80.165.41 with SMTP id y38mr62452476edb.72.1514911475368; Tue, 02 Jan 2018 08:44:35 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:34 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:55 +0000 Message-Id: <1514911451-4520-10-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 09/25] arm: imx: hab: Add IVT header definitions 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" The various i.MX BootROMs containing the High Assurance Boot (HAB) block rely on a data structure called the Image Vector Table (IVT) to describe to the BootROM where to locate various data-structures used by HAB during authentication. This patch adds a definition of the IVT header for use in later patches, where we will break the current incorrect dependence on fixed offsets in favour of an IVT described parsing of incoming binaries. 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/include/asm/mach-imx/hab.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index b2a8031..28cde38 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -10,6 +10,34 @@ #include +/* + * IVT header definitions + * Security Reference Manual for i.MX 7Dual and 7Solo Applications Processors, + * Rev. 0, 03/2017 + * Section : 6.7.1.1 + */ +#define IVT_HEADER_MAGIC 0xD1 +#define IVT_TOTAL_LENGTH 0x20 +#define IVT_HEADER_V1 0x40 +#define IVT_HEADER_V2 0x41 + +struct ivt_header { + uint8_t magic; + uint16_t length; + uint8_t version; +} __attribute__((packed)); + +struct ivt { + struct ivt_header hdr; /* IVT header above */ + uint32_t entry; /* Absolute address of first instruction */ + uint32_t reserved1; /* Reserved should be zero */ + uint32_t dcd; /* Absolute address of the image DCD */ + uint32_t boot; /* Absolute address of the boot data */ + uint32_t self; /* Absolute address of the IVT */ + uint32_t csf; /* Absolute address of the CSF */ + uint32_t reserved2; /* Reserved should be zero */ +}; + /* -------- start of HAB API updates ------------*/ /* The following are taken from HAB4 SIS */ From patchwork Tue Jan 2 16:43: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: 123165 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9176447qgn; Tue, 2 Jan 2018 08:52:58 -0800 (PST) X-Google-Smtp-Source: ACJfBovBOuoqFOm44JWExQVLKOTZSOoJ85hU5gDKi1vTKAVL5bw44gmk+HmIekl3220RiucJrD/B X-Received: by 10.80.219.136 with SMTP id p8mr62161030edk.84.1514911978119; Tue, 02 Jan 2018 08:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911978; cv=none; d=google.com; s=arc-20160816; b=BdbtWStdlRAZ9rul0NU6pZUI4D4tnDDIXDA6VfxstPQS8aTOHeBoihx8ggjH5369og 2q2eZ4TlKLaAW1n0P5uBHadqDIF82A3ZjcxNdVZ453A+8xcHPDgc5HJqKrHTvILeQq/g h37e2r6pV0HYpH8Rv7S7WCwn6pU/ririSTZHnIvBrzbFLzSOpEAQc4jAAWo+d+yrncPP RJAcvVJllPlOWo2ECMGOuS8MQ2+/WFmGSZcohhGhdsp2w3/AddyNmU7xJ3aqJOkc9irp ZONU8AcUlbfHk5p8hg12wxW254WXITPGmd8oHUSgdQgyd75E0XEooy0EIwmiTScYAf6G 8cqQ== 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=A6DwTfRPSiUzXqtgXzsWZpp3nihoECQ7yhUhZrQlyq8=; b=cEkZCG+21uADrygKo1HzBswZ+7gSG9eigI8P1ISHzZ2LoBcecUW2FZR3eAsJSAxiPf lNCH3bi9A5ugQWBKsy5dvbf3QJxTI97+017ZY1mk/TiWvoJ6OqqWkyfP26BYcNWSscSk EjDaejfYvJ492FvgrCVxOwXPYyYHTxqJH9JzZEfrRhECt+fOdyqDA0LAiRvtSDPDph2z jT5joA1yK0bFh+AftOt48Z3Xrz6AqOOCZ1JsFox965WWKoR3OpsrBR98UiXx3K/bSAlg Zeo0FQsmA5vV3o09R/TLP5JXQx8RSsCGEaXmeQn4x3XDRSI13c+FEjKt2VTOZCKLaDpo SdKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KTjw2u6G; 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 57si4188953edz.9.2018.01.02.08.52.57; Tue, 02 Jan 2018 08:52:58 -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=KTjw2u6G; 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 B9D1AC21DE8; Tue, 2 Jan 2018 16:49:42 +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 548AAC21DDD; Tue, 2 Jan 2018 16:45:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5C70DC21DEF; Tue, 2 Jan 2018 16:44:41 +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 7F147C21DF1 for ; Tue, 2 Jan 2018 16:44:37 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id a79so22900492wma.0 for ; Tue, 02 Jan 2018 08:44:37 -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=K8jGXjHJlQG52Itin0ehjRHo3P34kiVJ1OjHqtyqcC4=; b=KTjw2u6Gd1GJa6tRTRUkSHjpYcNET1H/TFiqCYr07dBwcBaE2OOcWoZL75lEEbJ4Ds viXQj43zz45h1l7yN4QKoyCy7mY405DHUMbJ5mRLys7/EZrIBgnRVmx0bJAZbkGDT8DN zXj7fUMgHjTfUdxyXwyTIl5EISwlWJcCCEhl0= 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=K8jGXjHJlQG52Itin0ehjRHo3P34kiVJ1OjHqtyqcC4=; b=uEjAQhShJH3dUJdlwVG1qMaEhZf7lDu1Q14OAkzotaKP1A+co7Hcxg1nliM1EgY2tR C08MHq3mokouUVZ2DrVXCEgvKiIP6PWXTvpDSw1YLoRkRuQD9xJccHMldW2KMbZa98Mx TYDfxAzrjyjHMvCTtAaHCAJ0vGMGQuasFaLqLLSXQ80a5f+t2ty/vMaFTngDUT7CyNPp t6MmWwXZl1BBuOb3EBrvFNovwVuvrH+qtkE0EhGS5K54qXwaeg/TfuKYwCnLEj3SXHdc ZVWPdgiud90e8k7OiITcKBjs2dDo+5a5kydph/6YoVYe63VTMy5HxsQES1Ax1tDM1rHD W1Pg== X-Gm-Message-State: AKGB3mLDPfxVaEuJ5xr5+n2zVKTHgdC95ZMmh9N2yGDsUFFTcJpoMSiU TFQFHIGR4F5DZ34+Te4MHyv2lytLY4Q= X-Received: by 10.80.142.178 with SMTP id w47mr64304346edw.251.1514911476735; Tue, 02 Jan 2018 08:44:36 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:35 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:56 +0000 Message-Id: <1514911451-4520-11-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 10/25] arm: imx: hab: Add IVT header verification 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" The IVT header contains a magic number, fixed length and one of two version identifiers. Validate these settings before doing anything with a putative IVT binary. 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 | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 1d7b069..cb6214d 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -80,6 +80,31 @@ static bool is_hab_enabled(void); +static int ivt_header_error(const char *err_str, struct ivt_header *ivt_hdr) +{ + printf("%s magic=0x%x length=0x%02x version=0x%x\n", err_str, + ivt_hdr->magic, ivt_hdr->length, ivt_hdr->version); + + return 1; +} + +static int verify_ivt_header(struct ivt_header *ivt_hdr) +{ + int result = 0; + + if (ivt_hdr->magic != IVT_HEADER_MAGIC) + result = ivt_header_error("bad magic", ivt_hdr); + + if (be16_to_cpu(ivt_hdr->length) != IVT_TOTAL_LENGTH) + result = ivt_header_error("bad length", ivt_hdr); + + if (ivt_hdr->version != IVT_HEADER_V1 && + ivt_hdr->version != IVT_HEADER_V2) + result = ivt_header_error("bad version", ivt_hdr); + + return result; +} + #if !defined(CONFIG_SPL_BUILD) #define MAX_RECORD_BYTES (8*1024) /* 4 kbytes */ @@ -394,6 +419,8 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, hab_rvt_authenticate_image_t *hab_rvt_authenticate_image; hab_rvt_entry_t *hab_rvt_entry; hab_rvt_exit_t *hab_rvt_exit; + struct ivt *ivt; + struct ivt_header *ivt_hdr; hab_rvt_authenticate_image = hab_rvt_authenticate_image_p; hab_rvt_entry = hab_rvt_entry_p; @@ -416,6 +443,13 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, /* Calculate IVT address header */ ivt_addr = ddr_start + ivt_offset; + ivt = (struct ivt *)ivt_addr; + ivt_hdr = &ivt->hdr; + + /* Verify IVT header bugging out on error */ + if (verify_ivt_header(ivt_hdr)) + goto hab_caam_clock_disable; + start = ddr_start; bytes = image_size; #ifdef DEBUG @@ -435,8 +469,6 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, printf("\tivt_offset = 0x%x\n", ivt_offset); printf("\tstart = 0x%08lx\n", start); printf("\tbytes = 0x%x\n", bytes); -#else - (void)ivt_addr; #endif /* * If the MMU is enabled, we have to notify the ROM From patchwork Tue Jan 2 16:43:57 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: 123161 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9172520qgn; Tue, 2 Jan 2018 08:48:34 -0800 (PST) X-Google-Smtp-Source: ACJfBouG2FK+lqkU7BOxvIrK2ymVeL7BniAn+JTM7LvJcg65VVdEY/+dn3WAKCi14MUrZ5uLmLF+ X-Received: by 10.80.136.228 with SMTP id d91mr62319597edd.296.1514911714467; Tue, 02 Jan 2018 08:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911714; cv=none; d=google.com; s=arc-20160816; b=e2CrO79vXVe9eyJmd3lTWz6kPFMMSqt8V7BPHpvpJ2NQ9lgemcSK8UZb6uFRHBudg9 55Cf2dEtF/BrIBD5vptMj6m+NYLIjdj0JBS36SO6m6uv5W+SBFEuRilVY7daK17qS6bA rhN3C8+XOkRC/yn0dsseUG07Y2Z1K7tOpk2SzS+iHWcpQW5d6QQ/91PKoTqE1URQ8TjF UftHol4fCP75BpsPt3rUfbrORACddHDjw5kS0NvnrkItH6V33OoNZxZtWz0tMy3K+ENH umcBjjBrrn9vXSTfR9MCOsjHfrD+/OyNEyNNrriZ7fkJTFJFohOi+6sJSxoo3Qu76UD/ MnTQ== 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=MMozsOA+Wk4tbzbRTQ3ojzdmn5TvblgykYvZr4MNXaI=; b=zwkeQUpEDXn/at25y5WVmaOwqNDa+1La6ptV1L6pJiRpiO2QAV1ZV4zU9sp6qbDCXQ yUBkQslA5ovu19KkRILGwOE58PrKCIZFZ85U5zOqa6kcu+bFQtBK54u/WnBEgxkIyRuK oZbZBr4EPdiOBkd6n/rhPiTKCPhJbaW4bfOFpRdtdKcLDaAELQIA9rBqHqKpeK7IHt4h aR2WseTlAKLRog0055M1kaepUaS4Y+GyA+bKLTZqKlL6Q5L3VHRvSIDIt84CVOWjpS79 k42nGuUgh2zSx205ULFnBqYmOtiLf7Att/0VbIlypnMUsp+0+MdD6y1lC0mlGY9JS8FJ z48w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=cKZISgVH; 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 v17si9092718edl.496.2018.01.02.08.48.34; Tue, 02 Jan 2018 08:48:34 -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=cKZISgVH; 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 EB6C6C21DE4; Tue, 2 Jan 2018 16:46:34 +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 69E9DC21DF3; Tue, 2 Jan 2018 16:44:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C82F5C21DD9; Tue, 2 Jan 2018 16:44:42 +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 A6F8EC21DE8 for ; Tue, 2 Jan 2018 16:44:38 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id g75so62447186wme.0 for ; Tue, 02 Jan 2018 08:44:38 -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=G8z/3TFmKGvjjpDslWr0bG7tKU0tOafBwtE3humwEZA=; b=cKZISgVHdP4/ugC6e9r2zVqIEfbgyKPWwZkJ2o5+3kMC+wIfJCDHvDMCGuPbGeO9U4 cJ2pn3aS8igvI3EEFhWNBQ6eySiHDvL2DFbztIGudPWArOSSaWLeHhzbuJjQbAhOLg/3 XDFONFhFZsDW8gvy5fkn78GEU8VUzOMIy8aRU= 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=G8z/3TFmKGvjjpDslWr0bG7tKU0tOafBwtE3humwEZA=; b=VZdqeZBmK+RqevVYZ/Rx/6nQgSf1mxwZ6Wo5Tzlva1leWJVEV6xpH9mHTY/daKj9uE eec1L07itbZvCNgukRVGeAmU3z5TQSONiILkClO+3kDVf8JKJNCC2mY65V3SviU2yd17 vNxP7G0gAVYu9wO71ftrXdVNKEzMfCohwVTtBICgREQxGkeWhaIRvfw8Pm+RmC8mpl2l GGjeQIRAvQaJLeh39LvGamYU6DDRexHIxFzhAt3uGnuPs6YM9vQyE5Svo/z/O3ppswnG pEPvJBx+CtEG4S0jz3ozcC2Lvb5cRGiG3qx21cc9DINpQg+7qV5IA116a37TGa5NugJR uKnA== X-Gm-Message-State: AKGB3mIJa+xvyjemENe1Jmu2zemHYCmKZv+bPSnm2nHnLeKOSXlb4M8j 1Kb9i7iG4HNyaov2I7owgWXJVLLVqn4= X-Received: by 10.80.225.3 with SMTP id h3mr63227665edl.128.1514911478072; Tue, 02 Jan 2018 08:44:38 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:37 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:57 +0000 Message-Id: <1514911451-4520-12-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 11/25] arm: imx: hab: Verify IVT self matches calculated address 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" The IVT is a self-describing structure which contains a self field. The self field is the absolute physical base address the IVT ought to be at in memory. Use the IVT self field to validate the calculated ivt_addr bugging out if the two values differ. 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index cb6214d..479ed96 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -450,6 +450,13 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, if (verify_ivt_header(ivt_hdr)) goto hab_caam_clock_disable; + /* Verify IVT body */ + if (ivt->self != ivt_addr) { + printf("ivt->self 0x%08x pointer is 0x%08x\n", + ivt->self, ivt_addr); + goto hab_caam_clock_disable; + } + start = ddr_start; bytes = image_size; #ifdef DEBUG From patchwork Tue Jan 2 16:43:58 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: 123176 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9180962qgn; Tue, 2 Jan 2018 08:58:07 -0800 (PST) X-Google-Smtp-Source: ACJfBou17H04adMcJmh0rQ2MpJjC72AWY5l1g+dww+MsofGe66k6APP1F6d1kKQCHM60kZTz+MUb X-Received: by 10.80.173.227 with SMTP id b32mr65102124edd.65.1514912287479; Tue, 02 Jan 2018 08:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912287; cv=none; d=google.com; s=arc-20160816; b=wXy/Ph1GXyvUVgd78Wz5xEf0KmifiNGWdgceeIIPvIvmZ9viaEldDKUuQPGR7xJCuG GE965J/BJAoEFUnxOvjw14F4fLXb6fpxPaP9iFkV9HZYsokC2laPcod6bSVGO7rNhJHf AfuJXIF44Pl9099OKvP+X8Z2vjT+kamToyrgo+pabMh+k1AEPOrFySVd0LBaRV44YNDH 2U+QwJFrQqvKwPAEUsXbN64jjCGkrQjn1kahR7KmMt76D9bdFWrXK97aPTmLQQ4w6w4p WJDoEDPmazSSh4NA419kwIdU1qn94Jj8Xu7AnEUbLjxM9Dym5twy2KJBDNXliLFavzS4 sWDQ== 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=/nuRl1OWXVRLCB+e7CucV1h9jwvZTNBoRIy+/w0y9DY=; b=dEkWygJwtWoQwgi/Ybmmzhr+TnrBAPM/aW9G1HJcJbPg16Ulu7lISfanyV7FUtBO6B i4BMFdjf/2gi8GC4AUz6aM+7P5ZdV2ZAb3m0KrjG5P5MWBbOXh/+fAaaAfHGiaY+42C5 jfqUSjN1obW5LTOY7GGvw1aM+MG6PiSd0Sk/5mVbu11URPWBaAvQP3eCy6JbzmNrr42c zOOF7F1SvjWdJsf+DUQ7X9wnCuaV7PyYAoFNnfdOYHs9+yS/+FcvLAUahSJV7pWb1Pkr o5IfQzCSIaVisfEK50wWKmBWuSC94foYllHyQEB8iuVrtYcqqWqxeh+Jef32A6yjNLLH fouA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CO85uKYU; 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 y1si237206ede.494.2018.01.02.08.58.07; Tue, 02 Jan 2018 08:58:07 -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=CO85uKYU; 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 1E8BDC21DDD; Tue, 2 Jan 2018 16:47:11 +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 7E7FEC21DDA; Tue, 2 Jan 2018 16:45:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BFC59C21C29; Tue, 2 Jan 2018 16:44:43 +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 C8348C21DA9 for ; Tue, 2 Jan 2018 16:44:39 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id r78so62432429wme.5 for ; Tue, 02 Jan 2018 08:44:39 -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=VtAGfiyk5udAW3m0qZRtOhS7+D+O3xb/XNtkhm1fVxU=; b=CO85uKYUOm1sq2IzH62ddnaChni5XCDi3MauiYgrX/q+apz5Wty8drVLyfe1h+6z+i LgwWzLxFZyAlVhsYXhTTtn2xXDHYVV96KcBhdsofq1h8ynQJyWlnfAN8vGW6lugwUibs CAMSF9Qgcci2ysQqXeL26FUh2ItlRc4z7/Nbc= 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=VtAGfiyk5udAW3m0qZRtOhS7+D+O3xb/XNtkhm1fVxU=; b=cnGRc3uDIEVu0xvDArEpKsOh+k+JJBNDg8Z96ythSDegEp5rpBaBopjpWFMgxigVWe 2cNbz/8IEpOVPw3cFezjXbYEo5/5nGsP+6qnyRI/HvZT1H3Rw0+UKu2uDRE/Wxwi08tz J3nx+YE5Yno2HE28hJ1UPgpJrQZ1F+8O6RXBKveQIpEcW+QrWQsB7SqQR4HhfsPKpISd iXqYSegY+Y7LMWEVL+W9Le5WQ20mghJniUeVF4nBU7ZEv2JeNiD0RNocnJRUgfYkcj4Y jYw7pxYAQfhLRoFMVkU24XbE4VPOKLAA+stDSNvNpTGDje2SVDFy5HZC5KdsixwP31CX j9nw== X-Gm-Message-State: AKGB3mJFSDfVRjGxYGBY8TXVx9kEcxN5rHthGE6kJo+VVw56z8Zi/23F 1ntLigwT4j+JToUC/UDW6WbkYS2cCZo= X-Received: by 10.80.209.193 with SMTP id i1mr61835576edg.107.1514911479214; Tue, 02 Jan 2018 08:44:39 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:38 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:58 +0000 Message-Id: <1514911451-4520-13-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 12/25] arm: imx: hab: Only call ROM once headers are verified 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" Previous patches added IVT header verification steps. We shouldn't call hab_rvt_entry() until we have done the basic header verification steps. This patch changes the time we make the hab_rvt_entry() call so that it only takes place if we are happy with the IVT header sanity checks. 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 479ed96..e325d1f 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -436,11 +436,6 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, hab_caam_clock_enable(1); - if (hab_rvt_entry() != HAB_SUCCESS) { - puts("hab entry function fail\n"); - goto hab_caam_clock_disable; - } - /* Calculate IVT address header */ ivt_addr = ddr_start + ivt_offset; ivt = (struct ivt *)ivt_addr; @@ -459,6 +454,12 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, start = ddr_start; bytes = image_size; + + if (hab_rvt_entry() != HAB_SUCCESS) { + puts("hab entry function fail\n"); + goto hab_caam_clock_disable; + } + #ifdef DEBUG printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", ivt_offset, ivt_addr); puts("Dumping IVT\n"); From patchwork Tue Jan 2 16:43:59 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: 123164 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9176281qgn; Tue, 2 Jan 2018 08:52:48 -0800 (PST) X-Google-Smtp-Source: ACJfBov7tujK1kmvMBmrx944xLTojuYITmmOQT5i8RL+XE9p4Wu/znDh1C3pm+t5Xly904qLt2Bp X-Received: by 10.80.140.176 with SMTP id q45mr65459430edq.186.1514911968720; Tue, 02 Jan 2018 08:52:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514911968; cv=none; d=google.com; s=arc-20160816; b=WkddteE2rGfgSON5fWGokuIn+L3TMorq7jgsQBiHFS9f4C1fuN2QPZfzAsr1fNlwtX pf/tYSrLVng7V6y8xW2pQ/c4rkF0yYbq2il68f0A34EYqcI5jLNBtYAh0ZzEJcvGQ0pc NsKt4gnwUnIN/tFeY3lY1+Bmz4UWDpCPbAeEGKq1XPr80G6hwSlIe2omaZ78sshMjbAB lBTpF1TvD8vHg3R2uC4wOAESm1hcpgeAtA4EM+PhLNkOgglTiBGnB2Ct7X2H7bgBWlVe Xd9n9Igl49u62DAnoYXu62Wg5Z0RmKp+UJt93/uo/Wr1NZH6neJomPrE5svgYCu9FrIv U6LQ== 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=jHtHebsiNpBRqzRYF81BeuG0MgMzhA4WgV9xEwynxzE=; b=suZAnRIEbYp9/LK2u9TIySrF8VxekvTUlfTd47nE9qxz8ospI397/BK4Z8sRRyYDbM EHBEUxuAdUvn9Eu8Uyyf1ASd11xaIQCM5F1Ek0w721PEfLsD20aVwlOT4VhCrBnXBRl8 E4YvoNWz84nJZdWjb1KJAfqNvl310GzlyCbrwKF/XoyDYo5hJLrdpeOQl8Oj9F6HIcSK ucceR2pSvrBEimWFWsXcGx6eYflQ248/eADY8ZNinJ/im/JmlHBwTLM4iKG9ol3llXFZ fcp7Wqa20g5+x6yvJBJFTM408pd7Yqbch3AKxAhXS2b/GFjAtsXXmMMVDeCFgguDloCm sgew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=CJuVv65S; 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 g54si1843325eda.26.2018.01.02.08.52.48; Tue, 02 Jan 2018 08:52:48 -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=CJuVv65S; 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 5817EC21DE6; Tue, 2 Jan 2018 16:48:26 +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 7904CC21E44; Tue, 2 Jan 2018 16:45:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DA4D6C21E3A; Tue, 2 Jan 2018 16:44:44 +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 E948BC21C4A for ; Tue, 2 Jan 2018 16:44:40 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id f206so61716015wmf.5 for ; Tue, 02 Jan 2018 08:44:40 -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=S3SrDJNFoijmSNw7esnWrnUgt812fxI6TA50eaO4ryM=; b=CJuVv65S6LI0YLs42DPwDXeY6Sb/SCveXvFhaKV7PADA85QFDaenzb8e8PDHkhCI9b BNsfEBtprq7JcTm/YuEWHS4OprMeFDmaPOXq1vOxWKrKdbAvpyoYMY4xVjBBTqUG0XfD rzPPYm/zeoFTcFcys8POHxB4dY41dR7y8dn5s= 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=S3SrDJNFoijmSNw7esnWrnUgt812fxI6TA50eaO4ryM=; b=VNXQ1abtq0WH+kkuGL0epHBqygSptcq5V2dxeRNTKBNZEv5jqRdbtjjjNKLAjQB+kZ YjxtExPwYJmTEMKzXlrsrHiBrdtOuF/1WRJteoF89j1rsjOLa6UlC/UzRuFxWuMv3uKC AE5MqbeCndtWxcpuU+eOz/3zV5KQKpYMjwGYWLXvLzJlpXV/yJ5ck4VNYru+8Ay1u2A8 bqVu1V7V1zv45F0AH5/UM/BJguxShIXY7bdo15AVTY4cgtR9UwBqUE/8Qh7iHk1shO7H kaJ1HJ4NVd0NrQWqQnMRR/wWMRTleHqu2eer/DShD0OP1f0b3EXDCDE204ts7Rz3djKF 6rSQ== X-Gm-Message-State: AKGB3mJktdcdo3YxkcFEEvKBTHaRu8bT4j8aoLSMgPvY21LGy0tUw/OT EaY71yfFvD9NN0lQjab5xHXpGzOeHMs= X-Received: by 10.80.149.210 with SMTP id x18mr60498180eda.4.1514911480362; Tue, 02 Jan 2018 08:44:40 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:39 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:43:59 +0000 Message-Id: <1514911451-4520-14-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 13/25] arm: imx: hab: Print CSF based on IVT descriptor 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" The IVT gives the absolute address of the CSF. There is no requirement for the CSF to be located adjacent to the IVT so lets use the address provided in the IVT header instead of the hard-coded fixed CSF offset currently in place. 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index e325d1f..f9b8cb7 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -466,8 +466,7 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, print_buffer(ivt_addr, (void *)(ivt_addr), 4, 0x8, 0); puts("Dumping CSF Header\n"); - print_buffer(ivt_addr + IVT_SIZE, (void *)(ivt_addr + IVT_SIZE), 4, - 0x10, 0); + print_buffer(ivt->csf, (void *)(ivt->csf), 4, 0x10, 0); #if !defined(CONFIG_SPL_BUILD) get_hab_status(); From patchwork Tue Jan 2 16:44:00 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: 123174 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9180661qgn; Tue, 2 Jan 2018 08:57:47 -0800 (PST) X-Google-Smtp-Source: ACJfBosT4lraY4xGN4fdCrQiAM1r6oYs1H2k0ifFxx31Txh6SWzuocB1bRpS4VTottNK6ny4pIIA X-Received: by 10.80.180.16 with SMTP id b16mr63186991edh.136.1514912267501; Tue, 02 Jan 2018 08:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912267; cv=none; d=google.com; s=arc-20160816; b=G20vJGsFSAQofv6fRA2qxJXHq/TB0S6xJYXHL0Qbve+go7jjrmacG0Rm91jUXRmPkV PxXQvHYiUzDXxmRC9dN+NsXaJ3jVkC8ERHy/kdhYoA0WN5Nc3DAezmMkquzWnuEuMT1p 6i9odMFHJKD4iGAzSSuQpSo0JY/KkUqsx42BNcUnT4PrJ1bhrEN3DyxlX04EDxyRqrfs yDkelg+r2HkG/14YoVVCKBpyGIwRHXJpaDrnKcIqB+0KoRBoBOK48DRN0e8xSzZqrnhP DFMgFKWSoU/q1FrwnO55afL/cMrYoZRIKOvnCh0ma7c4LntckpgcGxbv4pw1hK6ZhVAW aGBg== 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=tguWdLB+cSGljzpdwFmWcdczxxhwHRGmkclYhxVzHMo=; b=OSMUY2UlfGJk82JHOHo7q5CaRZ9z4c6BvzI1RpoO03fY7CEM+0cu6ktw5nxBvgACkB c2da4GsueUdzXqekFkL5CNkueK7FTfFORavHgOwl5FLUmPl+8k9Es1o6qDtIRDYhd3Ti cdLszDRvewenv9TcjOmmwtd8OdE4ZerW1EPnbb62SNSL1v0LIuQNFh/JwgcC0UoUJIIj c5B2HMAF5PrvMBcsONfdZEaUK8OZQuvHIH2uNww6zZSAKTVM34PJ7Yd+v8Y3E8zi1LQ+ 5mfVmpvpYBSpUf95T17HxxZNiTXjAoWc7ym8ArCN3wIC940HfI5vLd8CJkzxt/wUUXiN IMHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=KQFS3CJE; 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 f6si8890807edi.534.2018.01.02.08.57.47; Tue, 02 Jan 2018 08:57:47 -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=KQFS3CJE; 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 0E35AC21DE9; Tue, 2 Jan 2018 16:49:24 +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 75311C21C2B; Tue, 2 Jan 2018 16:45:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1301DC21E57; Tue, 2 Jan 2018 16:44:46 +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 18090C21CB6 for ; Tue, 2 Jan 2018 16:44:42 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id g75so62447441wme.0 for ; Tue, 02 Jan 2018 08:44:42 -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=Q5DyyaMBYNHiqW+IHw8e4o3ykhOOFXzq0W14FWG2fkQ=; b=KQFS3CJEpbUocR7GRXCtq9fdEmvMqwmf9T+Xy6F2dpwDRvaK/mwKCq+WGt7SjZX1/j 0+0nYnG3tvOTOFMl/OnqLfTE2/VXf7iPPwSFFliot7ARa5W5+B9BgTEnxTn28SURyyJA gDpNKnPaeGUmcLReQ4hMvVE+rDRNoFa+fHrGw= 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=Q5DyyaMBYNHiqW+IHw8e4o3ykhOOFXzq0W14FWG2fkQ=; b=m0Ko+7xLKgByPeFGDxxm49OlPMptNl4J307EThHxpkXOnH+ZZlas3SUwP/zyKGRPLY 13xif4Gl7pf6haSHHJ3WCSqTL00fLORP5lC8YlU6/3ZWUJSIl1uy8zyhhOkzpF9vQV1A LZKDisn5+ZKmKbpcNYfBLaiEMZdfNYWsk47msggX4eyj8acjMEE+LS3mvJmKPPkULGPU JaVwr2OK/CfmT+YSDjJM10OFwkyttBtdLUQBQlaOs4PMpBQG0lb2ngsDaVEp0driggrF LX9xJIOIV48YFmYhOSxv7i4NuXCFNdPIpUe2+36m85wsd2SDO5AmV/quwRXSyETryg1z BVXQ== X-Gm-Message-State: AKGB3mJsMHknyN0P3th6mdWNT4W/WUy2djcyki/IA+GqtvQdUh0H3lqD k+50Gl8hTmt27xAyKvGola8TiccopMY= X-Received: by 10.80.170.207 with SMTP id r15mr65668624edc.220.1514911481498; Tue, 02 Jan 2018 08:44:41 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:40 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:00 +0000 Message-Id: <1514911451-4520-15-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 14/25] arm: imx: hab: Print additional IVT elements during debug 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" This patch enables printout of the IVT entry, dcd and csf data fields. 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index f9b8cb7..7c3a621 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -462,6 +462,8 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, #ifdef DEBUG printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", ivt_offset, ivt_addr); + printf("ivt entry = 0x%08x, dcd = 0x%08x, csf = 0x%08x\n", ivt->entry, + ivt->dcd, ivt->csf); puts("Dumping IVT\n"); print_buffer(ivt_addr, (void *)(ivt_addr), 4, 0x8, 0); From patchwork Tue Jan 2 16:44:01 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: 123179 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9184193qgn; Tue, 2 Jan 2018 09:01:16 -0800 (PST) X-Google-Smtp-Source: ACJfBoskiERIsbJ0wAdtvfEISD3MpI/r5QOv05O367enE1L+8dxT1NGN8Y5mDD/mz1KFm8ieHnHu X-Received: by 10.80.151.215 with SMTP id f23mr61506562edb.141.1514912476485; Tue, 02 Jan 2018 09:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912476; cv=none; d=google.com; s=arc-20160816; b=fX27rmcjeRLE4P7g8gbgcgFzgfEQXxCttfEXoND9ruaEz60hOE95DZP2FbmpgT1X/F hmXtqfPezMrknVyieJmOXqmefxC9m8qbPkEqg8LBYBNIMm/S23M8NdZzjyvrLwjNBaV/ O1/8pb/XZSAAXO55c4ltFDey/pEl+Gz4pra3GGFeKbqWjRKE0GOqpZj5HBCkFON7hriF Zw1ZpaXHmkitWTrSf8HPOYm8mhrO5kuJCyP2cMEpfghRxlFnW6EzXD+AiDWhpC55oC4J ZOBT0UhIFrTxie8+9sslDvvg7vTnLEcaY3xBUYXfwYAFj6g2GuMzvFaXXr3jTIDz0sU4 oTbA== 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=k5X/ItTmKzhWMdp0uZ8EBVqBbJj/pKMrT4QgVq8r6rY=; b=t6P8GPGGOAuv5bAv+hQRq5KuevwkNYR6gCoxOTL++QPQ1YrfZX21UG/mZQtZP1CMYz a2K9aOIQxhvmVA60E62bR5cqyM/Nqb+4vH6BOZZmgNTtLLXnaDE5rHwkE873AA5cpWFq TrdgpR8BmetKU8Cr8aRd2rKAKDKjnFz6m4jWvfhUbeSgtSRFfSA6j5oa6eTypzPevkkU MkO4X7jQCQhp0ECH33mu2YmsckKiEFmxBdjJ7MacpVLEwER9/eJyE4RDbz1c1Xrqu1dv nSMXMQj9MDdbnowfrdHI1sdfSIXpyx90SewuN+ZHHJ4DWboF7vfx3PoM6T7W2ARXvATh hBFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=S6F3Rks/; 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 h12si507074edk.131.2018.01.02.09.01.16; Tue, 02 Jan 2018 09:01:16 -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=S6F3Rks/; 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 14960C21C2F; Tue, 2 Jan 2018 16:50:40 +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 BA9DFC21DB0; Tue, 2 Jan 2018 16:45:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F3D62C21DC1; Tue, 2 Jan 2018 16:44:47 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id 5F35DC21E06 for ; Tue, 2 Jan 2018 16:44:43 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id y82so16940895wmg.1 for ; Tue, 02 Jan 2018 08:44: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=GOymI+l1h69sKsRpkjL0ZhctMF1/wS3/aTxVjfkswBY=; b=S6F3Rks/JmLXgDV3npcw6J3JCcrjZIBXYvHFMRaMuuEdMq0ze0UwWw/0XRCTCVRxsl dH+6hZpkp6c07MV1QIDl1VkCUr7aB71AaEMwzLImUHuMOPXpV60KXfjkSpbVnVxzlAu/ dzhNwU8IGyDy4UVIkOcwGQy/NANQHesDxFxeA= 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=GOymI+l1h69sKsRpkjL0ZhctMF1/wS3/aTxVjfkswBY=; b=IBxDkLPeVJVfZr1xORyhT/2bq+tija1gZYN0n20XHDvk6Ia3B6wYmkO4rXwCQU6yH0 GTHX7aRz2d3Vz3dIr9ZvR6gz3rsuJuLRPwrLcUkywYwSU1fMJCqKg1gqxN/gYDYk+U6F pGjDj9WdWCO6e6XLO+4yvamvB+ZJRnOrbeUog1ZWXsLPK0sEk0ih5bHjZLcv8L2lPUG8 CfW1Pr2GKkQXkTELGx84IcofrM/crai/EGjeakyPLDdEpFjcb+VMFB5c8N867CPnZ1S5 9vRAo/q7/4UUilEsZD3tr7HyQbigREXyLeE2Fj4yaZqTEIDK44YAsAGtNc4J7Giuie3n tirw== X-Gm-Message-State: AKGB3mJZ3EZiUPW7oIhpHTG0KYjnE/4WZ/HB0AHwxki9dLXTz3/+88Hm kysq8cvP9DBuBfK50neQiMHVpPZe4V8= X-Received: by 10.80.164.27 with SMTP id u27mr60765697edb.11.1514911482785; Tue, 02 Jan 2018 08:44:42 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:42 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:01 +0000 Message-Id: <1514911451-4520-16-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 15/25] arm: imx: hab: Define rvt_check_target() 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" The hab_rvt_check_target() callback according to the HABv4 documentation: "This function reports whether or not a given target region is allowed for either peripheral configuration or image loading in memory. It is intended for use by post-ROM boot stage components, via the ROM Vector Table, in order to avoid configuring security-sensitive peripherals, or loading images over sensitive memory regions or outside recognized memory devices in the address map." It is a useful function to support as a precursor to calling into authenticate_image() to validate the target memory region is good. 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/include/asm/mach-imx/hab.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 28cde38..14e1220 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -113,6 +113,12 @@ enum hab_context { HAB_CTX_MAX }; +enum hab_target { + HAB_TGT_MEMORY = 0x0f, + HAB_TGT_PERIPHERAL = 0xf0, + HAB_TGT_ANY = 0x55, +}; + struct imx_sec_config_fuse_t { int bank; int word; @@ -132,6 +138,8 @@ typedef enum hab_status hab_rvt_entry_t(void); typedef enum hab_status hab_rvt_exit_t(void); typedef void *hab_rvt_authenticate_image_t(uint8_t, ptrdiff_t, void **, size_t *, hab_loader_callback_f_t); +typedef enum hab_status hab_rvt_check_target_t(enum hab_target, const void *, + size_t); typedef void hapi_clock_init_t(void); #define HAB_ENG_ANY 0x00 /* Select first compatible engine */ @@ -158,6 +166,7 @@ typedef void hapi_clock_init_t(void); #define HAB_RVT_ENTRY (*(uint32_t *)(HAB_RVT_BASE + 0x04)) #define HAB_RVT_EXIT (*(uint32_t *)(HAB_RVT_BASE + 0x08)) +#define HAB_RVT_CHECK_TARGET (*(uint32_t *)(HAB_RVT_BASE + 0x0C)) #define HAB_RVT_AUTHENTICATE_IMAGE (*(uint32_t *)(HAB_RVT_BASE + 0x10)) #define HAB_RVT_REPORT_EVENT (*(uint32_t *)(HAB_RVT_BASE + 0x20)) #define HAB_RVT_REPORT_STATUS (*(uint32_t *)(HAB_RVT_BASE + 0x24)) From patchwork Tue Jan 2 16:44:02 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: 123175 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9180712qgn; Tue, 2 Jan 2018 08:57:51 -0800 (PST) X-Google-Smtp-Source: ACJfBotbo8NjsY7Wptj0teYVmAfBu/E1b7Kp8gJhfmx4ab8nQMoO9O0VnDfjGNbS4VWn7TH0DhWz X-Received: by 10.80.181.130 with SMTP id a2mr61849492ede.263.1514912270811; Tue, 02 Jan 2018 08:57:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912270; cv=none; d=google.com; s=arc-20160816; b=l59lMJD04a5JuqxXMkkBkCjkDTml/NNmwCA8gR43dc6yIrG89RvCxDM/HurITod0kn cNtwwZZaUpttRR73s+HmT0yKPzEusiC4OQwQR0KxTDB2SgC4Yrxf2z1SsWe3Yx54J402 IYrUX/O5SmV+gLXdbXPiyRwGgo3bdGU861QgpBSe9lYAdmVSguECNsgQCZ3AC/MPCTm0 MfHmkSayVJ2VB7JGp8BncFSPKjAC+2XtifnqyGrehOX1beBIV2TAcSZUMLAuSqyPk3uS oHEaNe4b5V6X0kNxbr+U7CcGF5xxUAI3miFRSbYCyEdG1FmPgpR3sQWeYBAXsNFgFK/z Dxbg== 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=mzuxfnTJjNtsJCHiP9xNDxxxKVy+wTtJHVVYWBFjUVY=; b=iFTbOCB9VhLuNL7/6rl2OXeRLxaVfJrpjHVxbppNpZXbttqnkq7DpJsh2s0KOi+JCZ LyH5cz5H5vfoX0i6mW+1DhLwoV9HznYC+RZo89TuNuQ8X/1EemaRg66hAhmbfpxP4D81 QXgejeHQYWNA51zd0W5jgO1GaRiCaDaVo1YCMYUTi4ehYxLkSqr+Yb4z7u2aA7y8E5dV g3sIxV+hnbGsZFI+eSh9IJ2/XURdza8oi5B4Nihfr3piNMJfO4gq7x4ZK4YtWwW5aKXC jd7o9cGa5+dRm+GNkuJQCE9B9oWQCv9LZAVctPZTtqvQrFzbQsG4MBpQ62GvWL41UVN5 tSRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VI/W5+76; 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 g61si1631527ede.22.2018.01.02.08.57.50; Tue, 02 Jan 2018 08:57:50 -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=VI/W5+76; 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 5C398C21DCE; Tue, 2 Jan 2018 16:49:08 +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 82677C21E50; Tue, 2 Jan 2018 16:45:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 22A5AC21E31; Tue, 2 Jan 2018 16:44:48 +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 CA665C21DA5 for ; Tue, 2 Jan 2018 16:44:44 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id y82so16941009wmg.1 for ; Tue, 02 Jan 2018 08:44:44 -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=bRa4wGLzLk7I8vWO5pXf2rFEnTfCcGvQeNd+XkL9i1s=; b=VI/W5+76x2m2X6+8yzEAKeWmwlEhaG/tYQssVJLNzwIoi4CvcGZY8Q7pfG9bDkxyfp 3l5rbuApuNQ6QE1UVgiJHm92NZDjJUjWN8IaJAg+dB1c5FM3mJVuewznzl/i4cxwzTcw Q6Xi7EsujM1j3QE7PlRJYnhxHMbI8aIaqXE2U= 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=bRa4wGLzLk7I8vWO5pXf2rFEnTfCcGvQeNd+XkL9i1s=; b=roRf04Vug5lr7UuDq7s15r5ai2GcgyoOecCHOgAfEwB6S2O4FGV7ZgE/4JIsxjW45s wXamwSFqZYeT0Eu53oXhOfQZLt5hGCF+5gWNDEzVYYrHFQAafSOOiGSGVtZHMon1Vk3c ZC13WdqVFNebJmlIkm9UULO7VHJrzdayvk2zO6s/Om/+CSJimvPMK81lzRc2wDzTnsqG z3DSIRiWCN5UBahb/JMiPcGneJAGp1fYXNLbDttmwxY6dPGUvSVyXNAjoIn22pzjTvf0 4ArSJaici/eqn6DLWAhnpk/7T46QgPqp7zwESJ13qbJ1aCbr1vetHVJo2vNfjJptZpi8 nJ8g== X-Gm-Message-State: AKGB3mKJ/7LdFqOpQ9LxAZNkt9hTg+kgkORrN/3Kzf9afm+1ppklkl91 TPzRAYQ54zySmcOCL/7b8OKPm3gTwEI= X-Received: by 10.80.145.98 with SMTP id f31mr61295514eda.168.1514911484184; Tue, 02 Jan 2018 08:44:44 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:43 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:02 +0000 Message-Id: <1514911451-4520-17-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 16/25] arm: imx: hab: Implement hab_rvt_check_target 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" This patch implements the basic callback hooks for hab_rvt_check_target() for BootROM code using the older BootROM address layout - in my test case the i.MX7. Code based on new BootROM callbacks will just have HAB_SUCCESS as a result code. Adding support for the new BootROM callbacks is a TODO. 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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 7c3a621..858f2a7 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -70,6 +70,24 @@ ((hab_rvt_exit_t *)HAB_RVT_EXIT) \ ) +static inline enum hab_status hab_rvt_check_target_new(enum hab_target target, + const void *start, + size_t bytes) +{ + return HAB_SUCCESS; +} + +#define hab_rvt_check_target_p \ +( \ + (is_mx6dqp()) ? \ + ((hab_rvt_check_target_t *)hab_rvt_check_target_new) : \ + (is_mx6dq() && (soc_rev() >= CHIP_REV_1_5)) ? \ + ((hab_rvt_check_target_t *)hab_rvt_check_target_new) : \ + (is_mx6sdl() && (soc_rev() >= CHIP_REV_1_2)) ? \ + ((hab_rvt_check_target_t *)hab_rvt_check_target_new) : \ + ((hab_rvt_check_target_t *)HAB_RVT_CHECK_TARGET) \ +) + #define ALIGN_SIZE 0x1000 #define MX6DQ_PU_IROM_MMU_EN_VAR 0x009024a8 #define MX6DLS_PU_IROM_MMU_EN_VAR 0x00901dd0 From patchwork Tue Jan 2 16:44:03 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: 123177 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9181018qgn; Tue, 2 Jan 2018 08:58:11 -0800 (PST) X-Google-Smtp-Source: ACJfBoveE+KOLHgmyuaDJXUOQVsRslkh/bmBiBmyJmDQO3e3LFpPsoVeldEGLwnC/Muo4sOHek1T X-Received: by 10.80.184.52 with SMTP id j49mr21404045ede.160.1514912291241; Tue, 02 Jan 2018 08:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912291; cv=none; d=google.com; s=arc-20160816; b=QL9vP8UqkVcw1Wtn9tOOca+ZYeA8OcT4iduuk2HfTZiQF+hfaHTGAOSk8kSIRNsCDA rCCbCfdMVfATL4AVvqG1JGwV9bSQDKz9drJdkJYjciyB9RO4CiNf3fuj6MWNvq+8ztp7 Sv/7vIjjmcaUamjtsXQLQRuSGOzmtFKEmjpPswn+3r5UbfdAzqIIV4+Ejnz3+t54zTjH 8RUM7SSD3uR4Bd0v604ZjWgb+63/ZvQdQCYlcuowr+y5/tnYCmRO2O4of0PE6SAjtM8a IUrpGVTnL/dfzl0VfAP+mLjnxJhJHAN1VVvVtd/dc6r1rOBKOtzmOUZ9QL2G0CJhhZZo VQEA== 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=3XTExcfm/R4RjVYQ5snUtBTR1VaGqHb70DkOCWDVdKo=; b=FXM0gXtkcx1St5LWkkqNYBrVzP62XgolxyOKBYfX6aiViXE+OlzEkVloliX1twd84l spd6nrxuH5YmoYWY1vx/9Jz3anvnOv3fcDoTFmCcWqAAGylQsjIQKqEmSGA4lt7AE4NT 0sjHgz50b8LCJs4RlQrZnsjTzLGDrQBgtieeOHDA74X9feoAIXm7oWXOutqu3mUhpdEn OzSvA1uDNqLml1A6uRy4QyytCSTStAEa7QuBUMMRTp4e4VRuAQkJAgjCFKiGiKMcZNeK iFJvM8wrOF9BM3fqdW7LTxq7JUjYP+3blb2eGI/VcmufknWdUZ6qYKem17Tp7/taY0yt NCFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OiujiYH6; 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 i6si3482398edf.419.2018.01.02.08.58.10; Tue, 02 Jan 2018 08:58:11 -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=OiujiYH6; 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 C7E53C21DA3; Tue, 2 Jan 2018 16:49:59 +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 82756C21DBB; Tue, 2 Jan 2018 16:45:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5F6F0C21DBB; Tue, 2 Jan 2018 16:44:49 +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 1DB7FC21DD9 for ; Tue, 2 Jan 2018 16:44:46 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id f140so61721763wmd.2 for ; Tue, 02 Jan 2018 08:44: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=PPsvQyZLH4Mt+sx5I0UYIarc4H2t9RPw5bIGqqXCotw=; b=OiujiYH64N4hC89K+FwGJnW/tkssdNFsnqmhYVd/uvW7y6v3yasgzBsv8r+JUExqRg wg7fMSfKvG1tdoXf1ldtt97As2Fof93YFNc16X1kNEzGuGT3F1ViXnENw7+eF+2fqI70 AKjl55jp8R8GXTD/DynQWU5DT3iFMqX3eQ7JM= 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=PPsvQyZLH4Mt+sx5I0UYIarc4H2t9RPw5bIGqqXCotw=; b=qR7CCRXyoeU6lJeGKDXREF8grk41kUuHvvzZCf7AYvSslmGS0QndTcXRt7gRaakaFa VNUJN42dXify1bhIQIKHT/hgGhol7Pzv/r9q7S3Vj4wT7SOYMe4ePLtrYHBFybewOjt2 YSJvyLSXz4IK+n8Y6jDCWCsfG8ARAmnWv/W0PSkMM4T5AgB5GFOMtcL19YcSaSuPq8Tn G5x3pkoFLPur7RBmHMS1nvokrpbOqskWRDEsMAnoq/Y2nVYbutFc8FgeZXtrnUDRwhmm sj5B6yCGNK+XpYNFcMmccpxgF6O3KGT9xLHEsKE6BFNs6tmmxi5iA9BGdlCx4uZA1e+D mX+A== X-Gm-Message-State: AKGB3mICjCD2EO3We0PrTT/PPH/MT0b+UgYSTK1vwFRB8Kar6uzCtmpE MfvrVJM0+wvoEQS/O1U040TB4yXw/l0= X-Received: by 10.80.149.141 with SMTP id w13mr62311210eda.79.1514911485493; Tue, 02 Jan 2018 08:44:45 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:44 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:03 +0000 Message-Id: <1514911451-4520-18-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 17/25] arm: imx: hab: Add a hab_rvt_check_target to image auth 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" Add a hab_rvt_check_target() step to authenticate_image() as a sanity check for the target memory region authenticate_image() will run over, prior to making the BootROM authentication callback itself. This check is recommended by the HAB documentation so it makes sense to adhere to the guidance and perform that check as directed. 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 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 858f2a7..92d342b 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -437,12 +437,15 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, hab_rvt_authenticate_image_t *hab_rvt_authenticate_image; hab_rvt_entry_t *hab_rvt_entry; hab_rvt_exit_t *hab_rvt_exit; + hab_rvt_check_target_t *hab_rvt_check_target; struct ivt *ivt; struct ivt_header *ivt_hdr; + enum hab_status status; hab_rvt_authenticate_image = hab_rvt_authenticate_image_p; hab_rvt_entry = hab_rvt_entry_p; hab_rvt_exit = hab_rvt_exit_p; + hab_rvt_check_target = hab_rvt_check_target_p; if (!is_hab_enabled()) { puts("hab fuse not enabled\n"); @@ -478,6 +481,12 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, goto hab_caam_clock_disable; } + status = hab_rvt_check_target(HAB_TGT_MEMORY, (void *)ddr_start, bytes); + if (status != HAB_SUCCESS) { + printf("HAB check target 0x%08x-0x%08x fail\n", + ddr_start, ddr_start + bytes); + goto hab_caam_clock_disable; + } #ifdef DEBUG printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", ivt_offset, ivt_addr); printf("ivt entry = 0x%08x, dcd = 0x%08x, csf = 0x%08x\n", ivt->entry, From patchwork Tue Jan 2 16:44: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: 123166 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9177380qgn; Tue, 2 Jan 2018 08:53:58 -0800 (PST) X-Google-Smtp-Source: ACJfBov+wTmDyN7X63N5Fbsdoxu+rJyn4KJQIx7wK8AyR7d5eWUnoQQjXpYlEfyJKa6DjjSYs+ha X-Received: by 10.80.172.29 with SMTP id v29mr65548564edc.143.1514912038132; Tue, 02 Jan 2018 08:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912038; cv=none; d=google.com; s=arc-20160816; b=wYkppXzhIv8Wnkl4ojMGHuryABjt3PshK7A7WE4GTv6KHeYZBgPFW7uIONQlgf3IYf dtL+FTHKe4o4b1SepOCShx+vCkdAKVuLMGtJC8tJB1DDaL2p6f9rEGkP5CVsHCAHBbhX Ni2SV2MCdYbaNeKSvQlr9tMpyoWpiZhS1vDIDl5CYg4drZe/UNIkb//PS2ZPG9BQSgfU agfx2hodL0Ng1w6a1U674WsruV1X1vNwJPcNyJZHNQI6LbUcy243GrCC3C9llj0ZnYof FvtAem4fmYER2qOB6zq/a8zkLuUTbcgWaA0k3F4cff9B0yJeC+95MhUKSogQIh4/DUDu Ae2w== 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=S0JhmcHhc1e3FB+iAlVlIisarDxPw3YaYB4JP6wXzfg=; b=ItI2tIqlQLEAhVyr1czhJ1LoO79Etrz9dRko+AxlCJMEm1/hvIWOBLJ9NKPnxufjGK BEhycB1jVh/ZWnEjT4WEiLCOiv2MmkGAe60AbJOu/fd11fLc7VQ0sUgva8PQ7TVrWYvw 1qBvQZn2UeGLlcNpTvm4UnkvHxU7Ewqg3KIK/TmcYt5dbaKc33RzokxWXVP87lk0Zp5/ shoRM0wxdhgkCbStB6Y2uAvuHovA1WcgMv/4hFXd/RJyQY/hwDgHBSF1pfCdrEEOaj+t G90GhfWpMDPKrIwudydscwgrJ/wqrIck5fFXBo7KYseCL3ZlUvAvLORkvqkLSyQy4dly tW9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Yy+huwBY; 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 7si116305edh.195.2018.01.02.08.53.57; Tue, 02 Jan 2018 08:53:58 -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=Yy+huwBY; 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 71729C21DF3; Tue, 2 Jan 2018 16:48: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 391C1C21E39; Tue, 2 Jan 2018 16:45:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 88786C21DC1; Tue, 2 Jan 2018 16:44:51 +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 60FB3C21DE4 for ; Tue, 2 Jan 2018 16:44:47 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id f140so61721879wmd.2 for ; Tue, 02 Jan 2018 08:44:47 -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=G0phrzE8QBsqEkSlDYYFjGIrOOsENIKZJkqtSyjgeQY=; b=Yy+huwBYKgpJSRBEC3ddt5Mm0v8Fp6hX0xUvClyv8N9vTP9rQPpzOuLCdj4ybBxn42 +x/dhwdt5cNuyl30qlH6KlsNGKjLbS9mgYZYN8ri5iCEWSboDnaCzTeS1D7Tl6/+fl0O 9OLwpNoPDuMmWGQmnlwXnp92JKPU2xVFkAsZc= 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=G0phrzE8QBsqEkSlDYYFjGIrOOsENIKZJkqtSyjgeQY=; b=XONQk5Ih4LRDjyidLOfPV0JXuxIowmwGwHx4YfSqJEn8z9Iw/r/78PLWV+MRjNn1VB Jw4qEpp1jFTdiG5wv7rmUjWITFz1ZBuK93iSm8J+yAPMk/QE3GnsDrl2QyboXYG4mWgO fER8Il0PE+h57dJZTLczFQuKZR6WKnrZMjXojqvkDTgcf8u9xrk8r8glLoQMtSvRVFRU SbH/7I9tKiRJsib5E2YzUtWeTRRJxDkW+nZfRdXRcwxykiJkkoQq1HvcHIS0/vw5D6pH m6HGKm5OEicVfSfZscs8e39Y1W80GgAFkisl3Bl04dMaLRS8aoVpnLzlgFkjXT6DR1JA bE2Q== X-Gm-Message-State: AKGB3mKb2kWXka5zbLMra3wNP1hKdw2wEeXTYnWwnzLGcpnSZoFzAyZa D/FiP+hCmi3YEARdVcMs6iRVm9TQzRY= X-Received: by 10.80.166.222 with SMTP id f30mr63288360edc.278.1514911486656; Tue, 02 Jan 2018 08:44:46 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:46 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:04 +0000 Message-Id: <1514911451-4520-19-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 18/25] arm: imx: hab: Print HAB event log only after calling ROM 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" The current flow of authenticate_image() will print the HAB event log even if we reject an element of the IVT header before ever calling into the ROM. This can be confusing. This patch changes the flow of the code so that the HAB event log is only printed out if we have called into the ROM and received some sort of status code. Signed-off-by: Bryan O'Donoghue Suggested-by: Cc: Breno Matheus Lima Cc: Stefano Babic Cc: Fabio Estevam Cc: Peng Fan Cc: Albert Aribaud Cc: Sven Ebenfeld Cc: George McCollister --- arch/arm/mach-imx/hab.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 92d342b..d574f2e 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -478,14 +478,14 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, if (hab_rvt_entry() != HAB_SUCCESS) { puts("hab entry function fail\n"); - goto hab_caam_clock_disable; + goto hab_exit_failure_print_status; } status = hab_rvt_check_target(HAB_TGT_MEMORY, (void *)ddr_start, bytes); if (status != HAB_SUCCESS) { printf("HAB check target 0x%08x-0x%08x fail\n", ddr_start, ddr_start + bytes); - goto hab_caam_clock_disable; + goto hab_exit_failure_print_status; } #ifdef DEBUG printf("\nivt_offset = 0x%x, ivt addr = 0x%x\n", ivt_offset, ivt_addr); @@ -558,12 +558,14 @@ int authenticate_image(uint32_t ddr_start, uint32_t image_size, load_addr = 0; } -hab_caam_clock_disable: - hab_caam_clock_enable(0); - +hab_exit_failure_print_status: #if !defined(CONFIG_SPL_BUILD) get_hab_status(); #endif + +hab_caam_clock_disable: + hab_caam_clock_enable(0); + if (load_addr != 0) result = 0; From patchwork Tue Jan 2 16:44:05 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: 123167 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9177427qgn; Tue, 2 Jan 2018 08:54:00 -0800 (PST) X-Google-Smtp-Source: ACJfBottuyKQOk3mnoukHvngbZnFkZtM7uzuyxsZS08ArO0fySftd5GSbxXFzKSptdpvn/AGvTtM X-Received: by 10.80.213.158 with SMTP id v30mr62696341edi.102.1514912040856; Tue, 02 Jan 2018 08:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912040; cv=none; d=google.com; s=arc-20160816; b=iK9VG/GdzwhRHpnwi/fY3Yn7d1BZiHFTEp1sd2pA54YqBOX8S2B0Zlxd5WyJLD3wZl PPHnlOhUkHkSH3827/Vb/cAniL2F63bDOXI0//kvY6mzx91p/eGSmMC9sEB4dQshcHrZ iaScbJP4lxzW1YwrUXAL9fYidDWr4xBFuQysqO1g2zMZhV7B8p2UZmcP1a4VfBflwITV z6/IvGln8H5cuIELR/GOoFS2IgBfXuFwOd6RFXondkzfpb1nYx19L3mKm/p0Fmvn3b61 7aOod6SxNxX9dmD0rKQKRdeD4rQRmTXpWgngkwBn5AVv7rEdJfmxd2mO1Mb2L6D056pZ OVwA== 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=dD3zPQquy7W3k6xQTL5tAyyr3ofV2invR217CjouUEI=; b=crL7MAcPyVdH1xweVWU00ybNg+ScOPesUmz+zIUS2mjszS2dqWsHfr72NH+xFz8laO 4tOis6PDlIGM7lzGEWDSDeCKqbboO7J7qPM9QZOnBmROw9W9OzJwCKNWxS4Tpm5IxmKf MBzya80NaeIfDHH1lR7huma2zThOg+kHhxNdhkmCONYMobedLd39tyKt4YaXwhrGCPOW iInEjUDdaDk/Eqc8UAcJo4lSBwpf5kGn9XwABdA6z2HS68IWqBmEiuzJzRoh2OzUlGLP UXVDyj2V1+YqYqvwRhELjMDX+0Wnn5omebGbwU9AWBTKT0DEVROJOv3korRMeYEP3YG0 XIDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DA3OzZ3E; 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 j2si3171004edf.153.2018.01.02.08.54.00; Tue, 02 Jan 2018 08:54:00 -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=DA3OzZ3E; 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 6EFDAC21DB0; Tue, 2 Jan 2018 16:50:18 +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 A57D0C21E5B; Tue, 2 Jan 2018 16:45:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E7198C21E26; Tue, 2 Jan 2018 16:44:52 +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 60F3AC21DFA for ; Tue, 2 Jan 2018 16:44:48 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id i11so61729238wmf.4 for ; Tue, 02 Jan 2018 08:44:48 -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=4ULRCNL6bNYyowzyRqmcK5GE/zoy4zTakoCDtkbwUmM=; b=DA3OzZ3EgFyiddGDa0dg4+tutjryPHcYEiLRFDY8TqI3jR+KEGciw9iEEBxxCVXuaf ADaB6HmpB8LfZt3eyUwqfqe25mzrCLNFWRdPP/7WAv/EgkH8P8wu5PkQoK45ZtZcqC5e H3EJgOwQhunY+UqQ3q0kfV4qk+9gFZue9o2Ug= 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=4ULRCNL6bNYyowzyRqmcK5GE/zoy4zTakoCDtkbwUmM=; b=jgVZTGcv3F/bVf+ZVSCOXki5XX4NzLBxRMerpqiDwkW3sSrEqbyap+kqMmdNRiEe6o aZiGqWGDUvb+nfMwVoroXFUtWl5TL7gN1eS+6UOHF2lVYZbHE8Rjaun584SpIMxMIc4f eIJfN/5dMO0Su+Uq0ardkCbugszcmL/O0IZsNhUbMYEt6DGG5Ex2N+7mtuaNSFjRTJol 0e7Z+qlKEmmP9GB12L+0sgkZrpV/+oohNkNpSEA139WNlXlZnVco6q2m9jJGwaz9FNql PZHWZPOQadT0eFfhY6bqJwMO034K72m+hXPA4IuOhyUsoT0VFESF5vpvoUomCNkLGEy7 K42g== X-Gm-Message-State: AKGB3mKF/xIVJ+e1qCP457A+SzYZKsKla4Gc+cWrwGNH+GGHC7hMU+X+ cJXDdMeMv9Q/txaaLTh/KiR1QOwCtv4= X-Received: by 10.80.165.41 with SMTP id y38mr62453260edb.72.1514911487738; Tue, 02 Jan 2018 08:44:47 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:47 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:05 +0000 Message-Id: <1514911451-4520-20-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 19/25] arm: imx: hab: Make internal functions and data static 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" There is no need to export these functions and data structures externally. Make them all static now. 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 | 159 +++++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 75 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index d574f2e..b2c3875 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -135,73 +135,81 @@ struct record { bool any_rec_flag; }; -char *rsn_str[] = {"RSN = HAB_RSN_ANY (0x00)\n", - "RSN = HAB_ENG_FAIL (0x30)\n", - "RSN = HAB_INV_ADDRESS (0x22)\n", - "RSN = HAB_INV_ASSERTION (0x0C)\n", - "RSN = HAB_INV_CALL (0x28)\n", - "RSN = HAB_INV_CERTIFICATE (0x21)\n", - "RSN = HAB_INV_COMMAND (0x06)\n", - "RSN = HAB_INV_CSF (0x11)\n", - "RSN = HAB_INV_DCD (0x27)\n", - "RSN = HAB_INV_INDEX (0x0F)\n", - "RSN = HAB_INV_IVT (0x05)\n", - "RSN = HAB_INV_KEY (0x1D)\n", - "RSN = HAB_INV_RETURN (0x1E)\n", - "RSN = HAB_INV_SIGNATURE (0x18)\n", - "RSN = HAB_INV_SIZE (0x17)\n", - "RSN = HAB_MEM_FAIL (0x2E)\n", - "RSN = HAB_OVR_COUNT (0x2B)\n", - "RSN = HAB_OVR_STORAGE (0x2D)\n", - "RSN = HAB_UNS_ALGORITHM (0x12)\n", - "RSN = HAB_UNS_COMMAND (0x03)\n", - "RSN = HAB_UNS_ENGINE (0x0A)\n", - "RSN = HAB_UNS_ITEM (0x24)\n", - "RSN = HAB_UNS_KEY (0x1B)\n", - "RSN = HAB_UNS_PROTOCOL (0x14)\n", - "RSN = HAB_UNS_STATE (0x09)\n", - "RSN = INVALID\n", - NULL}; - -char *sts_str[] = {"STS = HAB_SUCCESS (0xF0)\n", - "STS = HAB_FAILURE (0x33)\n", - "STS = HAB_WARNING (0x69)\n", - "STS = INVALID\n", - NULL}; - -char *eng_str[] = {"ENG = HAB_ENG_ANY (0x00)\n", - "ENG = HAB_ENG_SCC (0x03)\n", - "ENG = HAB_ENG_RTIC (0x05)\n", - "ENG = HAB_ENG_SAHARA (0x06)\n", - "ENG = HAB_ENG_CSU (0x0A)\n", - "ENG = HAB_ENG_SRTC (0x0C)\n", - "ENG = HAB_ENG_DCP (0x1B)\n", - "ENG = HAB_ENG_CAAM (0x1D)\n", - "ENG = HAB_ENG_SNVS (0x1E)\n", - "ENG = HAB_ENG_OCOTP (0x21)\n", - "ENG = HAB_ENG_DTCP (0x22)\n", - "ENG = HAB_ENG_ROM (0x36)\n", - "ENG = HAB_ENG_HDCP (0x24)\n", - "ENG = HAB_ENG_RTL (0x77)\n", - "ENG = HAB_ENG_SW (0xFF)\n", - "ENG = INVALID\n", - NULL}; - -char *ctx_str[] = {"CTX = HAB_CTX_ANY(0x00)\n", - "CTX = HAB_CTX_FAB (0xFF)\n", - "CTX = HAB_CTX_ENTRY (0xE1)\n", - "CTX = HAB_CTX_TARGET (0x33)\n", - "CTX = HAB_CTX_AUTHENTICATE (0x0A)\n", - "CTX = HAB_CTX_DCD (0xDD)\n", - "CTX = HAB_CTX_CSF (0xCF)\n", - "CTX = HAB_CTX_COMMAND (0xC0)\n", - "CTX = HAB_CTX_AUT_DAT (0xDB)\n", - "CTX = HAB_CTX_ASSERT (0xA0)\n", - "CTX = HAB_CTX_EXIT (0xEE)\n", - "CTX = INVALID\n", - NULL}; - -uint8_t hab_statuses[5] = { +static char *rsn_str[] = { + "RSN = HAB_RSN_ANY (0x00)\n", + "RSN = HAB_ENG_FAIL (0x30)\n", + "RSN = HAB_INV_ADDRESS (0x22)\n", + "RSN = HAB_INV_ASSERTION (0x0C)\n", + "RSN = HAB_INV_CALL (0x28)\n", + "RSN = HAB_INV_CERTIFICATE (0x21)\n", + "RSN = HAB_INV_COMMAND (0x06)\n", + "RSN = HAB_INV_CSF (0x11)\n", + "RSN = HAB_INV_DCD (0x27)\n", + "RSN = HAB_INV_INDEX (0x0F)\n", + "RSN = HAB_INV_IVT (0x05)\n", + "RSN = HAB_INV_KEY (0x1D)\n", + "RSN = HAB_INV_RETURN (0x1E)\n", + "RSN = HAB_INV_SIGNATURE (0x18)\n", + "RSN = HAB_INV_SIZE (0x17)\n", + "RSN = HAB_MEM_FAIL (0x2E)\n", + "RSN = HAB_OVR_COUNT (0x2B)\n", + "RSN = HAB_OVR_STORAGE (0x2D)\n", + "RSN = HAB_UNS_ALGORITHM (0x12)\n", + "RSN = HAB_UNS_COMMAND (0x03)\n", + "RSN = HAB_UNS_ENGINE (0x0A)\n", + "RSN = HAB_UNS_ITEM (0x24)\n", + "RSN = HAB_UNS_KEY (0x1B)\n", + "RSN = HAB_UNS_PROTOCOL (0x14)\n", + "RSN = HAB_UNS_STATE (0x09)\n", + "RSN = INVALID\n", + NULL +}; + +static char *sts_str[] = { + "STS = HAB_SUCCESS (0xF0)\n", + "STS = HAB_FAILURE (0x33)\n", + "STS = HAB_WARNING (0x69)\n", + "STS = INVALID\n", + NULL +}; + +static char *eng_str[] = { + "ENG = HAB_ENG_ANY (0x00)\n", + "ENG = HAB_ENG_SCC (0x03)\n", + "ENG = HAB_ENG_RTIC (0x05)\n", + "ENG = HAB_ENG_SAHARA (0x06)\n", + "ENG = HAB_ENG_CSU (0x0A)\n", + "ENG = HAB_ENG_SRTC (0x0C)\n", + "ENG = HAB_ENG_DCP (0x1B)\n", + "ENG = HAB_ENG_CAAM (0x1D)\n", + "ENG = HAB_ENG_SNVS (0x1E)\n", + "ENG = HAB_ENG_OCOTP (0x21)\n", + "ENG = HAB_ENG_DTCP (0x22)\n", + "ENG = HAB_ENG_ROM (0x36)\n", + "ENG = HAB_ENG_HDCP (0x24)\n", + "ENG = HAB_ENG_RTL (0x77)\n", + "ENG = HAB_ENG_SW (0xFF)\n", + "ENG = INVALID\n", + NULL +}; + +static char *ctx_str[] = { + "CTX = HAB_CTX_ANY(0x00)\n", + "CTX = HAB_CTX_FAB (0xFF)\n", + "CTX = HAB_CTX_ENTRY (0xE1)\n", + "CTX = HAB_CTX_TARGET (0x33)\n", + "CTX = HAB_CTX_AUTHENTICATE (0x0A)\n", + "CTX = HAB_CTX_DCD (0xDD)\n", + "CTX = HAB_CTX_CSF (0xCF)\n", + "CTX = HAB_CTX_COMMAND (0xC0)\n", + "CTX = HAB_CTX_AUT_DAT (0xDB)\n", + "CTX = HAB_CTX_ASSERT (0xA0)\n", + "CTX = HAB_CTX_EXIT (0xEE)\n", + "CTX = INVALID\n", + NULL +}; + +static uint8_t hab_statuses[5] = { HAB_STS_ANY, HAB_FAILURE, HAB_WARNING, @@ -209,7 +217,7 @@ uint8_t hab_statuses[5] = { -1 }; -uint8_t hab_reasons[26] = { +static uint8_t hab_reasons[26] = { HAB_RSN_ANY, HAB_ENG_FAIL, HAB_INV_ADDRESS, @@ -238,7 +246,7 @@ uint8_t hab_reasons[26] = { -1 }; -uint8_t hab_contexts[12] = { +static uint8_t hab_contexts[12] = { HAB_CTX_ANY, HAB_CTX_FAB, HAB_CTX_ENTRY, @@ -253,7 +261,7 @@ uint8_t hab_contexts[12] = { -1 }; -uint8_t hab_engines[16] = { +static uint8_t hab_engines[16] = { HAB_ENG_ANY, HAB_ENG_SCC, HAB_ENG_RTIC, @@ -284,7 +292,7 @@ static inline uint8_t get_idx(uint8_t *list, uint8_t tgt) return -1; } -void process_event_record(uint8_t *event_data, size_t bytes) +static void process_event_record(uint8_t *event_data, size_t bytes) { struct record *rec = (struct record *)event_data; @@ -294,7 +302,7 @@ void process_event_record(uint8_t *event_data, size_t bytes) printf("%s", eng_str[get_idx(hab_engines, rec->contents[3])]); } -void display_event(uint8_t *event_data, size_t bytes) +static void display_event(uint8_t *event_data, size_t bytes) { uint32_t i; @@ -313,7 +321,7 @@ void display_event(uint8_t *event_data, size_t bytes) process_event_record(event_data, bytes); } -int get_hab_status(void) +static int get_hab_status(void) { uint32_t index = 0; /* Loop index */ uint8_t event_data[128]; /* Event data buffer */ @@ -358,7 +366,8 @@ int get_hab_status(void) return 0; } -int do_hab_status(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_hab_status(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) { if ((argc != 1)) { cmd_usage(cmdtp); @@ -371,7 +380,7 @@ int do_hab_status(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) + char * const argv[]) { ulong addr, length, ivt_offset; int rcode = 0; From patchwork Tue Jan 2 16:44:06 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: 123172 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9179871qgn; Tue, 2 Jan 2018 08:56:46 -0800 (PST) X-Google-Smtp-Source: ACJfBos4IcqNAKgSBBmyOK7d24rqovqECc236+F8fv6vVzf6lz22os224wknxzPGPcaVZO5fxiG7 X-Received: by 10.80.178.195 with SMTP id p61mr63751970edd.113.1514912206824; Tue, 02 Jan 2018 08:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912206; cv=none; d=google.com; s=arc-20160816; b=qaHpGJ1816Y5DwtBxIfPzY1EDx5QYE32e6VW5VCSbIdM7SRNN6YM2sTM5Evp3R5je3 Ry3FxK1+iiCU7CLIu3q9vdlzceUx+p+gYtZ3ytrq13G6ZSzMkR8wwZwo9LpLqhb8JLWI 2SkjSausf2sD6pEJaIQtS6EE7smG5zNRcLwe/z74yn4WOZ0HXMS3Jp0pEE0nja16TCez aGmVjIWx4vJZCjnin2rp1U07CfespOZh3RZ4QI6CzHgcImJzMl58sZ7svsrxAIKIemha v5LKlmmf9RwHKBrz5xBHLLxXiyjc1GoEm3awexBnmtVXtZAqF8MSNZweutEC93d49uSW jOZw== 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=22dF+e3huFLZmIRbjIwf+ehsrCbjE0AcINiAj07HYgI=; b=ZvVEf7on/eIuQMYPD38rgDV2lnUukaCrBy2Cc/MjIC8tXexIxI9Ca/zs5F7UUFNoYM imwCKQMpD3Psmj2z084+svbSSNXE9kBCcJnaD7UBKqy3mXT1YRPLuI7GEl5aAa37vfdE m/EwUjfdFrLP1BetWqS2wW82H/FpjEn6jiSgPlJzVulYwiV3GV1AreYe/mI00/9hGeko WRqdnbw6+uil5RilqPG9YDeJplMzyYTO7n0iBeBOXlwttp3F3FFtks23huZtlcEScNCe R3re9FV2v0mcIEIujagnbDPbMj8fXuPIDcZFZ9DXmirISW7HNToFrh8xNtthE+9k79r2 N3jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WDpC8XTu; 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 m18si2697569edf.244.2018.01.02.08.56.46; Tue, 02 Jan 2018 08:56:46 -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=WDpC8XTu; 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 70C09C21C2B; Tue, 2 Jan 2018 16:52:08 +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 CBA75C21E09; Tue, 2 Jan 2018 16:49:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 945A6C21DB9; Tue, 2 Jan 2018 16:44:54 +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 C8529C21DDF for ; Tue, 2 Jan 2018 16:44:49 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id t8so62062297wmc.3 for ; Tue, 02 Jan 2018 08:44:49 -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=UqVqhCaIeOzN2MgQXJr9c+L5sychqrTpuh+6MMjPlEs=; b=WDpC8XTuIwP+s6nb64AMLZtPCxT/0vGqvGTB/u200cq9B9Q59BmNG3K4+cVzb6/sHd ZKPouGlvemJdC/X4r0dj3360hE6Ce+PMgK9k1xYU+ub+zNpcGvi44dYcqml+qu07vrQr q16dTIqFYfZWO76s9XTDjg5X1C19biQrPc4cA= 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=UqVqhCaIeOzN2MgQXJr9c+L5sychqrTpuh+6MMjPlEs=; b=i/lH1Yq3F1WDKjybF0SiraXYWDe4g9/+TIi7Vn6Zy06KtQtYBvk9NSqRScmLCjE2Hu mqZAlsGJyf8765iVkPHw82YVukuj0Y7I0nQnJK/BsOaDwlf8RfS51Ytb9hpxl5JtWayN noQ9ZOmlaLAQrkzE2HerRZ34BzBY8oOYgChu+0GZO7tQ/X84Gr+GpBKcQLWrfFTDh5u3 /zBSxW21CpHrg/2Euc/jToTBJSdp153xu4dz4poF6DgjPDwZcGlTnELCjnX07Y0tRkT/ Y0vPnieWaDCZuqHWDu+q8150iKYSzprb2FMf2QG3TY2P5iEiNWotmvYtHPRQKIfEuyD4 1pvg== X-Gm-Message-State: AKGB3mL8m5xXBVtyM1OsXM/JlNDYvDijDph59jZ2MyMW5Xm4WsVYI2eJ i/3/xrT2sSUdc0ZQXP+glOffVd2D9CU= X-Received: by 10.80.142.178 with SMTP id w47mr64305138edw.251.1514911489230; Tue, 02 Jan 2018 08:44:49 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:48 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:06 +0000 Message-Id: <1514911451-4520-21-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 20/25] arm: imx: hab: Prefix authenticate_image with imx_hab 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" Tidy up the HAB namespace a bit by prefixing external functions with imx_hab. All external facing functions past this point will be prefixed in the same way to make the fact we are doing IMX HAB activities clear from reading the code. authenticate_image() could mean anything imx_hab_authenticate_image() is on the other hand very explicit. 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/include/asm/mach-imx/hab.h | 4 ++-- arch/arm/mach-imx/hab.c | 6 +++--- arch/arm/mach-imx/spl.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 14e1220..98bc1bd 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -185,7 +185,7 @@ typedef void hapi_clock_init_t(void); /* ----------- end of HAB API updates ------------*/ -int authenticate_image(uint32_t ddr_start, uint32_t image_size, - uint32_t ivt_offset); +int imx_hab_authenticate_image(uint32_t ddr_start, uint32_t image_size, + uint32_t ivt_offset); #endif diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index b2c3875..c72508b 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -392,7 +392,7 @@ static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc, length = simple_strtoul(argv[2], NULL, 16); ivt_offset = simple_strtoul(argv[3], NULL, 16); - rcode = authenticate_image(addr, length, ivt_offset); + rcode = imx_hab_authenticate_image(addr, length, ivt_offset); if (rcode == 0) rcode = CMD_RET_SUCCESS; else @@ -435,8 +435,8 @@ static bool is_hab_enabled(void) return (reg & IS_HAB_ENABLED_BIT) == IS_HAB_ENABLED_BIT; } -int authenticate_image(uint32_t ddr_start, uint32_t image_size, - uint32_t ivt_offset) +int imx_hab_authenticate_image(uint32_t ddr_start, uint32_t image_size, + uint32_t ivt_offset) { uint32_t load_addr = 0; size_t bytes; diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index e5d0c35..a5478ce 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -196,8 +196,9 @@ __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 */ offset = spl_image->size - CONFIG_CSF_SIZE; - if (!authenticate_image(spl_image->load_addr, - offset + IVT_SIZE + CSF_PAD_SIZE, offset)) { + if (!imx_hab_authenticate_image(spl_image->load_addr, + offset + IVT_SIZE + CSF_PAD_SIZE, + offset)) { image_entry(); } else { puts("spl: ERROR: image authentication unsuccessful\n"); From patchwork Tue Jan 2 16:44:07 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: 123178 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9181921qgn; Tue, 2 Jan 2018 08:59:17 -0800 (PST) X-Google-Smtp-Source: ACJfBou99wU4AvNiIUnSeZhhrMYS0JImVflDB1iBorqTfdPm8bQYLndxhFLhgoreF+1M8dwQOh2R X-Received: by 10.80.206.26 with SMTP id y26mr51953027edi.117.1514912357199; Tue, 02 Jan 2018 08:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912357; cv=none; d=google.com; s=arc-20160816; b=TYRZScqsVPT0Uz3udllGTyO+KjpfGfaORo866a7EmPpeDNZS5U6YdnsEntODwKadzE muA8K44NCiMh7B7XNiTFnnF1kWjWGcyR7Lc3HZjWS6u4wsPoOZdGWrszA9rhcBiRWMK/ Y8355UBtFg1sDrE+xbO1uXCfJPFxV+uwG+hzNtmRpryEvKXrGS7uo63xG29V5yLwEYgs TY4Obmjqre7RA/glXfLi1Z70s/8l0zI6nfih+uZKIlNL1zAZLJ/yf2OK7MFEsG1rU7xQ tdrHE6fozQNK0kUPhIdTrzoVS3YSZsK8DbV/Ad7innMSSNCL+hyl0YK/CMDYx1hxd8e+ 2Crw== 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=e/Uir0tbjDnb2zO3GcLO1BcvpUYVRXi25MYbO5XUXSU=; b=Y5kHkRIXadL19PXnCM9+c3jeD+gr/lASeiDIaVMvcFo2gc4B3bXQri1z0VMS7dNB2c Wn4Sb4ujCl73w+CgmnKDDYRkY9Dmxd9kURp2gpnxedvC3VduqiHl7Uj2eojaQbjbNua8 gJAUy6PEq5jEw+xQ/Q3NTRakRVBlNjfzuVOlDLqVaWEdpw6klfyrOLaEJgMnlvVivsa3 iX8RLQx8ApDvvto4pUNPgSZMTQassXE3Y3QV2i6sNTmdQ5nAnsxPwSPnI8fPwsI4pmC8 DThLyJ+CyvQYdxk69ZNSrBNOQZXbUZi3qeLv9Oa6dCmRmLTP7OpSKg3ZrNIEBvtNiflX xmsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iFiuV0Gg; 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 y21si1486172edi.523.2018.01.02.08.59.16; Tue, 02 Jan 2018 08:59:17 -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=iFiuV0Gg; 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 881DCC21D9F; Tue, 2 Jan 2018 16:51:33 +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 84339C21DA6; Tue, 2 Jan 2018 16:46:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 36E4EC21DA9; Tue, 2 Jan 2018 16:44:55 +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 0D775C21DB9 for ; Tue, 2 Jan 2018 16:44:51 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id b141so15533281wme.1 for ; Tue, 02 Jan 2018 08:44:51 -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=g2HmgnQkl5/bbc105cI9Rm/KxGhxo3DI5aopA73o8EA=; b=iFiuV0GgCgOAN/Nf2AZgNp3Xo4NtirbFZTIX9Qnf6yTNumyPzXdDiIiP9DR62OShTv 2AJ6BtuVqbtinxSGEA+RVLPC0bSznrnWEtU7JY2Z/At/nBfhYUVCcRMfS4FySVphofmX dxKiI92l5r9mNxqJxFRgayAF8cTG6SaHM4AWE= 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=g2HmgnQkl5/bbc105cI9Rm/KxGhxo3DI5aopA73o8EA=; b=Yw8jdbveRB0r1wK5UDV9l39hRb2G2LmHdhtBljv+rCyiP4unFO9qhmZS60WhiSU3xH 4FxNu5ng8jnOVCMV824pOYB4+CIYX1ivOvJaq2vov6J+rJZUDpxpAZ87Ex1v6nNixopN wh8587fJBRSIeinbc4t8Y1bEHgnBP4k0TiCEQ2Bp0U8IfIKy/yjdNiIaz1tHmUErRUSG dSGGk+w0LMCGpHcrPHhAvS/ob1DEo9nGS+ITqEEUlHkBT2HsVd3dtvawozaZ8EO3YY1E EGlPZ30x2F0UKnwLP22M6b2DLk9XUMFyVnZJqbgNiJycH1sZ5CJPgs2AsmUZfHC7/voN hWBA== X-Gm-Message-State: AKGB3mKlgkKjbUNyJUqcqCvKlrlD5nrXCgl5kWBQ9uio3Go3aF1Aabyu +lx0nvT9vKOaDRnQyBgLclyYhx+U7wo= X-Received: by 10.80.137.106 with SMTP id f39mr64670871edf.148.1514911490368; Tue, 02 Jan 2018 08:44:50 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:49 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:07 +0000 Message-Id: <1514911451-4520-22-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 21/25] arm: imx: hab: Rename is_hab_enabled imx_hab_is_enabled 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" Understanding if the HAB is enabled is something that we want to interrogate and report on outside of the HAB layer. First step to that is renaming the relevant function to match the previously introduced external naming convention imx_hab_function() The name imx_hab_is_hab_enabled() is a tautology. A more logical name is imx_hab_is_enabled(). 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index c72508b..f39174d 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -96,7 +96,7 @@ static inline enum hab_status hab_rvt_check_target_new(enum hab_target target, (is_soc_type(MXC_SOC_MX7ULP) ? 0x80000000 : \ (is_soc_type(MXC_SOC_MX7) ? 0x2000000 : 0x2)) -static bool is_hab_enabled(void); +static bool imx_hab_is_enabled(void); static int ivt_header_error(const char *err_str, struct ivt_header *ivt_hdr) { @@ -334,7 +334,7 @@ static int get_hab_status(void) hab_rvt_report_event = hab_rvt_report_event_p; hab_rvt_report_status = hab_rvt_report_status_p; - if (is_hab_enabled()) + if (imx_hab_is_enabled()) puts("\nSecure boot enabled\n"); else puts("\nSecure boot disabled\n"); @@ -419,7 +419,7 @@ U_BOOT_CMD( #endif /* !defined(CONFIG_SPL_BUILD) */ -static bool is_hab_enabled(void) +static bool imx_hab_is_enabled(void) { struct imx_sec_config_fuse_t *fuse = (struct imx_sec_config_fuse_t *)&imx_sec_config_fuse; @@ -456,7 +456,7 @@ int imx_hab_authenticate_image(uint32_t ddr_start, uint32_t image_size, hab_rvt_exit = hab_rvt_exit_p; hab_rvt_check_target = hab_rvt_check_target_p; - if (!is_hab_enabled()) { + if (!imx_hab_is_enabled()) { puts("hab fuse not enabled\n"); return result; } From patchwork Tue Jan 2 16:44:08 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: 123181 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9185370qgn; Tue, 2 Jan 2018 09:02:10 -0800 (PST) X-Google-Smtp-Source: ACJfBosdPmuymoHo6fip49nteux2QXffd3oxpfVNBLaVIdmBjWOm7kl7Ee7M+RquN1O2+JAiS+7r X-Received: by 10.80.168.162 with SMTP id k31mr64843070edc.253.1514912530589; Tue, 02 Jan 2018 09:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912530; cv=none; d=google.com; s=arc-20160816; b=lakMTqxhjIVUGQwrJa1bI54/Li0eyTGeiLyZdngk6l3f4a+N181zuARD+0ZA0f1I2A ARk49rQNt2fFBYZjQ7GdQi6OgE1f1+OzMucjNWp4bacf37y4MI70iHu8jnkf2NnkuZNV 0VSRN5kXcTxpMpPGsYb4DKIvE7e4+AdWVthYOdR8mEL8vqSj+SvLwj9QMXpzyX/5VPHR O64SGL0lg3s+cENDY6TbtcfgyIT2xS7gu+ItG6fGXChTkReTd2j1a+TncB9A9KtyTHOj nfHqH7b37tbq1igTNHEZEyDrVYvk01gQoQgr9iZf+/4YaZLVO5ScUgo82peiHx5rGcou pAZQ== 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=R9avwgqFddUomNIB7aDnWBoO8/toFIyRAvBryJEn3oQ=; b=yGhwLJUAaHCkKhQiZcT5qFymAqSe2cZko0N30R6dyK/h1vBYdClJ4Vi15ikeCYmhfy nxHRunr3X4vDjkFyhCJo8fN0UgAohQo/T90Vq0Tt59Ey6Tgh08bk6my0FMKZyPGvfyDI kUEAnaugs1FS3YD2UGajhxDJWpOFsWAU19iJcTi6x8p8h+4OiLKx5q4zpnbk8gTqtUsl rSk3AxXzfpKe8UW0FCYhauQZQqBNUEdiQDPOE5JaXYKCqXdgGJvFUG2gHSF3z8EbZ9Uh VvSmFIWNth2YyVcHrQo+MoCVnYcXAHyGAJ6770Fa4CmKsP3LspodMP7/GAfLKc/bOipq aX5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Zm2S78bM; 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 s10si1092919edc.387.2018.01.02.09.02.10; Tue, 02 Jan 2018 09:02:10 -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=Zm2S78bM; 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 20B6CC21DE8; Tue, 2 Jan 2018 16:51:50 +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 9CB09C21E76; Tue, 2 Jan 2018 16:46:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C0D6DC21E4C; Tue, 2 Jan 2018 16:44:57 +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 53A62C21DA9 for ; Tue, 2 Jan 2018 16:44:52 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id n138so62061769wmg.2 for ; Tue, 02 Jan 2018 08:44:52 -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=ktW14LjkBOmNYdKs8hyHshup1gAU1RkLhU0pGCF1UXI=; b=Zm2S78bMc+WIcsIYW2M8pl1BzNTjx53wiPhqSil2cO+acrn1RKc+zpoLJl2Oo8R1un ujqGoGUiiltnyaNt0XmMlsCHXnDQtqNaLtRxMcepQNa3UCsiTlxgRWTJR/HucLYQ7CG2 xu/reysEbTiRvofvxXybjl5/phsIq6QN1KAnE= 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=ktW14LjkBOmNYdKs8hyHshup1gAU1RkLhU0pGCF1UXI=; b=pD3SPtEIj+8yqFGP+ia8TyYhuL8fpCIX0zAa9yxR+5H8R64qWaefOORVK8fYzFJcTS 2P/iuOSHtToU2zKyoDLI+xKcpy9mOXdXkCdIWSWrS15naWId+Gu+tePXwGSY9E3GbjJK FDqNEAk/xzT9JZEG6l2dSVRlzk7LbSof8Q1sI7kl+RvFzcHtRP6NRm7wxCMCBHNgw+ik iCWpknHHBAFiX0FJVNCAX+09CGNU1r4V3Kh0hmieXAANpQZMjeO8y0SZKkVmlqVZW+Pr pXFw6sOkSVzcXnC1uNcxgY6QmX4J8XCwxKDFL0XHUCmqGz7ylChML2h7WC1lUrqo0Xrd ECnw== X-Gm-Message-State: AKGB3mKop+0hsz5bQS08tNdt3wGUOvGqaiCwcvzRxsCF9/Rvtfp1Ryf+ AiNf/mIbA8d1QnR3QDO7xqvZ16WUL5Y= X-Received: by 10.80.173.170 with SMTP id a39mr61928768edd.49.1514911491707; Tue, 02 Jan 2018 08:44:51 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:50 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:08 +0000 Message-Id: <1514911451-4520-23-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 22/25] arm: imx: hab: Make imx_hab_is_enabled global 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" It will be helpful to boot commands to know if the HAB is enabled. Export imx_hab_is_enabled() now to facilitate further work with this data-point in a secure-boot context. 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/include/asm/mach-imx/hab.h | 1 + arch/arm/mach-imx/hab.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 98bc1bd..5c13aff 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -187,5 +187,6 @@ typedef void hapi_clock_init_t(void); int imx_hab_authenticate_image(uint32_t ddr_start, uint32_t image_size, uint32_t ivt_offset); +bool imx_hab_is_enabled(void); #endif diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index f39174d..99834c5 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -96,8 +96,6 @@ static inline enum hab_status hab_rvt_check_target_new(enum hab_target target, (is_soc_type(MXC_SOC_MX7ULP) ? 0x80000000 : \ (is_soc_type(MXC_SOC_MX7) ? 0x2000000 : 0x2)) -static bool imx_hab_is_enabled(void); - static int ivt_header_error(const char *err_str, struct ivt_header *ivt_hdr) { printf("%s magic=0x%x length=0x%02x version=0x%x\n", err_str, @@ -419,7 +417,7 @@ U_BOOT_CMD( #endif /* !defined(CONFIG_SPL_BUILD) */ -static bool imx_hab_is_enabled(void) +bool imx_hab_is_enabled(void) { struct imx_sec_config_fuse_t *fuse = (struct imx_sec_config_fuse_t *)&imx_sec_config_fuse; From patchwork Tue Jan 2 16:44:09 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: 123171 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9179011qgn; Tue, 2 Jan 2018 08:55:48 -0800 (PST) X-Google-Smtp-Source: ACJfBovUIF6dM5QAFcurwtPabFhp4wEvTUXhMq8A+/ShBSgoY2GPnXAcKJJ6N75KbehPFI02Jps3 X-Received: by 10.80.134.197 with SMTP id 5mr63703820edu.129.1514912147900; Tue, 02 Jan 2018 08:55:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912147; cv=none; d=google.com; s=arc-20160816; b=GYPuXj8K7qzdC6TTck5JKmDlUD32UzvlIb2i26of/xehibQuU7ACAWEcRJp2lYt+6P gUi6tt3CSg8LHhVIw5IwHWHd5D1aHMT0mSwud4HlrMLNQne0JfP90dikvV8D/uZILkg2 xFO7MFHrZ2Wj8re8CV+c+y0Qhmu1gMns2S8tmkf43J0ufCCibR7tAxcJHCFoYiYM+6+w F+02tHXWSijWJl2C1OtFuf/jq9BZBRe3YXVSCrcWaZ+C8Lye6CMmWU4s53Wv0BbxDSpV tSlx5+4bk7I39hYYgnRwykI6Tpf2zKMHjzpSlE196mtzUuor1FwzasOf1NuS2C11RnBx flTg== 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=nEiq0xect4AoWDmrA6PY0pIBd0aNAXXS+iZ9gzfxaCI=; b=NgJ7lbPLlYNmhnL/Hkw+7oFOEb4CPiM9XzHmaWO14120/lGQCBbQ1B0lmArZ3Hn2hk wUX6J3Ye4SYIXIvHUds2E6jn62WR/E2sZJ1xc440RzsPsGtaCrgfIjSLXzVJSZMlS13B /4vYlDxDINo0nNHJZkI44W9yB+Q06yjjs43YDOadw8qg9hLlfBimhgkhRFGb+r0XHsJW ZpmXNdQ3LeBNfKLIRwklaKpo3BRHux/74K5A3SFXfJbPIXLzoH+LF6unu/ebHeuST2ze Px0qF9Vld/wnZ/OPqyWwOM5A/tFVV5/ZOwhSFnrRRuz5yiEClGe5hcvMFpy1lOEJLRRm Sk7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a1zgUGSK; 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 r38si2445719edd.139.2018.01.02.08.55.42; Tue, 02 Jan 2018 08:55:47 -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=a1zgUGSK; 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 96122C21D9F; Tue, 2 Jan 2018 16:52:29 +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 0F2FBC21DF0; Tue, 2 Jan 2018 16:49:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 343E2C21DDE; Tue, 2 Jan 2018 16:44:57 +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 82E72C21DE8 for ; Tue, 2 Jan 2018 16:44:53 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id b141so15533493wme.1 for ; Tue, 02 Jan 2018 08:44:53 -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=cYwMYV7HIFFPZjWLmuiyD2xuH7kQg/RPLyU9z34NM2o=; b=a1zgUGSKza1WgNXKWZzxU5CY48F/PD3FW82pB/aJwtM6iEmy6zJmboFYEmZwNbkwag JWnoBfDlkYAGg/+VGaAD2K5cLnIawk6NcdnBgWIRTtNzSD9DlOzoNsEzBrlTLNeqLHf5 WvI8A4waeVXiXnhYwONQrEsvaydOEGGWvlYRY= 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=cYwMYV7HIFFPZjWLmuiyD2xuH7kQg/RPLyU9z34NM2o=; b=Jm4CvfAf6ns/D/wPNqGOWeRJrYbXSLTEm6zNDh0Kj4rYaVIDs8dv3WAATM6U+9HDjG 1q4IlYIs1Acx7QW2+TYdcMJzGiOA2bxlXWvPzX//7YqxScgO0ICiFHrhQaR5N8nJn5R3 Y6NwTT+wFIaDfO50jIneZ5lRLCAMVRrY83QLxIpbgoOWp2nMST68McJYvUIGSVAuyAqH 2CR6ns+rHWnIfNDls8EITAetpYgre4Ao0QmfaUmBnNFCmKzHXR81uGgjTqANbdJlohmT LxF8sxO6SkE3jLnzzVgXaah5PGnwb9XdaG2hT9x5DMSQob3+LRAvNlUodkOXsc1+75/X JEOg== X-Gm-Message-State: AKGB3mKb8WNG51ofOnLsbP7xfppzpb2jieXVCLdB2hHuFL4+dVYLJfT7 yxVyPSgY6++PKTu9qz8IUQKRGKh5hsU= X-Received: by 10.80.146.77 with SMTP id j13mr63224647eda.298.1514911492930; Tue, 02 Jan 2018 08:44:52 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:52 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:09 +0000 Message-Id: <1514911451-4520-24-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 23/25] arm: imx: hab: Define rvt_failsafe() 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" The hab_rvt_failsafe() callback according to the HABv4 documentation: "This function provides a safe path when image authentication has failed and all possible boot paths have been exhausted. It is intended for use by post-ROM boot stage components, via the ROM Vector Table." Once invoked the part will drop down to its BootROM USB recovery mode. Should it be the case that the part is in secure boot mode - only an appropriately signed binary will be accepted by the ROM and subsequently executed. 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/include/asm/mach-imx/hab.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 5c13aff..a0cb19d 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -140,6 +140,7 @@ typedef void *hab_rvt_authenticate_image_t(uint8_t, ptrdiff_t, void **, size_t *, hab_loader_callback_f_t); typedef enum hab_status hab_rvt_check_target_t(enum hab_target, const void *, size_t); +typedef void hab_rvt_failsafe_t(void); typedef void hapi_clock_init_t(void); #define HAB_ENG_ANY 0x00 /* Select first compatible engine */ @@ -170,6 +171,7 @@ typedef void hapi_clock_init_t(void); #define HAB_RVT_AUTHENTICATE_IMAGE (*(uint32_t *)(HAB_RVT_BASE + 0x10)) #define HAB_RVT_REPORT_EVENT (*(uint32_t *)(HAB_RVT_BASE + 0x20)) #define HAB_RVT_REPORT_STATUS (*(uint32_t *)(HAB_RVT_BASE + 0x24)) +#define HAB_RVT_FAILSAFE (*(uint32_t *)(HAB_RVT_BASE + 0x28)) #define HAB_RVT_REPORT_EVENT_NEW (*(uint32_t *)0x000000B8) #define HAB_RVT_REPORT_STATUS_NEW (*(uint32_t *)0x000000BC) From patchwork Tue Jan 2 16:44:10 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: 123182 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9185593qgn; Tue, 2 Jan 2018 09:02:19 -0800 (PST) X-Google-Smtp-Source: ACJfBot51tKeoZ4Y3XTzXfxLJ+9jyTUgpz+7v7dZuROmioGu4i0imBgjCVWgHRPmErJwtCzLuxnd X-Received: by 10.80.194.194 with SMTP id u2mr62177486edf.260.1514912539128; Tue, 02 Jan 2018 09:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912539; cv=none; d=google.com; s=arc-20160816; b=DOVdfLUMpRiCOXt3f9ma1qlUeGRTpYHYJca9GpCSvKN0QL/vZ+96A7f+dfK0Xic9g4 bNx0In1xX+rJ3N5vp6qBuM/EQk2KRLx5ahyxOOHfq1EAJQIsZkbwiEn1m+J6IyZE/6Wf /mWiKwrz7goSxGJY9XZ8FyHUy1WYctOHkiszFEN2b9yTlViEcvx/8168KP187u5uYUG0 T1Yk/PDGu5KDucyoPTuoCYPFIGY6S7tU1jm3qaeyHk0aESJeeaAVx983dpLbFAf/wNgS bj1svXFSCZHrVlA0WAVnGId34IN3StZbVQlmNG0NrODfbUCKnrt7CF6cMvKsRipqfPdi lUdw== 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=5aAhBf9TQl8mzvVoKIHOndg3Rfe271NtQ7Tokz3atAY=; b=0kkwicdhVoAfxGfS5ipw7n4c41pchjWUH4AJ0SKGaPOmqH5SVxf/94apwlQcmxienm HLF0Gim4hQ3wCl4kH91jalIGXkizYlm5bzaeRMdQwneIYF+KdsQFsXGRhG9MIaYdFzPe ikQENa8IQ3vVrFoMdCLIyfsqka6Om3I8MqqayO3g0JSWJdka8PuIHb67VwxsU5BryA8o GlyFGok/Q4nOsq1H1+jBWK5wphPxbQ2q8oymbq1eNBzHQhD+7PkrR0q8kAerzBvVaVxB qN9EOGSld2B77EL81mEQkuYNfnZvXVGmhMUx48f/9qaVk7UOTmcpPMG/I91P4dvua/5r E3xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=a6VxdYN6; 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 c2si6943758edb.172.2018.01.02.09.02.18; Tue, 02 Jan 2018 09:02:19 -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=a6VxdYN6; 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 ABABFC21DC8; Tue, 2 Jan 2018 16:50:57 +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 17B1CC21DC5; Tue, 2 Jan 2018 16:46:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D7919C21DC5; Tue, 2 Jan 2018 16:44:58 +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 2C83CC21E09 for ; Tue, 2 Jan 2018 16:44:55 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id 64so61741998wme.3 for ; Tue, 02 Jan 2018 08:44:55 -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=bIDBs87SIUyzKGvj+1kHHmbQp6H0l/o+wbf/3o2tIOo=; b=a6VxdYN643KlrbQJjKapjmgk+7Bn+JN8T+mdbDoEDRUWIMmG23fy8pYLrA77N223/2 aDaIb7CPzFtmTtOylQrdY6caMgC4b/OgY88MtkWlbA90ywJUJ+b5EP+u2krpj/vPpoEH BO3queiXGM3OJNlzHuDpKsbssl4eZ7mFJWOU0= 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=bIDBs87SIUyzKGvj+1kHHmbQp6H0l/o+wbf/3o2tIOo=; b=iDSXPJBzrsRHiohUe5YPY+JSu/3jKZqaSFStp5Pi1l5hJQfO994uMxueQo6hszkgxd ed2S9cVTCor+b9N+OIMb4+4vpauUAPqY5qqLySyWPNhIL/P8U4Je49O3ZJtouQHdkhC1 sLVvieYmfQfD+KSwb8EL2pU1OdSPjLb/FhsxmBKODZzNBeGdNOzBV2Q+5K9rqKJHJzPi sGJQznjNLwSraffA+tHaen12ncidSi2hppWSnWzCHuiH0dAJQmy9rfPiOLqIi8IraPCU cI4/zUUtj8YLGDj4wRcif4bqo69jBFRj7Pepq8/TogauvcbIsa2VxttX/YfsjF+uY2b8 HWrA== X-Gm-Message-State: AKGB3mLzUoMBSfa/nZk4VsC+eeMBkEh3hF0nJ8tSpKlu0zh9930Gun+k n3RShWtqJdqmm+BPrRIJ4cgZ1mcNofY= X-Received: by 10.80.209.193 with SMTP id i1mr61836532edg.107.1514911494568; Tue, 02 Jan 2018 08:44:54 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:53 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:10 +0000 Message-Id: <1514911451-4520-25-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 24/25] arm: imx: hab: Implement hab_rvt_failsafe 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" This patch implements the basic callback hooks for hab_rvt_check_failsafe for BootROM code using the older BootROM address layout - in my test case the i.MX7. Code based on new BootROM callbacks will just do nothing and there's definitely a TODO to implement that extra functionality on the alternative BootROM API. 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 99834c5..17dac16 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -70,6 +70,21 @@ ((hab_rvt_exit_t *)HAB_RVT_EXIT) \ ) +static inline void hab_rvt_failsafe_new(void) +{ +} + +#define hab_rvt_failsafe_p \ +( \ + (is_mx6dqp()) ? \ + ((hab_rvt_failsafe_t *)hab_rvt_failsafe_new) : \ + (is_mx6dq() && (soc_rev() >= CHIP_REV_1_5)) ? \ + ((hab_rvt_failsafe_t *)hab_rvt_failsafe_new) : \ + (is_mx6sdl() && (soc_rev() >= CHIP_REV_1_2)) ? \ + ((hab_rvt_failsafe_t *)hab_rvt_failsafe_new) : \ + ((hab_rvt_failsafe_t *)HAB_RVT_FAILSAFE) \ +) + static inline enum hab_status hab_rvt_check_target_new(enum hab_target target, const void *start, size_t bytes) From patchwork Tue Jan 2 16:44:11 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: 123180 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp9184974qgn; Tue, 2 Jan 2018 09:01:55 -0800 (PST) X-Google-Smtp-Source: ACJfBotd52qi5Ivl7rHxfbuGPHvUoscarg+FpfnFyClmYpu7b1b7b5E7cRZmUy4I34/bmyzxBtGn X-Received: by 10.80.142.88 with SMTP id 24mr64065692edx.153.1514912515429; Tue, 02 Jan 2018 09:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514912515; cv=none; d=google.com; s=arc-20160816; b=YYkcOJmKs/5qXevmeYhOh0su71IkB3d/rDzdYrWdN0VES2OwTbgH8XQakaRPwHjfTo 5qzMJuqp09viLdSeu2NVHT2ew1IIJismJcgG5dcghxHQcKs4xp2mane1fyaROdpHepMH ex06NYQtsjkf3QjQS+cwN1myvqL009aKAougmO3YRFnfpVb8DhDK13sXnvsqEHxMP5L/ OTQyzu2IwywHYKabuRiScS2LOLhsKut7JiLPwxHTuAbrW5pR4xCE19kv/esARAHBPNOg XeFlSwOeEMl8V4vY9pdY7OenzrKPDXS6BDvoheZ5WWfFBOSSRslzTQkCTtH8JAgqM/fJ iylw== 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=GP1lfaSNRWT1Z7xYm1hpfq/e9ft3MV/KXcVJdpqm8p8=; b=bn7j5yQVNvniVU54B0QlJtNqrHnHsG6liadHV74lOPJdx853Qjdawdlo3P7eeukcp3 fq6SPbboR1PSPeUlrMfgJLNRENoRLZ5ObmsgVDytLQEHpkip5muL2kX3r46+OZLqhmEc hiYcoCr19DNmdbbgf4zaG+Wrlm+wa3n6KyxwHlXtuefpkOdZ2ek2Mup02f9uT6l2SgvU PKhBumKgHaqTkHSAiqsm8fPDJgULt/dJs19KC1xS/LYVvuU4q3GMFFceZkX85qgs7Ml6 YPPgOwXZWNPLLeezFbCHqE6jBspQeB8NzDsmoUgTR5Ff7yZWr7dBb3BcF0zE/5PfekTC q1QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Y8f3tzYa; 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 n3si432459edd.202.2018.01.02.09.01.54; Tue, 02 Jan 2018 09:01:55 -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=Y8f3tzYa; 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 C7DDFC21DEF; Tue, 2 Jan 2018 16:51:15 +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 2C813C21E6F; Tue, 2 Jan 2018 16:46:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1843EC21DD9; Tue, 2 Jan 2018 16:44:59 +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 52713C21DB9 for ; Tue, 2 Jan 2018 16:44:56 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id r78so62433812wme.5 for ; Tue, 02 Jan 2018 08:44:56 -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=MgvIrmfm1jMCPovnavZF+skWhR7Gxc7ZMQGz5yUrGgM=; b=Y8f3tzYaaXNHTnKtNIVpA2P9z21m4otQHx1RminFxe+4pD9lPp357qiQAiJ/JvfxuK CafbpA1fi6xUgKw5QyNx8WfI9larevpoXg3tW5sIAe8HctB/UzySLU9fqBOSHz79ghdr rHQer0RnMMcjUUT2+PkaOR/8wfEULfrlXXo+E= 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=MgvIrmfm1jMCPovnavZF+skWhR7Gxc7ZMQGz5yUrGgM=; b=jQUVjiaYsFyapX5tkNZ6U1j/1UL930v/ack9rVhNKI3jcUWQz7qeZ76+LX5z4d/v1V 3N+ka4gX8jcO4fH5bUWOn7N7MozvQIodV36djVcIbSPFiS6fAr3jFfgKzyEiCgs2Eeif 0oxuF/HskALDyg7mhD+lI+l7TNg2ePJxZxngt+OiPJxfcSI3/aAfjFahNmYITaDT7vTG eCh68WdKRRG7fze/8TdnghR8sUYdY4D1TmA64+VYmNWgH/pT3/M8inbIryd9TfBuXAgA XlhQeFCV61bkfYihsQwrp9C3vndXNCmbzrgC3sN8qR1fnVI8wkucjPcddBHQmwjOu4NG u3wg== X-Gm-Message-State: AKGB3mJNaH87iihdVPjGYPTOmQpx5+X/O7hsWIQ5V8XiMWU9WhCTMaaZ T2zORIugOZvC5tZtgi9Ttk8Q6dXYx/I= X-Received: by 10.80.170.207 with SMTP id r15mr65669600edc.220.1514911495753; Tue, 02 Jan 2018 08:44:55 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id z5sm29850584edh.76.2018.01.02.08.44.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 08:44:55 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Tue, 2 Jan 2018 16:44:11 +0000 Message-Id: <1514911451-4520-26-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> References: <1514911451-4520-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v4 25/25] arm: imx: hab: Add hab_failsafe console command 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" hab_failsafe when called puts the part into BootROM recovery mode. This will allow u-boot scripts to script the dropping down into recovery mode. => hab_failsafe Shows the i.MX7 appear as "hiddev0,hidraw5: USB HID v1.10 Device [Freescale SemiConductor Inc SP Blank ULT1] " in a Linux dmesg thus allowing download of a new image via the BootROM USB download protocol routine. 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index 17dac16..79ee4d5 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -414,6 +414,22 @@ static int do_authenticate_image(cmd_tbl_t *cmdtp, int flag, int argc, return rcode; } +static int do_hab_failsafe(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + hab_rvt_failsafe_t *hab_rvt_failsafe; + + if (argc != 1) { + cmd_usage(cmdtp); + return 1; + } + + hab_rvt_failsafe = hab_rvt_failsafe_p; + hab_rvt_failsafe(); + + return 0; +} + U_BOOT_CMD( hab_status, CONFIG_SYS_MAXARGS, 1, do_hab_status, "display HAB status", @@ -429,6 +445,11 @@ U_BOOT_CMD( "ivt_offset - hex offset of IVT in the image" ); +U_BOOT_CMD( + hab_failsafe, CONFIG_SYS_MAXARGS, 1, do_hab_failsafe, + "run BootROM failsafe routine", + "" + ); #endif /* !defined(CONFIG_SPL_BUILD) */