diff options
-rw-r--r-- | arch/ia64/include/asm/kvm_host.h | 4 | ||||
-rw-r--r-- | arch/ia64/kvm/Makefile | 2 | ||||
-rw-r--r-- | arch/ia64/kvm/irq.h | 5 | ||||
-rw-r--r-- | arch/x86/kvm/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/kvm/irq.c | 33 | ||||
-rw-r--r-- | arch/x86/kvm/irq.h | 8 | ||||
-rw-r--r-- | include/asm-x86/kvm_host.h | 2 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 6 | ||||
-rw-r--r-- | virt/kvm/irq_comm.c | 60 |
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 | ||
418 | union cpuid3_t { | 422 | union 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/ | |||
44 | EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ | 44 | EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ |
45 | 45 | ||
46 | common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ | 46 | common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ |
47 | coalesced_mmio.o) | 47 | coalesced_mmio.o irq_comm.o) |
48 | 48 | ||
49 | kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o | 49 | kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o |
50 | obj-$(CONFIG_KVM) += kvm.o | 50 | obj-$(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 | ||
26 | struct kvm; | ||
27 | |||
28 | static 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 | ||
5 | common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ | 5 | common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ |
6 | coalesced_mmio.o) | 6 | coalesced_mmio.o irq_comm.o) |
7 | ifeq ($(CONFIG_KVM_TRACE),y) | 7 | ifeq ($(CONFIG_KVM_TRACE),y) |
8 | common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) | 8 | common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) |
9 | endif | 9 | endif |
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 */ | ||
104 | void 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 | |||
114 | void 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 | |||
124 | void 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 | |||
130 | void 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 | ||
70 | struct kvm_pic *kvm_create_pic(struct kvm *kvm); | 70 | struct kvm_pic *kvm_create_pic(struct kvm *kvm); |
71 | void kvm_pic_set_irq(void *opaque, int irq, int level); | ||
72 | int kvm_pic_read_irq(struct kvm *kvm); | 71 | int kvm_pic_read_irq(struct kvm *kvm); |
73 | void kvm_pic_update_irq(struct kvm_pic *s); | 72 | void kvm_pic_update_irq(struct kvm_pic *s); |
74 | void kvm_pic_clear_isr_ack(struct kvm *kvm); | 73 | void kvm_pic_clear_isr_ack(struct kvm *kvm); |
@@ -85,13 +84,6 @@ static inline int irqchip_in_kernel(struct kvm *kvm) | |||
85 | 84 | ||
86 | void kvm_pic_reset(struct kvm_kpic_state *s); | 85 | void kvm_pic_reset(struct kvm_kpic_state *s); |
87 | 86 | ||
88 | void kvm_set_irq(struct kvm *kvm, int irq, int level); | ||
89 | void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); | ||
90 | void kvm_register_irq_ack_notifier(struct kvm *kvm, | ||
91 | struct kvm_irq_ack_notifier *kian); | ||
92 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, | ||
93 | struct kvm_irq_ack_notifier *kian); | ||
94 | |||
95 | void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec); | 87 | void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec); |
96 | void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); | 88 | void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); |
97 | void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); | 89 | void 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); | |||
565 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, | 565 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, |
566 | u32 error_code); | 566 | u32 error_code); |
567 | 567 | ||
568 | void kvm_pic_set_irq(void *opaque, int irq, int level); | ||
569 | |||
568 | void kvm_inject_nmi(struct kvm_vcpu *vcpu); | 570 | void kvm_inject_nmi(struct kvm_vcpu *vcpu); |
569 | 571 | ||
570 | void fx_init(struct kvm_vcpu *vcpu); | 572 | void 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 | }; |
312 | void kvm_set_irq(struct kvm *kvm, int irq, int level); | ||
313 | void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); | ||
314 | void kvm_register_irq_ack_notifier(struct kvm *kvm, | ||
315 | struct kvm_irq_ack_notifier *kian); | ||
316 | void 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 |
314 | int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, | 320 | int 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 */ | ||
28 | void 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 | |||
40 | void 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 | |||
50 | void 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 | |||
56 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, | ||
57 | struct kvm_irq_ack_notifier *kian) | ||
58 | { | ||
59 | hlist_del(&kian->link); | ||
60 | } | ||