Skip to content

Commit 7920c38

Browse files
M-Moawadjhedberg
authored andcommitted
tests: kernel: fatal: Add ARC-specific stack protection test
Add ARC-specific variant of kernel.common.stack_protection test that omits frame pointers to work around GNU toolchain code generation issue. The GNU toolchain generates FP-relative memory accesses (st r0,[fp,-8]) for local variables when frame pointers are enabled, which bypasses ARC hardware stack checking that only monitors SP-based instructions. This causes the test to fail with MPU violations instead of stack check violations. Signed-off-by: Mohamed Moawad <[email protected]>
1 parent a2b554c commit 7920c38

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

tests/kernel/fatal/exception/src/main.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,11 @@ ZTEST(fatal_exception, test_fatal)
415415

416416
#ifdef CONFIG_USERSPACE
417417

418-
/* on arc, this fails with an MPU error instead of a stack
419-
* overflow because the priv stack is merged into the defined
420-
* stack.
421-
*/
422-
#if !defined(CONFIG_ARC)
423418
TC_PRINT("test stack HW-based overflow - user 1\n");
424419
check_stack_overflow(stack_hw_overflow, K_USER);
425420

426421
TC_PRINT("test stack HW-based overflow - user 2\n");
427422
check_stack_overflow(stack_hw_overflow, K_USER);
428-
#endif
429423

430424
TC_PRINT("test stack HW-based overflow - user priv stack 1\n");
431425
check_stack_overflow(user_priv_stack_hw_overflow, K_USER);

tests/kernel/fatal/exception/testcase.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ tests:
99
filter: CONFIG_ARCH_HAS_STACK_PROTECTION
1010
arch_exclude:
1111
- posix
12+
- arc
13+
tags:
14+
- kernel
15+
- userspace
16+
kernel.common.stack_protection.arc:
17+
extra_args: CONF_FILE=prj.conf
18+
filter: CONFIG_ARCH_HAS_STACK_PROTECTION
19+
arch_allow: arc
20+
extra_configs:
21+
- CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT=y
22+
- CONFIG_OMIT_FRAME_POINTER=y
1223
tags:
1324
- kernel
1425
- userspace

0 commit comments

Comments
 (0)