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 13:01:37 -0500 Message-ID: <20140217180136.GQ29329@ERROL.INI.CMU.EDU> References: <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> <20140217175659.GP29329@ERROL.INI.CMU.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alex Williamson , Alexander Graf , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , "eddie.dong@intel.com" , pbonzini@redhat.com To: "Michael S. Tsirkin" Return-path: Received: from mail-qa0-f42.google.com ([209.85.216.42]:36960 "EHLO mail-qa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752139AbaBQSDZ (ORCPT ); Mon, 17 Feb 2014 13:03:25 -0500 Received: by mail-qa0-f42.google.com with SMTP id k4so22294440qaq.15 for ; Mon, 17 Feb 2014 10:03:25 -0800 (PST) Content-Disposition: inline In-Reply-To: <20140217175659.GP29329@ERROL.INI.CMU.EDU> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Feb 17, 2014 at 12:57:00PM -0500, Gabriel L. Somlo wrote: > 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()): Make that rather: -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 AND for level trig interrupt, active-low */ + return !~(*irq_state); + } else { + /* Logical OR for level trig interrupt, active-high */ + return !!(*irq_state); + } } Thanks, and sorry for the noise :) --Gabriel