From patchwork Fri Feb 4 18:21:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 81933 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 A033EB7106 for ; Sat, 5 Feb 2011 05:22:11 +1100 (EST) Received: from localhost ([127.0.0.1]:58418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlQIJ-0001GG-QO for incoming@patchwork.ozlabs.org; Fri, 04 Feb 2011 13:22:07 -0500 Received: from [140.186.70.92] (port=60873 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlQHm-0001Eo-FF for qemu-devel@nongnu.org; Fri, 04 Feb 2011 13:21:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlQHl-0007iw-4Z for qemu-devel@nongnu.org; Fri, 04 Feb 2011 13:21:34 -0500 Received: from goliath.siemens.de ([192.35.17.28]:29628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlQHk-0007i9-RO for qemu-devel@nongnu.org; Fri, 04 Feb 2011 13:21:33 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id p14ILQhB006505; Fri, 4 Feb 2011 19:21:27 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p14ILPih009469; Fri, 4 Feb 2011 19:21:25 +0100 Message-ID: <4D4C43A5.2030207@siemens.com> Date: Fri, 04 Feb 2011 19:21:25 +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: Anthony Liguori References: <4D4C389D.4060607@codemonkey.ws> <4D4C3CC8.9040202@siemens.com> In-Reply-To: <4D4C3CC8.9040202@siemens.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: Marcelo Tosatti , "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" Subject: [Qemu-devel] [PATCH v3 02/23] Stop current VCPU on synchronous reset requests 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-02-04 18:52, Jan Kiszka wrote: > On 2011-02-04 18:34, Anthony Liguori wrote: >> On 02/04/2011 09:47 AM, Marcelo Tosatti wrote: >>> The following changes since commit bfddb47a343b4718e5768aa80bce8adead0f7fca: >>> >>> Open up the 0.15 development branch (2011-02-02 08:39:28 +0100) >>> >> >> This series breaks reboot of a Linux guest both with TCG and KVM. >> >> Perhaps it's a conflict with the ioapic changes from Jan? I can post a >> tree but if you just rebase to the latest master there shouldn't be any >> conflicts. >> > > The problem is some patch in the queue itself. I obviously missed that > case. Will have a look. > Yet another IOTHREAD vs. !IOTHREAD case: We don't need to do anything in cpu_stop_current in the single-thread setup as qemu_notify_event already kicks us out. Specifically, we must not set the current cpu on stop as reset happens without stop/start. This replaces patch 2 in the series. Jan --------8<---------- Subject: [PATCH] Stop current VCPU on synchronous reset requests If some I/O operation ends up calling qemu_system_reset_request in VCPU context, we record this and inform the io-thread, but we do not terminate the VCPU loop. This can lead to fairly unexpected behavior if the triggering reset operation is supposed to work synchronously. Fix this for TCG (when run in deterministic I/O mode) by setting the VCPU on stop and issuing a cpu_exit. KVM requires some more work on its VCPU loop. [ ported from qemu-kvm ] Signed-off-by: Jan Kiszka --- cpus.c | 17 +++++++++++++---- cpus.h | 1 + vl.c | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index ab6e40e..f8a88e3 100644 --- a/cpus.c +++ b/cpus.c @@ -312,6 +312,10 @@ void qemu_notify_event(void) void qemu_mutex_lock_iothread(void) {} void qemu_mutex_unlock_iothread(void) {} +void cpu_stop_current(void) +{ +} + void vm_stop(int reason) { do_vm_stop(reason); @@ -852,6 +856,14 @@ static void qemu_system_vmstop_request(int reason) qemu_notify_event(); } +void cpu_stop_current(void) +{ + if (cpu_single_env) { + cpu_single_env->stopped = 1; + cpu_exit(cpu_single_env); + } +} + void vm_stop(int reason) { QemuThread me; @@ -863,10 +875,7 @@ void vm_stop(int reason) * FIXME: should not return to device code in case * vm_stop() has been requested. */ - if (cpu_single_env) { - cpu_exit(cpu_single_env); - cpu_single_env->stop = 1; - } + cpu_stop_current(); return; } do_vm_stop(reason); diff --git a/cpus.h b/cpus.h index bf4d9bb..4cadb64 100644 --- a/cpus.h +++ b/cpus.h @@ -6,6 +6,7 @@ int qemu_init_main_loop(void); void qemu_main_loop_start(void); void resume_all_vcpus(void); void pause_all_vcpus(void); +void cpu_stop_current(void); /* vl.c */ extern int smp_cores; diff --git a/vl.c b/vl.c index 655617f..b1dc3ff 100644 --- a/vl.c +++ b/vl.c @@ -1296,6 +1296,7 @@ void qemu_system_reset_request(void) } else { reset_requested = 1; } + cpu_stop_current(); qemu_notify_event(); }