From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: RFC: ioapic polarity vs. qemu os-x guest Date: Mon, 17 Feb 2014 19:06:11 +0100 Message-ID: <53024F93.3040709@redhat.com> 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> <20140217180136.GQ29329@ERROL.INI.CMU.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Alex Williamson , Alexander Graf , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , "eddie.dong@intel.com" To: "Gabriel L. Somlo" , "Michael S. Tsirkin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:65065 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752815AbaBQSrr (ORCPT ); Mon, 17 Feb 2014 13:47:47 -0500 In-Reply-To: <20140217180136.GQ29329@ERROL.INI.CMU.EDU> Sender: kvm-owner@vger.kernel.org List-ID: Il 17/02/2014 19:01, Gabriel L. Somlo ha scritto: > 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); This is ~*irq_state == 0, i.e. *irq_state == ~0. What if high-order bits of *irq_state are never used? That is, do you need to consider the maximum valid irq_source_id too? > + } else { > + /* Logical OR for level trig interrupt, active-high */ > + return !!(*irq_state); Better rewrite this as *irq_state != 0. Paolo > + } > } > > Thanks, and sorry for the noise :) > --Gabriel >