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 14:38:09 -0500 Message-ID: <20140217193808.GR29329@ERROL.INI.CMU.EDU> 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> <20140217175659.GP29329@ERROL.INI.CMU.EDU> <20140217180136.GQ29329@ERROL.INI.CMU.EDU> <53024F93.3040709@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Michael S. Tsirkin" , Alex Williamson , Alexander Graf , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" , "eddie.dong@intel.com" To: Paolo Bonzini Return-path: Received: from mail-qc0-f174.google.com ([209.85.216.174]:49201 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbaBQTj5 (ORCPT ); Mon, 17 Feb 2014 14:39:57 -0500 Received: by mail-qc0-f174.google.com with SMTP id x13so24456910qcv.33 for ; Mon, 17 Feb 2014 11:39:57 -0800 (PST) Content-Disposition: inline In-Reply-To: <53024F93.3040709@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Feb 17, 2014 at 07:06:11PM +0100, Paolo Bonzini wrote: > 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()): > > > >- 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? Oh, I think I'm starting to comprehend the problem here. The bits of "*irq_state" are indexed by "irq_source_id", which is dynamically assigned by kvm_request_irq_source_id(). So, doing the OR thing when assuming always-active-high makes sense. Doing AND based on an active-low assumption doesn't make sense, because there could ALWAYS be 0 bits that just weren't allocated (yet), and I'm having trouble imagining how I'd keep track of where the current allocation boundary is in a sane way :) Which I *think* was Michael's original point... --Gabriel