Received: from eggs.gnu.org ([208.118.235.92]:46186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TloiG-0007HO-09 for qemu-devel@nongnu.org; Thu, 20 Dec 2012 17:35:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TloiE-0006Jz-8V for qemu-devel@nongnu.org; Thu, 20 Dec 2012 17:35:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11755) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TloiE-0006Jv-0D for qemu-devel@nongnu.org; Thu, 20 Dec 2012 17:35:34 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBKMZXdt024390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Dec 2012 17:35:33 -0500 Message-ID: <1356042932.3625.19.camel@ul30vt.home> From: Alex Williamson Date: Thu, 20 Dec 2012 15:35:32 -0700 In-Reply-To: <1356038055-29507-1-git-send-email-stefanha@redhat.com> References: <1356038055-29507-1-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vfio-pci: Add missing kvm_enabled() checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org On Thu, 2012-12-20 at 22:14 +0100, Stefan Hajnoczi wrote: > It's necessary to check kvm_enabled() since a QEMU binary can be > compiled with KVM support but TCG can be used at run-time. > kvm_check_extension() segfaults if kvm_state is NULL. Ugh, this is exactly why we added kvm_irqfds_enabled() which doesn't call kvm_check_extension(). How is it possible to fall through to a kvm_check_extension() with that in place? Thanks, Alex > Reported-by: Joe Terranova > Signed-off-by: Stefan Hajnoczi > --- > hw/vfio_pci.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c > index fbfe670..677dc48 100644 > --- a/hw/vfio_pci.c > +++ b/hw/vfio_pci.c > @@ -275,7 +275,8 @@ static void vfio_enable_intx_kvm(VFIODevice *vdev) > int ret, argsz; > int32_t *pfd; > > - if (!kvm_irqfds_enabled() || > + if (!kvm_enabled() || > + !kvm_irqfds_enabled() || > vdev->intx.route.mode != PCI_INTX_ENABLED || > !kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) { > return; > @@ -438,7 +439,8 @@ static int vfio_enable_intx(VFIODevice *vdev) > * Only conditional to avoid generating error messages on platforms > * where we won't actually use the result anyway. > */ > - if (kvm_irqfds_enabled() && > + if (kvm_enabled() && > + kvm_irqfds_enabled() && > kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) { > vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev, > vdev->intx.pin);