[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/84] softmmu: Check watchpoints for read+write at once
From: |
Richard Henderson |
Subject: |
[PULL 07/84] softmmu: Check watchpoints for read+write at once |
Date: |
Sun, 5 Mar 2023 16:38:37 -0800 |
Atomic operations are read-modify-write, and we'd like to
be able to test both read and write with one call. This is
easy enough, with BP_MEM_READ | BP_MEM_WRITE.
Add BP_HIT_SHIFT to make it easy to set BP_WATCHPOINT_HIT_*.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/hw/core/cpu.h | 7 ++++---
softmmu/watchpoint.c | 19 ++++++++++---------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index fb5d9667ca..75689bff02 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -923,9 +923,10 @@ void cpu_single_step(CPUState *cpu, int enabled);
#define BP_GDB 0x10
#define BP_CPU 0x20
#define BP_ANY (BP_GDB | BP_CPU)
-#define BP_WATCHPOINT_HIT_READ 0x40
-#define BP_WATCHPOINT_HIT_WRITE 0x80
-#define BP_WATCHPOINT_HIT (BP_WATCHPOINT_HIT_READ | BP_WATCHPOINT_HIT_WRITE)
+#define BP_HIT_SHIFT 6
+#define BP_WATCHPOINT_HIT_READ (BP_MEM_READ << BP_HIT_SHIFT)
+#define BP_WATCHPOINT_HIT_WRITE (BP_MEM_WRITE << BP_HIT_SHIFT)
+#define BP_WATCHPOINT_HIT (BP_MEM_ACCESS << BP_HIT_SHIFT)
int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
CPUBreakpoint **breakpoint);
diff --git a/softmmu/watchpoint.c b/softmmu/watchpoint.c
index 279129dd1c..ad58736787 100644
--- a/softmmu/watchpoint.c
+++ b/softmmu/watchpoint.c
@@ -162,9 +162,12 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr
len,
/* this is currently used only by ARM BE32 */
addr = cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len);
}
+
+ assert((flags & ~BP_MEM_ACCESS) == 0);
QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
- if (watchpoint_address_matches(wp, addr, len)
- && (wp->flags & flags)) {
+ int hit_flags = wp->flags & flags;
+
+ if (hit_flags && watchpoint_address_matches(wp, addr, len)) {
if (replay_running_debug()) {
/*
* replay_breakpoint reads icount.
@@ -184,16 +187,14 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr,
vaddr len,
replay_breakpoint();
return;
}
- if (flags == BP_MEM_READ) {
- wp->flags |= BP_WATCHPOINT_HIT_READ;
- } else {
- wp->flags |= BP_WATCHPOINT_HIT_WRITE;
- }
+
+ wp->flags |= hit_flags << BP_HIT_SHIFT;
wp->hitaddr = MAX(addr, wp->vaddr);
wp->hitattrs = attrs;
- if (wp->flags & BP_CPU && cc->tcg_ops->debug_check_watchpoint &&
- !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) {
+ if (wp->flags & BP_CPU
+ && cc->tcg_ops->debug_check_watchpoint
+ && !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) {
wp->flags &= ~BP_WATCHPOINT_HIT;
continue;
}
--
2.34.1
- [PULL 03/84] tcg: Merge two sequential labels, (continued)
- [PULL 03/84] tcg: Merge two sequential labels, Richard Henderson, 2023/03/05
- [PULL 06/84] accel/tcg: Honor TLB_DISCARD_WRITE in atomic_mmu_lookup, Richard Henderson, 2023/03/05
- [PULL 08/84] accel/tcg: Trigger watchpoints from atomic_mmu_lookup, Richard Henderson, 2023/03/05
- [PULL 18/84] target/arm: Drop DisasContext.tmp_a64, Richard Henderson, 2023/03/05
- [PULL 17/84] target/arm: Drop tcg_temp_free from translator.c, Richard Henderson, 2023/03/05
- [PULL 09/84] include/qemu/cpuid: Introduce xgetbv_low, Richard Henderson, 2023/03/05
- [PULL 16/84] target/arm: Remove value_global from DisasCompare, Richard Henderson, 2023/03/05
- [PULL 30/84] target/avr: Drop R from trans_COM, Richard Henderson, 2023/03/05
- [PULL 13/84] accel/tcg: Remove translator_loop_temp_check, Richard Henderson, 2023/03/05
- [PULL 04/84] target/sparc: Use tlb_set_page_full, Richard Henderson, 2023/03/05
- [PULL 07/84] softmmu: Check watchpoints for read+write at once,
Richard Henderson <=
- [PULL 10/84] tcg/i386: Mark Win64 call-saved vector regs as reserved, Richard Henderson, 2023/03/05
- [PULL 11/84] tcg: Decode the operand to INDEX_op_mb in dumps, Richard Henderson, 2023/03/05
- [PULL 14/84] target/alpha: Drop tcg_temp_free, Richard Henderson, 2023/03/05
- [PULL 19/84] target/arm: Drop new_tmp_a64, Richard Henderson, 2023/03/05
- [PULL 22/84] target/arm: Drop tcg_temp_free from translator-m-nocp.c, Richard Henderson, 2023/03/05
- [PULL 25/84] target/arm: Drop tcg_temp_free from translator-sme.c, Richard Henderson, 2023/03/05
- [PULL 26/84] target/arm: Drop tcg_temp_free from translator-sve.c, Richard Henderson, 2023/03/05
- [PULL 24/84] target/arm: Drop tcg_temp_free from translator-neon.c, Richard Henderson, 2023/03/05
- [PULL 27/84] target/arm: Drop tcg_temp_free from translator-vfp.c, Richard Henderson, 2023/03/05
- [PULL 29/84] target/avr: Drop DisasContext.free_skip_var0, Richard Henderson, 2023/03/05