From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v2] KVM: x86: reset lapic_timer.expired_tscdeadline at SET_LAPIC time Date: Tue, 21 Jun 2016 09:50:54 +0200 Message-ID: References: <20160617234126.GA24514@amt.cnet> <6bc78368-d559-fa09-7e77-389b0e87d695@gmail.com> <20160620130531.GA8139@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: kvm-devel To: Marcelo Tosatti , Alan Jenkins Return-path: Received: from mail-lb0-f196.google.com ([209.85.217.196]:33024 "EHLO mail-lb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754576AbcFUHu5 (ORCPT ); Tue, 21 Jun 2016 03:50:57 -0400 Received: by mail-lb0-f196.google.com with SMTP id o4so827484lbp.0 for ; Tue, 21 Jun 2016 00:50:57 -0700 (PDT) In-Reply-To: <20160620130531.GA8139@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 20/06/2016 15:05, Marcelo Tosatti wrote: > > 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_vcpu *vcpu, > { > kvm_apic_post_state_restore(vcpu, s); > update_cr8_intercept(vcpu); > + vcpu->arch.apic->lapic_timer.expired_tscdeadline = 0; > I think this is not correct. You have programmed the host timer to an early value when kvm_apic_post_state_restore called start_apic_timer. I think that: 1) post_state_restore should cancel the timer and clear lapic_timer.pending before writing the registers, not afterwards. lapic_timer.expired_tscdeadline can be cleared at the same time. 2) kvm_write_tsc should do the same and restart the timer afterwards. Thanks, Paolo