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>,
"eddie.dong@intel.com" <eddie.dong@intel.com>,
Alexander Graf <agraf@suse.de>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [PATCH RFC] kvm: ignore apic polarity
Date: Thu, 27 Feb 2014 23:30:55 +0100 [thread overview]
Message-ID: <530FBC9F.8080800@redhat.com> (raw)
In-Reply-To: <20140227214102.GG17184@ERROL.INI.CMU.EDU>
Il 27/02/2014 22:41, Gabriel L. Somlo ha scritto:
> On Thu, Feb 27, 2014 at 07:05:49PM +0200, Michael S. Tsirkin wrote:
>> apic polarity in KVM does not work: too many things assume active high.
>> Let's not pretend it works, let's just ignore polarity flag. If we ever
>> want to emulate it exactly, this will need a feature flag anyway.
>>
>> Also report this to userspace: this makes it
>> possible to report the interrupt active-low
>> in ACPI, this way we are closer to real hardware.
>>
>> This patch fixes OSX running on KVM.
>>
>> Reported-by: "Gabriel L. Somlo" <gsomlo@gmail.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>
>> ---
>>
>> Gabriel, could you confirm this fixes OSX for you?
>> If you can play with linux tweaking interrupt
>> to active low, that would be very nice too:
>> it's weekend here.
>
> With Fedora 20 Live x86_64:
>
> If all I do is 's/ActiveHigh/ActiveLow/' in hw/i386/[q36-]acpi-dsdt.dsl,
> but otherwise don't try to change how QEMU deals with "logical" vs.
> "physical" ioapic polarity, things work great. Printk's show polarity
> set to 1, but with the ignore-polarity patch things work fine.
>
> With normal (ActiveHigh) ACPI, printk reports polarity set to 0, and
> things *still* work exactly the same.
>
>
> So, the way I understand this (and I'm writing this mainly for myself,
> to make sure I understand correctly, so please kick me if I got it
> wrong), ACPI tells the guest OS how to configure "physical" ioapic polarity.
>
> With ActiveHigh, "physical" == "logical", i.e. "high" == "asserted"
> and "low" == "deasserted".
>
> With ActiveLow, "physical" == !"logical", so the other way around.
>
> QEMU being hard-coded to ActiveHigh is the moral equivalent of always
> sending the kernel (KVM) "logical" line states, rather than "physical"
> ones.
>
> Assuming KVM's userland clients are all coded for ActiveHigh, we can
> (should, for sanity's sake) just assume line states from userland are
> logical, and stop paying attention the polarity bits. That way,
> misbehaving guests [*] can configure their ioapics as they please, and
> things will just work OK regardless.
>
> As you pointed out earlier, even KVM itself already kind-of assumes
> ActiveHigh (e.g. in __kvm_irq_line_state(), which should be coded
> differently if ActiveLow were a serious possibility, and, BTW,
> irq_states[irq] would probably have to be initialized to all-1's if
> ActiveLow wre used, etc, etc).
This is a much better description. Can you turn it into a patch to
Documentation/virtual/kvm/api.txt and a more complete commit message?
Also, there is a problem in this: we definitely do not want to have
different ACPI tables for TCG vs. KVM. Have you guys tested what
happens with Linux guests + TCG if interrupts are declared active-low?
QEMU likely has many other places that hard-code active-high. One
approach could be to add a QOM property to the ioapic that is a bitmask
of which GSIs are active-low. The ioapic can consult it like this:
if (vector >= 0 && vector < IOAPIC_NUM_PINS) {
uint32_t mask = 1 << vector;
uint64_t entry = s->ioredtbl[vector];
if (entry & (1 << IOAPIC_LVT_POLARITY_SHIFT)) {
level = !level;
}
+ if (s->active_low_mask & (1 << vector)) {
+ level = !level;
+ }
if (((entry >> IOAPIC_LVT_TRIGGER_MODE_SHIFT) & 1) ==
IOAPIC_TRIGGER_LEVEL) {
/* level triggered */
etc. so that the two NOTs undo each other, making the input to QEMU's
ioapic also "logical" rather than "physical".
Paolo
next prev parent reply other threads:[~2014-02-27 22:30 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 [this message]
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=530FBC9F.8080800@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).