From patchwork Tue Oct 18 17:45:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 120474 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 47AF5B6F69 for ; Wed, 19 Oct 2011 04:45:30 +1100 (EST) Received: from localhost ([::1]:46079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGDjD-00061V-05 for incoming@patchwork.ozlabs.org; Tue, 18 Oct 2011 13:45:27 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGDj5-00061E-G0 for qemu-devel@nongnu.org; Tue, 18 Oct 2011 13:45:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGDj4-0004zy-BA for qemu-devel@nongnu.org; Tue, 18 Oct 2011 13:45:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGDj4-0004zr-2u for qemu-devel@nongnu.org; Tue, 18 Oct 2011 13:45:18 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9IHjHaE014038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Oct 2011 13:45:17 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9IHjGdn000348; Tue, 18 Oct 2011 13:45:16 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 3AF4E250B85; Tue, 18 Oct 2011 19:45:12 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org, kvm@vger.kernel.org, Jan Kiszka Date: Tue, 18 Oct 2011 19:45:04 +0200 Message-Id: <1318959904-9617-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] 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 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 e783b23..4c8aebd 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; @@ -897,6 +898,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) { @@ -909,6 +917,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)