From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: RFC: ioapic polarity vs. qemu os-x guest Date: Sun, 16 Feb 2014 13:41:52 +0200 Message-ID: <20140216114151.GB30056@redhat.com> References: <20140130204423.GK29329@ERROL.INI.CMU.EDU> <20140211182330.GC29329@ERROL.INI.CMU.EDU> <20140211195444.GB10951@redhat.com> <20140214211311.GH29329@ERROL.INI.CMU.EDU> <20140214220600.GI29329@ERROL.INI.CMU.EDU> <2CEB9F8C-E983-4182-A514-44EC568E18D8@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Gabriel L. Somlo" , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , "eddie.dong@intel.com" , pbonzini@redhat.com To: Alexander Graf Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9157 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938AbaBPLg5 (ORCPT ); Sun, 16 Feb 2014 06:36:57 -0500 Content-Disposition: inline In-Reply-To: <2CEB9F8C-E983-4182-A514-44EC568E18D8@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Feb 14, 2014 at 11:13:04PM +0100, Alexander Graf wrote: > > On 14.02.2014, at 23:06, Gabriel L. Somlo wrote: > > > On Fri, Feb 14, 2014 at 10:21:09PM +0100, Alexander Graf wrote: > >> > >> Can't you just turn the polarity around in the pci host adapter? > > > > I tried this: > > > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > > index 1221f32..0e86d21 100644 > > --- a/hw/pci/pci.c > > +++ b/hw/pci/pci.c > > @@ -118,13 +118,13 @@ static int pci_bar(PCIDevice *d, int reg) > > > > static inline int pci_irq_state(PCIDevice *d, int irq_num) > > { > > - return (d->irq_state >> irq_num) & 0x1; > > + return !(d->irq_state >> irq_num) & 0x1; > > } > > > > static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level) > > { > > d->irq_state &= ~(0x1 << irq_num); > > - d->irq_state |= level << irq_num; > > + d->irq_state &= ~(level << irq_num); > > } > > > > static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change) > > @@ -229,7 +229,7 @@ static void pcibus_reset(BusState *qbus) > > } > > > > for (i = 0; i < bus->nirq; i++) { > > - assert(bus->irq_count[i] == 0); > > + assert(bus->irq_count[i] != 0); > > } > > } > > > > --- > > > > but now OS X freezes during boot right after > > > > [ PCI configuration begin ] > > [ PCI configuration end, bridges 1, devices 10 ] > > RTC: Only single RAM bank (128 bytes) > > > > which all looks normal, except the process is supposed to continue on > > from there and doesn't :) > > > > On Linux, I get Fedora 20 live all the way up with no obvious/loud > > complaints, but mouse and keyboard don't work at all... > > > > I have to admit I'm a bit out of my depth here, though :) > > Yeah, another thing we have to take into account is vhost-net which generates IRQs directly through irqfd. I guess for those we'll have to configure the polarity in the irq routing table? > > > Alex What will be affected is VFIO which uses IRQFD for level interrupts with KVM_IRQFD_FLAG_RESAMPLE. I suspect this will need a kernel change, maybe a new flag for IRQFD: KVM_IRQFD_FLAG_ACTIVE_LOW, since at the moment that does: static void irqfd_inject(struct work_struct *work) { struct _irqfd *irqfd = container_of(work, struct _irqfd, inject); struct kvm *kvm = irqfd->kvm; if (!irqfd->resampler) { kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1, false); kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0, false); } else kvm_set_irq(kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID, irqfd->gsi, 1, false); } -- MST From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WF01t-0005pF-U4 for qemu-devel@nongnu.org; Sun, 16 Feb 2014 06:37:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WF01n-00022q-UN for qemu-devel@nongnu.org; Sun, 16 Feb 2014 06:37:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WF01n-00022i-M8 for qemu-devel@nongnu.org; Sun, 16 Feb 2014 06:36:55 -0500 Date: Sun, 16 Feb 2014 13:41:52 +0200 From: "Michael S. Tsirkin" Message-ID: <20140216114151.GB30056@redhat.com> References: <20140130204423.GK29329@ERROL.INI.CMU.EDU> <20140211182330.GC29329@ERROL.INI.CMU.EDU> <20140211195444.GB10951@redhat.com> <20140214211311.GH29329@ERROL.INI.CMU.EDU> <20140214220600.GI29329@ERROL.INI.CMU.EDU> <2CEB9F8C-E983-4182-A514-44EC568E18D8@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2CEB9F8C-E983-4182-A514-44EC568E18D8@suse.de> Subject: Re: [Qemu-devel] RFC: ioapic polarity vs. qemu os-x guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: pbonzini@redhat.com, "Gabriel L. Somlo" , "eddie.dong@intel.com" , "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" On Fri, Feb 14, 2014 at 11:13:04PM +0100, Alexander Graf wrote: > > On 14.02.2014, at 23:06, Gabriel L. Somlo wrote: > > > On Fri, Feb 14, 2014 at 10:21:09PM +0100, Alexander Graf wrote: > >> > >> Can't you just turn the polarity around in the pci host adapter? > > > > I tried this: > > > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > > index 1221f32..0e86d21 100644 > > --- a/hw/pci/pci.c > > +++ b/hw/pci/pci.c > > @@ -118,13 +118,13 @@ static int pci_bar(PCIDevice *d, int reg) > > > > static inline int pci_irq_state(PCIDevice *d, int irq_num) > > { > > - return (d->irq_state >> irq_num) & 0x1; > > + return !(d->irq_state >> irq_num) & 0x1; > > } > > > > static inline void pci_set_irq_state(PCIDevice *d, int irq_num, int level) > > { > > d->irq_state &= ~(0x1 << irq_num); > > - d->irq_state |= level << irq_num; > > + d->irq_state &= ~(level << irq_num); > > } > > > > static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change) > > @@ -229,7 +229,7 @@ static void pcibus_reset(BusState *qbus) > > } > > > > for (i = 0; i < bus->nirq; i++) { > > - assert(bus->irq_count[i] == 0); > > + assert(bus->irq_count[i] != 0); > > } > > } > > > > --- > > > > but now OS X freezes during boot right after > > > > [ PCI configuration begin ] > > [ PCI configuration end, bridges 1, devices 10 ] > > RTC: Only single RAM bank (128 bytes) > > > > which all looks normal, except the process is supposed to continue on > > from there and doesn't :) > > > > On Linux, I get Fedora 20 live all the way up with no obvious/loud > > complaints, but mouse and keyboard don't work at all... > > > > I have to admit I'm a bit out of my depth here, though :) > > Yeah, another thing we have to take into account is vhost-net which generates IRQs directly through irqfd. I guess for those we'll have to configure the polarity in the irq routing table? > > > Alex What will be affected is VFIO which uses IRQFD for level interrupts with KVM_IRQFD_FLAG_RESAMPLE. I suspect this will need a kernel change, maybe a new flag for IRQFD: KVM_IRQFD_FLAG_ACTIVE_LOW, since at the moment that does: static void irqfd_inject(struct work_struct *work) { struct _irqfd *irqfd = container_of(work, struct _irqfd, inject); struct kvm *kvm = irqfd->kvm; if (!irqfd->resampler) { kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1, false); kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0, false); } else kvm_set_irq(kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID, irqfd->gsi, 1, false); } -- MST