Add an identifier for use by targets with BP_CPU. For most targets the index of the hardware breakpoint resource is to hand. For s390x, there is only one resource so use id 0.
Signed-off-by: Richard Henderson <[email protected]> --- include/exec/breakpoint.h | 4 +++- accel/tcg/tcg-accel-ops.c | 2 +- accel/tcg/user-exec-stub.c | 3 ++- system/watchpoint.c | 3 ++- target/arm/tcg/debug.c | 2 +- target/i386/tcg/system/bpt_helper.c | 4 ++-- target/ppc/cpu.c | 3 ++- target/riscv/debug.c | 8 ++++---- target/s390x/tcg/debug.c | 11 +++++------ target/xtensa/dbg_helper.c | 2 +- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/include/exec/breakpoint.h b/include/exec/breakpoint.h index 588ff13fe1..6da8a007df 100644 --- a/include/exec/breakpoint.h +++ b/include/exec/breakpoint.h @@ -41,6 +41,7 @@ struct CPUWatchpoint { vaddr hitaddr; MemTxAttrs hitattrs; int flags; /* BP_* */ + unsigned id; QTAILQ_ENTRY(CPUWatchpoint) entry; }; @@ -52,7 +53,8 @@ void cpu_breakpoint_remove_all(CPUState *cpu, BreakpointFlags mask); bool cpu_breakpoint_test(CPUState *cpu, vaddr pc, BreakpointFlags mask); int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, - BreakpointFlags flags, CPUWatchpoint **watchpoint); + BreakpointFlags flags, unsigned id, + CPUWatchpoint **watchpoint); int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, vaddr len, BreakpointFlags flags); void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint); diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 88d0c093eb..afac859b8d 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -148,7 +148,7 @@ static int tcg_insert_gdbstub_breakpoint(CPUState *cs, GdbBreakpointType type, case GDB_WATCHPOINT_ACCESS: CPU_FOREACH(cpu) { err = cpu_watchpoint_insert(cpu, addr, len, - xlat_gdb_type(cpu, type), NULL); + xlat_gdb_type(cpu, type), 0, NULL); if (err) { break; } diff --git a/accel/tcg/user-exec-stub.c b/accel/tcg/user-exec-stub.c index 973bdbcd7a..42e4861868 100644 --- a/accel/tcg/user-exec-stub.c +++ b/accel/tcg/user-exec-stub.c @@ -22,7 +22,8 @@ void cpu_exec_reset_hold(CPUState *cpu) } int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, - BreakpointFlags flags, CPUWatchpoint **watchpoint) + BreakpointFlags flags, unsigned id, + CPUWatchpoint **watchpoint) { return -ENOSYS; } diff --git a/system/watchpoint.c b/system/watchpoint.c index 67e4560e78..a618bb5acd 100644 --- a/system/watchpoint.c +++ b/system/watchpoint.c @@ -26,7 +26,8 @@ /* Add a watchpoint. */ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, - BreakpointFlags flags, CPUWatchpoint **watchpoint) + BreakpointFlags flags, unsigned id, + CPUWatchpoint **watchpoint) { CPUWatchpoint *wp; vaddr in_page; diff --git a/target/arm/tcg/debug.c b/target/arm/tcg/debug.c index 73d694ca4f..50b90ad675 100644 --- a/target/arm/tcg/debug.c +++ b/target/arm/tcg/debug.c @@ -622,7 +622,7 @@ void hw_watchpoint_update(ARMCPU *cpu, int n) wvr += basstart; } - cpu_watchpoint_insert(CPU(cpu), wvr, len, flags, + cpu_watchpoint_insert(CPU(cpu), wvr, len, flags, n, &env->cpu_watchpoint[n]); } diff --git a/target/i386/tcg/system/bpt_helper.c b/target/i386/tcg/system/bpt_helper.c index d847d77d71..662ffbacfc 100644 --- a/target/i386/tcg/system/bpt_helper.c +++ b/target/i386/tcg/system/bpt_helper.c @@ -76,7 +76,7 @@ static int hw_breakpoint_insert(CPUX86State *env, int index) if (hw_breakpoint_enabled(dr7, index)) { err = cpu_watchpoint_insert(cs, drN, hw_breakpoint_len(dr7, index), - BP_CPU | BP_MEM_WRITE, + BP_CPU | BP_MEM_WRITE, index, &env->cpu_watchpoint[index]); } break; @@ -85,7 +85,7 @@ static int hw_breakpoint_insert(CPUX86State *env, int index) if (hw_breakpoint_enabled(dr7, index)) { err = cpu_watchpoint_insert(cs, drN, hw_breakpoint_len(dr7, index), - BP_CPU | BP_MEM_ACCESS, + BP_CPU | BP_MEM_ACCESS, index, &env->cpu_watchpoint[index]); } break; diff --git a/target/ppc/cpu.c b/target/ppc/cpu.c index 020c8126b3..581fa6a575 100644 --- a/target/ppc/cpu.c +++ b/target/ppc/cpu.c @@ -171,7 +171,8 @@ void ppc_update_daw(CPUPPCState *env, int rid) flags |= BP_MEM_WRITE; } - cpu_watchpoint_insert(cs, deaw, len, flags, &env->dawr_watchpoint[rid]); + cpu_watchpoint_insert(cs, deaw, len, flags, rid, + &env->dawr_watchpoint[rid]); } void ppc_store_dawr0(CPUPPCState *env, target_ulong val) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index bf9accf6e8..1b88cd136c 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -501,12 +501,12 @@ static void type2_breakpoint_insert(CPURISCVState *env, target_ulong index) if (flags & BP_MEM_ACCESS) { size = type2_breakpoint_size(env, ctrl); if (size != 0) { - cpu_watchpoint_insert(cs, addr, size, flags, + cpu_watchpoint_insert(cs, addr, size, flags, index, &env->cpu_watchpoint[index]); } else { def_size = riscv_cpu_mxl(env) == MXL_RV64 ? 8 : 4; - cpu_watchpoint_insert(cs, addr, def_size, flags, + cpu_watchpoint_insert(cs, addr, def_size, flags, index, &env->cpu_watchpoint[index]); } } @@ -628,10 +628,10 @@ static void type6_breakpoint_insert(CPURISCVState *env, target_ulong index) if (flags & BP_MEM_ACCESS) { size = extract32(ctrl, 16, 4); if (size != 0) { - cpu_watchpoint_insert(cs, addr, size, flags, + cpu_watchpoint_insert(cs, addr, size, flags, index, &env->cpu_watchpoint[index]); } else { - cpu_watchpoint_insert(cs, addr, 8, flags, + cpu_watchpoint_insert(cs, addr, 8, flags, index, &env->cpu_watchpoint[index]); } } diff --git a/target/s390x/tcg/debug.c b/target/s390x/tcg/debug.c index 7a838775ec..25968d9a3c 100644 --- a/target/s390x/tcg/debug.c +++ b/target/s390x/tcg/debug.c @@ -34,19 +34,18 @@ void s390_cpu_recompute_watchpoints(CPUState *cs) if (env->cregs[10] == 0 && env->cregs[11] == -1LL) { /* We can't create a watchoint spanning the whole memory range, so split it in two parts. */ - cpu_watchpoint_insert(cs, 0, 1ULL << 63, wp_flags, NULL); - cpu_watchpoint_insert(cs, 1ULL << 63, 1ULL << 63, wp_flags, NULL); + cpu_watchpoint_insert(cs, 0, 1ULL << 63, wp_flags, 0, NULL); + cpu_watchpoint_insert(cs, 1ULL << 63, 1ULL << 63, wp_flags, 0, NULL); } else if (env->cregs[10] > env->cregs[11]) { /* The address range loops, create two watchpoints. */ cpu_watchpoint_insert(cs, env->cregs[10], -env->cregs[10], - wp_flags, NULL); - cpu_watchpoint_insert(cs, 0, env->cregs[11] + 1, wp_flags, NULL); - + wp_flags, 0, NULL); + cpu_watchpoint_insert(cs, 0, env->cregs[11] + 1, wp_flags, 0, NULL); } else { /* Default case, create a single watchpoint. */ cpu_watchpoint_insert(cs, env->cregs[10], env->cregs[11] - env->cregs[10] + 1, - wp_flags, NULL); + wp_flags, 0, NULL); } } diff --git a/target/xtensa/dbg_helper.c b/target/xtensa/dbg_helper.c index 4cf147bbfb..20ddc527f8 100644 --- a/target/xtensa/dbg_helper.c +++ b/target/xtensa/dbg_helper.c @@ -105,7 +105,7 @@ static void set_dbreak(CPUXtensaState *env, unsigned i, uint32_t dbreaka, mask = 0xffffffff << (32 - clo32(mask)); } if (cpu_watchpoint_insert(cs, dbreaka & mask, ~mask + 1, - flags, &env->cpu_watchpoint[i])) { + flags, i, &env->cpu_watchpoint[i])) { env->cpu_watchpoint[i] = NULL; qemu_log_mask(LOG_GUEST_ERROR, "Failed to set data breakpoint at 0x%08x/%d\n", -- 2.43.0
