diff options
-rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 5 | ||||
-rw-r--r-- | arch/s390/kvm/interrupt.c | 5 | ||||
-rw-r--r-- | arch/x86/kvm/i8254.c | 10 | ||||
-rw-r--r-- | arch/x86/kvm/irq.c | 15 | ||||
-rw-r--r-- | arch/x86/kvm/irq.h | 3 | ||||
-rw-r--r-- | arch/x86/kvm/lapic.c | 10 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 1 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 1 |
8 files changed, 50 insertions, 0 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 9c56b6429cb6..ca1cfb124d4f 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -1778,6 +1778,11 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu) | |||
1778 | return 0; | 1778 | return 0; |
1779 | } | 1779 | } |
1780 | 1780 | ||
1781 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) | ||
1782 | { | ||
1783 | return 0; | ||
1784 | } | ||
1785 | |||
1781 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) | 1786 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) |
1782 | { | 1787 | { |
1783 | return gfn; | 1788 | return gfn; |
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index f62588cb75f8..fcd1ed8015c1 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c | |||
@@ -325,6 +325,11 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu) | |||
325 | return rc; | 325 | return rc; |
326 | } | 326 | } |
327 | 327 | ||
328 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) | ||
329 | { | ||
330 | return 0; | ||
331 | } | ||
332 | |||
328 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) | 333 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) |
329 | { | 334 | { |
330 | u64 now, sltime; | 335 | u64 now, sltime; |
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 9f118e2f350d..ed1af80432b3 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -212,6 +212,16 @@ int __pit_timer_fn(struct kvm_kpit_state *ps) | |||
212 | return (pt->period == 0 ? 0 : 1); | 212 | return (pt->period == 0 ? 0 : 1); |
213 | } | 213 | } |
214 | 214 | ||
215 | int pit_has_pending_timer(struct kvm_vcpu *vcpu) | ||
216 | { | ||
217 | struct kvm_pit *pit = vcpu->kvm->arch.vpit; | ||
218 | |||
219 | if (pit && vcpu->vcpu_id == 0) | ||
220 | return atomic_read(&pit->pit_state.pit_timer.pending); | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
215 | static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) | 225 | static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) |
216 | { | 226 | { |
217 | struct kvm_kpit_state *ps; | 227 | struct kvm_kpit_state *ps; |
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c index dbfe21c99c48..ce1f583459b1 100644 --- a/arch/x86/kvm/irq.c +++ b/arch/x86/kvm/irq.c | |||
@@ -26,6 +26,21 @@ | |||
26 | #include "i8254.h" | 26 | #include "i8254.h" |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * check if there are pending timer events | ||
30 | * to be processed. | ||
31 | */ | ||
32 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) | ||
33 | { | ||
34 | int ret; | ||
35 | |||
36 | ret = pit_has_pending_timer(vcpu); | ||
37 | ret |= apic_has_pending_timer(vcpu); | ||
38 | |||
39 | return ret; | ||
40 | } | ||
41 | EXPORT_SYMBOL(kvm_cpu_has_pending_timer); | ||
42 | |||
43 | /* | ||
29 | * check if there is pending interrupt without | 44 | * check if there is pending interrupt without |
30 | * intack. | 45 | * intack. |
31 | */ | 46 | */ |
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h index fa5ed5d59b5d..1802134b836f 100644 --- a/arch/x86/kvm/irq.h +++ b/arch/x86/kvm/irq.h | |||
@@ -85,4 +85,7 @@ void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); | |||
85 | void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); | 85 | void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); |
86 | void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu); | 86 | void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu); |
87 | 87 | ||
88 | int pit_has_pending_timer(struct kvm_vcpu *vcpu); | ||
89 | int apic_has_pending_timer(struct kvm_vcpu *vcpu); | ||
90 | |||
88 | #endif | 91 | #endif |
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 31280df7d2e3..debf58211bdd 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -952,6 +952,16 @@ static int __apic_timer_fn(struct kvm_lapic *apic) | |||
952 | return result; | 952 | return result; |
953 | } | 953 | } |
954 | 954 | ||
955 | int apic_has_pending_timer(struct kvm_vcpu *vcpu) | ||
956 | { | ||
957 | struct kvm_lapic *lapic = vcpu->arch.apic; | ||
958 | |||
959 | if (lapic) | ||
960 | return atomic_read(&lapic->timer.pending); | ||
961 | |||
962 | return 0; | ||
963 | } | ||
964 | |||
955 | static int __inject_apic_timer_irq(struct kvm_lapic *apic) | 965 | static int __inject_apic_timer_irq(struct kvm_lapic *apic) |
956 | { | 966 | { |
957 | int vector; | 967 | int vector; |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index bd0c2d2d840f..0bc400387cae 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -269,6 +269,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm); | |||
269 | 269 | ||
270 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); | 270 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); |
271 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); | 271 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); |
272 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); | ||
272 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); | 273 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); |
273 | 274 | ||
274 | static inline void kvm_guest_enter(void) | 275 | static inline void kvm_guest_enter(void) |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d5911d9895c3..47cbc6e3fafd 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -765,6 +765,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) | |||
765 | * We will block until either an interrupt or a signal wakes us up | 765 | * We will block until either an interrupt or a signal wakes us up |
766 | */ | 766 | */ |
767 | while (!kvm_cpu_has_interrupt(vcpu) | 767 | while (!kvm_cpu_has_interrupt(vcpu) |
768 | && !kvm_cpu_has_pending_timer(vcpu) | ||
768 | && !signal_pending(current) | 769 | && !signal_pending(current) |
769 | && !kvm_arch_vcpu_runnable(vcpu)) { | 770 | && !kvm_arch_vcpu_runnable(vcpu)) { |
770 | set_current_state(TASK_INTERRUPTIBLE); | 771 | set_current_state(TASK_INTERRUPTIBLE); |