kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"eddie.dong@intel.com" <eddie.dong@intel.com>
Subject: Re: RFC: ioapic polarity vs. qemu os-x guest
Date: Mon, 17 Feb 2014 19:06:11 +0100	[thread overview]
Message-ID: <53024F93.3040709@redhat.com> (raw)
In-Reply-To: <20140217180136.GQ29329@ERROL.INI.CMU.EDU>

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
>


  reply	other threads:[~2014-02-17 18:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140130204423.GK29329@ERROL.INI.CMU.EDU>
2014-02-11 18:23 ` RFC: ioapic polarity vs. qemu os-x guest Gabriel L. Somlo
2014-02-11 19:54   ` Michael S. Tsirkin
2014-02-11 21:35     ` Gabriel L. Somlo
2014-02-14 21:13     ` Gabriel L. Somlo
2014-02-14 21:21       ` Alexander Graf
2014-02-14 22:06         ` Gabriel L. Somlo
2014-02-14 22:13           ` Alexander Graf
2014-02-16 11:18             ` Michael S. Tsirkin
2014-02-16 11:41             ` Michael S. Tsirkin
2014-02-16 14:47               ` Alex Williamson
2014-02-16 16:23                 ` Michael S. Tsirkin
2014-02-17 17:57                   ` Gabriel L. Somlo
2014-02-17 18:01                     ` Gabriel L. Somlo
2014-02-17 18:06                       ` Paolo Bonzini [this message]
2014-02-17 19:38                         ` Gabriel L. Somlo
2014-02-18  0:58                           ` Gabriel L. Somlo
2014-02-27 17:05                   ` [PATCH RFC] kvm: ignore apic polarity Michael S. Tsirkin
2014-02-27 21:41                     ` Gabriel L. Somlo
2014-02-27 22:30                       ` Paolo Bonzini
2014-02-27 23:13                         ` Gabriel L. Somlo
2014-02-27 23:31                           ` Paolo Bonzini
2014-02-28  4:06                             ` [RFC PATCH v2] kvm: x86: ignore ioapic polarity Gabriel L. Somlo
2014-03-02 14:55                               ` Michael S. Tsirkin
2014-03-13 10:53                               ` Paolo Bonzini
2014-03-13 13:43                                 ` Gabriel L. Somlo
2014-02-28  4:55                         ` [PATCH RFC] kvm: ignore apic polarity Michael S. Tsirkin
2014-02-28  8:10                           ` Paolo Bonzini
2014-02-28  8:11                           ` Paolo Bonzini
2014-03-01  5:03                     ` Alex Williamson
2014-02-16 11:34       ` RFC: ioapic polarity vs. qemu os-x guest Michael S. Tsirkin
2014-02-16 15:12         ` [Qemu-devel] " Peter Maydell
2014-02-16 11:37       ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53024F93.3040709@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=eddie.dong@intel.com \
    --cc=gsomlo@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).