From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2B43C4338F for ; Mon, 16 Aug 2021 09:41:52 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6304A61B07 for ; Mon, 16 Aug 2021 09:41:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6304A61B07 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C3D083131; Mon, 16 Aug 2021 11:41:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629106909; bh=SbYrYrGeUzs9uoOIHTO5TL9MDnaOkoD9Q8NbB+UO+QM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Reply-To:From; b=zOMJtgtGryt9c1Vm3PB1BLj5DrX+3OHfV3SJmXwKH3ubbAi4vBC0PTotO+vcFoKi8 lexh09bgfP66ZtYVMd4dJAiI3JBJJljc4UKA7LskQ9Xavhfo1hFyXx8R325sqkEz5E Fg77fwkbiYy1kRIWX7QS9rV6pcodx8GnkFTfJGtrcROqstyjHblgHobvhnASNJr2xx ZAZm8UfKYpiWTHdKVB5a34LNq4RhwI5XXCUqv5Eb0YaeE4j4bE1BmBOAkEdw+bGbEj 01dI//8+RftRLsUvi1K+p1qa62nOKx/jp9erYfIIHD74Ek4nrKUAqQjxIQaW8poCYv yGaWUA9/XiHig== Received: from [192.168.1.107] (87-97-28-105.pool.digikabel.hu [87.97.28.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: hs@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 5F45482E8D; Mon, 16 Aug 2021 11:41:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629106907; bh=SbYrYrGeUzs9uoOIHTO5TL9MDnaOkoD9Q8NbB+UO+QM=; h=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From; b=BFjUZ7kZNcuV45ef9Re5+YcEH8+K61RtlETgocv6G97JStuWqcso41sLuZMAuIYth Z+Xqy8JfVLtCHTtRvt4QC3NcIZwyEHv1sTTgD57tMHZq+fn+relJMpyXobvryO39wH //1q3qJnEDFl+CtNiIgf10DTFyc4ykKj1Kmthho55OziuX49OZ3TEEhX8MRg/0GWag FvJyHxaRJ8iId6ZsftT472LAIt025TrquIsg0QA3kDeq0ll99krQa/CB4fJY9sr5en aIZOBXV5StO/QiHHRn1DB+5qQI8B/j3BqCJ5OpxKRUsoH+42Y67bo18Vu+5pRV8xt9 +tv6EzbuZMtVA== Subject: Re: [EXT] [PATCH v1] imx: spl: fix imx8m secure boot To: Ye Li , "u-boot@lists.denx.de" Cc: "marex@denx.de" , "tharvey@gateworks.com" , "sjg@chromium.org" , "festevam@gmail.com" , dl-uboot-imx , "philippe.reynes@softathome.com" , "michal.simek@xilinx.com" , "mr.nuke.me@gmail.com" , "Peng Fan (OSS)" , "sbabic@denx.de" References: <20210816050706.2665092-1-hs@denx.de> <1629102387.13390.7.camel@nxp.com> From: Heiko Schocher Message-ID: <88869d4f-ce63-21f0-83a0-d297560c4d47@denx.de> Date: Mon, 16 Aug 2021 11:41:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <1629102387.13390.7.camel@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: hs@denx.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hello Li, On 16.08.21 10:26, Ye Li wrote: > Hi Heiko, > > On Mon, 2021-08-16 at 07:07 +0200, Heiko Schocher wrote: >> Caution: EXT Email >> >> inspired from NXP code: >> 719d665a87c6: ("MLK-20467 imx8m: Fix issue for booting signed image >> through uuu") >> >> fix loading FIT buffer address to fix position >> CONFIG_SYS_TEXT_BASE - CONFIG_FIT_EXTERNAL_OFFSET >> >> and fix secure boot on imx8m based boards. Problem was >> that FIT header and so IVT header too, was loaded to >> memallocated address. So the ivt header address coded >> in IVT itself does not fit with the real position. >> >> Signed-off-by: Heiko Schocher >> >> >> --- >> replaces Series: >> https://lists.denx.de/pipermail/u-boot/2021-August/457308.html >> >> @Tim: could you please test this version on your hardware? >> >> azure build: >> https://dev.azure.com/hs0298/hs/_build/results?buildId=71&view=result >> s >> (fetch error for rockchip, but this should be no problem for this >>  patch. How do I restart one specific job on azure?) >> >> Works on sdcard and QSPI NOR boot on phycore-imx8mp board. >> >>  arch/arm/mach-imx/spl.c | 11 +++++++++++ >>  common/spl/spl_fit.c    |  7 ++++++- >>  2 files changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c >> index 36033d611c..6991d88dbf 100644 >> --- a/arch/arm/mach-imx/spl.c >> +++ b/arch/arm/mach-imx/spl.c >> @@ -334,6 +334,17 @@ void board_spl_fit_post_load(const void *fit) >>  } >>  #endif >> >> +#if defined(CONFIG_FIT_EXTERNAL_OFFSET) >> +void *board_spl_fit_buffer_addr(ulong fit_size, int bl_len) >> +{ >> +       /* >> +        * use fix position >> +        * TEXT_BASE - FIT_EXTERNAL_OFFSET >> +        */ >> +       return  (void *)((CONFIG_SYS_TEXT_BASE - >> CONFIG_FIT_EXTERNAL_OFFSET)); > > It looks odd to use CONFIG_FIT_EXTERNAL_OFFSET. This config is used > to designate the image offset inside the FIT. It is irrelevant here. > Please follow the patch 719d665a87c6: ("MLK-20467 imx8m: Fix issue for > booting signed image through uuu") to fix the issue, which also keep > the HAB block aligned. Hmm.. ok, I can change... bye, Heiko > > Best regards, > Ye Li > >> +} >> +#endif >> + >>  #endif >> >>  #if defined(CONFIG_MX6) && defined(CONFIG_SPL_OS_BOOT) >> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c >> index f41abca0cc..a4337d3c88 100644 >> --- a/common/spl/spl_fit.c >> +++ b/common/spl/spl_fit.c >> @@ -538,6 +538,11 @@ static void *spl_get_fit_load_buffer(size_t >> size) >>         return buf; >>  } >> >> +__weak void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, >> int bl_len) >> +{ >> +       return spl_get_fit_load_buffer(sectors * bl_len); >> +} >> + >>  /* >>   * Weak default function to allow customizing SPL fit loading for >> load-only >>   * use cases by allowing to skip the parsing/processing of the FIT >> contents >> @@ -631,7 +636,7 @@ static int spl_simple_fit_read(struct >> spl_fit_info *ctx, >>          * For FIT with external data, data is not loaded in this >> step. >>          */ >>         sectors = get_aligned_image_size(info, size, 0); >> -       buf = spl_get_fit_load_buffer(sectors * info->bl_len); >> +       buf = board_spl_fit_buffer_addr(size, sectors, info->bl_len); >> >>         count = info->read(info, sector, sectors, buf); >>         ctx->fit = buf; >> -- >> 2.31.1 -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs@denx.de