KVM: disable tpr/cr8 sync when in-kernel APIC is used
[deliverable/linux.git] / drivers / kvm / irq.c
CommitLineData
85f455f7
ED
1/*
2 * irq.c: API for in kernel interrupt controller
3 * Copyright (c) 2007, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 * Authors:
18 * Yaozu (Eddie) Dong <Eddie.dong@intel.com>
19 *
20 */
21
22#include <linux/module.h>
23
24#include "kvm.h"
25#include "irq.h"
26
27/*
28 * check if there is pending interrupt without
29 * intack.
30 */
31int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
32{
97222cc8
ED
33 struct kvm_pic *s;
34
35 if (kvm_apic_has_interrupt(v) == -1) { /* LAPIC */
36 s = pic_irqchip(v->kvm); /* PIC */
37 return s->output;
38 }
39 return 1;
85f455f7
ED
40}
41EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
42
43/*
44 * Read pending interrupt vector and intack.
45 */
46int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
47{
97222cc8 48 struct kvm_pic *s;
85f455f7
ED
49 int vector;
50
97222cc8
ED
51 vector = kvm_get_apic_interrupt(v); /* APIC */
52 if (vector == -1) {
53 s = pic_irqchip(v->kvm);
54 s->output = 0; /* PIC */
55 vector = kvm_pic_read_irq(s);
56 }
57 return vector;
85f455f7
ED
58}
59EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);
97222cc8
ED
60
61static void vcpu_kick_intr(void *info)
62{
63#ifdef DEBUG
64 struct kvm_vcpu *vcpu = (struct kvm_vcpu *)info;
65 printk(KERN_DEBUG "vcpu_kick_intr %p \n", vcpu);
66#endif
67}
68
69void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
70{
71 int ipi_pcpu = vcpu->cpu;
72
b6958ce4
ED
73 if (waitqueue_active(&vcpu->wq)) {
74 wake_up_interruptible(&vcpu->wq);
75 ++vcpu->stat.halt_wakeup;
76 }
97222cc8
ED
77 if (vcpu->guest_mode)
78 smp_call_function_single(ipi_pcpu, vcpu_kick_intr, vcpu, 0, 0);
79}
80
1b9778da
ED
81void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu)
82{
83 kvm_inject_apic_timer_irqs(vcpu);
84 /* TODO: PIT, RTC etc. */
85}
86EXPORT_SYMBOL_GPL(kvm_inject_pending_timer_irqs);
87
88void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec)
89{
90 kvm_apic_timer_intr_post(vcpu, vec);
91 /* TODO: PIT, RTC etc. */
92}
93EXPORT_SYMBOL_GPL(kvm_timer_intr_post);
This page took 0.028059 seconds and 5 git commands to generate.