target/xtensa: use generic instruction breakpoint infrastructure
cover target/xtensa: use generic instruction breakpoint infrastructure
Hello,
this series makes target/xtensa use generic instruction breakpoint infrastructure removing its use of tb_invalidate_phys_addr. It also adds a new TCG test checking relative priority of icount and ibreak exceptions for target/xtensa.
Max Filippov (2):
target/xtensa: use generic instruction breakpoint infrastructure tests/tcg/xtensa: add icount/ibreak priority test
target/xtensa/cpu.c | 1 + target/xtensa/cpu.h | 4 +++ target/xtensa/dbg_helper.c | 46 +++++++++++++++++++++++------------ target/xtensa/helper.c | 12 +++++++++ target/xtensa/translate.c | 17 ------------- tests/tcg/xtensa/test_break.S | 25 ++++++++++++++++++- 6 files changed, 71 insertions(+), 34 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/2 target/xtensa: use generic instruction breakpoint infrastructure
Don't embed ibreak exception generation into TB and don't invalidate TB on ibreak address change. Add CPUBreakpoint pointers to xtensa CPUArchState, use cpu_breakpoint_insert/cpu_breakpoint_remove_by_ref to manage ibreak breakpoints and provide TCGCPUOps::debug_check_breakpoint callback that recognizes valid instruction breakpoints.
--- target/xtensa/cpu.c | 1 + target/xtensa/cpu.h | 4 ++++ target/xtensa/dbg_helper.c | 46 +++++++++++++++++++++++++------------- target/xtensa/helper.c | 12 ++++++++++ target/xtensa/translate.c | 17 -------------- 5 files changed, 47 insertions(+), 33 deletions(-)
target/xtensa/cpu.c +1 -0
@@ -235,6 +235,7 @@ static const struct TCGCPUOps xtensa_tcg_ops = { .do_interrupt = xtensa_cpu_do_interrupt, .do_transaction_failed = xtensa_cpu_do_transaction_failed, .do_unaligned_access = xtensa_cpu_do_unaligned_access, + .debug_check_breakpoint = xtensa_debug_check_breakpoint,#endif /* !CONFIG_USER_ONLY */ };
target/xtensa/cpu.h +4 -0
@@ -229,6 +229,7 @@ enum {#define MAX_NCCOMPARE 3#define MAX_TLB_WAY_SIZE 8#define MAX_NDBREAK 2 +#define MAX_NIBREAK 2#define MAX_NMEMORY 4#define MAX_MPU_FOREGROUND_SEGMENTS 32
@@ -547,6 +548,8 @@ struct CPUArchState {/* Watchpoints for DBREAK registers */ struct CPUWatchpoint *cpu_watchpoint[MAX_NDBREAK ]; +/* Breakpoints for IBREAK registers */ +struct CPUBreakpoint *cpu_breakpoint[MAX_NIBREAK ]; };/**
@@ -590,6 +593,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t retaddr);hwaddr xtensa_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); +bool xtensa_debug_check_breakpoint (CPUState *cs);#endif void xtensa_cpu_dump_state (CPUState *cpu,FILE *f,int flags); void xtensa_count_regs(const XtensaConfig *config,
target/xtensa/dbg_helper.c +30 -16
69 lines not on this page · raw message
target/xtensa/helper.c +12 -0
@@ -231,6 +231,18 @@ void xtensa_breakpoint_handler(CPUState *cs) }cpu_loop_exit_noexc (cs); } + }else { +if (cpu_breakpoint_test (cs, env->pc,BP_GDB ) + || !cpu_breakpoint_test (cs, env->pc,BP_CPU )) { +return ; + } +if (env->sregs[ICOUNT ] ==0xffffffff && +xtensa_get_cintlevel (env) < env->sregs[ICOUNTLEVEL ]) { +debug_exception_env (env,DEBUGCAUSE_IC ); + }else { +debug_exception_env (env,DEBUGCAUSE_IB ); + } +cpu_loop_exit_noexc (cs); } }
target/xtensa/translate.c +0 -17
@@ -1123,19 +1123,6 @@ static inline unsigned xtensa_insn_len(CPUXtensaState *env, DisasContext *dc)return xtensa_op0_insn_len (dc, b0); } -static void gen_ibreak_check (CPUXtensaState *env,DisasContext *dc) -{ -unsigned i; - -for (i =0 ; i < dc->config->nibreak; ++i) { -if ((env->sregs[IBREAKENABLE ] & (1 << i)) && - env->sregs[IBREAKA + i] == dc->pc) { -gen_debug_exception (dc,DEBUGCAUSE_IB ); -break ; - } - } -} -static void xtensa_tr_init_disas_context (DisasContextBase *dcbase,CPUState *cpu) {
@@ -1205,10 +1192,6 @@ static void xtensa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)gen_set_label (label); } -if (dc->debug) { -gen_ibreak_check (env, dc); - } -disas_xtensa_insn (env, dc);if (dc->icount) {
Signature · 1 line
2.39.2
Quoted 6 lines · Max Filippov
Don't embed ibreak exception generation into TB and don't invalidate TB on ibreak address change. Add CPUBreakpoint pointers to xtensa CPUArchState, use cpu_breakpoint_insert/cpu_breakpoint_remove_by_ref to manage ibreak breakpoints and provide
TCGCPUOps::debug_check_breakpointcallback that recognizes valid instruction breakpoints.
Quoted 8 lines
Signed-off-by Max Filippov <[email protected]>--- target/xtensa/cpu.c | 1 + target/xtensa/cpu.h | 4 ++++ target/xtensa/dbg_helper.c | 46 +++++++++++++++++++++++++------------- target/xtensa/helper.c | 12 ++++++++++ target/xtensa/translate.c | 17 -------------- 5 files changed, 47 insertions(+), 33 deletions(-)
Thanks a bunch,
r~
PATCH 2/2 tests/tcg/xtensa: add icount/ibreak priority test
In reply to Max FilippovWhen icount and ibreak exceptions are due to happen on the same address icount has higher precedence.
--- tests/tcg/xtensa/test_break.S | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
tests/tcg/xtensa/test_break.S +24 -1
@@ -129,7 +129,7 @@ test ibreak_remove 4: test_end -test ibreak_priority +test ibreak_break_priority set_vector debug_vector, 2f rsil a2, debug_level - 1 movi a2, 1f
@@ -145,6 +145,29 @@ test ibreak_priority movi a3, 0x2 assert eq, a2, a3 test_end + +test ibreak_icount_priority + set_vector debug_vector, 2f + rsil a2, debug_level - 1 + movi a2, 1f + wsr a2, ibreaka0 + movi a2, 1 + wsr a2, ibreakenable + movi a2, -2 + wsr a2, icount + movi a2, 1 + wsr a2, icountlevel + isync + rsil a2, 0 + nop +1: + break 0, 0 + test_fail +2: + rsr a2, debugcause + movi a3, 0x1 + assert eq, a2, a3 +test_end #endif test icount
Signature · 1 line
2.39.2
Re: [PATCH 2/2] tests/tcg/xtensa: add icount/ibreak priority test
Quoted 7 lines · Max Filippov
When icount and ibreak exceptions are due to happen on the same address icount has higher precedence.
Signed-off-by Max Filippov <[email protected]>--- tests/tcg/xtensa/test_break.S | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
r~
Quoted 10 lines · Max Filippov
Hello,
this series makes target/xtensa use generic instruction breakpoint infrastructure removing its use of
tb_invalidate_phys_addr. It also adds a new TCG test checking relative priority of icount and ibreak exceptions for target/xtensa.Max Filippov (2):
target/xtensa: use generic instruction breakpoint infrastructure tests/tcg/xtensa: add icount/ibreak priority test
Thanks Max, series queued.