All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: Ye Li <ye.li@nxp.com>, "u-boot@lists.denx.de" <u-boot@lists.denx.de>
Cc: "marex@denx.de" <marex@denx.de>,
	"tharvey@gateworks.com" <tharvey@gateworks.com>,
	"sjg@chromium.org" <sjg@chromium.org>,
	"festevam@gmail.com" <festevam@gmail.com>,
	dl-uboot-imx <uboot-imx@nxp.com>,
	"philippe.reynes@softathome.com" <philippe.reynes@softathome.com>,
	"michal.simek@xilinx.com" <michal.simek@xilinx.com>,
	"mr.nuke.me@gmail.com" <mr.nuke.me@gmail.com>,
	"Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
	"sbabic@denx.de" <sbabic@denx.de>
Subject: Re: [EXT] [PATCH v1] imx: spl: fix imx8m secure boot
Date: Mon, 16 Aug 2021 11:41:42 +0200	[thread overview]
Message-ID: <88869d4f-ce63-21f0-83a0-d297560c4d47@denx.de> (raw)
In-Reply-To: <1629102387.13390.7.camel@nxp.com>

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 <hs@denx.de>
>>
>>
>> ---
>> 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

      reply	other threads:[~2021-08-16  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16  5:07 [PATCH v1] imx: spl: fix imx8m secure boot Heiko Schocher
2021-08-16  8:26 ` [EXT] " Ye Li
2021-08-16  9:41   ` Heiko Schocher [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88869d4f-ce63-21f0-83a0-d297560c4d47@denx.de \
    --to=hs@denx.de \
    --cc=festevam@gmail.com \
    --cc=marex@denx.de \
    --cc=michal.simek@xilinx.com \
    --cc=mr.nuke.me@gmail.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=philippe.reynes@softathome.com \
    --cc=sbabic@denx.de \
    --cc=sjg@chromium.org \
    --cc=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    --cc=ye.li@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.