From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbRM0-0004t3-00 for qemu-devel@nongnu.org; Mon, 14 Sep 2015 06:51:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbRLy-00022z-Un for qemu-devel@nongnu.org; Mon, 14 Sep 2015 06:51:19 -0400 Received: from mail-lb0-x233.google.com ([2a00:1450:4010:c04::233]:33579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbRLy-00022q-OG for qemu-devel@nongnu.org; Mon, 14 Sep 2015 06:51:18 -0400 Received: by lbcjc2 with SMTP id jc2so65038454lbc.0 for ; Mon, 14 Sep 2015 03:51:18 -0700 (PDT) From: Sergey Fedorov Date: Mon, 14 Sep 2015 13:50:51 +0300 Message-Id: <1442227851-11414-3-git-send-email-serge.fdrv@gmail.com> In-Reply-To: <1442227851-11414-1-git-send-email-serge.fdrv@gmail.com> References: <1442227851-11414-1-git-send-email-serge.fdrv@gmail.com> Subject: [Qemu-devel] [PATCH 2/2] target-arm: Implement checking of fired watchpoint List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Sergey Fedorov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Paolo Bonzini ARM stops before access to a location covered by watchpoint. Also, QEMU watchpoint fire is not necessarily an architectural watchpoint match. Unfortunately, that is hardly possible to ignore a fired watchpoint in debug exception handler. So move watchpoint check from debug exception handler to the dedicated watchpoint checking callback. Signed-off-by: Sergey Fedorov --- target-arm/cpu.c | 1 + target-arm/internals.h | 3 +++ target-arm/op_helper.c | 35 +++++++++++++++++++++-------------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index cc6c6f3..69dd158 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -1428,6 +1428,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_core_xml_file = "arm-core.xml"; cc->gdb_stop_before_watchpoint = true; cc->debug_excp_handler = arm_debug_excp_handler; + cc->debug_check_watchpoint = arm_debug_check_watchpoint; cc->disas_set_info = arm_disas_set_info; } diff --git a/target-arm/internals.h b/target-arm/internals.h index 924aff9..251d5f6 100644 --- a/target-arm/internals.h +++ b/target-arm/internals.h @@ -372,6 +372,9 @@ void hw_breakpoint_update(ARMCPU *cpu, int n); */ void hw_breakpoint_update_all(ARMCPU *cpu); +/* Callback function for checking if a watchpoint should trigger. */ +bool arm_debug_check_watchpoint(CPUState *cs); + /* Callback function for when a watchpoint or breakpoint triggers. */ void arm_debug_excp_handler(CPUState *cs); diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 1425a1d..b298e57 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -867,6 +867,16 @@ static bool check_breakpoints(ARMCPU *cpu) return false; } +bool arm_debug_check_watchpoint(CPUState *cs) +{ + /* Called by core code when a CPU watchpoint fires; need to check if this + * is also an architectural watchpoint match. + */ + ARMCPU *cpu = ARM_CPU(cs); + + return check_watchpoints(cpu); +} + void arm_debug_excp_handler(CPUState *cs) { /* Called by core code when a watchpoint or breakpoint fires; @@ -878,23 +888,20 @@ void arm_debug_excp_handler(CPUState *cs) if (wp_hit) { if (wp_hit->flags & BP_CPU) { + bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0; + bool same_el = arm_debug_target_el(env) == arm_current_el(env); + cs->watchpoint_hit = NULL; - if (check_watchpoints(cpu)) { - bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0; - bool same_el = arm_debug_target_el(env) == arm_current_el(env); - - if (extended_addresses_enabled(env)) { - env->exception.fsr = (1 << 9) | 0x22; - } else { - env->exception.fsr = 0x2; - } - env->exception.vaddress = wp_hit->hitaddr; - raise_exception(env, EXCP_DATA_ABORT, - syn_watchpoint(same_el, 0, wnr), - arm_debug_target_el(env)); + + if (extended_addresses_enabled(env)) { + env->exception.fsr = (1 << 9) | 0x22; } else { - cpu_resume_from_signal(cs, NULL); + env->exception.fsr = 0x2; } + env->exception.vaddress = wp_hit->hitaddr; + raise_exception(env, EXCP_DATA_ABORT, + syn_watchpoint(same_el, 0, wnr), + arm_debug_target_el(env)); } } else { if (check_breakpoints(cpu)) { -- 1.9.1