]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: fix tsc catchup issue with tsc scaling
authorMarcelo Tosatti <mtosatti@redhat.com>
Mon, 6 Jan 2014 14:18:59 +0000 (12:18 -0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 15 Jan 2014 12:44:46 +0000 (13:44 +0100)
commit56c6d470988bd8bcdf69608e9c717d17da6fa6bf
treee88286a2bc521b4b86915e1519f5555a8576fb21
parente123dc61632ed94bba9b8c7df71985a9b30b09b7
KVM: x86: fix tsc catchup issue with tsc scaling

To fix a problem related to different resolution of TSC and system clock,
the offset in TSC units is approximated by

delta = vcpu->hv_clock.tsc_timestamp  -  vcpu->last_guest_tsc

(Guest TSC value at  (Guest TSC value at last VM-exit)
the last kvm_guest_time_update
call)

Delta is then later scaled using mult,shift pair found in hv_clock
structure (which is correct against tsc_timestamp in that
structure).

However, if a frequency change is performed between these two points,
this delta is measured using different TSC frequencies, but scaled using
mult,shift pair for one frequency only.

The end result is an incorrect delta.

The bug which this code works around is not the only cause for
clock backwards events. The global accumulator is still
necessary, so remove the max_kernel_ns fix and rely on the
global accumulator for no clock backwards events.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c