diff options
| -rw-r--r-- | arch/x86/kvm/vmx.c | 8 | ||||
| -rw-r--r-- | arch/x86/kvm/x86.c | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d205e9246f99..aff0f3ee6a1d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
| @@ -12435,7 +12435,7 @@ static inline int u64_shl_div_u64(u64 a, unsigned int shift, | |||
| 12435 | static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc) | 12435 | static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc) |
| 12436 | { | 12436 | { |
| 12437 | struct vcpu_vmx *vmx; | 12437 | struct vcpu_vmx *vmx; |
| 12438 | u64 tscl, guest_tscl, delta_tsc; | 12438 | u64 tscl, guest_tscl, delta_tsc, lapic_timer_advance_cycles; |
| 12439 | 12439 | ||
| 12440 | if (kvm_mwait_in_guest(vcpu->kvm)) | 12440 | if (kvm_mwait_in_guest(vcpu->kvm)) |
| 12441 | return -EOPNOTSUPP; | 12441 | return -EOPNOTSUPP; |
| @@ -12444,6 +12444,12 @@ static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc) | |||
| 12444 | tscl = rdtsc(); | 12444 | tscl = rdtsc(); |
| 12445 | guest_tscl = kvm_read_l1_tsc(vcpu, tscl); | 12445 | guest_tscl = kvm_read_l1_tsc(vcpu, tscl); |
| 12446 | delta_tsc = max(guest_deadline_tsc, guest_tscl) - guest_tscl; | 12446 | delta_tsc = max(guest_deadline_tsc, guest_tscl) - guest_tscl; |
| 12447 | lapic_timer_advance_cycles = nsec_to_cycles(vcpu, lapic_timer_advance_ns); | ||
| 12448 | |||
| 12449 | if (delta_tsc > lapic_timer_advance_cycles) | ||
| 12450 | delta_tsc -= lapic_timer_advance_cycles; | ||
| 12451 | else | ||
| 12452 | delta_tsc = 0; | ||
| 12447 | 12453 | ||
| 12448 | /* Convert to host delta tsc if tsc scaling is enabled */ | 12454 | /* Convert to host delta tsc if tsc scaling is enabled */ |
| 12449 | if (vcpu->arch.tsc_scaling_ratio != kvm_default_tsc_scaling_ratio && | 12455 | if (vcpu->arch.tsc_scaling_ratio != kvm_default_tsc_scaling_ratio && |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1d3dfc2c941d..93dd25d005a1 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -138,6 +138,7 @@ module_param(tsc_tolerance_ppm, uint, S_IRUGO | S_IWUSR); | |||
| 138 | /* lapic timer advance (tscdeadline mode only) in nanoseconds */ | 138 | /* lapic timer advance (tscdeadline mode only) in nanoseconds */ |
| 139 | unsigned int __read_mostly lapic_timer_advance_ns = 0; | 139 | unsigned int __read_mostly lapic_timer_advance_ns = 0; |
| 140 | module_param(lapic_timer_advance_ns, uint, S_IRUGO | S_IWUSR); | 140 | module_param(lapic_timer_advance_ns, uint, S_IRUGO | S_IWUSR); |
| 141 | EXPORT_SYMBOL_GPL(lapic_timer_advance_ns); | ||
| 141 | 142 | ||
| 142 | static bool __read_mostly vector_hashing = true; | 143 | static bool __read_mostly vector_hashing = true; |
| 143 | module_param(vector_hashing, bool, S_IRUGO); | 144 | module_param(vector_hashing, bool, S_IRUGO); |
