* [PATCH] common: spl: Warn about overflow of SRAM stack
@ 2023-06-07 4:28 Vignesh Raghavendra
2023-06-07 5:00 ` [EXTERNAL] " Kamlesh Gurudasani
2023-06-07 16:55 ` Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Vignesh Raghavendra @ 2023-06-07 4:28 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot, Vignesh Raghavendra
If early stack usage is exactly same as SIZE_LIMIT_PROVIDE_STACK, then
its most likely to have overflowed beyond this limit and corrupted any
regions beyond stack. Warn about this to the user.
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
I found this useful when debugging slient corruption of code/data leading
to random failures post relocation.
common/spl/spl.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 72078a8ebc8e..9a9c8fad7673 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -950,6 +950,13 @@ __weak void spl_relocate_stack_check(void)
}
printf("SPL initial stack usage: %lu bytes\n",
CONFIG_VAL(SIZE_LIMIT_PROVIDE_STACK) - i);
+
+ /*
+ * If we used up all of the SIZE_LIMIT_PROVIDE_STACK, then here is high
+ * possibility of stack overflow, warn the user accordingly
+ */
+ if (!i)
+ printf("SPL possible initial stack overflow detected!!\n");
#endif
}
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [EXTERNAL] [PATCH] common: spl: Warn about overflow of SRAM stack
2023-06-07 4:28 [PATCH] common: spl: Warn about overflow of SRAM stack Vignesh Raghavendra
@ 2023-06-07 5:00 ` Kamlesh Gurudasani
2023-06-07 16:55 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Kamlesh Gurudasani @ 2023-06-07 5:00 UTC (permalink / raw)
To: Vignesh Raghavendra, Tom Rini; +Cc: u-boot, Vignesh Raghavendra
Vignesh Raghavendra <vigneshr@ti.com> writes:
> If early stack usage is exactly same as SIZE_LIMIT_PROVIDE_STACK, then
> its most likely to have overflowed beyond this limit and corrupted any
> regions beyond stack. Warn about this to the user.
>
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
>
> I found this useful when debugging slient corruption of code/data leading
> to random failures post relocation.
>
> common/spl/spl.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Reviewed-by: Kamlesh Gurudasani <kamlesh@ti.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] common: spl: Warn about overflow of SRAM stack
2023-06-07 4:28 [PATCH] common: spl: Warn about overflow of SRAM stack Vignesh Raghavendra
2023-06-07 5:00 ` [EXTERNAL] " Kamlesh Gurudasani
@ 2023-06-07 16:55 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-06-07 16:55 UTC (permalink / raw)
To: Vignesh Raghavendra; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]
On Wed, Jun 07, 2023 at 09:58:41AM +0530, Vignesh Raghavendra wrote:
> If early stack usage is exactly same as SIZE_LIMIT_PROVIDE_STACK, then
> its most likely to have overflowed beyond this limit and corrupted any
> regions beyond stack. Warn about this to the user.
>
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
>
> I found this useful when debugging slient corruption of code/data leading
> to random failures post relocation.
>
> common/spl/spl.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 72078a8ebc8e..9a9c8fad7673 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -950,6 +950,13 @@ __weak void spl_relocate_stack_check(void)
> }
> printf("SPL initial stack usage: %lu bytes\n",
> CONFIG_VAL(SIZE_LIMIT_PROVIDE_STACK) - i);
> +
> + /*
> + * If we used up all of the SIZE_LIMIT_PROVIDE_STACK, then here is high
> + * possibility of stack overflow, warn the user accordingly
> + */
> + if (!i)
> + printf("SPL possible initial stack overflow detected!!\n");
> #endif
Since we're already inside of CONFIG_SPL_SYS_REPORT_STACK_F_USAGE being
enabled, we should rework the previous print to include something like
"%lu bytes free".
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-07 16:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 4:28 [PATCH] common: spl: Warn about overflow of SRAM stack Vignesh Raghavendra
2023-06-07 5:00 ` [EXTERNAL] " Kamlesh Gurudasani
2023-06-07 16:55 ` 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.