[PATCH] ARM: i.MX: prevent use of imx_cpu_type in PBL
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon May 25 23:41:39 PDT 2026
Hello Sascha,
On 5/26/26 08:35, Sascha Hauer wrote:
> On 2026-05-22 15:48, Ahmad Fatoum wrote:
>> Functions like cpu_is_mx6q internally call cpu_is_mx6() first,
>> which can be evaluated at compile-time if only i.MX6 boards are enabled.
>>
>> This allowed calling cpu_is_mx6q in PBL entry points as long as barebox was
>> compiled for only a single SoC.
>>
>> Since the multi-arch/multi-platform support was added however,
>> cpu_is_mx6 became a runtime check that's never true in PBL, leading all
>> cpu_is_mx* in 32-boards to silently fail at runtime.
>>
>> We have no in-tree boards that are affected by this, so until some
>> out-of-tree user is bothered enough to fix is, acknowledge that this no
>> longer works and turn the silent breakage into a loud compile-time error
>> whenever anything ends up referencing __imx_cpu_type.
>
> imx_set_cpu_type() has users in PBL:
>
> arch/arm/mach-imx/atf.c:280: imx_set_cpu_type(IMX_CPU_IMX8MM);
> arch/arm/mach-imx/atf.c:343: imx_set_cpu_type(IMX_CPU_IMX8MP);
> arch/arm/mach-imx/atf.c:406: imx_set_cpu_type(IMX_CPU_IMX8MN);
> arch/arm/mach-imx/atf.c:463: imx_set_cpu_type(IMX_CPU_IMX8MQ);
> arch/arm/mach-imx/atf.c:492: imx_set_cpu_type(IMX_CPU_IMX93);
>
> Also several consumers rely on it in PBL:
>
> arch/arm/mach-imx/tzasc.c:358: if (cpu_is_mx8mm() || cpu_is_mx8mn() || cpu_is_mx8mp())
> arch/arm/mach-imx/tzasc.c:365: if (cpu_is_mx8mn() || cpu_is_mx8mp())
> arch/arm/mach-imx/atf.c:90: if (cpu_is_mx8mn())
> arch/arm/mach-imx/atf.c:143: if (cpu_is_mx8mn())
> arch/arm/mach-imx/atf.c:198: if (!IS_ENABLED(CONFIG_ARCH_IMX_ATF_PASS_BL_PARAMS) || cpu_is_mx8mq()) {
Yes and the definition is still emitted for CONFIG_ARCH_IMX_ATF=y.
The change here onl affects 32-bit i.MX.
Cheers,
Ahmad
>
> Sascha
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list