From 659972ebdaea70028f505ab63e88209937be6159 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 4 Mar 2008 10:44:51 +0200 Subject: [PATCH] --- yaml --- r: 93818 b: refs/heads/master c: 019960ae9933161c2809fa4ee608ba30d9639fd2 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/arch/x86/kvm/vmx.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 73920a6496bb..4731aeef586f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b8688d51bbe4872fbcec751e04369606082ac610 +refs/heads/master: 019960ae9933161c2809fa4ee608ba30d9639fd2 diff --git a/trunk/arch/x86/kvm/vmx.c b/trunk/arch/x86/kvm/vmx.c index 7ef710afceba..fb0389d3a8d1 100644 --- a/trunk/arch/x86/kvm/vmx.c +++ b/trunk/arch/x86/kvm/vmx.c @@ -519,7 +519,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); u64 phys_addr = __pa(vmx->vmcs); - u64 tsc_this, delta; + u64 tsc_this, delta, new_offset; if (vcpu->cpu != cpu) { vcpu_clear(vmx); @@ -559,8 +559,11 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) * Make sure the time stamp counter is monotonous. */ rdtscll(tsc_this); - delta = vcpu->arch.host_tsc - tsc_this; - vmcs_write64(TSC_OFFSET, vmcs_read64(TSC_OFFSET) + delta); + if (tsc_this < vcpu->arch.host_tsc) { + delta = vcpu->arch.host_tsc - tsc_this; + new_offset = vmcs_read64(TSC_OFFSET) + delta; + vmcs_write64(TSC_OFFSET, new_offset); + } } }