From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] kvm-qemu: Proper vm_stop on debug events Date: Fri, 23 May 2008 04:10:34 +0200 Message-ID: <4836279A.6060308@web.de> References: <48360B4B.10105@web.de> <48361154.4080805@codemonkey.ws> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6EC06AA36584DF99D519D1EB" Cc: kvm-devel To: Anthony Liguori Return-path: Received: from fmmailgate03.web.de ([217.72.192.234]:51127 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752944AbYEWCKj (ORCPT ); Thu, 22 May 2008 22:10:39 -0400 In-Reply-To: <48361154.4080805@codemonkey.ws> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6EC06AA36584DF99D519D1EB Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Anthony Liguori wrote: > Jan Kiszka wrote: >> When a vcpu exits after hitting a debug exception, we have to invoke >> vm_stop(EXCP_DEBUG). But this has to take place over the io-thread. >> >> This patch introduces kvm_debug_stop_requested to signal this event, a= nd >> it takes care that the interrupted vcpu itself goes immediately into >> stop state. >> >> Signed-off-by: Jan Kiszka >> --- >> qemu/qemu-kvm.c | 9 ++++++++- >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> Index: b/qemu/qemu-kvm.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- a/qemu/qemu-kvm.c >> +++ b/qemu/qemu-kvm.c >> @@ -58,6 +58,8 @@ pthread_t io_thread; >> static int io_thread_fd =3D -1; >> static int io_thread_sigfd =3D -1; >> =20 >> +static int kvm_debug_stop_requested; >> + >> =20 >=20 > Why use this instead of just keying off of exception_index =3D=3D EXCP_= DEBUG? >=20 >> static inline unsigned long kvm_get_thread_id(void) >> { >> return syscall(SYS_gettid); >> @@ -517,6 +519,10 @@ int kvm_main_loop(void) >> qemu_system_powerdown(); >> else if (qemu_reset_requested()) >> qemu_kvm_system_reset(); >> + else if (kvm_debug_stop_requested) { >> + kvm_debug_stop_requested =3D 0; >> + vm_stop(EXCP_DEBUG); >> + } >> } >> =20 >> pause_all_threads(); >> @@ -529,7 +535,8 @@ static int kvm_debug(void *opaque, int v >> { >> CPUState *env =3D cpu_single_env; >> =20 >> - env->exception_index =3D EXCP_DEBUG; >> + kvm_debug_stop_requested =3D 1; >> + vcpu_info[vcpu].stopped =3D 1; >> =20 >=20 > This isn't quite right. In the very least, you need to set stopping =3D= 0 > and signal on the qemu_pause_cond. Thinking it through more though, a > breakpoint should stop all VCPUs, right? It does already, give it a try. >=20 > vm_stop(EXCP_DEBUG) will actually do this. It invokes the > vm_state_notify callbacks and the io-thread registers one. I think you= > should probably just issue vm_stop(EXCP_DEBUG) from kvm_debug. As explained, it can't be called over the vcpu contexts (there is even an assert() fence against it). This policy has been recently agreed on while fixing other deadlock issues of qemu-kvm. Jan --------------enig6EC06AA36584DF99D519D1EB 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.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFINiedniDOoMHTA+kRAtpbAJ4sscoBaQlZR+eEj+lHDYlsRzfZ8QCeLLr6 ERO7jC/lDiEJlDJvBBMBZOE= =6Tpp -----END PGP SIGNATURE----- --------------enig6EC06AA36584DF99D519D1EB--