kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>, kvm@vger.kernel.org
Cc: mst@redhat.com, alex.williamson@redhat.com, eddie.dong@intel.com,
	agraf@suse.de, qemu-devel@nongnu.org
Subject: Re: [RFC PATCH v2] kvm: x86: ignore ioapic polarity
Date: Thu, 13 Mar 2014 11:53:04 +0100	[thread overview]
Message-ID: <53218E10.60503@redhat.com> (raw)
In-Reply-To: <20140228040617.GA22103@crash.ini.cmu.edu>

Il 28/02/2014 05:06, Gabriel L. Somlo ha scritto:
> +NOTE: For each level-triggered interrupt managed by a virtual ioapic,
> +the guest OS may set a polarity value (bit 13 of each corresponding I/O
> +redirection table register). The polarity bit defines the relationship
> +between an irq line's logical state (active/asserted = 1, inactive = 0)
> +and its physical state (high = 1, low = 0). When the polarity bit is 0
> +(ActiveHigh), logical and physical states are matched (active == high == 1,
> +inactive == low == 0). When polarity is set to 1 (ActiveLow), logical and
> +physical state are opposites (logical == !physical). Typically, guests are
> +expected to use the same polarity across all level-triggered interrupts,
> +as directed by ACPI. Historically, both KVM and QEMU have accumulated a
> +significant number of optimizations based on the hard-coded assumption
> +that polarity will always be set to ActiveHigh. When interfacing with KVM,
> +QEMU will use the ActiveHigh convention for all level-triggered irqs,
> +regardless of how the guest OS has configured the polarity bits in the
> +ioapic registers. As such, KVM must also ignore these bits, and always act
> +as if the logical and physical states of an irq line exactly match each
> +other (i.e., follow the ActiveHigh convention regardless of polarity).
> +

Instead of this, I'm adding the following to the KVM_IRQ_LINE ioctl:

+On real hardware, interrupt pins can be active-low or active-high.  This
+does not matter for the level field of struct kvm_irq_level: 1 always
+means active (asserted), 0 means inactive (deasserted).
+
+x86 allows the operating system to program the interrupt polarity
+(active-low/active-high) for level-triggered interrupts, and KVM used
+to consider the polarity.  However, due to bitrot in the handling of
+active-low interrupts, the above convention is now valid on x86 too.
+This is signaled by KVM_CAP_X86_IOAPIC_POLARITY_IGNORED.  Userspace
+should not present interrupts to the guest as active-low unless this
+capability is present (or unless it is not using the in-kernel irqchip,
+of course).

and applying the patch to kvm/queue.

Paolo

  parent reply	other threads:[~2014-03-13 10:53 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
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 [this message]
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=53218E10.60503@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).