From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 07/18] kvm: Add MCE signal support for !CONFIG_IOTHREAD Date: Mon, 24 Jan 2011 09:17:28 -0200 Message-ID: <20110124111728.GA29184@amt.cnet> References: <39b9c54e6cd122cb613f5fb79502eb053609d237.1294648329.git.jan.kiszka@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org, Huang Ying To: Jan Kiszka Return-path: Received: from mx1.redhat.com ([209.132.183.28]:44545 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497Ab1AXMBP (ORCPT ); Mon, 24 Jan 2011 07:01:15 -0500 Content-Disposition: inline In-Reply-To: <39b9c54e6cd122cb613f5fb79502eb053609d237.1294648329.git.jan.kiszka@web.de> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jan 10, 2011 at 09:32:00AM +0100, Jan Kiszka wrote: > From: Jan Kiszka > > Currently, we only configure and process MCE-related SIGBUS events if > CONFIG_IOTHREAD is enabled. Fix this by factoring out the required > handler registration and system configuration. Make sure that events > happening over a VCPU context in non-threaded mode get dispatched as > VCPU MCEs. > > We also need to call qemu_kvm_eat_signals in non-threaded mode now, so > move it (unmodified) and add the required Windows stub. > > Signed-off-by: Jan Kiszka > CC: Huang Ying > --- > cpus.c | 200 +++++++++++++++++++++++++++++++++++++++------------------------ > 1 files changed, 124 insertions(+), 76 deletions(-) > > diff --git a/cpus.c b/cpus.c > index 6da0f8f..b6f1cfb 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -34,9 +34,6 @@ > > #include "cpus.h" > #include "compatfd.h" > -#ifdef CONFIG_LINUX > -#include > -#endif > > #ifdef SIGRTMIN > #define SIG_IPI (SIGRTMIN+4) > @@ -44,10 +41,24 @@ > #define SIG_IPI SIGUSR1 > #endif > > @@ -912,6 +954,8 @@ static int qemu_cpu_exec(CPUState *env) > > bool cpu_exec_all(void) > { > + int r; > + > if (next_cpu == NULL) > next_cpu = first_cpu; > for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) { > @@ -923,7 +967,11 @@ bool cpu_exec_all(void) > if (qemu_alarm_pending()) > break; > if (cpu_can_run(env)) { > - if (qemu_cpu_exec(env) == EXCP_DEBUG) { > + r = qemu_cpu_exec(env); > + if (kvm_enabled()) { > + qemu_kvm_eat_signals(env); > + } > + if (r == EXCP_DEBUG) { > break; > } SIGBUS should be processed outside of vcpu execution context, think of a non MCE SIGBUS while vm is stopped. Could use signalfd for that. But the SIGBUS handler for !IOTHREAD case should not ignore Action Required, since it might have been generated in vcpu context. From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47378 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhL6i-0003no-Tg for qemu-devel@nongnu.org; Mon, 24 Jan 2011 07:01:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhL6h-0000Kd-4V for qemu-devel@nongnu.org; Mon, 24 Jan 2011 07:01:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhL6g-0000KU-Ts for qemu-devel@nongnu.org; Mon, 24 Jan 2011 07:01:15 -0500 Date: Mon, 24 Jan 2011 09:17:28 -0200 From: Marcelo Tosatti Message-ID: <20110124111728.GA29184@amt.cnet> References: <39b9c54e6cd122cb613f5fb79502eb053609d237.1294648329.git.jan.kiszka@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <39b9c54e6cd122cb613f5fb79502eb053609d237.1294648329.git.jan.kiszka@web.de> Subject: [Qemu-devel] Re: [PATCH 07/18] kvm: Add MCE signal support for !CONFIG_IOTHREAD List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Huang Ying , Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org On Mon, Jan 10, 2011 at 09:32:00AM +0100, Jan Kiszka wrote: > From: Jan Kiszka > > Currently, we only configure and process MCE-related SIGBUS events if > CONFIG_IOTHREAD is enabled. Fix this by factoring out the required > handler registration and system configuration. Make sure that events > happening over a VCPU context in non-threaded mode get dispatched as > VCPU MCEs. > > We also need to call qemu_kvm_eat_signals in non-threaded mode now, so > move it (unmodified) and add the required Windows stub. > > Signed-off-by: Jan Kiszka > CC: Huang Ying > --- > cpus.c | 200 +++++++++++++++++++++++++++++++++++++++------------------------ > 1 files changed, 124 insertions(+), 76 deletions(-) > > diff --git a/cpus.c b/cpus.c > index 6da0f8f..b6f1cfb 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -34,9 +34,6 @@ > > #include "cpus.h" > #include "compatfd.h" > -#ifdef CONFIG_LINUX > -#include > -#endif > > #ifdef SIGRTMIN > #define SIG_IPI (SIGRTMIN+4) > @@ -44,10 +41,24 @@ > #define SIG_IPI SIGUSR1 > #endif > > @@ -912,6 +954,8 @@ static int qemu_cpu_exec(CPUState *env) > > bool cpu_exec_all(void) > { > + int r; > + > if (next_cpu == NULL) > next_cpu = first_cpu; > for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) { > @@ -923,7 +967,11 @@ bool cpu_exec_all(void) > if (qemu_alarm_pending()) > break; > if (cpu_can_run(env)) { > - if (qemu_cpu_exec(env) == EXCP_DEBUG) { > + r = qemu_cpu_exec(env); > + if (kvm_enabled()) { > + qemu_kvm_eat_signals(env); > + } > + if (r == EXCP_DEBUG) { > break; > } SIGBUS should be processed outside of vcpu execution context, think of a non MCE SIGBUS while vm is stopped. Could use signalfd for that. But the SIGBUS handler for !IOTHREAD case should not ignore Action Required, since it might have been generated in vcpu context.