From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-ID: <4D749D46.4000409@web.de> Date: Mon, 07 Mar 2011 09:54:30 +0100 From: Jan Kiszka MIME-Version: 1.0 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> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig906CCF6BFDEB7990A1B94E81" Sender: jan.kiszka@web.de List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: TeLeMan Cc: Anthony Liguori , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig906CCF6BFDEB7990A1B94E81 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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(). >=20 > 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; } =20 +static CPUDebugExcpHandler *debug_excp_handler; + +CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *han= dler) +{ + CPUDebugExcpHandler *old_handler =3D debug_excp_handler; + + debug_excp_handler =3D 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 &=3D ~BP_WATCHPOINT_HIT; + } + } + if (debug_excp_handler) { + debug_excp_handler(env); + } +} + /* main execution loop */ =20 volatile sig_atomic_t exit_request; @@ -263,6 +287,9 @@ int cpu_exec(CPUState *env1) if (env->exception_index >=3D EXCP_INTERRUPT) { /* exit request from the cpu execution loop */ ret =3D env->exception_index; + if (ret =3D=3D 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; } =20 -static CPUDebugExcpHandler *debug_excp_handler; - -CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *han= dler) -{ - CPUDebugExcpHandler *old_handler =3D debug_excp_handler; - - debug_excp_handler =3D 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 &=3D ~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 =3D kvm_cpu_exec(env); if (r =3D=3D 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 =3D tcg_cpu_exec(env); } if (r =3D=3D EXCP_DEBUG) { - cpu_handle_debug_exception(env); + cpu_handle_guest_debug(env); break; } } else if (env->stop || env->stopped) { --=20 1.7.1 --------------enig906CCF6BFDEB7990A1B94E81 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAk10nUYACgkQitSsb3rl5xQ5PACgjE88LQPvvAoPQUhrsG6m8pr+ /sMAoIm+GyZzehjmAkrqUL3KTQUNMNNQ =sOVG -----END PGP SIGNATURE----- --------------enig906CCF6BFDEB7990A1B94E81--