]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - arch/x86/kvm/x86.c
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)
commitf25e656d31ad112612839edaded18920cafea3b1
treee88286a2bc521b4b86915e1519f5555a8576fb21
parent9ed96e87c5748de4c2807ef17e81287c7304186c
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