aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/kvm/irq.h1
-rw-r--r--drivers/kvm/lapic.c14
-rw-r--r--drivers/kvm/svm.c1
-rw-r--r--drivers/kvm/vmx.c4
4 files changed, 19 insertions, 1 deletions
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 87baf7e69ea..f324cfb4008 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -158,5 +158,6 @@ void kvm_apic_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
158void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec); 158void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
159void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); 159void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
160void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); 160void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
161void kvm_migrate_apic_timer(struct kvm_vcpu *vcpu);
161 162
162#endif 163#endif
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 490d4939dba..2706ec36c25 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -979,3 +979,17 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu)
979 update_divide_count(apic); 979 update_divide_count(apic);
980 start_apic_timer(apic); 980 start_apic_timer(apic);
981} 981}
982
983void kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)
984{
985 struct kvm_lapic *apic = vcpu->apic;
986 struct hrtimer *timer;
987
988 if (!apic)
989 return;
990
991 timer = &apic->timer.dev;
992 if (hrtimer_cancel(timer))
993 hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
994}
995EXPORT_SYMBOL_GPL(kvm_migrate_apic_timer);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 00119ec4166..3de9ec35ebf 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -633,6 +633,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
633 delta = vcpu->host_tsc - tsc_this; 633 delta = vcpu->host_tsc - tsc_this;
634 svm->vmcb->control.tsc_offset += delta; 634 svm->vmcb->control.tsc_offset += delta;
635 vcpu->cpu = cpu; 635 vcpu->cpu = cpu;
636 kvm_migrate_apic_timer(vcpu);
636 } 637 }
637 638
638 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++) 639 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index eeecadf5da4..f4618b9edf9 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -441,8 +441,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
441 u64 phys_addr = __pa(vmx->vmcs); 441 u64 phys_addr = __pa(vmx->vmcs);
442 u64 tsc_this, delta; 442 u64 tsc_this, delta;
443 443
444 if (vcpu->cpu != cpu) 444 if (vcpu->cpu != cpu) {
445 vcpu_clear(vmx); 445 vcpu_clear(vmx);
446 kvm_migrate_apic_timer(vcpu);
447 }
446 448
447 if (per_cpu(current_vmcs, cpu) != vmx->vmcs) { 449 if (per_cpu(current_vmcs, cpu) != vmx->vmcs) {
448 u8 error; 450 u8 error;