From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: [PATCH] vhost-net: fix reversed logic in mask notifiers Date: Tue, 25 May 2010 17:00:43 +0300 Message-ID: <20100525140043.GA19688@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: kvm@vger.kernel.org, amit.shah@redhat.com, quintela@redhat.com, kraxel@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4628 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932693Ab0EYOE7 (ORCPT ); Tue, 25 May 2010 10:04:59 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4PE4w8r005322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 May 2010 10:04:58 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: When guest notifier is assigned, we set mask notifier, which will assign kvm irqfd. When guest notifier is unassigned, mask notifier is unset, which should unassign kvm irqfd. The way to do this is to call mask notifier telling it to mask the vector. This, unless vector is already masked which unassigns irqfd already. The logic in unassign was reversed, which left kvm irqfd assigned. This patch is qemu-kvm only as irqfd is not upstream. Signed-off-by: Michael S. Tsirkin Reported-by: Amit Shah --- hw/msix.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 8f9a621..1398680 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -617,6 +617,7 @@ int msix_set_mask_notifier(PCIDevice *dev, unsigned vector, void *opaque) assert(opaque); assert(!dev->msix_mask_notifier_opaque[vector]); + /* Unmask the new notifier unless vector is masked. */ if (msix_is_masked(dev, vector)) { return 0; } @@ -638,12 +639,13 @@ int msix_unset_mask_notifier(PCIDevice *dev, unsigned vector) assert(dev->msix_mask_notifier); assert(dev->msix_mask_notifier_opaque[vector]); + /* Mask the old notifier unless it is already masked. */ if (msix_is_masked(dev, vector)) { return 0; } r = dev->msix_mask_notifier(dev, vector, dev->msix_mask_notifier_opaque[vector], - msix_is_masked(dev, vector)); + !msix_is_masked(dev, vector)); if (r < 0) { return r; } -- 1.7.1.12.g42b7f