Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00D71C433EF for ; Sat, 25 Jun 2022 17:58:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5BDC8843FD; Sat, 25 Jun 2022 19:58:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1656179911; bh=l/5sBiX4QUWbn4ajZt6oPwHrMjruEynaYBL7MwV5TnI=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=MoX38FF9zaJVwEKryF2egO+2/GE0Y552whI+1ExRj2k05LFLa4vsOSuDN33qy2LQx xQ8TCv8rivBTSF6gnfMv37cs+zpavIq2f6pcT0z/vBFkFvAoVL4iPVMpXP/KzwjSCo hRI/WEl6xHByKEiUhxxMD6SB6oC3Xdf5AZbC8YQ0gZRpDfLdG/Tnh+76TWBFFpZn7B VxrRvxoXvEEtMWLaNtpNgrFi+1G65A0vdkTQYrwGHmPU9O/g7kWS6cAWrCZBtM6WJZ 9tgEAcQA6/c1fu3/97yVlZTXmMYGn28pAFviY4ob/0MdLKlljhUHUmNYY5z52hVSe2 5ExLK60li54Bw== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id BAEBC82113; Sat, 25 Jun 2022 19:58:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1656179910; bh=l/5sBiX4QUWbn4ajZt6oPwHrMjruEynaYBL7MwV5TnI=; h=From:To:Cc:Subject:Date:From; b=PmVgNG+1I/llzvBe7kHDwiFfumJEJ7lEAA0Ncis6L3V7kegdqR8sJJdyRRmrIB17A rcGSlcn/Aa3oBbTIOwA4a5ry4qfLsM/mXY2GTa7AVKHmaUjqlOR4BHQU99RATOkd92 qvj25ZtSIvCchK0mAw0GDEIHniwYzCMjtK/IhRIK2XPB6Ec2+emD80RnbPFGmfpX0+ 0P+us152gHH+eTgkKib9zD+OQv+h9qLfBw7P0Qce4V3wIA7avLudsdKi02OirI+VWk 24xYXKChJPKdujVmWs0hH7x3HD0zAv+luX7td0OxVxKF97erpZH22CVHsOLw0H5UWh g9M7OI01eCCNA== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Albert ARIBAUD , Fabio Estevam , Peng Fan , Simon Glass , Stefano Babic , Thomas Chou , Tom Rini Subject: [PATCH] board_init: Do not reserve MALLOC_F area on stack if non-zero MALLOC_F_ADDR Date: Sat, 25 Jun 2022 19:58:24 +0200 Message-Id: <20220625175824.128263-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 Cc: Albert ARIBAUD Cc: Fabio Estevam Cc: Peng Fan Cc: Simon Glass Cc: Stefano Babic Cc: Thomas Chou Cc: Tom Rini --- common/init/board_init.c | 2 ++ 1 file changed, 2 insertions(+) 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