From patchwork Mon Mar 26 14:11:43 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: 890985 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="etO9b9Ku"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 408x1K44lzz9s1B for ; Tue, 27 Mar 2018 01:12:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5534EC21F68; Mon, 26 Mar 2018 14:12: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 C20DDC21F32; Mon, 26 Mar 2018 14:11:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 80B65C21E7E; Mon, 26 Mar 2018 14:11:49 +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 F3029C21E26 for ; Mon, 26 Mar 2018 14:11:48 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id l16so15819744wmh.3 for ; Mon, 26 Mar 2018 07:11:48 -0700 (PDT) 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=rzoIKHhhWd2qWMFKQ+oYI8u1CUjNVZwwjeZrLbeB7os=; b=etO9b9Kuyosd/YokslTFo1XKLUTxWqayBNsNMZB1OjpPaxQVjR0+qWWXX85ezq7w/z BdEVfB9Tb5oA/MKygcDoGjdRArSiAP+/504YaBh/jeDhCxiSdHEVW80etAnR60WBSiBd doFgIDwOy4SlZ9HhzQ0qgmaxXDrFgqcgeNPR0= 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=rzoIKHhhWd2qWMFKQ+oYI8u1CUjNVZwwjeZrLbeB7os=; b=cirAzAKbE4WLl2o6kmbH6HlvNHNz0h2Wp9ZQDBa4GDYOpdeLykS2e/MU7yV/AgwtQE wX78xbhIt0F3nTowQ/JKG/QI4jwK/TgfuvjKqPWOoIqCC3z1jZLYvkG9FaoRSf0++zUV zR8CURA9t5LmsuSyTfL3Dac4D3EZGW3jPqSQZ85s6deVCiLUJUpykPh4tLrdg3qDORQM d0JrpjCtpN+Z4jpv46WRQ67Qn7J7Cogd0FFF1+gs9ntTtgICFKVB0c8P2BgDHRja5fZZ mBE0/3fSmPh8VC7SlCX7Y7z6gBDIvMRzPfQlK/IHgKxE2/iv+z5lOtGXYVLrxn1exv3j ziIg== X-Gm-Message-State: AElRT7GcWNc9fwoHe0AVOsKTIWShNwodHLuSXNtJLRbX4SdPu5Yg5bha cKxgM5ox/6XAA1TQP5le/9dhGOCSeiM= X-Google-Smtp-Source: AG47ELsq4u2VRszYrb2heH2Eb21N2zaWsWnO00e/yUDPXh8i2CHvLtq06HNVnpzapAib+Lhp4F5maw== X-Received: by 10.80.247.4 with SMTP id g4mr15917189edn.121.1522073508370; Mon, 26 Mar 2018 07:11:48 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id a10sm10714045eda.71.2018.03.26.07.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Mar 2018 07:11:47 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de, sbabic@denx.de Date: Mon, 26 Mar 2018 15:11:43 +0100 Message-Id: <1522073505-13066-2-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522073505-13066-1-git-send-email-bryan.odonoghue@linaro.org> References: <1522073505-13066-1-git-send-email-bryan.odonoghue@linaro.org> Cc: breno.lima@nxp.com, fabio.estevam@nxp.com, utkarsh.gupta@nxp.com Subject: [U-Boot] [PATCH v2 1/3] imximage: Encase majority of header in __ASSEMBLY__ declaration 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" Subsequent patches will want to include imageimage.h but in doing so include it on an assembly compile path causing a range of compile errors. Fix the errors pre-emptively by encasing the majority of the declarations in imximage.h inside an ifdef __ASSEMBLY__ block. Signed-off-by: Bryan O'Donoghue Cc: Utkarsh Gupta Cc: Breno Lima Cc: Fabio Estevam --- include/imximage.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/imximage.h b/include/imximage.h index de1ea8f..553b852 100644 --- a/include/imximage.h +++ b/include/imximage.h @@ -56,6 +56,7 @@ #define DCD_CHECK_BITS_SET_PARAM 0x14 #define DCD_CHECK_BITS_CLR_PARAM 0x04 +#ifndef __ASSEMBLY__ enum imximage_cmd { CMD_INVALID, CMD_IMAGE_VERSION, @@ -197,4 +198,5 @@ typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr, typedef void (*set_imx_hdr_t)(struct imx_header *imxhdr, uint32_t dcd_len, uint32_t entry_point, uint32_t flash_offset); +#endif /* __ASSEMBLY__ */ #endif /* _IMXIMAGE_H_ */ From patchwork Mon Mar 26 14:11:44 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: 890986 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FDT4yCEp"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 408x1Z5LY5z9s1B for ; Tue, 27 Mar 2018 01:12:50 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 00726C21F1B; Mon, 26 Mar 2018 14:12:25 +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 A57C8C21F4A; Mon, 26 Mar 2018 14:12:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 844DCC21F52; Mon, 26 Mar 2018 14:11:53 +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 322CEC21EE7 for ; Mon, 26 Mar 2018 14:11:50 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id r82so15865156wme.0 for ; Mon, 26 Mar 2018 07:11:50 -0700 (PDT) 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=FTY450W573+LAOAxsd6pMkGZOtoltz0Gr3RUeQrcG04=; b=FDT4yCEpXaFhwnG2Erj0hSBqGHlrCE2u86o6AWDnPpzC3Es597Ld/aC+Qw0vTa6VWu aJw3QAoAuWLFrtLYOvRJMsUfEIL/tL6fHL5Erx3WOzjtzZXp6/C96tc/IGyhRZaMl1qq C1CBZmHFMuO4wMKhq2EHpdWUeVL4EMhUzLADE= 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=FTY450W573+LAOAxsd6pMkGZOtoltz0Gr3RUeQrcG04=; b=LPALAAzPEmf+58sWtV0XLFi8UjIoe42uYb7JXoo94cFauczgo1oBji+GykuxCkitxt mM7qrQ/G+fUR70mYBUqKErMJyz4DAeAHNTTdwlaTDml1zy1xBPcrFUMDzvVtkT2CDJz1 lDN8b7qciapWweQv5dXckXNCIWKOu+VvSi0ZZH2zDhELayAhL0S4uIRhAznkhus5ngjj wl6/haC8b6rzt4kXx3EKl1OH97lCV/L5cjq//AWXPRDK5RKITivTaqjz4FD4LelijRBl zJQZxGHWLLDtCPZXpHjMtHothOr2b1rfse74zzqo/l8cX/VgvRhCNaZk++/vf/4YAxzq dM6g== X-Gm-Message-State: AElRT7F1WwQAF27NlK6D4h1OOrjTl/H7a3AlEc6K7GDR1MI02Oc2CgEM bYNqBqoQiB9G5XHXZxLt+FPhWSUqtqk= X-Google-Smtp-Source: AG47ELvHYJteICzxQDjfCY0vDXvAqgmKXhe/tcY1dwvH6ycdyBktix2pUDb8tjfoKtoAqyn1HOZ0Qw== X-Received: by 10.80.137.13 with SMTP id e13mr33029808ede.292.1522073509578; Mon, 26 Mar 2018 07:11:49 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id a10sm10714045eda.71.2018.03.26.07.11.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Mar 2018 07:11:48 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de, sbabic@denx.de Date: Mon, 26 Mar 2018 15:11:44 +0100 Message-Id: <1522073505-13066-3-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522073505-13066-1-git-send-email-bryan.odonoghue@linaro.org> References: <1522073505-13066-1-git-send-email-bryan.odonoghue@linaro.org> Cc: breno.lima@nxp.com, fabio.estevam@nxp.com, utkarsh.gupta@nxp.com Subject: [U-Boot] [PATCH v2 2/3] imximage: Specify default IVT offset in IMX image 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 adds BOOTROM_IVT_HDR_OFFSET at 0xC00. The BootROM expects to find the IVT header at a particular offset in an i.MX image. Defining the expected offset of the IVT header in the first-stage BootROM image format is of use of later stage authentication routines where those routines continue to follow the first-stage authentication layout. This patch defines the first stage offset with an upcoming set of BSP patches making use of that offset subsequently. Signed-off-by: Bryan O'Donoghue Cc: Utkarsh Gupta Cc: Breno Lima Cc: Fabio Estevam --- include/imximage.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/imximage.h b/include/imximage.h index 553b852..800fd63 100644 --- a/include/imximage.h +++ b/include/imximage.h @@ -14,6 +14,9 @@ #define APP_CODE_BARKER 0xB1 #define DCD_BARKER 0xB17219E9 +/* Specify the offset of the IVT in the IMX header as expected by BootROM */ +#define BOOTROM_IVT_HDR_OFFSET 0xC00 + /* * NOTE: This file must be kept in sync with arch/arm/include/asm/\ * mach-imx/imximage.cfg because tools/imximage.c can not From patchwork Mon Mar 26 14:11:45 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: 890987 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gJKgqZgh"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 408x2b0dpjz9s3K for ; Tue, 27 Mar 2018 01:13:42 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 95F52C21F1B; Mon, 26 Mar 2018 14:12: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 6F131C21F5B; Mon, 26 Mar 2018 14:12:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 978E3C21F3A; Mon, 26 Mar 2018 14:11:55 +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 41109C21F47 for ; Mon, 26 Mar 2018 14:11:51 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id t7so15725904wmh.5 for ; Mon, 26 Mar 2018 07:11:51 -0700 (PDT) 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=Rn8td2mpFzHPshW3xP1CDBr/cWifBNZl0TdWk46pT9s=; b=gJKgqZghHNLSZ0RcSDcnZxvd36eZDzfc8ppn0QORxCvwVetHmFcEExVyF1gVRo4/O/ CBDoDEs3EApWsa24aF85sl7o8bQgonqp8gUcpRbqdFeThNuqONHerCmrQ/BYCCwuRDuH YybkRNdsIhYbiUqiVelu5ob4/cW4e1YERUgtY= 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=Rn8td2mpFzHPshW3xP1CDBr/cWifBNZl0TdWk46pT9s=; b=LLCkcZ0cP/fZUJKHOcxowLhIht9UsNJy/Ya19yKxP+KI1ucJc3z33hmn40VKA+rBTY Xs73tsCCqG/+kK9m9V7Eu0N7GZ3OxktBATEbAdA1QF5J8tH58xMghPnTF8DIdJfUniSn cZSPR4Rup/P5HwuM5zg7MMYvLOqwhMH5GRPZd04gFAZ0ejLm6fTf9UVPrzR0b2yzQVqs Ip1Qaj3zY9y40+y1tBQ4stj5bAmrLPNgKAnz+Wv1ryBPrSdUM1CfnWaFiJZ1bWXCmVuS HyYIKMGgI7GrLCI9WJGHD+eriDQVj9pLz3sJOWNPeEtvX3gr/WzfM/GqNnPcYw/RYXYS LHjA== X-Gm-Message-State: AElRT7Ed1J5nnI/f+64qkr3ywZC2ezbrUjjw/j/42FzgDtruhJX12Yko 7XN4DxrTPzL+DMBMWNJh1GhlJckhPWU= X-Google-Smtp-Source: AG47ELvqL85TC52ivJDM7U/HVLK9QYcUmFtaKrS4bBdhxe7UEzeYAKv1a2PtwaFcN0Ln3kAeJ7qqaA== X-Received: by 10.80.214.206 with SMTP id l14mr40793690edj.44.1522073510610; Mon, 26 Mar 2018 07:11:50 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id a10sm10714045eda.71.2018.03.26.07.11.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Mar 2018 07:11:50 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de, sbabic@denx.de Date: Mon, 26 Mar 2018 15:11:45 +0100 Message-Id: <1522073505-13066-4-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522073505-13066-1-git-send-email-bryan.odonoghue@linaro.org> References: <1522073505-13066-1-git-send-email-bryan.odonoghue@linaro.org> Cc: breno.lima@nxp.com, fabio.estevam@nxp.com, utkarsh.gupta@nxp.com Subject: [U-Boot] [PATCH v2 3/3] imx: hab: Provide hab_auth_img_or_fail 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" This patch adds hab_auth_img_or_fail() a command line function that encapsulates a common usage of authenticate and failover, namely if authenticate image fails, then drop to BootROM USB recovery mode. For secure-boot systems, this type of locked down behavior is important to ensure no unsigned images can be run. It's possible to script this logic but, when done over and over again the environment starts get very complex and repetitive, reducing that script repetition down to a command line function makes sense. Signed-off-by: Bryan O'Donoghue Cc: Utkarsh Gupta Cc: Breno Lima Cc: Fabio Estevam Tested-by: Breno Lima --- arch/arm/mach-imx/hab.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index c730c8f..9ca7bad 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -341,6 +341,31 @@ static int do_hab_failsafe(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } +static int do_authenticate_image_or_failover(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + int ret = CMD_RET_FAILURE; + + if (argc != 4) { + ret = CMD_RET_USAGE; + goto error; + } + + if (!imx_hab_is_enabled()) { + printf("error: secure boot disabled\n"); + goto error; + } + + if (do_authenticate_image(NULL, flag, argc, argv) != CMD_RET_SUCCESS) { + fprintf(stderr, "authentication fail -> %s %s %s %s\n", + argv[0], argv[1], argv[2], argv[3]); + do_hab_failsafe(0, 0, 1, NULL); + }; + ret = CMD_RET_SUCCESS; +error: + return ret; +} + U_BOOT_CMD( hab_status, CONFIG_SYS_MAXARGS, 1, do_hab_status, "display HAB status", @@ -362,6 +387,16 @@ U_BOOT_CMD( "" ); +U_BOOT_CMD( + hab_auth_img_or_fail, 4, 0, + do_authenticate_image_or_failover, + "authenticate image via HAB on failure drop to USB BootROM mode", + "addr length ivt_offset\n" + "addr - image hex address\n" + "length - image hex length\n" + "ivt_offset - hex offset of IVT in the image" + ); + #endif /* !defined(CONFIG_SPL_BUILD) */ /* Get CSF Header length */