From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4AOC-0007kX-6z for qemu-devel@nongnu.org; Thu, 15 Sep 2011 07:46:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4AOA-00058C-Q3 for qemu-devel@nongnu.org; Thu, 15 Sep 2011 07:45:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4AOA-000586-Gc for qemu-devel@nongnu.org; Thu, 15 Sep 2011 07:45:54 -0400 Date: Thu, 15 Sep 2011 08:45:31 -0300 From: Marcelo Tosatti Message-ID: <20110915114531.GA5817@amt.cnet> References: <20110914114530.GA20351@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 1/2] KVM: emulate lapic tsc deadline timer for guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Liu, Jinsong" Cc: "Tian, Kevin" , Avi Kivity , "kvm@vger.kernel.org" , "qemu-devel@nongnu.org" On Thu, Sep 15, 2011 at 04:17:20PM +0800, Liu, Jinsong wrote: > Marcelo Tosatti wrote: > >> + } else if (apic_lvtt_tscdeadline(apic)) { > >> + /* lapic timer in tsc deadline mode */ > >> + u64 guest_tsc, guest_tsc_delta, ns = 0; > >> + struct kvm_vcpu *vcpu = apic->vcpu; > >> + unsigned long this_tsc_khz = vcpu_tsc_khz(vcpu); + unsigned long > >> flags; + > >> + if (unlikely(!apic->lapic_timer.tscdeadline || !this_tsc_khz)) > >> + return; + > >> + local_irq_save(flags); > >> + > >> + now = apic->lapic_timer.timer.base->get_time(); > >> + kvm_get_msr(vcpu, MSR_IA32_TSC, &guest_tsc); > > > > Use kvm_x86_ops->read_l1_tsc(vcpu) instead of direct MSR read > > (to avoid reading L2 guest TSC in case of nested virt). > > > >> + guest_tsc_delta = apic->lapic_timer.tscdeadline - guest_tsc; > > > > if (guest_tsc <= tscdeadline), the timer should start immediately. > > > > Yes, under such case the timer does start immediately, with ns = 0 No, guest_tsc_delta is unsigned, so the "< 0" comparation fails.