From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: [PATCH RFC] kvm: ignore apic polarity Date: Thu, 27 Feb 2014 19:05:49 +0200 Message-ID: <20140227170549.GA23037@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> <20140216114151.GB30056@redhat.com> <1392562020.15608.437.camel@ul30vt.home> <20140216162300.GI30056@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "kvm@vger.kernel.org" , "eddie.dong@intel.com" , Alexander Graf , "qemu-devel@nongnu.org" , "Gabriel L. Somlo" , pbonzini@redhat.com To: Alex Williamson Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbaB0R7y (ORCPT ); Thu, 27 Feb 2014 12:59:54 -0500 Content-Disposition: inline In-Reply-To: <20140216162300.GI30056@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- Gabriel, could you confirm this fixes OSX for you? If you can play with linux tweaking interrupt to active low, that would be very nice too: it's weekend here. diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 902f124..db29b27 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -674,6 +676,7 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_ARM_EL1_32BIT 93 #define KVM_CAP_SPAPR_MULTITCE 94 #define KVM_CAP_EXT_EMUL_CPUID 95 +#define KVM_CAP_X86_IOAPIC_POLARITY_IGNORED 96 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 2d68297..ad170b4 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -328,7 +328,6 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id, irq_level = __kvm_irq_line_state(&ioapic->irq_states[irq], irq_source_id, level); entry = ioapic->redirtbl[irq]; - irq_level ^= entry.fields.polarity; if (!irq_level) { ioapic->irr &= ~mask; ret = 1; From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJ5FU-0007oE-Oh for qemu-devel@nongnu.org; Thu, 27 Feb 2014 13:00:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJ5FO-0004KL-Q9 for qemu-devel@nongnu.org; Thu, 27 Feb 2014 12:59:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJ5FO-0004K7-Gq for qemu-devel@nongnu.org; Thu, 27 Feb 2014 12:59:50 -0500 Date: Thu, 27 Feb 2014 19:05:49 +0200 From: "Michael S. Tsirkin" Message-ID: <20140227170549.GA23037@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> <20140216114151.GB30056@redhat.com> <1392562020.15608.437.camel@ul30vt.home> <20140216162300.GI30056@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140216162300.GI30056@redhat.com> Subject: [Qemu-devel] [PATCH RFC] kvm: ignore apic polarity List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: "kvm@vger.kernel.org" , "eddie.dong@intel.com" , Alexander Graf , "qemu-devel@nongnu.org" , "Gabriel L. Somlo" , pbonzini@redhat.com 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 --- Gabriel, could you confirm this fixes OSX for you? If you can play with linux tweaking interrupt to active low, that would be very nice too: it's weekend here. diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 902f124..db29b27 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -674,6 +676,7 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_ARM_EL1_32BIT 93 #define KVM_CAP_SPAPR_MULTITCE 94 #define KVM_CAP_EXT_EMUL_CPUID 95 +#define KVM_CAP_X86_IOAPIC_POLARITY_IGNORED 96 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 2d68297..ad170b4 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -328,7 +328,6 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id, irq_level = __kvm_irq_line_state(&ioapic->irq_states[irq], irq_source_id, level); entry = ioapic->redirtbl[irq]; - irq_level ^= entry.fields.polarity; if (!irq_level) { ioapic->irr &= ~mask; ret = 1;