Skip to content

Commit b696257

Browse files
dcpleungnashif
authored andcommitted
xtensa: fix getting exccause during backtrace
We have frame pointer struct and BSA struct to extract the exception cause (exccause). There is no need to resort to custom assembly to do that. Besides, given that the BSA is different between different Xtensa cores, there is no guarantee it is at the same place as what the assembly assumes. So just do that without assembly. Signed-off-by: Daniel Leung <[email protected]>
1 parent 682b572 commit b696257

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

arch/xtensa/core/xtensa_backtrace.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#elif defined(CONFIG_SOC_XTENSA_DC233C)
1515
#include "backtrace_helpers.h"
1616
#endif
17+
18+
#include <xtensa_asm2_context.h>
19+
1720
static int mask, cause;
1821

1922
static inline uint32_t xtensa_cpu_process_stack_pc(uint32_t pc)
@@ -91,14 +94,18 @@ int xtensa_backtrace_print(int depth, int *interrupted_stack)
9194
return -1;
9295
}
9396

97+
_xtensa_irq_stack_frame_raw_t *frame = (void *)interrupted_stack;
98+
_xtensa_irq_bsa_t *bsa;
99+
100+
bsa = frame->ptr_to_bsa;
101+
cause = bsa->exccause;
102+
94103
/* Initialize stk_frame with first frame of stack */
95104
struct xtensa_backtrace_frame_t stk_frame;
96105

97106
xtensa_backtrace_get_start(&(stk_frame.pc), &(stk_frame.sp),
98107
&(stk_frame.next_pc), interrupted_stack);
99-
__asm__ volatile("l32i a4, a3, 0");
100-
__asm__ volatile("l32i a4, a4, 4");
101-
__asm__ volatile("mov %0, a4" : "=r"(cause));
108+
102109
if (cause != EXCCAUSE_INSTR_PROHIBITED) {
103110
mask = stk_frame.pc & 0xc0000000;
104111
}

0 commit comments

Comments
 (0)