aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/kvm_host.h2
-rw-r--r--arch/x86/kvm/lapic.c2
-rw-r--r--arch/x86/kvm/svm.c4
-rw-r--r--arch/x86/kvm/vmx.c5
-rw-r--r--arch/x86/kvm/x86.c5
5 files changed, 9 insertions, 9 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index b2e11f452435..d60535adec98 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -700,7 +700,7 @@ struct kvm_x86_ops {
700 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset); 700 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset);
701 701
702 u64 (*compute_tsc_offset)(struct kvm_vcpu *vcpu, u64 target_tsc); 702 u64 (*compute_tsc_offset)(struct kvm_vcpu *vcpu, u64 target_tsc);
703 u64 (*read_l1_tsc)(struct kvm_vcpu *vcpu); 703 u64 (*read_l1_tsc)(struct kvm_vcpu *vcpu, u64 host_tsc);
704 704
705 void (*get_exit_info)(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2); 705 void (*get_exit_info)(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2);
706 706
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 43e9fadca5d0..9392f527f107 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1011,7 +1011,7 @@ static void start_apic_timer(struct kvm_lapic *apic)
1011 local_irq_save(flags); 1011 local_irq_save(flags);
1012 1012
1013 now = apic->lapic_timer.timer.base->get_time(); 1013 now = apic->lapic_timer.timer.base->get_time();
1014 guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu); 1014 guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu, native_read_tsc());
1015 if (likely(tscdeadline > guest_tsc)) { 1015 if (likely(tscdeadline > guest_tsc)) {
1016 ns = (tscdeadline - guest_tsc) * 1000000ULL; 1016 ns = (tscdeadline - guest_tsc) * 1000000ULL;
1017 do_div(ns, this_tsc_khz); 1017 do_div(ns, this_tsc_khz);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index e93908fabf46..94f5ceba7e1e 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3005,11 +3005,11 @@ static int cr8_write_interception(struct vcpu_svm *svm)
3005 return 0; 3005 return 0;
3006} 3006}
3007 3007
3008u64 svm_read_l1_tsc(struct kvm_vcpu *vcpu) 3008u64 svm_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc)
3009{ 3009{
3010 struct vmcb *vmcb = get_host_vmcb(to_svm(vcpu)); 3010 struct vmcb *vmcb = get_host_vmcb(to_svm(vcpu));
3011 return vmcb->control.tsc_offset + 3011 return vmcb->control.tsc_offset +
3012 svm_scale_tsc(vcpu, native_read_tsc()); 3012 svm_scale_tsc(vcpu, host_tsc);
3013} 3013}
3014 3014
3015static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data) 3015static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 6599e45f73f6..896efd4842e7 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1839,11 +1839,10 @@ static u64 guest_read_tsc(void)
1839 * Like guest_read_tsc, but always returns L1's notion of the timestamp 1839 * Like guest_read_tsc, but always returns L1's notion of the timestamp
1840 * counter, even if a nested guest (L2) is currently running. 1840 * counter, even if a nested guest (L2) is currently running.
1841 */ 1841 */
1842u64 vmx_read_l1_tsc(struct kvm_vcpu *vcpu) 1842u64 vmx_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc)
1843{ 1843{
1844 u64 host_tsc, tsc_offset; 1844 u64 tsc_offset;
1845 1845
1846 rdtscll(host_tsc);
1847 tsc_offset = is_guest_mode(vcpu) ? 1846 tsc_offset = is_guest_mode(vcpu) ?
1848 to_vmx(vcpu)->nested.vmcs01_tsc_offset : 1847 to_vmx(vcpu)->nested.vmcs01_tsc_offset :
1849 vmcs_read64(TSC_OFFSET); 1848 vmcs_read64(TSC_OFFSET);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1dfe9d318734..1155059c512e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1150,7 +1150,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
1150 1150
1151 /* Keep irq disabled to prevent changes to the clock */ 1151 /* Keep irq disabled to prevent changes to the clock */
1152 local_irq_save(flags); 1152 local_irq_save(flags);
1153 tsc_timestamp = kvm_x86_ops->read_l1_tsc(v); 1153 tsc_timestamp = kvm_x86_ops->read_l1_tsc(v, native_read_tsc());
1154 kernel_ns = get_kernel_ns(); 1154 kernel_ns = get_kernel_ns();
1155 this_tsc_khz = __get_cpu_var(cpu_tsc_khz); 1155 this_tsc_khz = __get_cpu_var(cpu_tsc_khz);
1156 if (unlikely(this_tsc_khz == 0)) { 1156 if (unlikely(this_tsc_khz == 0)) {
@@ -5338,7 +5338,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5338 if (hw_breakpoint_active()) 5338 if (hw_breakpoint_active())
5339 hw_breakpoint_restore(); 5339 hw_breakpoint_restore();
5340 5340
5341 vcpu->arch.last_guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu); 5341 vcpu->arch.last_guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu,
5342 native_read_tsc());
5342 5343
5343 vcpu->mode = OUTSIDE_GUEST_MODE; 5344 vcpu->mode = OUTSIDE_GUEST_MODE;
5344 smp_wmb(); 5345 smp_wmb();