From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH RFC] kvm: ignore apic polarity Date: Fri, 28 Feb 2014 00:31:27 +0100 Message-ID: <530FCACF.40100@redhat.com> References: <20140214211311.GH29329@ERROL.INI.CMU.EDU> <20140214220600.GI29329@ERROL.INI.CMU.EDU> <2CEB9F8C-E983-4182-A514-44EC568E18D8@suse.de> <20140216114151.GB30056@redhat.com> <1392562020.15608.437.camel@ul30vt.home> <20140216162300.GI30056@redhat.com> <20140227170549.GA23037@redhat.com> <20140227214102.GG17184@ERROL.INI.CMU.EDU> <530FBC9F.8080800@redhat.com> <20140227231312.GH17184@ERROL.INI.CMU.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Michael S. Tsirkin" , Alex Williamson , "kvm@vger.kernel.org" , "eddie.dong@intel.com" , Alexander Graf , "qemu-devel@nongnu.org" To: "Gabriel L. Somlo" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:30589 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbaB0Xbh (ORCPT ); Thu, 27 Feb 2014 18:31:37 -0500 In-Reply-To: <20140227231312.GH17184@ERROL.INI.CMU.EDU> Sender: kvm-owner@vger.kernel.org List-ID: Il 28/02/2014 00:13, Gabriel L. Somlo ha scritto: > On Thu, Feb 27, 2014 at 11:30:55PM +0100, Paolo Bonzini wrote: >> Il 27/02/2014 22:41, Gabriel L. Somlo ha scritto: >>> On Thu, Feb 27, 2014 at 07:05:49PM +0200, Michael S. Tsirkin wrote: >>>> apic polarity in KVM does not work: too many things assume active high. >>>> Let's not pretend it works, let's just ignore polarity flag. If we ever >>>> want to emulate it exactly, this will need a feature flag anyway. >>>> >>>> Also report this to userspace: this makes it >>>> possible to report the interrupt active-low >>>> in ACPI, this way we are closer to real hardware. >>>> >>>> This patch fixes OSX running on KVM. >>>> >>>> Reported-by: "Gabriel L. Somlo" >>>> Signed-off-by: Michael S. Tsirkin >>>> >>>> --- >>> >>> So, the way I understand this (and I'm writing this mainly for myself, >>> to make sure I understand correctly, so please kick me if I got it >>> wrong), ACPI tells the guest OS how to configure "physical" ioapic polarity. >>> >>> With ActiveHigh, "physical" == "logical", i.e. "high" == "asserted" >>> and "low" == "deasserted". >>> >>> With ActiveLow, "physical" == !"logical", so the other way around. >>> >>> QEMU being hard-coded to ActiveHigh is the moral equivalent of always >>> sending the kernel (KVM) "logical" line states, rather than "physical" >>> ones. >>> >>> Assuming KVM's userland clients are all coded for ActiveHigh, we can >>> (should, for sanity's sake) just assume line states from userland are >>> logical, and stop paying attention the polarity bits. That way, >>> misbehaving guests [*] can configure their ioapics as they please, and >>> things will just work OK regardless. >>> >>> As you pointed out earlier, even KVM itself already kind-of assumes >>> ActiveHigh (e.g. in __kvm_irq_line_state(), which should be coded >>> differently if ActiveLow were a serious possibility, and, BTW, >>> irq_states[irq] would probably have to be initialized to all-1's if >>> ActiveLow wre used, etc, etc). >> >> This is a much better description. Can you turn it into a patch to >> Documentation/virtual/kvm/api.txt and a more complete commit >> message? > > Do you mean one patch to change both virt/kvm/ioapic.c and > Documentation/virtual/kvm/api.txt ? Or a separate documentation patch ? > (sorry for my ignorance, I'm new to being a KVM contributor :) ) Yes. > I think removing the polarity xor from KVM is about giving up on > trying to add ActiveLow support to QEMU altogether. What I tested > was what would happen if Linux (which pays attention to ACPI) were > told to use ActiveLow, but thre rest of QEMU continued being hardcoded > as ActiveHigh. Basically, another datapoint similar to what happens > with OS X, which completely ignores ACPI and configures the ioapic as > ActiveLow (even while running on ActiveHigh "hardware", i.e. QEMU). > > With KVM no longer paying attention to the polarity bit, things work > fine, both with Linux-thinking-it's-ActiveLow, and with OS X. > > But, since QEMU will stay ActiveHigh, I don't think TCG will be > impacted in any way by this change. If you change ACPI tables to ActiveLow, and leave the polarity inversion in hw/intc/ioapic.c, then it will matter. > (Hmmm, maybe this one of the reasons I never got OS X to boot without > -enable-kvm... I should look at the QEMU hw/intc/ioapic*.c, and see if > *it* cares about guest-configured polarity, and maybe get it to *stop* > caring :) Exactly my point. :) Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJAQX-0003gi-Ga for qemu-devel@nongnu.org; Thu, 27 Feb 2014 18:31:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJAQR-00056P-H0 for qemu-devel@nongnu.org; Thu, 27 Feb 2014 18:31:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9110) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJAQR-00055Z-8Z for qemu-devel@nongnu.org; Thu, 27 Feb 2014 18:31:35 -0500 Message-ID: <530FCACF.40100@redhat.com> Date: Fri, 28 Feb 2014 00:31:27 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20140214211311.GH29329@ERROL.INI.CMU.EDU> <20140214220600.GI29329@ERROL.INI.CMU.EDU> <2CEB9F8C-E983-4182-A514-44EC568E18D8@suse.de> <20140216114151.GB30056@redhat.com> <1392562020.15608.437.camel@ul30vt.home> <20140216162300.GI30056@redhat.com> <20140227170549.GA23037@redhat.com> <20140227214102.GG17184@ERROL.INI.CMU.EDU> <530FBC9F.8080800@redhat.com> <20140227231312.GH17184@ERROL.INI.CMU.EDU> In-Reply-To: <20140227231312.GH17184@ERROL.INI.CMU.EDU> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC] kvm: ignore apic polarity List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gabriel L. Somlo" Cc: "kvm@vger.kernel.org" , "Michael S. Tsirkin" , "eddie.dong@intel.com" , "qemu-devel@nongnu.org" , Alexander Graf , Alex Williamson Il 28/02/2014 00:13, Gabriel L. Somlo ha scritto: > On Thu, Feb 27, 2014 at 11:30:55PM +0100, Paolo Bonzini wrote: >> Il 27/02/2014 22:41, Gabriel L. Somlo ha scritto: >>> On Thu, Feb 27, 2014 at 07:05:49PM +0200, Michael S. Tsirkin wrote: >>>> apic polarity in KVM does not work: too many things assume active high. >>>> Let's not pretend it works, let's just ignore polarity flag. If we ever >>>> want to emulate it exactly, this will need a feature flag anyway. >>>> >>>> Also report this to userspace: this makes it >>>> possible to report the interrupt active-low >>>> in ACPI, this way we are closer to real hardware. >>>> >>>> This patch fixes OSX running on KVM. >>>> >>>> Reported-by: "Gabriel L. Somlo" >>>> Signed-off-by: Michael S. Tsirkin >>>> >>>> --- >>> >>> So, the way I understand this (and I'm writing this mainly for myself, >>> to make sure I understand correctly, so please kick me if I got it >>> wrong), ACPI tells the guest OS how to configure "physical" ioapic polarity. >>> >>> With ActiveHigh, "physical" == "logical", i.e. "high" == "asserted" >>> and "low" == "deasserted". >>> >>> With ActiveLow, "physical" == !"logical", so the other way around. >>> >>> QEMU being hard-coded to ActiveHigh is the moral equivalent of always >>> sending the kernel (KVM) "logical" line states, rather than "physical" >>> ones. >>> >>> Assuming KVM's userland clients are all coded for ActiveHigh, we can >>> (should, for sanity's sake) just assume line states from userland are >>> logical, and stop paying attention the polarity bits. That way, >>> misbehaving guests [*] can configure their ioapics as they please, and >>> things will just work OK regardless. >>> >>> As you pointed out earlier, even KVM itself already kind-of assumes >>> ActiveHigh (e.g. in __kvm_irq_line_state(), which should be coded >>> differently if ActiveLow were a serious possibility, and, BTW, >>> irq_states[irq] would probably have to be initialized to all-1's if >>> ActiveLow wre used, etc, etc). >> >> This is a much better description. Can you turn it into a patch to >> Documentation/virtual/kvm/api.txt and a more complete commit >> message? > > Do you mean one patch to change both virt/kvm/ioapic.c and > Documentation/virtual/kvm/api.txt ? Or a separate documentation patch ? > (sorry for my ignorance, I'm new to being a KVM contributor :) ) Yes. > I think removing the polarity xor from KVM is about giving up on > trying to add ActiveLow support to QEMU altogether. What I tested > was what would happen if Linux (which pays attention to ACPI) were > told to use ActiveLow, but thre rest of QEMU continued being hardcoded > as ActiveHigh. Basically, another datapoint similar to what happens > with OS X, which completely ignores ACPI and configures the ioapic as > ActiveLow (even while running on ActiveHigh "hardware", i.e. QEMU). > > With KVM no longer paying attention to the polarity bit, things work > fine, both with Linux-thinking-it's-ActiveLow, and with OS X. > > But, since QEMU will stay ActiveHigh, I don't think TCG will be > impacted in any way by this change. If you change ACPI tables to ActiveLow, and leave the polarity inversion in hw/intc/ioapic.c, then it will matter. > (Hmmm, maybe this one of the reasons I never got OS X to boot without > -enable-kvm... I should look at the QEMU hw/intc/ioapic*.c, and see if > *it* cares about guest-configured polarity, and maybe get it to *stop* > caring :) Exactly my point. :) Paolo