All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spl: fix stack usage check if gd is not initialized
@ 2019-11-11 21:30 Simon Goldschmidt
  2020-01-10 21:48 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Goldschmidt @ 2019-11-11 21:30 UTC (permalink / raw)
  To: u-boot

Most platforms do not set up gd->start_addr_sp in SPL. Since this is
required for CONFIG_SPL_SYS_REPORT_SACK_F_USAGE to work correctly, set
up gd->start_addr_sp in SPL to the value passed to
board_init_f_init_reserve if it is not set yet.

Fixes: d8c0332031 ("spl: implement stack usage check")
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

 common/init/board_init.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/common/init/board_init.c b/common/init/board_init.c
index e52106966d..3bc7994586 100644
--- a/common/init/board_init.c
+++ b/common/init/board_init.c
@@ -18,6 +18,19 @@ __weak void arch_setup_gd(struct global_data *gd_ptr)
 }
 #endif /* !CONFIG_X86 && !CONFIG_ARM */
 
+/**
+ * This function is called from board_init_f_init_reserve to set up
+ * gd->start_addr_sp for stack protection if not already set otherwise
+ */
+__weak void board_init_f_init_stack_protection_addr(ulong base)
+{
+#if CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE)
+	/* set up stack pointer for stack usage if not set yet */
+	if (!gd->start_addr_sp)
+		gd->start_addr_sp = base;
+#endif
+}
+
 /**
  * This function is called after the position of the initial stack is
  * determined in gd->start_addr_sp. Boards can override it to set up
@@ -129,6 +142,10 @@ void board_init_f_init_reserve(ulong base)
 #if !defined(CONFIG_ARM)
 	arch_setup_gd(gd_ptr);
 #endif
+
+	if (CONFIG_IS_ENABLED(SYS_REPORT_STACK_F_USAGE))
+		board_init_f_init_stack_protection_addr(base);
+
 	/* next alloc will be higher by one GD plus 16-byte alignment */
 	base += roundup(sizeof(struct global_data), 16);
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] spl: fix stack usage check if gd is not initialized
  2019-11-11 21:30 [U-Boot] [PATCH] spl: fix stack usage check if gd is not initialized Simon Goldschmidt
@ 2020-01-10 21:48 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-01-10 21:48 UTC (permalink / raw)
  To: u-boot

On Mon, Nov 11, 2019 at 10:30:46PM +0100, Simon Goldschmidt wrote:

> Most platforms do not set up gd->start_addr_sp in SPL. Since this is
> required for CONFIG_SPL_SYS_REPORT_SACK_F_USAGE to work correctly, set
> up gd->start_addr_sp in SPL to the value passed to
> board_init_f_init_reserve if it is not set yet.
> 
> Fixes: d8c0332031 ("spl: implement stack usage check")
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200110/08197518/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-10 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 21:30 [U-Boot] [PATCH] spl: fix stack usage check if gd is not initialized Simon Goldschmidt
2020-01-10 21:48 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.