From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Steve Rutherford <srutherford@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: x86: fix edge EOI and IOAPIC reconfig race
Date: Fri, 14 Aug 2015 10:38:58 +0200 [thread overview]
Message-ID: <20150814083857.GA2492@potion.redhat.com> (raw)
In-Reply-To: <55CCAF5D.8050204@redhat.com>
2015-08-13 16:53+0200, Paolo Bonzini:
> On 13/08/2015 15:46, Radim Krčmář wrote:
>> 1) IOAPIC inject a vector from i8254
>> 2) guest reconfigures that vector's VCPU and therefore eoi_exit_bitmap
>> on original VCPU gets cleared
>> 3) guest's handler for the vector does EOI
>> 4) KVM's EOI handler doesn't pass that vector to IOAPIC because it is
>> not in that VCPU's eoi_exit_bitmap
>> 5) i8254 stops working
>>
>> This creates an unwanted situation if the vector is reused by a
>> non-IOAPIC source, but I think it is so rare that we don't want to make
>> the solution more sophisticated.
>
> What happens if the vector is changed in step 2?
> __kvm_ioapic_update_eoi won't match the redirection table entry.
Yes, the EOI is going to be ignored. (With APICv, VMX won't even exit.)
In the patch, I dissmissed it as "shouldn't happen in the wild" because
we've always had the vector-change bug :) (Unlike the destination-change
one, which was APICv-only before recent changes.)
A simple solution to the vector-change would have a list of one-time
fixups (vector, *ioapic) and hooks in ioapic reconfig, scan and EOI.
A complex solution would replace ioapic scanning with an array of list
of ioapics (it needs to be a list or small array because vectors can be
shared).
An ioapic would be added to list[vector] on reconfig and removed on
reconfig unless an edge fixup was needed, then it would last til next
EOI (I guess we won't need to consider vector in IRR and ISR).
Callbacks would update the eoi_exit_bitmap on relevant changes.
I considered doing the complex one, but then it occured to me that we
want the destination-change fixed in stable as APICv machines are
starting to get used and people might migrate old guests on them.
> How do you reproduce the bug?
I run rhel4 (2.6.9) kernel on 2 VCPUs and frequently alternate
smp_affinity of "timer". The bug is hit within seconds.
next prev parent reply other threads:[~2015-08-14 8:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 13:46 [PATCH 0/2] KVM: x86: fix edge EOI and IOAPIC reconfig race Radim Krčmář
2015-08-13 13:46 ` [PATCH 1/2] KVM: x86: return bool from x86_ops.sync_pir_to_irr Radim Krčmář
2015-08-13 13:46 ` [PATCH 2/2] KVM: x86: fix edge EOI and IOAPIC reconfig race Radim Krčmář
2015-08-13 14:53 ` Paolo Bonzini
2015-08-14 8:38 ` Radim Krčmář [this message]
2015-08-15 0:00 ` Paolo Bonzini
2015-10-06 20:33 ` Radim Krčmář
2015-10-07 9:31 ` Paolo Bonzini
2015-10-07 15:05 ` Radim Krčmář
2015-10-07 9:29 ` Paolo Bonzini
2015-10-07 15:01 ` Radim Krčmář
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=20150814083857.GA2492@potion.redhat.com \
--to=rkrcmar@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=srutherford@google.com \
--cc=stable@vger.kernel.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).