[PATCH] common: spl: Warn about overflow of SRAM stack

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 }

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

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".
participants (3)
-
Kamlesh Gurudasani
-
Tom Rini
-
Vignesh Raghavendra