From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: "Alice Guo (OSS)" <alice.guo@oss.nxp.com>
Cc: Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Simon Glass <sjg@chromium.org>, Stefano Babic <sbabic@denx.de>,
Fabio Estevam <festevam@gmail.com>,
Alper Nebi Yasak <alpernebiyasak@gmail.com>,
Alice Guo <alice.guo@nxp.com>,
u-boot@lists.denx.de, Marek Vasut <marex@denx.de>,
Ye Li <ye.li@nxp.com>, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH v10 13/21] spl: imx: use trampoline buffer to load images to secure region
Date: Thu, 24 Apr 2025 09:14:23 +0200 [thread overview]
Message-ID: <20250424091423.68e348d8@karo-electronics.de> (raw)
In-Reply-To: <20250424-imx95-v1-13-10a8449b1e5e@oss.nxp.com>
Hi,
On Thu, 24 Apr 2025 14:33:09 +0800 Alice Guo (OSS) wrote:
> From: Ye Li <ye.li@nxp.com>
>
> When SPL loading image to secure region, for example, ATF and tee to
> DDR secure region. Because the USDHC controller is non-secure master,
> it can't access this region and will cause loading issue.
>
> So use a trampoline buffer in non-secure region, then use CPU to copy the
> image from trampoline buffer to destination secure region.
>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Signed-off-by: Alice Guo <alice.guo@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> ---
> arch/arm/mach-imx/imx9/scmi/soc.c | 18 +++++++++++++++++
> common/spl/Kconfig | 6 ++++++
> common/spl/spl_imx_container.c | 41 +++++++++++++++++++++++++++++++++------
> 3 files changed, 59 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
> index 3a5bdddd785..d2b0455bff9 100644
> --- a/arch/arm/mach-imx/imx9/scmi/soc.c
> +++ b/arch/arm/mach-imx/imx9/scmi/soc.c
> @@ -729,3 +729,21 @@ enum boot_device get_boot_device(void)
> return boot_dev;
> }
> #endif
> +
> +bool arch_check_dst_in_secure(void *start, ulong size)
> +{
> + ulong ns_end = CFG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE;
> +#ifdef PHYS_SDRAM_2_SIZE
> + ns_end += PHYS_SDRAM_2_SIZE;
> +#endif
> +
> + if ((ulong)start < CFG_SYS_SDRAM_BASE || (ulong)start + size > ns_end)
> + return true;
> +
> + return false;
> +}
> +
> +void *arch_get_container_trampoline(void)
> +{
> + return (void *)((ulong)CFG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE - SZ_16M);
> +}
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index 3282e08a754..a2b214f3d74 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -361,6 +361,12 @@ config SPL_LOAD_IMX_CONTAINER
> Support booting U-Boot from an i.MX8 container image. If you are not
> using i.MX8, say 'n'.
>
> +config SPL_IMX_CONTAINER_USE_TRAMPOLINE
> + bool
> + depends on SPL
> + help
> + Enable SPL load reader to load data to a trampoline buffer.
> +
> config IMX_CONTAINER_CFG
> string "i.MX8 Container config file"
> depends on SPL && SPL_LOAD_IMX_CONTAINER
> diff --git a/common/spl/spl_imx_container.c b/common/spl/spl_imx_container.c
> index 2c31777fcd3..6e6afec1ff3 100644
> --- a/common/spl/spl_imx_container.c
> +++ b/common/spl/spl_imx_container.c
[...]
> @@ -42,12 +53,30 @@ static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image,
[...]
> + if (info->read(info, offset, size,
> + map_sysmem(images[image_index].dst - overhead,
> + images[image_index].size)) <
> + images[image_index].size) {
> + printf("%s: failed to load image to a non-secure region\n", __func__);
> + return NULL;
> + }
Strange indentation and rather unreadable code...
Since 'map_sysmem(images[image_index].dst - overhead, images[image_index].size)'
has been assigned to 'buf' before, this could be written as:
if (info->read(info, offset, size, buf) < images[image_index].size) {
printf("%s: failed to load image to a non-secure region\n", __func__);
return NULL;
}
Lothar Waßmann
next prev parent reply other threads:[~2025-04-24 7:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 6:32 [PATCH v10 00/21] imx: add i.MX95 support Alice Guo (OSS)
2025-04-24 6:32 ` [PATCH v10 01/21] firmware: scmi: support to manage SCMI protocol drivers with a linker-genetated array Alice Guo (OSS)
2025-04-24 6:32 ` [PATCH v10 02/21] firmware: scmi: use scmi_proto_driver_get() function to get SCMI protocol driver Alice Guo (OSS)
2025-04-24 6:32 ` [PATCH v10 03/21] pinctrl: nxp: add a pin controller driver based on SCMI pin control protocol Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 04/21] firmware: scmi_agent: add SCMI pin control protocol support Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 05/21] scmi_protocols: add SCMI misc protocol protocol_id and message_id for getting the ROM passover data Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 06/21] scmi_protocols: add SCMI Performance domain management protocol message IDs Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 07/21] clk: scmi: add the command CLOCK_PARENT_SET Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 08/21] clk: scmi: check the clock state/parent/rate control permissions Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 09/21] sandbox: add SCMI clock control permissions to sandbox Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 10/21] scmi_protocols: update struct scmi_base_discover_list_protocols_out Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 11/21] imx9: scmi: add i.MX95 SoC and clock related code Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 12/21] cpu: imx95: add i.MX95 support Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 13/21] spl: imx: use trampoline buffer to load images to secure region Alice Guo (OSS)
2025-04-24 7:14 ` Lothar Waßmann [this message]
2025-04-24 6:33 ` [PATCH v10 14/21] imx9: add i.MX95 Kconfig and Makefile Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 15/21] imx: Kconfig: IMX8_ROMAPI is not configured for i.MX95 Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 16/21] binman: add a new entry type for packing DDR PHY firmware images Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 17/21] tools: imx8image: add i.MX95 support Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 18/21] imx: container: add V2X container support for i.MX95 Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 19/21] doc: imx: add document for i.MX95 Image Container Format Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 20/21] imx95_evk: add i.MX95 19x19 EVK board basic support Alice Guo (OSS)
2025-04-24 6:33 ` [PATCH v10 21/21] Makefile: add some files to CLEAN_FILES Alice Guo (OSS)
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=20250424091423.68e348d8@karo-electronics.de \
--to=lw@karo-electronics.de \
--cc=alice.guo@nxp.com \
--cc=alice.guo@oss.nxp.com \
--cc=alpernebiyasak@gmail.com \
--cc=festevam@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=peng.fan@nxp.com \
--cc=sbabic@denx.de \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--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.