Skip to content

Commit 27f4e7f

Browse files
dcpleungnashif
authored andcommitted
xtensa: only use BREAK if explicitly enabled
Introduce CONFIG_XTENSA_BREAK_ON_UNRECOVERABLE_EXCEPTIONS to use BREAK instruction for unrecoverable exceptions. This definitely requires debugger to be attached to the hardware or simulator to catch that. Also move the infinite loop to NOT result in an infinite interrupt storm as the debug interrupt will be triggered over and over again. Same for the simcall exit as it does not need to be called repetitively. Signed-off-by: Daniel Leung <[email protected]>
1 parent bc3e77b commit 27f4e7f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

arch/xtensa/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ config XTENSA_NUM_SPIN_RELAX_NOPS
103103
Specify the number of NOPs in Xtensa specific
104104
arch_spin_relax().
105105

106+
config XTENSA_BREAK_ON_UNRECOVERABLE_EXCEPTIONS
107+
bool "Use BREAK instruction on unrecoverable exceptions"
108+
help
109+
Use BREAK instruction when unrecoverable exceptions are
110+
encountered. This requires a debugger attached to catch
111+
the BREAK.
112+
106113
menu "Xtensa HiFi Options"
107114

108115
config XTENSA_CPU_HAS_HIFI

arch/xtensa/core/xtensa_asm2_util.S

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,13 @@ _DoubleExceptionVector:
503503
j _Level1Vector
504504
#else
505505

506-
#if defined(CONFIG_SIMULATOR_XTENSA) || defined(XT_SIMULATOR)
507-
1:
506+
#if XCHAL_HAVE_DEBUG && defined(CONFIG_XTENSA_BREAK_ON_UNRECOVERABLE_EXCEPTIONS)
507+
/* Signals an unhandled double exception, and unrecoverable exceptions.
508+
* Definitely needs debugger to be attached to the hardware or simulator
509+
* to catch this.
510+
*/
511+
break 1, 4
512+
#elif defined(CONFIG_SIMULATOR_XTENSA) || defined(XT_SIMULATOR)
508513
/* Tell simulator to stop executing here, instead of trying to do
509514
* an infinite loop (see below). Greatly help with using tracing in
510515
* simulator so that traces will not have infinite iterations of
@@ -513,12 +518,8 @@ _DoubleExceptionVector:
513518
movi a3, 1
514519
movi a2, SYS_exit
515520
simcall
516-
#elif XCHAL_HAVE_DEBUG
517-
/* Signals an unhandled double exception */
518-
1: break 1, 4
519-
#else
520-
1:
521521
#endif
522+
1:
522523
j 1b
523524
#endif /* CONFIG_XTENSA_MMU */
524525

0 commit comments

Comments
 (0)