From patchwork Tue Apr 5 02:17:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 8746461 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5EF289F336 for ; Tue, 5 Apr 2016 02:18:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACBD420204 for ; Tue, 5 Apr 2016 02:18:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0657B201F5 for ; Tue, 5 Apr 2016 02:18:00 +0000 (UTC) Received: from localhost ([::1]:33921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anGZ5-0001t6-CK for patchwork-qemu-devel@patchwork.kernel.org; Mon, 04 Apr 2016 22:17:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anGXl-000843-62 for qemu-devel@nongnu.org; Mon, 04 Apr 2016 22:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anGXg-0002Iu-Ju for qemu-devel@nongnu.org; Mon, 04 Apr 2016 22:16:37 -0400 Received: from ozlabs.org ([103.22.144.67]:50430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anGXg-0002Ab-9I; Mon, 04 Apr 2016 22:16:32 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3qfCBw6bWBz9sdb; Tue, 5 Apr 2016 12:16:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1459822568; bh=JTf8fDGdvFi1owC7FYaprq1PP/5uw2UT7H5TcC7eu8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHBycqq/ifJ0XcrP9bOcjZzuVXgwsjP2fXxMmi/yIVjBk4bCZLuu6oPv0Pe/sL5Kj msrbh4zeQcxvcYCwVrkAJvyrug46YZg0CRj2xCFb47GJDv2W4lXWhr8YocbXeVuJMJ 6+I8xDQgjL1QiJ3FcafDY06qw96AU57spCqfZqBs= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 5 Apr 2016 12:17:23 +1000 Message-Id: <1459822643-4770-4-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459822643-4770-1-git-send-email-david@gibson.dropbear.id.au> References: <1459822643-4770-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, agraf@suse.de, mdroth@linux.vnet.ibm.com, clg@fr.ibm.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, David Gibson Subject: [Qemu-devel] [PULL 3/3] vl: Move cpu_synchronize_all_states() into qemu_system_reset() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are currently 3 calls to qemu_system_reset() in vl.c. Two of them are immediately preceded by a cpu_synchronize_all_states9) and the remaining one should be. The one which doesn't is the very first reset called directly from main(). Without a cpu_synchronize_all_states(), kvm_vcpu_dirty is false at this point from the earlier cpu_synchronize_all_post_init(). That's incorrect because the reset path is quite likely to update the CPU state, and that updated state should be pushed back to KVM, not overwritten with stale data pushed to KVM immediately after init. This patch moves the call to cpu_synchronize_all_states() into qemu_system_reset() for safety, so it is always called. AFAICT this should be safe for the handful of callers outside vl.c - these all appear to be in places where the cpu state is already synchronized so the extra call will be a no-op. Signed-off-by: David Gibson Acked-by: Paolo Bonzini Tested-by: Laurent Vivier --- vl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index bd81ea9..3629336 100644 --- a/vl.c +++ b/vl.c @@ -1745,6 +1745,8 @@ void qemu_system_reset(bool report) mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; + cpu_synchronize_all_states(); + if (mc && mc->reset) { mc->reset(); } else { @@ -1893,7 +1895,6 @@ static bool main_loop_should_exit(void) } if (qemu_reset_requested()) { pause_all_vcpus(); - cpu_synchronize_all_states(); qemu_system_reset(VMRESET_REPORT); resume_all_vcpus(); if (!runstate_check(RUN_STATE_RUNNING) && @@ -1903,7 +1904,6 @@ static bool main_loop_should_exit(void) } if (qemu_wakeup_requested()) { pause_all_vcpus(); - cpu_synchronize_all_states(); qemu_system_reset(VMRESET_SILENT); notifier_list_notify(&wakeup_notifiers, &wakeup_reason); wakeup_reason = QEMU_WAKEUP_REASON_NONE;