Skip to content

Commit 580e93e

Browse files
RobinKastbergdkalowsk
authored andcommitted
arm: tests: kernel: fix bug in fatal_exception test
In ARM architectures the entry_cpu_exception_extend calls svc #0 when trying to generate a `K_ERR_CPU_EXCEPTION`, however z_arm_svc calls z_do_oops with a stack frame only, and gets the reason from `r0`. This means that the test working was just lucky and running it with another compiler (or setting the value of r0 before the svc #0 call, made the test fail). Cortex-A/R 32-bit architectures was doing a BKPT, this works better but will not be a hard exception when debugger is attached. I switched all the Cortex 32-bits to the ARM specified undefined instruction. Also RISC-V has a designated unimp instruction that should be used to guarantee trap. Signed-off-by: Robin Kastberg <[email protected]>
1 parent eb9fc64 commit 580e93e

File tree

1 file changed

+3
-3
lines changed
  • tests/kernel/fatal/exception/src

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@ void entry_cpu_exception_extend(void *p1, void *p2, void *p3)
108108
#if defined(CONFIG_ARM64)
109109
__asm__ volatile ("svc 0");
110110
#elif defined(CONFIG_CPU_AARCH32_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
111-
__asm__ volatile ("BKPT");
111+
__asm__ volatile ("udf #0");
112112
#elif defined(CONFIG_CPU_CORTEX_M)
113-
__asm__ volatile ("swi 0");
113+
__asm__ volatile ("udf #0");
114114
#elif defined(CONFIG_NIOS2)
115115
__asm__ volatile ("trap");
116116
#elif defined(CONFIG_RISCV)
117117
/* In riscv architecture, use an undefined
118118
* instruction to trigger illegal instruction on RISCV.
119119
*/
120-
__asm__ volatile (".word 0x77777777");
120+
__asm__ volatile ("unimp");
121121
/* In arc architecture, SWI instruction is used
122122
* to trigger soft interrupt.
123123
*/

0 commit comments

Comments
 (0)