From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: KVM: x86: reset lapic_timer.expired_tscdeadline at SET_LAPIC time Date: Fri, 17 Jun 2016 20:41:29 -0300 Message-ID: <20160617234126.GA24514@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Paolo Bonzini To: kvm-devel , Alan Jenkins Return-path: Received: from mx1.redhat.com ([209.132.183.28]:37285 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbcFQXmH (ORCPT ); Fri, 17 Jun 2016 19:42:07 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Alan Jenkins reports hang at https://bugzilla.redhat.com/show_bug.cgi?id=3D1337667. * APIC write: expiration =3D 1000. * LAPIC tsc deadline code sets timer to 1000-30. * Timer fires at 970. * Guest writes TSC=3Dw. Guest fails to VM-entry to process signal to perform "vmload" in userspace. Case 1: w > 970: Guest entry can be performed. Case 2: w < 970: Guest entry should not be performed because "An interrupt is generated when the logical processor=E2=80=99s time-stamp counter equals or excee= ds the target value in the IA32_TSC_DEADLINE MSR." Setting of APIC test resets all APIC state, including=20 any pending interrupts. Signed-off-by: Marcelo Tosatti diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ea306ad..89be6e9 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2991,6 +2991,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vc= pu *vcpu, { kvm_apic_post_state_restore(vcpu, s); update_cr8_intercept(vcpu); + vcpu->arch.apic->lapic_timer.expired_tscdeadline =3D 0; =20 return 0; }