aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/include/asm/kvm_host.h4
-rw-r--r--arch/ia64/kvm/Makefile2
-rw-r--r--arch/ia64/kvm/irq.h5
-rw-r--r--arch/x86/kvm/Makefile2
-rw-r--r--arch/x86/kvm/irq.c33
-rw-r--r--arch/x86/kvm/irq.h8
-rw-r--r--include/asm-x86/kvm_host.h2
-rw-r--r--include/linux/kvm_host.h6
-rw-r--r--virt/kvm/irq_comm.c60
9 files changed, 74 insertions, 48 deletions
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 1efe513a9941..da579a33db12 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -413,6 +413,10 @@ struct kvm_arch {
413 struct kvm_ioapic *vioapic; 413 struct kvm_ioapic *vioapic;
414 struct kvm_vm_stat stat; 414 struct kvm_vm_stat stat;
415 struct kvm_sal_data rdv_sal_data; 415 struct kvm_sal_data rdv_sal_data;
416
417 struct list_head assigned_dev_head;
418 struct dmar_domain *intel_iommu_domain;
419 struct hlist_head irq_ack_notifier_list;
416}; 420};
417 421
418union cpuid3_t { 422union cpuid3_t {
diff --git a/arch/ia64/kvm/Makefile b/arch/ia64/kvm/Makefile
index bf22fb9e6dcf..3b1a1c156ef9 100644
--- a/arch/ia64/kvm/Makefile
+++ b/arch/ia64/kvm/Makefile
@@ -44,7 +44,7 @@ EXTRA_CFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
44EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ 44EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/
45 45
46common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ 46common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
47 coalesced_mmio.o) 47 coalesced_mmio.o irq_comm.o)
48 48
49kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o 49kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o
50obj-$(CONFIG_KVM) += kvm.o 50obj-$(CONFIG_KVM) += kvm.o
diff --git a/arch/ia64/kvm/irq.h b/arch/ia64/kvm/irq.h
index f2e6545debf4..604329ac3c99 100644
--- a/arch/ia64/kvm/irq.h
+++ b/arch/ia64/kvm/irq.h
@@ -23,10 +23,5 @@
23#ifndef __IRQ_H 23#ifndef __IRQ_H
24#define __IRQ_H 24#define __IRQ_H
25 25
26struct kvm;
27
28static inline void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
29{
30}
31 26
32#endif 27#endif
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 7dce593b9c66..c02343594b4d 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ 5common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
6 coalesced_mmio.o) 6 coalesced_mmio.o irq_comm.o)
7ifeq ($(CONFIG_KVM_TRACE),y) 7ifeq ($(CONFIG_KVM_TRACE),y)
8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) 8common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o)
9endif 9endif
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index 8c1b9c5def78..c019b8edcdb7 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -99,36 +99,3 @@ void __kvm_migrate_timers(struct kvm_vcpu *vcpu)
99 __kvm_migrate_apic_timer(vcpu); 99 __kvm_migrate_apic_timer(vcpu);
100 __kvm_migrate_pit_timer(vcpu); 100 __kvm_migrate_pit_timer(vcpu);
101} 101}
102
103/* This should be called with the kvm->lock mutex held */
104void kvm_set_irq(struct kvm *kvm, int irq, int level)
105{
106 /* Not possible to detect if the guest uses the PIC or the
107 * IOAPIC. So set the bit in both. The guest will ignore
108 * writes to the unused one.
109 */
110 kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
111 kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
112}
113
114void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
115{
116 struct kvm_irq_ack_notifier *kian;
117 struct hlist_node *n;
118
119 hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link)
120 if (kian->gsi == gsi)
121 kian->irq_acked(kian);
122}
123
124void kvm_register_irq_ack_notifier(struct kvm *kvm,
125 struct kvm_irq_ack_notifier *kian)
126{
127 hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
128}
129
130void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
131 struct kvm_irq_ack_notifier *kian)
132{
133 hlist_del(&kian->link);
134}
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index 4748532fd1da..f17c8f5bbf31 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -68,7 +68,6 @@ struct kvm_pic {
68}; 68};
69 69
70struct kvm_pic *kvm_create_pic(struct kvm *kvm); 70struct kvm_pic *kvm_create_pic(struct kvm *kvm);
71void kvm_pic_set_irq(void *opaque, int irq, int level);
72int kvm_pic_read_irq(struct kvm *kvm); 71int kvm_pic_read_irq(struct kvm *kvm);
73void kvm_pic_update_irq(struct kvm_pic *s); 72void kvm_pic_update_irq(struct kvm_pic *s);
74void kvm_pic_clear_isr_ack(struct kvm *kvm); 73void kvm_pic_clear_isr_ack(struct kvm *kvm);
@@ -85,13 +84,6 @@ static inline int irqchip_in_kernel(struct kvm *kvm)
85 84
86void kvm_pic_reset(struct kvm_kpic_state *s); 85void kvm_pic_reset(struct kvm_kpic_state *s);
87 86
88void kvm_set_irq(struct kvm *kvm, int irq, int level);
89void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
90void kvm_register_irq_ack_notifier(struct kvm *kvm,
91 struct kvm_irq_ack_notifier *kian);
92void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
93 struct kvm_irq_ack_notifier *kian);
94
95void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec); 87void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
96void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); 88void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
97void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); 89void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index ca6bbc0bd97c..411fb8cfb24e 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -565,6 +565,8 @@ void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
565void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, 565void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2,
566 u32 error_code); 566 u32 error_code);
567 567
568void kvm_pic_set_irq(void *opaque, int irq, int level);
569
568void kvm_inject_nmi(struct kvm_vcpu *vcpu); 570void kvm_inject_nmi(struct kvm_vcpu *vcpu);
569 571
570void fx_init(struct kvm_vcpu *vcpu); 572void fx_init(struct kvm_vcpu *vcpu);
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index b3b7598b4d94..3833c48fae3a 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -309,6 +309,12 @@ struct kvm_assigned_dev_kernel {
309 struct pci_dev *dev; 309 struct pci_dev *dev;
310 struct kvm *kvm; 310 struct kvm *kvm;
311}; 311};
312void kvm_set_irq(struct kvm *kvm, int irq, int level);
313void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
314void kvm_register_irq_ack_notifier(struct kvm *kvm,
315 struct kvm_irq_ack_notifier *kian);
316void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
317 struct kvm_irq_ack_notifier *kian);
312 318
313#ifdef CONFIG_DMAR 319#ifdef CONFIG_DMAR
314int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, 320int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
new file mode 100644
index 000000000000..d0169f5e6047
--- /dev/null
+++ b/virt/kvm/irq_comm.c
@@ -0,0 +1,60 @@
1/*
2 * irq_comm.c: Common 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/kvm_host.h>
23#include "irq.h"
24
25#include "ioapic.h"
26
27/* This should be called with the kvm->lock mutex held */
28void kvm_set_irq(struct kvm *kvm, int irq, int level)
29{
30 /* Not possible to detect if the guest uses the PIC or the
31 * IOAPIC. So set the bit in both. The guest will ignore
32 * writes to the unused one.
33 */
34 kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
35#ifdef CONFIG_X86
36 kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
37#endif
38}
39
40void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
41{
42 struct kvm_irq_ack_notifier *kian;
43 struct hlist_node *n;
44
45 hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link)
46 if (kian->gsi == gsi)
47 kian->irq_acked(kian);
48}
49
50void kvm_register_irq_ack_notifier(struct kvm *kvm,
51 struct kvm_irq_ack_notifier *kian)
52{
53 hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
54}
55
56void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
57 struct kvm_irq_ack_notifier *kian)
58{
59 hlist_del(&kian->link);
60}