Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: Separate irq ack notification out of arch/x86/kvm/irq.c

Moving irq ack notification logic as common, and make
it shared with ia64 side.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>

authored by

Xiantao Zhang and committed by
Avi Kivity
3de42dc0 c77fb9dc

+74 -48
+4
arch/ia64/include/asm/kvm_host.h
··· 413 413 struct kvm_ioapic *vioapic; 414 414 struct kvm_vm_stat stat; 415 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 422 union cpuid3_t {
+1 -1
arch/ia64/kvm/Makefile
··· 44 44 EXTRA_AFLAGS += -Ivirt/kvm -Iarch/ia64/kvm/ 45 45 46 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 49 kvm-objs := $(common-objs) kvm-ia64.o kvm_fw.o 50 50 obj-$(CONFIG_KVM) += kvm.o
-5
arch/ia64/kvm/irq.h
··· 23 23 #ifndef __IRQ_H 24 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 27 #endif
+1 -1
arch/x86/kvm/Makefile
··· 3 3 # 4 4 5 5 common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \ 6 - coalesced_mmio.o) 6 + coalesced_mmio.o irq_comm.o) 7 7 ifeq ($(CONFIG_KVM_TRACE),y) 8 8 common-objs += $(addprefix ../../../virt/kvm/, kvm_trace.o) 9 9 endif
-33
arch/x86/kvm/irq.c
··· 99 99 __kvm_migrate_apic_timer(vcpu); 100 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 - }
-8
arch/x86/kvm/irq.h
··· 68 68 }; 69 69 70 70 struct kvm_pic *kvm_create_pic(struct kvm *kvm); 71 - void kvm_pic_set_irq(void *opaque, int irq, int level); 72 71 int kvm_pic_read_irq(struct kvm *kvm); 73 72 void kvm_pic_update_irq(struct kvm_pic *s); 74 73 void kvm_pic_clear_isr_ack(struct kvm *kvm); ··· 83 84 } 84 85 85 86 void kvm_pic_reset(struct kvm_kpic_state *s); 86 - 87 - void kvm_set_irq(struct kvm *kvm, int irq, int level); 88 - void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); 89 - void kvm_register_irq_ack_notifier(struct kvm *kvm, 90 - struct kvm_irq_ack_notifier *kian); 91 - void kvm_unregister_irq_ack_notifier(struct kvm *kvm, 92 - struct kvm_irq_ack_notifier *kian); 93 87 94 88 void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec); 95 89 void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
+2
include/asm-x86/kvm_host.h
··· 565 565 void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, 566 566 u32 error_code); 567 567 568 + void kvm_pic_set_irq(void *opaque, int irq, int level); 569 + 568 570 void kvm_inject_nmi(struct kvm_vcpu *vcpu); 569 571 570 572 void fx_init(struct kvm_vcpu *vcpu);
+6
include/linux/kvm_host.h
··· 309 309 struct pci_dev *dev; 310 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 319 #ifdef CONFIG_DMAR 314 320 int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
+60
virt/kvm/irq_comm.c
··· 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 + }