From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Avi Kivity Date: Tue, 18 Oct 2011 19:45:04 +0200 Message-Id: <1318959904-9617-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH] kvm: avoid reentring kvm_flush_coalesced_mmio_buffer() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kvm@vger.kernel.org, Jan Kiszka 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) -- 1.7.6.3