diff options
-rw-r--r-- | arch/mips/kvm/kvm_tlb.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/mips/kvm/kvm_tlb.c b/arch/mips/kvm/kvm_tlb.c index 9d371ee0a755..d65999a9f8af 100644 --- a/arch/mips/kvm/kvm_tlb.c +++ b/arch/mips/kvm/kvm_tlb.c | |||
@@ -656,6 +656,23 @@ void kvm_local_flush_tlb_all(void) | |||
656 | local_irq_restore(flags); | 656 | local_irq_restore(flags); |
657 | } | 657 | } |
658 | 658 | ||
659 | /** | ||
660 | * kvm_mips_migrate_count() - Migrate timer. | ||
661 | * @vcpu: Virtual CPU. | ||
662 | * | ||
663 | * Migrate CP0_Count hrtimer to the current CPU by cancelling and restarting it | ||
664 | * if it was running prior to being cancelled. | ||
665 | * | ||
666 | * Must be called when the VCPU is migrated to a different CPU to ensure that | ||
667 | * timer expiry during guest execution interrupts the guest and causes the | ||
668 | * interrupt to be delivered in a timely manner. | ||
669 | */ | ||
670 | static void kvm_mips_migrate_count(struct kvm_vcpu *vcpu) | ||
671 | { | ||
672 | if (hrtimer_cancel(&vcpu->arch.comparecount_timer)) | ||
673 | hrtimer_restart(&vcpu->arch.comparecount_timer); | ||
674 | } | ||
675 | |||
659 | /* Restore ASID once we are scheduled back after preemption */ | 676 | /* Restore ASID once we are scheduled back after preemption */ |
660 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | 677 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) |
661 | { | 678 | { |
@@ -691,6 +708,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
691 | if (vcpu->arch.last_sched_cpu != cpu) { | 708 | if (vcpu->arch.last_sched_cpu != cpu) { |
692 | kvm_info("[%d->%d]KVM VCPU[%d] switch\n", | 709 | kvm_info("[%d->%d]KVM VCPU[%d] switch\n", |
693 | vcpu->arch.last_sched_cpu, cpu, vcpu->vcpu_id); | 710 | vcpu->arch.last_sched_cpu, cpu, vcpu->vcpu_id); |
711 | /* | ||
712 | * Migrate the timer interrupt to the current CPU so that it | ||
713 | * always interrupts the guest and synchronously triggers a | ||
714 | * guest timer interrupt. | ||
715 | */ | ||
716 | kvm_mips_migrate_count(vcpu); | ||
694 | } | 717 | } |
695 | 718 | ||
696 | if (!newasid) { | 719 | if (!newasid) { |