[Xenial,SRU] kvm: x86: correctly reset dest_map->vector when restoring LAPIC state

Message ID 1488285761-16912-2-git-send-email-f.gruenbichler@proxmox.com
State New
Headers show

Commit Message

Fabian Grünbichler Feb. 28, 2017, 12:42 p.m.
From: Paolo Bonzini <pbonzini@redhat.com>

BugLink: http://bugs.launchpad.net/bugs/1668594

When userspace sends KVM_SET_LAPIC, KVM schedules a check between
the vCPU's IRR and ISR and the IOAPIC redirection table, in order
to re-establish the IOAPIC's dest_map (the list of CPUs servicing
the real-time clock interrupt with the corresponding vectors).

However, __rtc_irq_eoi_tracking_restore_one was forgetting to
set dest_map->vectors.  Because of this, the IOAPIC did not process
the real-time clock interrupt EOI, ioapic->rtc_status.pending_eoi
got stuck at a non-zero value, and further RTC interrupts were
reported to userspace as coalesced.

Fixes: 9e4aabe2bb3454c83dac8139cf9974503ee044db
Fixes: 4d99ba898dd0c521ca6cdfdde55c9b58aea3cb3d
Cc: stable@vger.kernel.org
Cc: Joerg Roedel <jroedel@suse.de>
Cc: David Gilbert <dgilbert@redhat.com>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit b0eaf4506f5f95d15d6731d72c0ddf4a2179eefa)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
 arch/x86/kvm/ioapic.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)


Stefan Bader Feb. 28, 2017, 2:55 p.m. | #1
More a note to ourself, this is required but has not come as upstream stable
because the changes introducing this had been picked to solve a different problem.



diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 4861e6e..ec62df3 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -109,6 +109,7 @@  static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
 	bool new_val, old_val;
 	struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
+	struct dest_map *dest_map = &ioapic->rtc_status.dest_map;
 	union kvm_ioapic_redirect_entry *e;
 	e = &ioapic->redirtbl[RTC_GSI];
@@ -117,16 +118,17 @@  static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
 	new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector);
-	old_val = test_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map);
+	old_val = test_bit(vcpu->vcpu_id, dest_map->map);
 	if (new_val == old_val)
 	if (new_val) {
-		__set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map);
+		__set_bit(vcpu->vcpu_id, dest_map->map);
+		dest_map->vectors[vcpu->vcpu_id] = e->fields.vector;
 	} else {
-		__clear_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map);
+		__clear_bit(vcpu->vcpu_id, dest_map->map);