Skip to contentSkip to conversation

target/hexagon: implement SSR.SS single-step

PATCH In review Brian Cain 2 participants 2 messages Oct 15

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

PATCH 1/1 target/hexagon: implement SSR.SS single-step

SSR.SS enables a single-step debug event after each packet executed in user or guest mode.

Carry the state in a new SS_ACTIVE TB flag. When it is set, translate one packet per TB and raise HEX_EVENT_DEBUG w/PC at the next packet (which becomes ELR).

---
 target/hexagon/cpu.h                      |  1 +
 target/hexagon/translate.h                |  1 +
 target/hexagon/cpu.c                      |  4 ++
 target/hexagon/hexswi.c                   |  1 -
 target/hexagon/translate.c                | 49 +++++++++++++++++++++++
 tests/functional/hexagon/test_systests.py |  3 ++
 6 files changed, 58 insertions(+), 1 deletion(-)
target/hexagon/cpu.h +1 -0
index 65fd2b29830..9feaaf790da 100644
@@ -228,6 +228,7 @@ FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1)
 FIELD(TB_FLAGS, MMU_INDEX, 1, 3)
 FIELD(TB_FLAGS, PCYCLE_ENABLED, 4, 1)
 FIELD(TB_FLAGS, HVX_COPROC_ENABLED, 5, 1)
+FIELD(TB_FLAGS, SS_ACTIVE, 6, 1)
 
 G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env,
                                             uint32_t exception,
target/hexagon/translate.h +1 -0
index 2d1ed5208b7..0e5419899fb 100644
@@ -45,6 +45,7 @@ typedef struct DisasContext {
     DECLARE_BITMAP(gpr_uncond, TOTAL_PER_THREAD_REGS);
     bool implicit_usr_write;
 #ifndef CONFIG_USER_ONLY
+    bool ss_active;
     int greg_log[GREG_WRITES_MAX];
     int greg_log_idx;
     DECLARE_BITMAP(gregs_written, NUM_GREGS);
target/hexagon/cpu.c +4 -0
index 6550e7fa800..9a25ed2d655 100644
@@ -353,6 +353,10 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs)
     hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, HVX_COPROC_ENABLED,
                            cpu->hvx_ctx[0] &&
                            GET_SSR_FIELD(SSR_XE, env->t_sreg[HEX_SREG_SSR]));
+    /* Single-step applies only to user and guest mode packets */
+    hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, SS_ACTIVE,
+                           GET_SSR_FIELD(SSR_SS, env->t_sreg[HEX_SREG_SSR]) &&
+                           get_cpu_mode(env) != HEX_CPU_MODE_MONITOR);
 #else
     hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, MMU_INDEX, MMU_USER_IDX);
 #endif
target/hexagon/hexswi.c +0 -1
index ef1d558dfc4..c4ea249155b 100644
@@ -868,7 +868,6 @@ void hexagon_cpu_do_interrupt(CPUState *cs)
     case HEX_EVENT_DEBUG:
         hexagon_ssr_set_cause(env, env->cause_code);
         set_addresses(env, 0, cs->exception_index);
-        qemu_log_mask(LOG_UNIMP, "single-step exception is not handled\n");
         break;
 
     case HEX_EVENT_PRECISE:
target/hexagon/translate.c +49 -0

71 lines not on this page · raw message

tests/functional/hexagon/test_systests.py +3 -0
index 20c58f84f67..4c822f9addc 100755
@@ -108,5 +108,8 @@ def test_hvx_multi(self):
     def test_standalone_vec(self):
         self.run_exit_zero("standalone_vec")
 
+    def test_single_step(self):
+        self.run_exit_zero("single_step")
+
 if __name__ == "__main__":
     QemuSystemTest.main()
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Brian Cain

SSR.SS enables a single-step debug event after each packet executed in user or guest mode.

Carry the state in a new SS_ACTIVE TB flag. When it is set, translate one packet per TB and raise HEX_EVENT_DEBUG w/PC at the next packet (which becomes ELR).

Quoted 9 lines
---
 target/hexagon/cpu.h                      |  1 +
 target/hexagon/translate.h                |  1 +
 target/hexagon/cpu.c                      |  4 ++
 target/hexagon/hexswi.c                   |  1 -
 target/hexagon/translate.c                | 49 +++++++++++++++++++++++
 tests/functional/hexagon/test_systests.py |  3 ++
 6 files changed, 58 insertions(+), 1 deletion(-)