All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Avoid busy loops over uninjectable pending APIC timers
@ 2013-03-16 20:49 Jan Kiszka
  2013-03-17  8:47 ` Gleb Natapov
  0 siblings, 1 reply; 26+ messages in thread
From: Jan Kiszka @ 2013-03-16 20:49 UTC (permalink / raw)
  To: Gleb Natapov, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

If the guest didn't take the last APIC timer interrupt yet and generates
another one on top, e.g. via periodic mode, we do not block the VCPU
even if the guest state is halted. The reason is that
apic_has_pending_timer continues to return a non-zero value.

Fix this busy loop by taking the IRR content for the LVT vector in
apic_has_pending_timer into account.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Not a critical issue, we are looping fully interruptible, but it's ugly
to do so IMHO.

 arch/x86/kvm/lapic.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index a8e9369..658abf5 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1473,7 +1473,9 @@ int apic_has_pending_timer(struct kvm_vcpu *vcpu)
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
 	if (kvm_vcpu_has_lapic(vcpu) && apic_enabled(apic) &&
-			apic_lvt_enabled(apic, APIC_LVTT))
+	    apic_lvt_enabled(apic, APIC_LVTT) &&
+	    !apic_test_vector(apic_lvt_vector(apic, APIC_LVTT),
+					      apic->regs + APIC_IRR))
 		return atomic_read(&apic->lapic_timer.pending);
 
 	return 0;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-04-28 10:23 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-16 20:49 [PATCH] KVM: x86: Avoid busy loops over uninjectable pending APIC timers Jan Kiszka
2013-03-17  8:47 ` Gleb Natapov
2013-03-17 10:45   ` Jan Kiszka
2013-03-17 10:47     ` Gleb Natapov
2013-03-20 19:30       ` Marcelo Tosatti
2013-03-20 20:03         ` Marcelo Tosatti
2013-03-20 21:32           ` Gleb Natapov
2013-03-20 23:19             ` Marcelo Tosatti
2013-03-21  4:54               ` Gleb Natapov
2013-03-21 14:02                 ` Marcelo Tosatti
2013-03-21 14:18                   ` Gleb Natapov
2013-03-21 14:27                     ` Zhang, Yang Z
2013-03-21 16:27                       ` Gleb Natapov
2013-03-21 20:51                         ` Marcelo Tosatti
2013-03-21 21:13                           ` Gleb Natapov
2013-03-21 23:06                             ` Marcelo Tosatti
2013-03-22  1:50                               ` Zhang, Yang Z
2013-03-22  6:53                               ` Gleb Natapov
2013-03-22 10:43                                 ` Marcelo Tosatti
2013-03-22 11:19                                   ` Gleb Natapov
2013-03-24 10:45                                     ` Zhang, Yang Z
2013-03-24 19:03                                       ` Gleb Natapov
2013-04-28 10:15   ` Jan Kiszka
2013-04-28 10:19     ` Gleb Natapov
2013-04-28 10:20       ` Jan Kiszka
2013-04-28 10:23         ` Gleb Natapov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.