diff options
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 11 |
2 files changed, 4 insertions, 8 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 8a34fca6c572..b23682900f41 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -422,6 +422,7 @@ struct kvm_vcpu_arch { | |||
422 | u64 last_kernel_ns; | 422 | u64 last_kernel_ns; |
423 | u64 last_tsc_nsec; | 423 | u64 last_tsc_nsec; |
424 | u64 last_tsc_write; | 424 | u64 last_tsc_write; |
425 | u64 last_host_tsc; | ||
425 | bool tsc_catchup; | 426 | bool tsc_catchup; |
426 | bool tsc_always_catchup; | 427 | bool tsc_always_catchup; |
427 | s8 virtual_tsc_shift; | 428 | s8 virtual_tsc_shift; |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2a59f76d96f1..39a57dac884a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -2253,13 +2253,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
2253 | 2253 | ||
2254 | kvm_x86_ops->vcpu_load(vcpu, cpu); | 2254 | kvm_x86_ops->vcpu_load(vcpu, cpu); |
2255 | if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) { | 2255 | if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) { |
2256 | /* Make sure TSC doesn't go backwards */ | 2256 | s64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 : |
2257 | s64 tsc_delta; | 2257 | native_read_tsc() - vcpu->arch.last_host_tsc; |
2258 | u64 tsc; | ||
2259 | |||
2260 | tsc = kvm_x86_ops->read_l1_tsc(vcpu); | ||
2261 | tsc_delta = tsc - vcpu->arch.last_guest_tsc; | ||
2262 | |||
2263 | if (tsc_delta < 0) | 2258 | if (tsc_delta < 0) |
2264 | mark_tsc_unstable("KVM discovered backwards TSC"); | 2259 | mark_tsc_unstable("KVM discovered backwards TSC"); |
2265 | if (check_tsc_unstable()) { | 2260 | if (check_tsc_unstable()) { |
@@ -2282,7 +2277,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | |||
2282 | { | 2277 | { |
2283 | kvm_x86_ops->vcpu_put(vcpu); | 2278 | kvm_x86_ops->vcpu_put(vcpu); |
2284 | kvm_put_guest_fpu(vcpu); | 2279 | kvm_put_guest_fpu(vcpu); |
2285 | vcpu->arch.last_guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu); | 2280 | vcpu->arch.last_host_tsc = native_read_tsc(); |
2286 | } | 2281 | } |
2287 | 2282 | ||
2288 | static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, | 2283 | static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, |