render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone
Justin M. Forbes eff942
From af483cb870ad81dce8e10215e0add284fcc38da4 Mon Sep 17 00:00:00 2001
Justin M. Forbes eff942
From: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes eff942
Date: Wed, 24 Feb 2010 21:09:45 +0200
Justin M. Forbes eff942
Subject: [PATCH] msix: migration fix
Justin M. Forbes eff942
Justin M. Forbes eff942
Be careful to match mask/unmask callbacks from msix.
Justin M. Forbes eff942
Fixes crash during migration.
Justin M. Forbes eff942
Justin M. Forbes eff942
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes eff942
---
Justin M. Forbes eff942
 hw/msix.c |   16 +++++++++++++---
Justin M. Forbes eff942
 1 files changed, 13 insertions(+), 3 deletions(-)
Justin M. Forbes eff942
Justin M. Forbes eff942
diff --git a/hw/msix.c b/hw/msix.c
Justin M. Forbes eff942
index 3fcf3a1..fafaf09 100644
Justin M. Forbes eff942
--- a/hw/msix.c
Justin M. Forbes eff942
+++ b/hw/msix.c
Justin M. Forbes eff942
@@ -614,9 +614,19 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque)
Justin M. Forbes eff942
     if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
Justin M. Forbes eff942
         return 0;
Justin M. Forbes eff942
Justin M. Forbes eff942
-    if (dev->msix_mask_notifier)
Justin M. Forbes eff942
-        r = dev->msix_mask_notifier(dev, vector, opaque,
Justin M. Forbes eff942
-                                    msix_is_masked(dev, vector));
Justin M. Forbes eff942
+    if (dev->msix_mask_notifier && !msix_is_masked(dev, vector)) {
Justin M. Forbes eff942
+        /* Mask previous notifier if any */
Justin M. Forbes eff942
+        if (dev->msix_mask_notifier_opaque[vector]) {
Justin M. Forbes eff942
+            r = dev->msix_mask_notifier(dev, vector,
Justin M. Forbes eff942
+                                        dev->msix_mask_notifier_opaque[vector],
Justin M. Forbes eff942
+                                        1);
Justin M. Forbes eff942
+            assert(r >= 0);
Justin M. Forbes eff942
+        }
Justin M. Forbes eff942
+        /* Unmask new notifier, assumed to be masked at start */
Justin M. Forbes eff942
+        if (opaque) {
Justin M. Forbes eff942
+            r = dev->msix_mask_notifier(dev, vector, opaque, 0);
Justin M. Forbes eff942
+        }
Justin M. Forbes eff942
+    }
Justin M. Forbes eff942
     if (r >= 0)
Justin M. Forbes eff942
         dev->msix_mask_notifier_opaque[vector] = opaque;
Justin M. Forbes eff942
     return r;
Justin M. Forbes eff942
-- 
Justin M. Forbes eff942
1.6.6.1
Justin M. Forbes eff942