target/riscv: set tval for triggered watchpoints
PATCH v2 1/1 target/riscv: set tval for triggered watchpoints
From: Sergey Matyukevich <[email protected]>
According to priviledged spec, if [sm]tval is written with a nonzero value when a breakpoint exception occurs, then [sm]tval will contain the faulting virtual address. Set tval to hit address when breakpoint exception is triggered by hardware watchpoint.
---
v1 -> v2
- do not set tval blindly for every breakpoint exception, handle current specific case under consideration
target/riscv/cpu_helper.c | 6 ++++++ target/riscv/debug.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-)
target/riscv/cpu_helper.c +6 -0
@@ -1641,6 +1641,12 @@ void riscv_cpu_do_interrupt(CPUState *cs)case RISCV_EXCP_VIRT_INSTRUCTION_FAULT : tval = env->bins;break ; +case RISCV_EXCP_BREAKPOINT : +if (cs->watchpoint_hit) { + tval = cs->watchpoint_hit->hitaddr; + cs->watchpoint_hit =NULL ; + } +break ;default :break ; }
target/riscv/debug.c +0 -1
@@ -761,7 +761,6 @@ void riscv_cpu_debug_excp_handler(CPUState *cs)if (cs->watchpoint_hit) {if (cs->watchpoint_hit->flags &BP_CPU ) { - cs->watchpoint_hit =NULL ;do_trigger_action (env,DBG_ACTION_BP ); } }else {
Signature · 1 line
2.39.0
Quoted 4 lines · Sergey Matyukevich
From: Sergey Matyukevich <[email protected]>
According to priviledged spec, if [sm]tval is written with a nonzero
typo: privileged
Quoted 8 lines
value when a breakpoint exception occurs, then [sm]tval will contain the faulting virtual address. Set tval to hit address when breakpoint exception is triggered by hardware watchpoint.
Signed-off-by Sergey Matyukevich <[email protected]>---
Quoted 8 lines
v1 -> v2
- do not set tval blindly for every breakpoint exception, handle current specific case under considerationtarget/riscv/cpu_helper.c | 6 ++++++ target/riscv/debug.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-)
Quoted 9 lines · Sergey Matyukevich
From: Sergey Matyukevich <[email protected]>
According to priviledged spec, if [sm]tval is written with a nonzero value when a breakpoint exception occurs, then [sm]tval will contain the faulting virtual address. Set tval to hit address when breakpoint exception is triggered by hardware watchpoint.
Signed-off-by Sergey Matyukevich <[email protected]>
Alistair
Quoted 44 lines
---
v1 -> v2
- do not set tval blindly for every breakpoint exception, handle current specific case under considerationtarget/riscv/cpu_helper.c | 6 ++++++ target/riscv/debug.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-)target/riscv/cpu_helper.c +6
-0@@ -1641,6 +1641,12 @@ void riscv_cpu_do_interrupt(CPUState *cs)case RISCV_EXCP_VIRT_INSTRUCTION_FAULT : tval = env->bins;break ; +case RISCV_EXCP_BREAKPOINT : +if (cs->watchpoint_hit) { + tval = cs->watchpoint_hit->hitaddr; + cs->watchpoint_hit =NULL ; + } +break ;default :break ; }target/riscv/debug.c +0
-2@@ -761,7 +761,6 @@ void riscv_cpu_debug_excp_handler(CPUState *cs)if (cs->watchpoint_hit) {if (cs->watchpoint_hit->flags &BP_CPU ) { - cs->watchpoint_hit =NULL ;do_trigger_action (env,DBG_ACTION_BP ); } }else { --2.39.0
Alistair Francis
AppliedQuoted 9 lines · Sergey Matyukevich
From: Sergey Matyukevich <[email protected]>
According to priviledged spec, if [sm]tval is written with a nonzero value when a breakpoint exception occurs, then [sm]tval will contain the faulting virtual address. Set tval to hit address when breakpoint exception is triggered by hardware watchpoint.
Signed-off-by Sergey Matyukevich <[email protected]>
Thanks!
Applied to riscv-to-apply.next with the typo fixed
Alistair
Quoted 44 lines
---
v1 -> v2
- do not set tval blindly for every breakpoint exception, handle current specific case under considerationtarget/riscv/cpu_helper.c | 6 ++++++ target/riscv/debug.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-)target/riscv/cpu_helper.c +6
-0@@ -1641,6 +1641,12 @@ void riscv_cpu_do_interrupt(CPUState *cs)case RISCV_EXCP_VIRT_INSTRUCTION_FAULT : tval = env->bins;break ; +case RISCV_EXCP_BREAKPOINT : +if (cs->watchpoint_hit) { + tval = cs->watchpoint_hit->hitaddr; + cs->watchpoint_hit =NULL ; + } +break ;default :break ; }target/riscv/debug.c +0
-2@@ -761,7 +761,6 @@ void riscv_cpu_debug_excp_handler(CPUState *cs)if (cs->watchpoint_hit) {if (cs->watchpoint_hit->flags &BP_CPU ) { - cs->watchpoint_hit =NULL ;do_trigger_action (env,DBG_ACTION_BP ); } }else { --2.39.0