Skip to content

Commit

Permalink
xtensa: only use BREAK if explicitly enabled
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dcpleung authored and nashif committed Jun 15, 2024
1 parent bc3e77b commit 27f4e7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 7 additions & 0 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ config XTENSA_NUM_SPIN_RELAX_NOPS
Specify the number of NOPs in Xtensa specific
arch_spin_relax().

config XTENSA_BREAK_ON_UNRECOVERABLE_EXCEPTIONS
bool "Use BREAK instruction on unrecoverable exceptions"
help
Use BREAK instruction when unrecoverable exceptions are
encountered. This requires a debugger attached to catch
the BREAK.

menu "Xtensa HiFi Options"

config XTENSA_CPU_HAS_HIFI
Expand Down
15 changes: 8 additions & 7 deletions arch/xtensa/core/xtensa_asm2_util.S
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,13 @@ _DoubleExceptionVector:
j _Level1Vector
#else

#if defined(CONFIG_SIMULATOR_XTENSA) || defined(XT_SIMULATOR)
1:
#if XCHAL_HAVE_DEBUG && defined(CONFIG_XTENSA_BREAK_ON_UNRECOVERABLE_EXCEPTIONS)
/* Signals an unhandled double exception, and unrecoverable exceptions.
* Definitely needs debugger to be attached to the hardware or simulator
* to catch this.
*/
break 1, 4
#elif defined(CONFIG_SIMULATOR_XTENSA) || defined(XT_SIMULATOR)
/* Tell simulator to stop executing here, instead of trying to do
* an infinite loop (see below). Greatly help with using tracing in
* simulator so that traces will not have infinite iterations of
Expand All @@ -513,12 +518,8 @@ _DoubleExceptionVector:
movi a3, 1
movi a2, SYS_exit
simcall
#elif XCHAL_HAVE_DEBUG
/* Signals an unhandled double exception */
1: break 1, 4
#else
1:
#endif
1:
j 1b
#endif /* CONFIG_XTENSA_MMU */

Expand Down

0 comments on commit 27f4e7f

Please sign in to comment.