aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2008-03-04 03:44:51 -0500
committerAvi Kivity <avi@qumranet.com>2008-04-27 04:53:27 -0400
commit019960ae9933161c2809fa4ee608ba30d9639fd2 (patch)
treec4ded864dfd339a2c64451220d0866eba854b63c /arch/x86/kvm
parentb8688d51bbe4872fbcec751e04369606082ac610 (diff)
KVM: VMX: Don't adjust tsc offset forward
Most Intel hosts have a stable tsc, and playing with the offset only reduces accuracy. By limiting tsc offset adjustment only to forward updates, we effectively disable tsc offset adjustment on these hosts. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 7ef710afceba..fb0389d3a8d1 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -519,7 +519,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
519{ 519{
520 struct vcpu_vmx *vmx = to_vmx(vcpu); 520 struct vcpu_vmx *vmx = to_vmx(vcpu);
521 u64 phys_addr = __pa(vmx->vmcs); 521 u64 phys_addr = __pa(vmx->vmcs);
522 u64 tsc_this, delta; 522 u64 tsc_this, delta, new_offset;
523 523
524 if (vcpu->cpu != cpu) { 524 if (vcpu->cpu != cpu) {
525 vcpu_clear(vmx); 525 vcpu_clear(vmx);
@@ -559,8 +559,11 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
559 * Make sure the time stamp counter is monotonous. 559 * Make sure the time stamp counter is monotonous.
560 */ 560 */
561 rdtscll(tsc_this); 561 rdtscll(tsc_this);
562 delta = vcpu->arch.host_tsc - tsc_this; 562 if (tsc_this < vcpu->arch.host_tsc) {
563 vmcs_write64(TSC_OFFSET, vmcs_read64(TSC_OFFSET) + delta); 563 delta = vcpu->arch.host_tsc - tsc_this;
564 new_offset = vmcs_read64(TSC_OFFSET) + delta;
565 vmcs_write64(TSC_OFFSET, new_offset);
566 }
564 } 567 }
565} 568}
566 569