From patchwork Thu Oct 27 12:10:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 122127 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 15E891007D8 for ; Thu, 27 Oct 2011 23:12:05 +1100 (EST) Received: from localhost ([::1]:36600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJOoS-0006fh-9D for incoming@patchwork.ozlabs.org; Thu, 27 Oct 2011 08:12:00 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJOoJ-0006eM-MF for qemu-devel@nongnu.org; Thu, 27 Oct 2011 08:11:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJOoH-0005EW-FM for qemu-devel@nongnu.org; Thu, 27 Oct 2011 08:11:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJOoH-0005E0-5z for qemu-devel@nongnu.org; Thu, 27 Oct 2011 08:11:49 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9RCBmKf021927 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 Oct 2011 08:11:48 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9RCBmY6006472; Thu, 27 Oct 2011 08:11:48 -0400 Received: from amt.cnet (vpn-9-128.rdu.redhat.com [10.11.9.128]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p9RCBlgr022274; Thu, 27 Oct 2011 08:11:47 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 3297D6520FC; Thu, 27 Oct 2011 10:10:30 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id p9RCAS8N029975; Thu, 27 Oct 2011 10:10:28 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Thu, 27 Oct 2011 10:10:16 -0200 Message-Id: <1cae88b9f4121c9af0bf677435c6129e643280fd.1319717419.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity Subject: [Qemu-devel] [PATCH 3/6] kvm: avoid reentring kvm_flush_coalesced_mmio_buffer() 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Avi Kivity mmio callbacks invoked by kvm_flush_coalesced_mmio_buffer() may themselves indirectly call kvm_flush_coalesced_mmio_buffer(). Prevent reentering the function by checking a flag that indicates we're processing coalesced mmio requests. Signed-off-by: Avi Kivity --- kvm-all.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index e7faf5c..c09ddf7 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -64,6 +64,7 @@ struct KVMState int vmfd; int coalesced_mmio; struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; + bool coalesced_flush_in_progress; int broken_set_mem_region; int migration_log; int vcpu_events; @@ -876,6 +877,13 @@ static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run) void kvm_flush_coalesced_mmio_buffer(void) { KVMState *s = kvm_state; + + if (s->coalesced_flush_in_progress) { + return; + } + + s->coalesced_flush_in_progress = true; + if (s->coalesced_mmio_ring) { struct kvm_coalesced_mmio_ring *ring = s->coalesced_mmio_ring; while (ring->first != ring->last) { @@ -888,6 +896,8 @@ void kvm_flush_coalesced_mmio_buffer(void) ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX; } } + + s->coalesced_flush_in_progress = false; } static void do_kvm_cpu_synchronize_state(void *_env)