From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sridhar Samudrala Subject: [PATCH] Fix bugs in msix_set/unset_mask_notifier() routines Date: Wed, 02 Jun 2010 09:09:37 -0700 Message-ID: <1275494978.989.62.camel@w-sridhar.beaverton.ibm.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: "kvm@vger.kernel.org" To: "Michael S. Tsirkin" , Avi Kivity Return-path: Received: from e1.ny.us.ibm.com ([32.97.182.141]:37908 "EHLO e1.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758030Ab0FBQJm (ORCPT ); Wed, 2 Jun 2010 12:09:42 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e1.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o52G3qiM010759 for ; Wed, 2 Jun 2010 12:03:52 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o52G9eJ91224782 for ; Wed, 2 Jun 2010 12:09:40 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o52G9doW030517 for ; Wed, 2 Jun 2010 13:09:40 -0300 Sender: kvm-owner@vger.kernel.org List-ID: I am hitting the following assertions in msix.c when doing a guest reboot or live migration using vhost. qemu-kvm/hw/msix.c:375: msix_mask_all: Assertion `r >= 0' failed. qemu-kvm/hw/msix.c:640: msix_unset_mask_notifier: Assertion `dev->msix_mask_notifier_opaque[vector]' failed. The following patch fixes the bugs in handling msix_is_masked() condition in msix_set/unset_mask_notifier() routines. Signed-off-by: Sridhar Samudrala diff --git a/hw/msix.c b/hw/msix.c index 1398680..a191df1 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -609,7 +609,7 @@ void msix_unuse_all_vectors(PCIDevice *dev) int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) { - int r; + int r = 0; if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) return 0; @@ -619,13 +619,15 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) /* Unmask the new notifier unless vector is masked. */ if (msix_is_masked(dev, vector)) { - return 0; + goto out; } r = dev->msix_mask_notifier(dev, vector, opaque, msix_is_masked(dev, vector)); if (r < 0) { return r; } + +out: dev->msix_mask_notifier_opaque[vector] = opaque; return r; } @@ -640,8 +642,8 @@ int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector) assert(dev->msix_mask_notifier_opaque[vector]); /* Mask the old notifier unless it is already masked. */ - if (msix_is_masked(dev, vector)) { - return 0; + if (!msix_is_masked(dev, vector)) { + goto out; } r = dev->msix_mask_notifier(dev, vector, dev->msix_mask_notifier_opaque[vector], @@ -649,6 +651,8 @@ int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector) if (r < 0) { return r; } + +out: dev->msix_mask_notifier_opaque[vector] = NULL; return r; }