aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/kvm_host.h16
-rw-r--r--arch/x86/kvm/Makefile5
-rw-r--r--arch/x86/kvm/ioapic.c (renamed from virt/kvm/ioapic.c)0
-rw-r--r--arch/x86/kvm/ioapic.h (renamed from virt/kvm/ioapic.h)1
-rw-r--r--arch/x86/kvm/irq_comm.c (renamed from virt/kvm/irq_comm.c)4
-rw-r--r--arch/x86/kvm/x86.c1
-rw-r--r--include/linux/kvm_host.h22
-rw-r--r--virt/kvm/eventfd.c7
-rw-r--r--virt/kvm/kvm_main.c3
9 files changed, 29 insertions, 30 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 769db36a3001..76ff3e2d8fd2 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -603,6 +603,9 @@ struct kvm_arch {
603 603
604 struct kvm_xen_hvm_config xen_hvm_config; 604 struct kvm_xen_hvm_config xen_hvm_config;
605 605
606 /* reads protected by irq_srcu, writes by irq_lock */
607 struct hlist_head mask_notifier_list;
608
606 /* fields used by HYPER-V emulation */ 609 /* fields used by HYPER-V emulation */
607 u64 hv_guest_os_id; 610 u64 hv_guest_os_id;
608 u64 hv_hypercall; 611 u64 hv_hypercall;
@@ -819,6 +822,19 @@ int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
819 const void *val, int bytes); 822 const void *val, int bytes);
820u8 kvm_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn); 823u8 kvm_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn);
821 824
825struct kvm_irq_mask_notifier {
826 void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked);
827 int irq;
828 struct hlist_node link;
829};
830
831void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
832 struct kvm_irq_mask_notifier *kimn);
833void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
834 struct kvm_irq_mask_notifier *kimn);
835void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
836 bool mask);
837
822extern bool tdp_enabled; 838extern bool tdp_enabled;
823 839
824u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu); 840u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 25d22b2d6509..ee1cd92b03be 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -7,14 +7,13 @@ CFLAGS_vmx.o := -I.
7 7
8KVM := ../../../virt/kvm 8KVM := ../../../virt/kvm
9 9
10kvm-y += $(KVM)/kvm_main.o $(KVM)/ioapic.o \ 10kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \
11 $(KVM)/coalesced_mmio.o $(KVM)/irq_comm.o \
12 $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o 11 $(KVM)/eventfd.o $(KVM)/irqchip.o $(KVM)/vfio.o
13kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += $(KVM)/assigned-dev.o $(KVM)/iommu.o 12kvm-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += $(KVM)/assigned-dev.o $(KVM)/iommu.o
14kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o 13kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o
15 14
16kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ 15kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \
17 i8254.o cpuid.o pmu.o 16 i8254.o ioapic.o irq_comm.o cpuid.o pmu.o
18kvm-intel-y += vmx.o 17kvm-intel-y += vmx.o
19kvm-amd-y += svm.o 18kvm-amd-y += svm.o
20 19
diff --git a/virt/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index f0f7ef82b7a6..f0f7ef82b7a6 100644
--- a/virt/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
diff --git a/virt/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
index dc3baa3a538f..deac8d509f2a 100644
--- a/virt/kvm/ioapic.h
+++ b/arch/x86/kvm/ioapic.h
@@ -96,7 +96,6 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
96 struct kvm_lapic_irq *irq, unsigned long *dest_map); 96 struct kvm_lapic_irq *irq, unsigned long *dest_map);
97int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); 97int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state);
98int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state); 98int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state);
99void kvm_vcpu_request_scan_ioapic(struct kvm *kvm);
100void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap, 99void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap,
101 u32 *tmr); 100 u32 *tmr);
102 101
diff --git a/virt/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 1345bde064f5..e9c135b639aa 100644
--- a/virt/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -234,7 +234,7 @@ void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
234{ 234{
235 mutex_lock(&kvm->irq_lock); 235 mutex_lock(&kvm->irq_lock);
236 kimn->irq = irq; 236 kimn->irq = irq;
237 hlist_add_head_rcu(&kimn->link, &kvm->mask_notifier_list); 237 hlist_add_head_rcu(&kimn->link, &kvm->arch.mask_notifier_list);
238 mutex_unlock(&kvm->irq_lock); 238 mutex_unlock(&kvm->irq_lock);
239} 239}
240 240
@@ -256,7 +256,7 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
256 idx = srcu_read_lock(&kvm->irq_srcu); 256 idx = srcu_read_lock(&kvm->irq_srcu);
257 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin); 257 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
258 if (gsi != -1) 258 if (gsi != -1)
259 hlist_for_each_entry_rcu(kimn, &kvm->mask_notifier_list, link) 259 hlist_for_each_entry_rcu(kimn, &kvm->arch.mask_notifier_list, link)
260 if (kimn->irq == gsi) 260 if (kimn->irq == gsi)
261 kimn->func(kimn, mask); 261 kimn->func(kimn, mask);
262 srcu_read_unlock(&kvm->irq_srcu, idx); 262 srcu_read_unlock(&kvm->irq_srcu, idx);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a8f53a6960fd..5337039427c8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7264,6 +7264,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
7264 if (type) 7264 if (type)
7265 return -EINVAL; 7265 return -EINVAL;
7266 7266
7267 INIT_HLIST_HEAD(&kvm->arch.mask_notifier_list);
7267 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); 7268 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages);
7268 INIT_LIST_HEAD(&kvm->arch.zapped_obsolete_pages); 7269 INIT_LIST_HEAD(&kvm->arch.zapped_obsolete_pages);
7269 INIT_LIST_HEAD(&kvm->arch.assigned_dev_head); 7270 INIT_LIST_HEAD(&kvm->arch.assigned_dev_head);
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ea53b04993f2..ded64cb3a081 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -395,7 +395,6 @@ struct kvm {
395 * Update side is protected by irq_lock. 395 * Update side is protected by irq_lock.
396 */ 396 */
397 struct kvm_irq_routing_table __rcu *irq_routing; 397 struct kvm_irq_routing_table __rcu *irq_routing;
398 struct hlist_head mask_notifier_list;
399#endif 398#endif
400#ifdef CONFIG_HAVE_KVM_IRQFD 399#ifdef CONFIG_HAVE_KVM_IRQFD
401 struct hlist_head irq_ack_notifier_list; 400 struct hlist_head irq_ack_notifier_list;
@@ -447,6 +446,14 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
447int __must_check vcpu_load(struct kvm_vcpu *vcpu); 446int __must_check vcpu_load(struct kvm_vcpu *vcpu);
448void vcpu_put(struct kvm_vcpu *vcpu); 447void vcpu_put(struct kvm_vcpu *vcpu);
449 448
449#ifdef __KVM_HAVE_IOAPIC
450void kvm_vcpu_request_scan_ioapic(struct kvm *kvm);
451#else
452static inline void kvm_vcpu_request_scan_ioapic(struct kvm *kvm)
453{
454}
455#endif
456
450#ifdef CONFIG_HAVE_KVM_IRQFD 457#ifdef CONFIG_HAVE_KVM_IRQFD
451int kvm_irqfd_init(void); 458int kvm_irqfd_init(void);
452void kvm_irqfd_exit(void); 459void kvm_irqfd_exit(void);
@@ -736,19 +743,6 @@ struct kvm_assigned_dev_kernel {
736 struct pci_saved_state *pci_saved_state; 743 struct pci_saved_state *pci_saved_state;
737}; 744};
738 745
739struct kvm_irq_mask_notifier {
740 void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked);
741 int irq;
742 struct hlist_node link;
743};
744
745void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
746 struct kvm_irq_mask_notifier *kimn);
747void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
748 struct kvm_irq_mask_notifier *kimn);
749void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
750 bool mask);
751
752int kvm_irq_map_gsi(struct kvm *kvm, 746int kvm_irq_map_gsi(struct kvm *kvm,
753 struct kvm_kernel_irq_routing_entry *entries, int gsi); 747 struct kvm_kernel_irq_routing_entry *entries, int gsi);
754int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin); 748int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin);
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index b0fb390943c6..148b2392c762 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -36,9 +36,6 @@
36#include <linux/seqlock.h> 36#include <linux/seqlock.h>
37#include <trace/events/kvm.h> 37#include <trace/events/kvm.h>
38 38
39#ifdef __KVM_HAVE_IOAPIC
40#include "ioapic.h"
41#endif
42#include "iodev.h" 39#include "iodev.h"
43 40
44#ifdef CONFIG_HAVE_KVM_IRQFD 41#ifdef CONFIG_HAVE_KVM_IRQFD
@@ -492,9 +489,7 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm,
492 mutex_lock(&kvm->irq_lock); 489 mutex_lock(&kvm->irq_lock);
493 hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); 490 hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list);
494 mutex_unlock(&kvm->irq_lock); 491 mutex_unlock(&kvm->irq_lock);
495#ifdef __KVM_HAVE_IOAPIC
496 kvm_vcpu_request_scan_ioapic(kvm); 492 kvm_vcpu_request_scan_ioapic(kvm);
497#endif
498} 493}
499 494
500void kvm_unregister_irq_ack_notifier(struct kvm *kvm, 495void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
@@ -504,9 +499,7 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
504 hlist_del_init_rcu(&kian->link); 499 hlist_del_init_rcu(&kian->link);
505 mutex_unlock(&kvm->irq_lock); 500 mutex_unlock(&kvm->irq_lock);
506 synchronize_srcu(&kvm->irq_srcu); 501 synchronize_srcu(&kvm->irq_srcu);
507#ifdef __KVM_HAVE_IOAPIC
508 kvm_vcpu_request_scan_ioapic(kvm); 502 kvm_vcpu_request_scan_ioapic(kvm);
509#endif
510} 503}
511#endif 504#endif
512 505
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 751ece6a595c..3be43424818b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -468,9 +468,6 @@ static struct kvm *kvm_create_vm(unsigned long type)
468 if (r) 468 if (r)
469 goto out_err_no_disable; 469 goto out_err_no_disable;
470 470
471#ifdef CONFIG_HAVE_KVM_IRQCHIP
472 INIT_HLIST_HEAD(&kvm->mask_notifier_list);
473#endif
474#ifdef CONFIG_HAVE_KVM_IRQFD 471#ifdef CONFIG_HAVE_KVM_IRQFD
475 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list); 472 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
476#endif 473#endif