From patchwork Wed May 12 21:25:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 52435 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 293FFB7E0F for ; Thu, 13 May 2010 14:23:27 +1000 (EST) Received: from localhost ([127.0.0.1]:37887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCPxD-0006LT-H3 for incoming@patchwork.ozlabs.org; Thu, 13 May 2010 00:23:23 -0400 Received: from [140.186.70.92] (port=41099 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCPA7-0008UA-Ka for qemu-devel@nongnu.org; Wed, 12 May 2010 23:32:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OCKGw-0000r8-LM for qemu-devel@nongnu.org; Wed, 12 May 2010 18:19:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11200) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OCJSO-0000uA-H6 for qemu-devel@nongnu.org; Wed, 12 May 2010 17:27:09 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR54L015620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 May 2010 17:27:06 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR5Ih019619; Wed, 12 May 2010 17:27:05 -0400 Received: from amt.cnet (vpn2-10-158.ams2.redhat.com [10.36.10.158]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4CLR2iA021864; Wed, 12 May 2010 17:27:04 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id F3B5A65607B; Wed, 12 May 2010 18:26:03 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o4CLPwK9028648; Wed, 12 May 2010 18:25:58 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Wed, 12 May 2010 18:25:00 -0300 Message-Id: <2705d56a6a7e9c7833e04d33aedbc01d2280a280.1273699506.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity Subject: [Qemu-devel] [PATCH 06/12] kvm: synchronize state from cpu context 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 It is not safe to retrieve the KVM internal state of a given cpu while its potentially modifying it. Queue the request to run on cpu context, similarly to qemu-kvm. Signed-off-by: Marcelo Tosatti Signed-off-by: Avi Kivity --- kvm-all.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index fbd084c..e766202 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -796,14 +796,22 @@ void kvm_flush_coalesced_mmio_buffer(void) #endif } -void kvm_cpu_synchronize_state(CPUState *env) +static void do_kvm_cpu_synchronize_state(void *_env) { + CPUState *env = _env; + if (!env->kvm_vcpu_dirty) { kvm_arch_get_registers(env); env->kvm_vcpu_dirty = 1; } } +void kvm_cpu_synchronize_state(CPUState *env) +{ + if (!env->kvm_vcpu_dirty) + run_on_cpu(env, do_kvm_cpu_synchronize_state, env); +} + void kvm_cpu_synchronize_post_reset(CPUState *env) { kvm_arch_put_registers(env, KVM_PUT_RESET_STATE);