summaryrefslogtreecommitdiffstats
path: root/kernel/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorJiang, Yunhong <yunhong.jiang@intel.com>2016-07-21 17:36:30 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-07-21 17:36:30 +0000
commit2c4b40f9829b14aa9bf12338f39d4e93474c7c77 (patch)
tree4c96faea090807f62f2a97d881f46b0b4ea1d83c /kernel/arch/x86/kvm/vmx.c
parent4463d0ee0febf49c4291962c8326301e3efd27f6 (diff)
parent6443c73ab06239ab4b1bc0511d9b78f7122f477d (diff)
Merge "KVM: vmx: fix underflow in TSC deadline calculation"
Diffstat (limited to 'kernel/arch/x86/kvm/vmx.c')
-rw-r--r--kernel/arch/x86/kvm/vmx.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/kernel/arch/x86/kvm/vmx.c b/kernel/arch/x86/kvm/vmx.c
index e378975f5..5da019be6 100644
--- a/kernel/arch/x86/kvm/vmx.c
+++ b/kernel/arch/x86/kvm/vmx.c
@@ -10663,9 +10663,9 @@ static inline int u64_shl_div_u64(u64 a, unsigned int shift,
static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
- u64 tscl = rdtsc(), delta_tsc;
-
- delta_tsc = guest_deadline_tsc - kvm_read_l1_tsc(vcpu, tscl);
+ u64 tscl = rdtsc();
+ u64 guest_tscl = kvm_read_l1_tsc(vcpu, tscl);
+ u64 delta_tsc = max(guest_deadline_tsc, guest_tscl) - guest_tscl;
/* Convert to host delta tsc if tsc scaling is enabled */
if (vcpu->arch.tsc_scaling_ratio != kvm_default_tsc_scaling_ratio &&