From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Gabriel L. Somlo" Subject: Re: RFC: ioapic polarity vs. qemu os-x guest Date: Tue, 11 Feb 2014 16:35:40 -0500 Message-ID: <20140211213539.GD29329@ERROL.INI.CMU.EDU> References: <20140130204423.GK29329@ERROL.INI.CMU.EDU> <20140211182330.GC29329@ERROL.INI.CMU.EDU> <20140211195444.GB10951@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, eddie.dong@intel.com, agraf@suse.de To: "Michael S. Tsirkin" Return-path: Received: from mail-qc0-f181.google.com ([209.85.216.181]:64071 "EHLO mail-qc0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbaBKVhH (ORCPT ); Tue, 11 Feb 2014 16:37:07 -0500 Received: by mail-qc0-f181.google.com with SMTP id e9so13847807qcy.26 for ; Tue, 11 Feb 2014 13:37:06 -0800 (PST) Content-Disposition: inline In-Reply-To: <20140211195444.GB10951@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Feb 11, 2014 at 09:54:44PM +0200, Michael S. Tsirkin wrote: > On Tue, Feb 11, 2014 at 01:23:31PM -0500, Gabriel L. Somlo wrote: > > I'm trying to get OS X to work as a QEMU guest, and one of the few > > remaining "mysteries" I need to solve is that the OS X guest hangs > > during boot, waiting for its boot disk to be available, unless the > > following KVM patch is applied: > > [...] > > 2. Is there anything in QEMU (besides the ACPI DSDT .dsl files) which > > has a hardcoded assumption re. "polarity == 0", or active-high, for > > level-triggered interrupts? I tried to dig through hw/i386/kvm/ioapic.c > > and a bunch of other files, but couldn't isolate anything that I could > > "flip" to fix things in userspace. > > > > > > Any ideas or suggestions about the appropriate way to move forward would > > be much appreciated !!! > > > > > > Thanks much, > > --Gabriel > > I think changing ACPI is the right thing to > do really. But we'll need to fix some things > first of course. > > I think it's PC Q35 that has this assumption. > hw/i386/pc_q35.c > > gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, > GSI_NUM_PINS); > > kvm_pc_gsi_handler simply forwards interrupts to kvm. > > and > > hw/isa/lpc_ich9.c > static void ich9_lpc_update_pic(ICH9LPCState *lpc, int pic_irq) > { > int i, pic_level; > > /* The pic level is the logical OR of all the PCI irqs mapped to it */ > /* The pic level is the logical OR of all the PCI irqs mapped to it > * */ > pic_level = 0; > for (i = 0; i < ICH9_LPC_NB_PIRQS; i++) { > int tmp_irq; > int tmp_dis; > ich9_lpc_pic_irq(lpc, i, &tmp_irq, &tmp_dis); > if (!tmp_dis && pic_irq == tmp_irq) { > pic_level |= pci_bus_get_irq_level(lpc->d.bus, i); > } > } > > so somewhere we need to flip it, I am guessing in ich9 > along the lines of: > > - pic_level = 0; > - pic_level |= pci_bus_get_irq_level(lpc->d.bus, i); > + pic_level = 1; > + pic_level &= !pci_bus_get_irq_level(lpc->d.bus, i); I think now we're on to something! I managed to boot OS X on q35 with absolutely no kernel patches, but Linux still hated it ("irqXX: nobody cared"). At least now I know what I'm looking for, so I'll try to come up with a way to flip level-triggered polarity to ActiveLow across all of i386, in a way that works for Linux and Windows guests as well. Thanks again for getting me unstuck! --Gabriel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDL13-0000Iq-SY for qemu-devel@nongnu.org; Tue, 11 Feb 2014 16:37:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDL0t-0002EI-4C for qemu-devel@nongnu.org; Tue, 11 Feb 2014 16:37:17 -0500 Received: from mail-qc0-x22d.google.com ([2607:f8b0:400d:c01::22d]:65420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDL0s-0002E2-V3 for qemu-devel@nongnu.org; Tue, 11 Feb 2014 16:37:07 -0500 Received: by mail-qc0-f173.google.com with SMTP id i8so14146985qcq.32 for ; Tue, 11 Feb 2014 13:37:06 -0800 (PST) Date: Tue, 11 Feb 2014 16:35:40 -0500 From: "Gabriel L. Somlo" Message-ID: <20140211213539.GD29329@ERROL.INI.CMU.EDU> References: <20140130204423.GK29329@ERROL.INI.CMU.EDU> <20140211182330.GC29329@ERROL.INI.CMU.EDU> <20140211195444.GB10951@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140211195444.GB10951@redhat.com> 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: "Michael S. Tsirkin" Cc: eddie.dong@intel.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, agraf@suse.de On Tue, Feb 11, 2014 at 09:54:44PM +0200, Michael S. Tsirkin wrote: > On Tue, Feb 11, 2014 at 01:23:31PM -0500, Gabriel L. Somlo wrote: > > I'm trying to get OS X to work as a QEMU guest, and one of the few > > remaining "mysteries" I need to solve is that the OS X guest hangs > > during boot, waiting for its boot disk to be available, unless the > > following KVM patch is applied: > > [...] > > 2. Is there anything in QEMU (besides the ACPI DSDT .dsl files) which > > has a hardcoded assumption re. "polarity == 0", or active-high, for > > level-triggered interrupts? I tried to dig through hw/i386/kvm/ioapic.c > > and a bunch of other files, but couldn't isolate anything that I could > > "flip" to fix things in userspace. > > > > > > Any ideas or suggestions about the appropriate way to move forward would > > be much appreciated !!! > > > > > > Thanks much, > > --Gabriel > > I think changing ACPI is the right thing to > do really. But we'll need to fix some things > first of course. > > I think it's PC Q35 that has this assumption. > hw/i386/pc_q35.c > > gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, > GSI_NUM_PINS); > > kvm_pc_gsi_handler simply forwards interrupts to kvm. > > and > > hw/isa/lpc_ich9.c > static void ich9_lpc_update_pic(ICH9LPCState *lpc, int pic_irq) > { > int i, pic_level; > > /* The pic level is the logical OR of all the PCI irqs mapped to it */ > /* The pic level is the logical OR of all the PCI irqs mapped to it > * */ > pic_level = 0; > for (i = 0; i < ICH9_LPC_NB_PIRQS; i++) { > int tmp_irq; > int tmp_dis; > ich9_lpc_pic_irq(lpc, i, &tmp_irq, &tmp_dis); > if (!tmp_dis && pic_irq == tmp_irq) { > pic_level |= pci_bus_get_irq_level(lpc->d.bus, i); > } > } > > so somewhere we need to flip it, I am guessing in ich9 > along the lines of: > > - pic_level = 0; > - pic_level |= pci_bus_get_irq_level(lpc->d.bus, i); > + pic_level = 1; > + pic_level &= !pci_bus_get_irq_level(lpc->d.bus, i); I think now we're on to something! I managed to boot OS X on q35 with absolutely no kernel patches, but Linux still hated it ("irqXX: nobody cared"). At least now I know what I'm looking for, so I'll try to come up with a way to flip level-triggered polarity to ActiveLow across all of i386, in a way that works for Linux and Windows guests as well. Thanks again for getting me unstuck! --Gabriel