kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug in KVM clock backwards compensation
@ 2011-04-28  6:59 Zachary Amsden
  2011-04-28  7:06 ` Jan Kiszka
  2011-04-28  7:13 ` Roedel, Joerg
  0 siblings, 2 replies; 12+ messages in thread
From: Zachary Amsden @ 2011-04-28  6:59 UTC (permalink / raw)
  To: kvm, Jan Kiszka, Joerg Roedel

So I've been going over the new code changes to the TSC related code and 
I don't like one particular set of changes.  In particular, here:

         kvm_x86_ops->vcpu_load(vcpu, cpu);
         if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) {
                 /* Make sure TSC doesn't go backwards */
                 s64 tsc_delta;
                 u64 tsc;

                 kvm_get_msr(vcpu, MSR_IA32_TSC, &tsc);
                 tsc_delta = !vcpu->arch.last_guest_tsc ? 0 :
                              tsc - vcpu->arch.last_guest_tsc;

                 if (tsc_delta < 0)
                         mark_tsc_unstable("KVM discovered backwards TSC");
                 if (check_tsc_unstable()) {
                         kvm_x86_ops->adjust_tsc_offset(vcpu, -tsc_delta);
                         vcpu->arch.tsc_catchup = 1;
                 }


The point of this code fragment is to test the host clock to see if it 
is stable, because we may have just come back from an idle phase which 
stopped the TSC, switched CPUs, or come back from a deep sleep state 
which reset the host TSC.

However, the above code is fetching the guest TSC instead of the host 
TSC, which isn't the way it is supposed to work.

I saw a patch floating around that touched this code recently, but I 
think there's a definite issue here that needs addressing.

Zach

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

end of thread, other threads:[~2011-04-29 18:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28  6:59 Bug in KVM clock backwards compensation Zachary Amsden
2011-04-28  7:06 ` Jan Kiszka
2011-04-28  7:22   ` Roedel, Joerg
2011-04-28 19:06     ` Zachary Amsden
2011-04-28 22:38       ` Jan Kiszka
2011-04-28 17:48   ` Zachary Amsden
2011-04-28  7:13 ` Roedel, Joerg
2011-04-28 18:34   ` Zachary Amsden
2011-04-28 20:20     ` Joerg Roedel
2011-04-29  3:00       ` Zachary Amsden
2011-04-29  8:40         ` Joerg Roedel
2011-04-29 18:17           ` Zachary Amsden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).