From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeW2n-000423-QF for qemu-devel@nongnu.org; Fri, 30 Nov 2012 14:14:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TeW2m-0000fI-St for qemu-devel@nongnu.org; Fri, 30 Nov 2012 14:14:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TeW2m-0000dQ-LJ for qemu-devel@nongnu.org; Fri, 30 Nov 2012 14:14:36 -0500 Message-ID: <1354302873.1809.246.camel@bling.home> From: Alex Williamson Date: Fri, 30 Nov 2012 12:14:33 -0700 In-Reply-To: References: <20121127194314.2422.65587.stgit@bling.home> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-1.3] vfio-pci: Fix KVM disabled path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, kvm@vger.kernel.org On Fri, 2012-11-30 at 18:57 +0000, Peter Maydell wrote: > On 27 November 2012 19:45, Alex Williamson wrote: > > kvm_check_extension() explodes when KVM isn't enabled so we need to > > first test whether KVM is enabled. Use kvm_irqchip_in_kernel() for > > this since it matches the test we do before using this result. > > > --- a/hw/vfio_pci.c > > +++ b/hw/vfio_pci.c > > @@ -438,7 +438,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_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) { > > + if (kvm_irqchip_in_kernel() && > > + kvm_check_extension(kvm_state, KVM_CAP_IRQFD_RESAMPLE)) { > > vdev->intx.route = pci_device_route_intx_to_irq(&vdev->pdev, > > vdev->intx.pin); > > > vfio_pci is supposed to be architecture-independent code, right? > kvm.h says you mustn't use kvm_irqchip_in_kernel() in such code > (its semantics vary from arch to arch). I think kvm_enabled() > is sufficient here since what we're actually guarding is just > the kvm_check_extension call. Here, yes. The other call spot we're matching is specifically looking for whether kvm is capable of using IRQFD_RESAMPLE and whether it should be used. I think kvm_irqfds_enabled() is probably the right way to go. Post 1.3 we might want to make kvm_intx_via_irqfd_enabled which encapsulates the IRQFD_RESAMPLE test. I'll do some testing and repost a kvm_irqfds_enabled() version. Thanks, Alex