From patchwork Sat Mar 16 20:49:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 2282811 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B6DA4DF5B1 for ; Sat, 16 Mar 2013 20:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751568Ab3CPUtL (ORCPT ); Sat, 16 Mar 2013 16:49:11 -0400 Received: from mout.web.de ([212.227.17.11]:54515 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751068Ab3CPUtK (ORCPT ); Sat, 16 Mar 2013 16:49:10 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.56.37]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MWAwH-1UEz1x2321-00XrOg; Sat, 16 Mar 2013 21:49:08 +0100 Message-ID: <5144DAC3.7080401@web.de> Date: Sat, 16 Mar 2013 21:49:07 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Gleb Natapov , Marcelo Tosatti CC: kvm Subject: [PATCH] KVM: x86: Avoid busy loops over uninjectable pending APIC timers X-Enigmail-Version: 1.5.1 X-Provags-ID: V02:K0:iBfm30esNI7t6oVcSB6dw+nCjssLAG4QbZ29vIvzMDS RFmiBMPC17MkIIvV1p3GjEtlgGTpXCLd3uAA/iJGz9VRuOj/iG XDjAqHiRdgXl/YK1MxFwgq2DesJVv+QccK/GWNKFTL1JRNT1Bq 3/QxpGaKjLLRc3ecyMuuBCWi/+U+vbhcg5ozM4G4x/cNCvj4/I 25P8y4eNWrXWYFluzYpwg== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Jan Kiszka 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 --- 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;