imx8m optee load address?

Jerome Forissier jerome.forissier at linaro.org
Fri Jun 16 11:06:12 CEST 2023


Hi,

On 6/16/23 05:31, Peng Fan wrote:
> 
> 
> On 6/16/2023 9:56 AM, Tim Harvey wrote:
>> Greetings,
>>
>> I've seen several IMX8M boards include a firmware/optee node in the
>> U-Boot dt (git grep optee arch/arm/dts/imx8m*.dtsi) yet but none that
>> I see configure binman to actually add the binary in the u-boot.dtsi,
>> do anything to keep U-Boot from accessing the OPTEE memory, or
>> document how to configure and build OPTEE for imx8m. I would like to
>> add such support but I find it odd that OPTEE needs to be built
>> differently depending on the dram size.
>>
>> Prior to switching to binman (v2021.10)
>> arch/arm/mach-imx/mkimage_fit_atf.sh [1] would include tee.bin in the
>> FIT image if it was found in the current directory and it was expected
>> that you provide a proper TEE_LOAD_ADDR via the env (commit
>> a9eed6e1b8d8 ("imx: imx8m: introduce script to generate fit image").
>>
>> According to the IMX OPTEE documentation [2] the size and location of
>> OPTEE is hard coded (CFG_TZDRAM_START and CFG_TZDRAM_SIZE) but looking
>> at the imx-optee source [3] this is calculated based off of
>> CFG_DDR_SIZE (which you can provide via env at build time or just
>> provide CFG_TZDRAM_START and CFG_TZDRAM_SIZE via env directly).
> 
> optee does not support PIE, it could only run at the address that built
> time defined.

PIE was introduced recently [1] but please note the limitation about EL2
SPMC.

[1] https://github.com/OP-TEE/optee_os/commit/0d9286927

Regards,
-- 
Jerome

> 
> And the TZASC needs following it to protect the region properly.
> 
>>
>> This results in the OPTEE location of 0x7e000000 for 1GiB systems,
>> 0xbe000000 for 2GiB systems, and 0x13e000000 for 4GiB systems for
>> example. This dependence on dram size causes a couple of issues:
>>   - OPTEE location depends on build-time configuration and several
>> boards have run-time identification of their memory size
>>   - for 4GiB systems the address 0x13e000000 crosses the 32bit address
>> boundary and U-Boot hangs
> 
> imx optee seems has this. But for overlapping with U-Boot, I doubt that.
> 
>>
>> Is there any reason OPTEE can't be located wherever you want and not
>> depend on dram size? 
> 
> You could , just modify the imx *.mk file per my recall.
> 
> I've tried to set it to 0x7e000000 (for a 1GiB
>> board) on a 4GiB board and U-Boot hangs near the DRAM banner which is
>> likely due to get_ram_size() stepping on OPTEE's memory range but then
> 
> You may give a try to disable TZASC settings in OP-TEE first.
> And you also need to carve out the memory of OP-TEE from U-Boot MMU
> to avoid prefetch.
> 
>> I'm not clear why that doesn't occur when OPTEE is located at the top
>> of dram on a 1GiB and 2GiB system. How would I go about adding a
>> carevout for this?
> 
> Are u using upstream optee or NXP downstream optee release?
> 
> Regards,
> Peng.
> 
>>
>> Best Regards,
>>
>> Tim
>> [1] https://elixir.bootlin.com/u-boot/v2021.10/source/arch/arm/mach-imx/mkimage_fit_atf.sh
>> [2] https://www.nxp.com/docs/en/user-guide/IMX_PORTING_GUIDE.pdf
>> [3] https://github.com/nxp-imx/imx-optee-os


More information about the U-Boot mailing list