Code Review
/
kvmfornfv.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
KVM: vmx: fix underflow in TSC deadline calculation
[kvmfornfv.git]
/
kernel
/
arch
/
x86
/
kvm
/
vmx.c
diff --git
a/kernel/arch/x86/kvm/vmx.c
b/kernel/arch/x86/kvm/vmx.c
index
e378975
..
5da019b
100644
(file)
--- 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);
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 &&
/* Convert to host delta tsc if tsc scaling is enabled */
if (vcpu->arch.tsc_scaling_ratio != kvm_default_tsc_scaling_ratio &&