aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-01-08 07:41:16 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2016-02-09 10:57:39 -0500
commit1e3161b4147caf2045ac4aae3d71fae6ac1a1d65 (patch)
tree06ab2411f3828f4d1b1fba89c593f987647a2e05
parentf8543d6a977a1bdb37eb13ad81ef2874526209b0 (diff)
KVM: x86: consolidate "has lapic" checks into irq.c
Do for kvm_cpu_has_pending_timer and kvm_inject_pending_timer_irqs what the other irq.c routines have been doing. Reviewed-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/irq.c9
-rw-r--r--arch/x86/kvm/lapic.c6
2 files changed, 7 insertions, 8 deletions
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 3982b479bb5f..95fcc7b13866 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -33,7 +33,10 @@
33 */ 33 */
34int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) 34int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
35{ 35{
36 return apic_has_pending_timer(vcpu); 36 if (lapic_in_kernel(vcpu))
37 return apic_has_pending_timer(vcpu);
38
39 return 0;
37} 40}
38EXPORT_SYMBOL(kvm_cpu_has_pending_timer); 41EXPORT_SYMBOL(kvm_cpu_has_pending_timer);
39 42
@@ -137,8 +140,8 @@ EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);
137 140
138void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu) 141void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu)
139{ 142{
140 kvm_inject_apic_timer_irqs(vcpu); 143 if (lapic_in_kernel(vcpu))
141 /* TODO: PIT, RTC etc. */ 144 kvm_inject_apic_timer_irqs(vcpu);
142} 145}
143EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs); 146EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs);
144 147
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index b1029051f664..57e3f27bdadb 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1801,8 +1801,7 @@ int apic_has_pending_timer(struct kvm_vcpu *vcpu)
1801{ 1801{
1802 struct kvm_lapic *apic = vcpu->arch.apic; 1802 struct kvm_lapic *apic = vcpu->arch.apic;
1803 1803
1804 if (kvm_vcpu_has_lapic(vcpu) && apic_enabled(apic) && 1804 if (apic_enabled(apic) && apic_lvt_enabled(apic, APIC_LVTT))
1805 apic_lvt_enabled(apic, APIC_LVTT))
1806 return atomic_read(&apic->lapic_timer.pending); 1805 return atomic_read(&apic->lapic_timer.pending);
1807 1806
1808 return 0; 1807 return 0;
@@ -1927,9 +1926,6 @@ void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu)
1927{ 1926{
1928 struct kvm_lapic *apic = vcpu->arch.apic; 1927 struct kvm_lapic *apic = vcpu->arch.apic;
1929 1928
1930 if (!kvm_vcpu_has_lapic(vcpu))
1931 return;
1932
1933 if (atomic_read(&apic->lapic_timer.pending) > 0) { 1929 if (atomic_read(&apic->lapic_timer.pending) > 0) {
1934 kvm_apic_local_deliver(apic, APIC_LVTT); 1930 kvm_apic_local_deliver(apic, APIC_LVTT);
1935 if (apic_lvtt_tscdeadline(apic)) 1931 if (apic_lvtt_tscdeadline(apic))