From patchwork Mon Mar 7 08:54:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 85695 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D6BAAB710E for ; Mon, 7 Mar 2011 19:55:26 +1100 (EST) Received: from localhost ([127.0.0.1]:54582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwWDr-0000za-9b for incoming@patchwork.ozlabs.org; Mon, 07 Mar 2011 03:55:23 -0500 Received: from [140.186.70.92] (port=41715 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwWD5-0000ve-8Q for qemu-devel@nongnu.org; Mon, 07 Mar 2011 03:54:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwWD3-0000h4-AK for qemu-devel@nongnu.org; Mon, 07 Mar 2011 03:54:34 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:51765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwWD2-0000gI-US for qemu-devel@nongnu.org; Mon, 07 Mar 2011 03:54:33 -0500 Received: from smtp03.web.de ( [172.20.0.65]) by fmmailgate03.web.de (Postfix) with ESMTP id 4C6E018998CB8; Mon, 7 Mar 2011 09:54:31 +0100 (CET) Received: from [92.74.54.57] (helo=mchn199C.mchp.siemens.de) by smtp03.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1PwWD1-0006b7-00; Mon, 07 Mar 2011 09:54:31 +0100 Message-ID: <4D749D46.4000409@web.de> Date: Mon, 07 Mar 2011 09:54:30 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: TeLeMan Subject: Re: [Qemu-devel] [PATCH 28/37] Move debug exception handling out of cpu_exec References: <83f338f73ecb88cc6f85d6e7b81ebef112ce07be.1297696986.git.mtosatti@redhat.com> <4D7496B7.8030201@web.de> In-Reply-To: <4D7496B7.8030201@web.de> X-Enigmail-Version: 1.1.2 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX19vJ3bihs+QKoWIMKfCdo/K3gr5Y6g5IvPtrcx6 hHiVoWYnPCV6JOceLzT01wpsZW9FPmL7Dtg18abcj/E+r3ayDP 5e4i5OBqs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.234 Cc: Anthony Liguori , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 2011-03-07 09:26, Jan Kiszka wrote: > On 2011-03-07 02:52, TeLeMan wrote: >> This patch breaks the support for x86 hardware breakpoints because >> cpu_resume_from_signal() and raise_exception_env() are used in >> breakpoint_handler(). > > Yeah, unfortunately true. The TCG bits of this refactoring have to be > moved back. Will fix. This seems to do the trick, but I haven't tested all scenarios yet. Jan diff --git a/cpu-exec.c b/cpu-exec.c index b03b3a7..0333617 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -196,6 +196,30 @@ static inline TranslationBlock *tb_find_fast(void) return tb; } +static CPUDebugExcpHandler *debug_excp_handler; + +CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler) +{ + CPUDebugExcpHandler *old_handler = debug_excp_handler; + + debug_excp_handler = handler; + return old_handler; +} + +static void cpu_handle_debug_exception(CPUState *env) +{ + CPUWatchpoint *wp; + + if (!env->watchpoint_hit) { + QTAILQ_FOREACH(wp, &env->watchpoints, entry) { + wp->flags &= ~BP_WATCHPOINT_HIT; + } + } + if (debug_excp_handler) { + debug_excp_handler(env); + } +} + /* main execution loop */ volatile sig_atomic_t exit_request; @@ -263,6 +287,9 @@ int cpu_exec(CPUState *env1) if (env->exception_index >= EXCP_INTERRUPT) { /* exit request from the cpu execution loop */ ret = env->exception_index; + if (ret == EXCP_DEBUG) { + cpu_handle_debug_exception(env); + } break; } else { #if defined(CONFIG_USER_ONLY) diff --git a/cpus.c b/cpus.c index 0f1ae50..d41a0ce 100644 --- a/cpus.c +++ b/cpus.c @@ -166,29 +166,8 @@ static bool all_cpu_threads_idle(void) return true; } -static CPUDebugExcpHandler *debug_excp_handler; - -CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler) -{ - CPUDebugExcpHandler *old_handler = debug_excp_handler; - - debug_excp_handler = handler; - return old_handler; -} - -static void cpu_handle_debug_exception(CPUState *env) +static void cpu_handle_guest_debug(CPUState *env) { - CPUWatchpoint *wp; - - if (!env->watchpoint_hit) { - QTAILQ_FOREACH(wp, &env->watchpoints, entry) { - wp->flags &= ~BP_WATCHPOINT_HIT; - } - } - if (debug_excp_handler) { - debug_excp_handler(env); - } - gdb_set_stop_cpu(env); qemu_system_debug_request(); #ifdef CONFIG_IOTHREAD @@ -836,7 +815,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) if (cpu_can_run(env)) { r = kvm_cpu_exec(env); if (r == EXCP_DEBUG) { - cpu_handle_debug_exception(env); + cpu_handle_guest_debug(env); } } qemu_kvm_wait_io_event(env); @@ -1106,7 +1085,7 @@ bool cpu_exec_all(void) r = tcg_cpu_exec(env); } if (r == EXCP_DEBUG) { - cpu_handle_debug_exception(env); + cpu_handle_guest_debug(env); break; } } else if (env->stop || env->stopped) {