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: Mon, 17 Feb 2014 12:57:00 -0500 Message-ID: <20140217175659.GP29329@ERROL.INI.CMU.EDU> 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" , Alex Williamson , pbonzini@redhat.com To: "Michael S. Tsirkin" Return-path: Content-Disposition: inline In-Reply-To: <20140216162300.GI30056@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On Sun, Feb 16, 2014 at 06:23:11PM +0200, Michael S. Tsirkin wrote: > Well there is a bigger issue: any interrupt with > multiple sources is broken. > > __kvm_irq_line_state does a logical OR of all sources, > before XOR with polarity. > > This makes no sense if polarity is active low. So, do you think something like this would make sense, to address active-low polarity in __kvm_irq_line_state ? (this would be independent of the subsequent xor in kvm_ioapic_set_irq()): -static inline int __kvm_irq_line_state(unsigned long *irq_state, +static inline int __kvm_irq_line_state(unsigned long *irq_state, int polarity, int irq_source_id, int level) { - /* Logical OR for level trig interrupt */ if (level) __set_bit(irq_source_id, irq_state); else __clear_bit(irq_source_id, irq_state); - return !!(*irq_state); + if (polarity) { + /* Logical OR for level trig interrupt, active-high */ + return !!(*irq_state); + } else { // active-low + /* Logical AND for level trig interrupt, active-low */ + return !~(*irq_state); + } } Thanks, --Gabriel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFST3-0007af-D9 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 12:59:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFSSv-0003AH-05 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 12:58:57 -0500 Received: from mail-qa0-x229.google.com ([2607:f8b0:400d:c00::229]:37113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFSSu-0003AD-R2 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 12:58:48 -0500 Received: by mail-qa0-f41.google.com with SMTP id w8so22530808qac.0 for ; Mon, 17 Feb 2014 09:58:48 -0800 (PST) Date: Mon, 17 Feb 2014 12:57:00 -0500 From: "Gabriel L. Somlo" Message-ID: <20140217175659.GP29329@ERROL.INI.CMU.EDU> 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: 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: "kvm@vger.kernel.org" , "eddie.dong@intel.com" , Alexander Graf , "qemu-devel@nongnu.org" , Alex Williamson , pbonzini@redhat.com On Sun, Feb 16, 2014 at 06:23:11PM +0200, Michael S. Tsirkin wrote: > Well there is a bigger issue: any interrupt with > multiple sources is broken. > > __kvm_irq_line_state does a logical OR of all sources, > before XOR with polarity. > > This makes no sense if polarity is active low. So, do you think something like this would make sense, to address active-low polarity in __kvm_irq_line_state ? (this would be independent of the subsequent xor in kvm_ioapic_set_irq()): -static inline int __kvm_irq_line_state(unsigned long *irq_state, +static inline int __kvm_irq_line_state(unsigned long *irq_state, int polarity, int irq_source_id, int level) { - /* Logical OR for level trig interrupt */ if (level) __set_bit(irq_source_id, irq_state); else __clear_bit(irq_source_id, irq_state); - return !!(*irq_state); + if (polarity) { + /* Logical OR for level trig interrupt, active-high */ + return !!(*irq_state); + } else { // active-low + /* Logical AND for level trig interrupt, active-low */ + return !~(*irq_state); + } } Thanks, --Gabriel