render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0206-kvm-avoid-reentring-kvm_flush_coalesced_mmio_buffer.patch

cd9d16
From 479c2a6a296d4fafc713746bf96127c1b20c381e Mon Sep 17 00:00:00 2001
cd9d16
From: Avi Kivity <avi@redhat.com>
cd9d16
Date: Tue, 18 Oct 2011 19:43:12 +0200
cd9d16
Subject: [PATCH] kvm: avoid reentring kvm_flush_coalesced_mmio_buffer()
cd9d16
MIME-Version: 1.0
cd9d16
Content-Type: text/plain; charset=UTF-8
cd9d16
Content-Transfer-Encoding: 8bit
cd9d16
cd9d16
mmio callbacks invoked by kvm_flush_coalesced_mmio_buffer() may
cd9d16
themselves indirectly call kvm_flush_coalesced_mmio_buffer().
cd9d16
Prevent reentering the function by checking a flag that indicates
cd9d16
we're processing coalesced mmio requests.
cd9d16
cd9d16
Signed-off-by: Avi Kivity <avi@redhat.com>
cd9d16
(cherry picked from commit 1cae88b9f4121c9af0bf677435c6129e643280fd)
cd9d16
cd9d16
Signed-off-by: Bruce Rogers <brogers@suse.com>
cd9d16
Signed-off-by: Andreas Färber <afaerber@suse.de>
cd9d16
---
cd9d16
 kvm-all.c | 10 ++++++++++
cd9d16
 1 file changed, 10 insertions(+)
cd9d16
cd9d16
diff --git a/kvm-all.c b/kvm-all.c
cd9d16
index cbc2532..26621d0 100644
cd9d16
--- a/kvm-all.c
cd9d16
+++ b/kvm-all.c
cd9d16
@@ -64,6 +64,7 @@ struct KVMState
cd9d16
     int vmfd;
cd9d16
     int coalesced_mmio;
cd9d16
     struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
cd9d16
+    bool coalesced_flush_in_progress;
cd9d16
     int broken_set_mem_region;
cd9d16
     int migration_log;
cd9d16
     int vcpu_events;
cd9d16
@@ -876,6 +877,13 @@ static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
cd9d16
 void kvm_flush_coalesced_mmio_buffer(void)
cd9d16
 {
cd9d16
     KVMState *s = kvm_state;
cd9d16
+
cd9d16
+    if (s->coalesced_flush_in_progress) {
cd9d16
+        return;
cd9d16
+    }
cd9d16
+
cd9d16
+    s->coalesced_flush_in_progress = true;
cd9d16
+
cd9d16
     if (s->coalesced_mmio_ring) {
cd9d16
         struct kvm_coalesced_mmio_ring *ring = s->coalesced_mmio_ring;
cd9d16
         while (ring->first != ring->last) {
cd9d16
@@ -888,6 +896,8 @@ void kvm_flush_coalesced_mmio_buffer(void)
cd9d16
             ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX;
cd9d16
         }
cd9d16
     }
cd9d16
+
cd9d16
+    s->coalesced_flush_in_progress = false;
cd9d16
 }
cd9d16
 
cd9d16
 static void do_kvm_cpu_synchronize_state(void *_env)
cd9d16
-- 
cd9d16
1.7.11.2
cd9d16