aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-08-06 08:24:45 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-08-06 08:24:47 -0400
commitc77dcacb397519b6ade8f08201a4a90a7f4f751e (patch)
tree40ef78afecdc7775b1507f862d18604f20ada399 /virt
parent56cc2406d68c0f09505c389e276f27a99f495cbd (diff)
KVM: Move more code under CONFIG_HAVE_KVM_IRQFD
Commits e4d57e1ee1ab (KVM: Move irq notifier implementation into eventfd.c, 2014-06-30) included the irq notifier code unconditionally in eventfd.c, while it was under CONFIG_HAVE_KVM_IRQCHIP before. Similarly, commit 297e21053a52 (KVM: Give IRQFD its own separate enabling Kconfig option, 2014-06-30) moved code from CONFIG_HAVE_IRQ_ROUTING to CONFIG_HAVE_KVM_IRQFD but forgot to move the pieces that used to be under CONFIG_HAVE_KVM_IRQCHIP. Together, this broke compilation without CONFIG_KVM_XICS. Fix by adding or changing the #ifdefs so that they point at CONFIG_HAVE_KVM_IRQFD. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/eventfd.c122
-rw-r--r--virt/kvm/kvm_main.c2
2 files changed, 63 insertions, 61 deletions
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index f5f61548f60d..3c5981c87c3f 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -445,6 +445,67 @@ out:
445 kfree(irqfd); 445 kfree(irqfd);
446 return ret; 446 return ret;
447} 447}
448
449bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin)
450{
451 struct kvm_irq_ack_notifier *kian;
452 int gsi, idx;
453
454 idx = srcu_read_lock(&kvm->irq_srcu);
455 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
456 if (gsi != -1)
457 hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
458 link)
459 if (kian->gsi == gsi) {
460 srcu_read_unlock(&kvm->irq_srcu, idx);
461 return true;
462 }
463
464 srcu_read_unlock(&kvm->irq_srcu, idx);
465
466 return false;
467}
468EXPORT_SYMBOL_GPL(kvm_irq_has_notifier);
469
470void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
471{
472 struct kvm_irq_ack_notifier *kian;
473 int gsi, idx;
474
475 trace_kvm_ack_irq(irqchip, pin);
476
477 idx = srcu_read_lock(&kvm->irq_srcu);
478 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
479 if (gsi != -1)
480 hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
481 link)
482 if (kian->gsi == gsi)
483 kian->irq_acked(kian);
484 srcu_read_unlock(&kvm->irq_srcu, idx);
485}
486
487void kvm_register_irq_ack_notifier(struct kvm *kvm,
488 struct kvm_irq_ack_notifier *kian)
489{
490 mutex_lock(&kvm->irq_lock);
491 hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list);
492 mutex_unlock(&kvm->irq_lock);
493#ifdef __KVM_HAVE_IOAPIC
494 kvm_vcpu_request_scan_ioapic(kvm);
495#endif
496}
497
498void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
499 struct kvm_irq_ack_notifier *kian)
500{
501 mutex_lock(&kvm->irq_lock);
502 hlist_del_init_rcu(&kian->link);
503 mutex_unlock(&kvm->irq_lock);
504 synchronize_srcu(&kvm->irq_srcu);
505#ifdef __KVM_HAVE_IOAPIC
506 kvm_vcpu_request_scan_ioapic(kvm);
507#endif
508}
448#endif 509#endif
449 510
450void 511void
@@ -867,64 +928,3 @@ kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
867 928
868 return kvm_assign_ioeventfd(kvm, args); 929 return kvm_assign_ioeventfd(kvm, args);
869} 930}
870
871bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin)
872{
873 struct kvm_irq_ack_notifier *kian;
874 int gsi, idx;
875
876 idx = srcu_read_lock(&kvm->irq_srcu);
877 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
878 if (gsi != -1)
879 hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
880 link)
881 if (kian->gsi == gsi) {
882 srcu_read_unlock(&kvm->irq_srcu, idx);
883 return true;
884 }
885
886 srcu_read_unlock(&kvm->irq_srcu, idx);
887
888 return false;
889}
890EXPORT_SYMBOL_GPL(kvm_irq_has_notifier);
891
892void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
893{
894 struct kvm_irq_ack_notifier *kian;
895 int gsi, idx;
896
897 trace_kvm_ack_irq(irqchip, pin);
898
899 idx = srcu_read_lock(&kvm->irq_srcu);
900 gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
901 if (gsi != -1)
902 hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
903 link)
904 if (kian->gsi == gsi)
905 kian->irq_acked(kian);
906 srcu_read_unlock(&kvm->irq_srcu, idx);
907}
908
909void kvm_register_irq_ack_notifier(struct kvm *kvm,
910 struct kvm_irq_ack_notifier *kian)
911{
912 mutex_lock(&kvm->irq_lock);
913 hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list);
914 mutex_unlock(&kvm->irq_lock);
915#ifdef __KVM_HAVE_IOAPIC
916 kvm_vcpu_request_scan_ioapic(kvm);
917#endif
918}
919
920void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
921 struct kvm_irq_ack_notifier *kian)
922{
923 mutex_lock(&kvm->irq_lock);
924 hlist_del_init_rcu(&kian->link);
925 mutex_unlock(&kvm->irq_lock);
926 synchronize_srcu(&kvm->irq_srcu);
927#ifdef __KVM_HAVE_IOAPIC
928 kvm_vcpu_request_scan_ioapic(kvm);
929#endif
930}
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a69a623938b8..33712fb26eb1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -465,6 +465,8 @@ static struct kvm *kvm_create_vm(unsigned long type)
465 465
466#ifdef CONFIG_HAVE_KVM_IRQCHIP 466#ifdef CONFIG_HAVE_KVM_IRQCHIP
467 INIT_HLIST_HEAD(&kvm->mask_notifier_list); 467 INIT_HLIST_HEAD(&kvm->mask_notifier_list);
468#endif
469#ifdef CONFIG_HAVE_KVM_IRQFD
468 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list); 470 INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
469#endif 471#endif
470 472