From patchwork Tue Feb 1 21:15:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 81388 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 B609FB70B3 for ; Wed, 2 Feb 2011 09:00:34 +1100 (EST) Received: from localhost ([127.0.0.1]:48474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkOGe-0006Eg-MJ for incoming@patchwork.ozlabs.org; Tue, 01 Feb 2011 17:00:08 -0500 Received: from [140.186.70.92] (port=47443 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PkNhC-00012v-Df for qemu-devel@nongnu.org; Tue, 01 Feb 2011 16:25:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PkNbO-0003Pg-4E for qemu-devel@nongnu.org; Tue, 01 Feb 2011 16:17:31 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:59212) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PkNbN-0003Ou-LV for qemu-devel@nongnu.org; Tue, 01 Feb 2011 16:17:30 -0500 Received: from smtp05.web.de ( [172.20.4.166]) by fmmailgate03.web.de (Postfix) with ESMTP id AA93E186EC4B6; Tue, 1 Feb 2011 22:16:13 +0100 (CET) Received: from [88.65.41.52] (helo=localhost.localdomain) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1PkNa9-0006FM-01; Tue, 01 Feb 2011 22:16:13 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Tue, 1 Feb 2011 22:15:55 +0100 Message-Id: <22496d65c09ffa0e6ebcc743fcd563c8bf7f1180.1296594961.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1/Wz6fHS+tBcqJD5Mf9It901ng+rODPh6rdeUfd WUC61CU2LS9x+DP0yFrkeLYY8qB3RQZMeFk1eYXk6nwk9aRvjB vqSqZmS2M= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.234 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH v2 15/24] kvm: Call qemu_kvm_eat_signals also under !CONFIG_IOTHREAD 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 From: Jan Kiszka Move qemu_kvm_eat_signals around and call it also when the IO-thread is not used. Do not yet process SIGBUS, will be armed in a separate step. Signed-off-by: Jan Kiszka --- cpus.c | 90 +++++++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 52 insertions(+), 38 deletions(-) diff --git a/cpus.c b/cpus.c index 04138ba..861e270 100644 --- a/cpus.c +++ b/cpus.c @@ -235,6 +235,47 @@ static void dummy_signal(int sig) { } +static void sigbus_reraise(void); + +static void qemu_kvm_eat_signals(CPUState *env) +{ + struct timespec ts = { 0, 0 }; + siginfo_t siginfo; + sigset_t waitset; + sigset_t chkset; + int r; + + sigemptyset(&waitset); + sigaddset(&waitset, SIG_IPI); + sigaddset(&waitset, SIGBUS); + + do { + r = sigtimedwait(&waitset, &siginfo, &ts); + if (r == -1 && !(errno == EAGAIN || errno == EINTR)) { + perror("sigtimedwait"); + exit(1); + } + + switch (r) { +#ifdef CONFIG_IOTHREAD + case SIGBUS: + if (kvm_on_sigbus_vcpu(env, siginfo.si_code, siginfo.si_addr)) { + sigbus_reraise(); + } + break; +#endif + default: + break; + } + + r = sigpending(&chkset); + if (r == -1) { + perror("sigpending"); + exit(1); + } + } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS)); +} + #else /* _WIN32 */ HANDLE qemu_event_handle; @@ -262,6 +303,10 @@ static void qemu_event_increment(void) exit (1); } } + +static void qemu_kvm_eat_signals(CPUState *env) +{ +} #endif /* _WIN32 */ #ifndef CONFIG_IOTHREAD @@ -648,43 +693,6 @@ static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo, } } -static void qemu_kvm_eat_signals(CPUState *env) -{ - struct timespec ts = { 0, 0 }; - siginfo_t siginfo; - sigset_t waitset; - sigset_t chkset; - int r; - - sigemptyset(&waitset); - sigaddset(&waitset, SIG_IPI); - sigaddset(&waitset, SIGBUS); - - do { - r = sigtimedwait(&waitset, &siginfo, &ts); - if (r == -1 && !(errno == EAGAIN || errno == EINTR)) { - perror("sigtimedwait"); - exit(1); - } - - switch (r) { - case SIGBUS: - if (kvm_on_sigbus_vcpu(env, siginfo.si_code, siginfo.si_addr)) { - sigbus_reraise(); - } - break; - default: - break; - } - - r = sigpending(&chkset); - if (r == -1) { - perror("sigpending"); - exit(1); - } - } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS)); -} - static void qemu_kvm_wait_io_event(CPUState *env) { while (!cpu_has_work(env)) @@ -949,6 +957,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) { @@ -960,7 +970,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; } } else if (env->stop) {