[PATCH] board_init: Do not reserve MALLOC_F area on stack if non-zero MALLOC_F_ADDR

Simon Glass sjg at chromium.org
Thu Jun 30 12:06:22 CEST 2022


Hi Marek,

On Sat, 25 Jun 2022 at 11:58, Marek Vasut <marex at denx.de> wrote:
>
> In case the MALLOC_F_ADDR is set to non-zero value, the early malloc area is
> not going to be placed just below stack top, but elsewhere. Do not reserve
> MALLOC_F bytes in this case, as that wastes stack space and may even cause
> insufficient stack space in SPL.
>
> This functionality is particularly useful on i.MX8M, where the insufficient
> stack space can be triggered.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
> Cc: Fabio Estevam <festevam at denx.de>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Thomas Chou <thomas at wytron.com.tw>
> Cc: Tom Rini <trini at konsulko.com>
> ---
>  common/init/board_init.c | 2 ++
>  1 file changed, 2 insertions(+)

Please can you migrate the option to Kconfig first? I suspect that
will simplify the logic and avoid the #ifndef

>
> diff --git a/common/init/board_init.c b/common/init/board_init.c
> index eab5ee13953..6a550261778 100644
> --- a/common/init/board_init.c
> +++ b/common/init/board_init.c
> @@ -78,8 +78,10 @@ __weak void board_init_f_init_stack_protection(void)
>  ulong board_init_f_alloc_reserve(ulong top)
>  {
>         /* Reserve early malloc arena */
> +#ifndef CONFIG_MALLOC_F_ADDR
>  #if CONFIG_VAL(SYS_MALLOC_F_LEN)
>         top -= CONFIG_VAL(SYS_MALLOC_F_LEN);
> +#endif
>  #endif
>         /* LAST : reserve GD (rounded up to a multiple of 16 bytes) */
>         top = rounddown(top-sizeof(struct global_data), 16);
> --
> 2.35.1
>

Regards,
Simon


More information about the U-Boot mailing list