From patchwork Mon Jan 8 17:36:33 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: 123776 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3015178qgn; Mon, 8 Jan 2018 09:46:28 -0800 (PST) X-Google-Smtp-Source: ACJfBovyi/s9jJ2OeHErNt7wrA/Os40Z7USRv3J9NFvwWzffFCDiRonBoq2RDIp0J71JeKpfm6cS X-Received: by 10.80.216.205 with SMTP id y13mr18160874edj.173.1515433588685; Mon, 08 Jan 2018 09:46:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515433588; cv=none; d=google.com; s=arc-20160816; b=WVFLyC7VfQ1NuvqqEr5ceJkMdtyklKcAvKnF3JNRK758BJhdgzIL1Pz1bgk2Ow6BGX iO/6PZQV2L+0Oo/M7m8V2Ls6jM9FMtZMXnokDZ2V25iE/RtNiz1Pg/iMJLYlYSAox8zp 1ux6IXks5FuLRtTqyrm0xRYyWpk6ZO7dqiqVMKWJ1O/7uuJ5u/HUJL8JS4vTLY0btiLB oTfnD20RpnIXFvDWAL/QeCNYkclT7l0VyBBAixhkNzfxUmr0XteIrumlUDPNVnExKAv6 r9Zlf3mxKfTDh6kOZOHlLp8Bkm+5T4owArkMwMEvOdjDJ1vFCSo+LMdhPluj/X35MQsR nGeg== 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=8TlqsH4mVjKUXbN6goMg8HZn3xnxG6Nk47gpESUU2iY=; b=WwWMnHhq4HTTOA6nCZNFfd72UPy2oabOjhHchNceEeesjo7dEvA5wK2/8l2W3FB5Xl Q1ahtoIvKmaxh5F1PRgUA8+6BwnrBweFfMF5KPByZlE5UedqomOprPjXiHTx+3XKEuYP 8Sdekc9DL1DwOgMSONEaBvMBoFkcnTgvfivM9zhJ5jzYFY6aVRByKUO4E57fKi09eS5O 3+m6J3YFR2Zez3THzklg0UsRRgmUxMMtPA1d7DSH+8XqTmF77yv6u1VDNq551C+NQCWr IARLpRaYqSL1zc99TRVWQ+P3RWu3+UcqmIJmGiQXMUOzI4Glez9vj3nA8QJNg8fWII65 iyjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GCp8XVkO; 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 x43si4389678edx.227.2018.01.08.09.46.28; Mon, 08 Jan 2018 09:46:28 -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=GCp8XVkO; 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 506EDC21F98; Mon, 8 Jan 2018 17:41:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3C103C21FB8; Mon, 8 Jan 2018 17:37:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 83AF0C21FC9; Mon, 8 Jan 2018 17:37:09 +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 66913C21F77 for ; Mon, 8 Jan 2018 17:37:05 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id a79so15702943wma.0 for ; Mon, 08 Jan 2018 09:37:05 -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=bDGiXyeGrstKzpxh4dz8o4SVfHf4OFCJ2mDeVzNoIdA=; b=GCp8XVkOGBTTlTt3e/x7RQREa0EzjdT1QiPv/47ml8Wrwt/9MH83G75955N5RWeBvK Wwit/1xzIfq9+yds1CNeue6QCXg7F/BYyUdwSIzjF+T5sBjnfdbTlWDnQ5AiZgCuPvgi 8tCCdpZ5v1j5yXR3KcrMid4e7WrQ8Oge2vl78= 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=bDGiXyeGrstKzpxh4dz8o4SVfHf4OFCJ2mDeVzNoIdA=; b=Yd4EOXc1sAZlbmnTpOJfPErbWFdROH4U8BKC36sFk7BPIDowqIIPvHKpiQsP+7YvfU /yFD4oQxZ1Cvftlom84qahY/rjdu9EiYlRDMVJHjNGF6Zr0nHfudfpmor6VpHZJU6DjS er55pAx/t4jjTWrF1UrgSzvu+ZZ3it/pdFAfUFuCbO9pSHC729xX4NXqSdnw60HAs2FI WmCvoQ07M6lGbjoc7Nil5zDzy0A9IP51qRycihSHIyXo7MF4b5CnzUha0sgDIkVeW+ii LSvGILhs4D9yIFQBNXh6AYjWEFLNGbbrbX6iFc2fLrfn3a0290W0ewiM7s2sCBk1NuP3 sxDQ== X-Gm-Message-State: AKGB3mJWvqgZqW/f+hSqfHWeGGHcHXAmFroc9XIhOsyNyoMHwJFfv63L ZD+1n2E77DDvqtrbzOdAP3f2HBZvSP4= X-Received: by 10.80.213.154 with SMTP id v26mr17488917edi.170.1515433024730; Mon, 08 Jan 2018 09:37:04 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id a38sm7160033edf.3.2018.01.08.09.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Jan 2018 09:37:04 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, brenomatheus@gmail.com Date: Mon, 8 Jan 2018 17:36:33 +0000 Message-Id: <1515433001-13857-17-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515433001-13857-1-git-send-email-bryan.odonoghue@linaro.org> References: <1515433001-13857-1-git-send-email-bryan.odonoghue@linaro.org> Cc: Fabio Estevam Subject: [U-Boot] [PATCH v5 16/24] 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 2a18ea2..079423a 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,