sched: Improve nxsched stack overflow checking implementation

1. Remove STACKCHECK_SOFTWARE config,
   2. Do sp value checking when STACKCHECK_MARGIN == 0,
   3. Do margin-based stack check when STACKCHECK_MARGIN > 0,
   4. Disable stack check when STACKCHECK_MARGIN == -1

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
This commit is contained in:
wangchengdong
2025-10-01 21:46:38 +08:00
committed by Xiang Xiao
parent 1210dc4919
commit 07a470f696
8 changed files with 119 additions and 30 deletions
+3 -13
View File
@@ -2455,23 +2455,13 @@ config STACK_COLORATION
Only supported by a few architectures.
config STACKCHECK_SOFTWARE
bool "Software detection of stack overflow"
depends on STACK_COLORATION && DEBUG_ASSERTIONS
---help---
When switching contexts, it will detect whether a stack overflow occurs.
Two methods are used here.
The first is to check the legitimacy of the value of the sp register;
the second is to check the specified number of bytes at the bottom of the stack.
If either of these two methods fails, an ASSERT will be triggered.
config STACKCHECK_MARGIN
int "Stack overflow check size (bytes)"
depends on STACKCHECK_SOFTWARE
default 16
depends on DEBUG_ASSERTIONS
default -1
---help---
Specifies the number of bytes at the end of the stack to check for overflow.
A value of 0 disables additional checking. Increase this value for stricter
A value of -1 disables additional checking. Increase this value for stricter
overflow detection, at the cost of additional overhead.
config STACK_CANARIES