diff mbox

[2/8] KVM: move lapic timer ack to EOI handler

Message ID 20090706015812.572925843@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti July 6, 2009, 1:55 a.m. UTC
lapic timer is acked on interrupt injection, move it to EOI
handler.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff mbox

Patch

Index: kvm-new/arch/x86/kvm/lapic.c
===================================================================
--- kvm-new.orig/arch/x86/kvm/lapic.c
+++ kvm-new/arch/x86/kvm/lapic.c
@@ -427,6 +427,7 @@  int kvm_apic_compare_prio(struct kvm_vcp
 static void apic_set_eoi(struct kvm_lapic *apic)
 {
 	int vector = apic_find_highest_isr(apic);
+	int lvt_vector = apic_get_reg(apic, APIC_LVTT) & APIC_VECTOR_MASK;
 	int trigger_mode;
 	/*
 	 * Not every write EOI will has corresponding ISR,
@@ -435,6 +436,9 @@  static void apic_set_eoi(struct kvm_lapi
 	if (vector == -1)
 		return;
 
+	if (vector == lvt_vector)
+		kvm_timer_ack(&apic->lapic_timer);
+
 	apic_clear_vector(vector, apic->regs + APIC_ISR);
 	apic_update_ppr(apic);
 
@@ -982,10 +986,8 @@  void kvm_inject_apic_timer_irqs(struct k
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (apic && kvm_timer_has_pending(&apic->lapic_timer)) {
-		if (kvm_apic_local_deliver(apic, APIC_LVTT))
-			kvm_timer_ack(&apic->lapic_timer);
-	}
+	if (apic && kvm_timer_has_pending(&apic->lapic_timer))
+		kvm_apic_local_deliver(apic, APIC_LVTT);
 }
 
 int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)