[PATCH v3 11/17] imx9: scmi: soc: Override h_spl_load_read with trampoline buffer

Marek Vasut marex at denx.de
Sun Jan 12 22:50:55 CET 2025


On 1/10/25 10:49 AM, Peng Fan wrote:
> On Sun, Jan 05, 2025 at 10:56:29PM +0100, Marek Vasut wrote:
>> On 1/3/25 7:45 AM, Alice Guo wrote:
>>> From: Ye Li <ye.li at 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 override h_spl_load_read to use a trampoline buffer in nonsecure
>>> region, then use CPU to copy the image from trampoline buffer to
>>> destination secure region.
>>>
>>> Signed-off-by: Ye Li <ye.li at nxp.com>
>>> Signed-off-by: Alice Guo <alice.guo at nxp.com>
>>> Reviewed-by: Peng Fan <peng.fan at nxp.com>
>>> ---
>>>    arch/arm/mach-imx/imx9/scmi/soc.c | 40 +++++++++++++++++++++++++++++++++++++++
>>>    common/spl/spl_mmc.c              |  2 +-
>>>    2 files changed, 41 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c b/arch/arm/mach-imx/imx9/scmi/soc.c
>>> index fefb1a6f4ca58722a5d93c39e4f6a7aaf85aa177..8a7df24afecc1d6d77b7162be639b56af95fd975 100644
>>> --- a/arch/arm/mach-imx/imx9/scmi/soc.c
>>> +++ b/arch/arm/mach-imx/imx9/scmi/soc.c
>>> @@ -41,6 +41,8 @@
>>>    #include <scmi_agent.h>
>>>    #include <scmi_protocols.h>
>>>    #endif
>>> +#include <spl.h>
>>> +#include <mmc.h>
>>>    DECLARE_GLOBAL_DATA_PTR;
>>> @@ -830,3 +832,41 @@ enum boot_device get_boot_device(void)
>>>    	return boot_dev;
>>>    }
>>>    #endif
>>> +
>>> +ulong h_spl_load_read(struct spl_load_info *load, ulong off,
>>> +		      ulong size, void *buf)
>>
>> Can you simply define spl_get_load_buffer() instead to make sure SPL loads
>> your stuff into the correct location ?
> 
> spl_get_load_buffer does not help here, unless do a big change to spl_mmc.c
> h_spl_load_read is set to info->read, info->read is not just for reading
> headers, it also needs to read container image data.
> 
>>
>> This hack in generic code is a NAK.
> 
> This is set it as __weak, and overwrite in soc code, there are many
> similar code
The more I am looking at this, the more this simply does not work. 
Consider these use cases for example where this fails:

- Board boots from SPI NOR
- Board boots from filesystem on SD/eMMC

So what about taking a different approach. First, use the SPL loader 
as-is to load whatever blobs you need to memory locations into which you 
can load. Second, implement board or arch specific spl_perform_fixups(), 
which is already empty weak function, and make it move the blobs into 
the correct location. Would that work ?


More information about the U-Boot mailing list