diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2017-11-17 06:52:50 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-11-27 11:32:53 -0500 |
commit | 12806ba937382fdfdbad62a399aa2dce65c10fcd (patch) | |
tree | 20498528e5a025aedf97ef2728259b054368ee90 | |
parent | e872fa94662d0644057c7c80b3071bdb9249e5ab (diff) |
KVM: lapic: Fixup LDR on load in x2apic
In x2apic mode the LDR is fixed based on the ID rather
than separately loadable like it was before x2.
When kvm_apic_set_state is called, the base is set, and if
it has the X2APIC_ENABLE flag set then the LDR is calculated;
however that value gets overwritten by the memcpy a few lines
below overwriting it with the value that came from userland.
The symptom is a lack of EOI after loading the state
(e.g. after a QEMU migration) and is due to the EOI bitmap
being wrong due to the incorrect LDR. This was seen with
a Win2016 guest under Qemu with irqchip=split whose USB mouse
didn't work after a VM migration.
This corresponds to RH bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1502591
Reported-by: Yiqian Wei <yiwei@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: stable@vger.kernel.org
[Applied fixup from Liran Alon. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/lapic.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index e2edb1103002..e2c1fb8d35ce 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -2250,6 +2250,7 @@ static int kvm_apic_state_fixup(struct kvm_vcpu *vcpu, | |||
2250 | { | 2250 | { |
2251 | if (apic_x2apic_mode(vcpu->arch.apic)) { | 2251 | if (apic_x2apic_mode(vcpu->arch.apic)) { |
2252 | u32 *id = (u32 *)(s->regs + APIC_ID); | 2252 | u32 *id = (u32 *)(s->regs + APIC_ID); |
2253 | u32 *ldr = (u32 *)(s->regs + APIC_LDR); | ||
2253 | 2254 | ||
2254 | if (vcpu->kvm->arch.x2apic_format) { | 2255 | if (vcpu->kvm->arch.x2apic_format) { |
2255 | if (*id != vcpu->vcpu_id) | 2256 | if (*id != vcpu->vcpu_id) |
@@ -2260,6 +2261,10 @@ static int kvm_apic_state_fixup(struct kvm_vcpu *vcpu, | |||
2260 | else | 2261 | else |
2261 | *id <<= 24; | 2262 | *id <<= 24; |
2262 | } | 2263 | } |
2264 | |||
2265 | /* In x2APIC mode, the LDR is fixed and based on the id */ | ||
2266 | if (set) | ||
2267 | *ldr = kvm_apic_calc_x2apic_ldr(*id); | ||
2263 | } | 2268 | } |
2264 | 2269 | ||
2265 | return 0; | 2270 | return 0; |