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

KVM: Distangle eventfd code from irqchip

The current eventfd code assumes that when we have eventfd, we also have
irqfd for in-kernel interrupt delivery. This is not necessarily true. On
PPC we don't have an in-kernel irqchip yet, but we can still support easily
support eventfd.

Signed-off-by: Alexander Graf <agraf@suse.de>

+17 -1
+11 -1
include/linux/kvm_host.h
··· 900 900 #ifdef CONFIG_HAVE_KVM_EVENTFD 901 901 902 902 void kvm_eventfd_init(struct kvm *kvm); 903 + int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args); 904 + 905 + #ifdef CONFIG_HAVE_KVM_IRQCHIP 903 906 int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args); 904 907 void kvm_irqfd_release(struct kvm *kvm); 905 908 void kvm_irq_routing_update(struct kvm *, struct kvm_irq_routing_table *); 906 - int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args); 909 + #else 910 + static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args) 911 + { 912 + return -EINVAL; 913 + } 914 + 915 + static inline void kvm_irqfd_release(struct kvm *kvm) {} 916 + #endif 907 917 908 918 #else 909 919
+6
virt/kvm/eventfd.c
··· 35 35 36 36 #include "iodev.h" 37 37 38 + #ifdef __KVM_HAVE_IOAPIC 38 39 /* 39 40 * -------------------------------------------------------------------- 40 41 * irqfd: Allows an fd to be used to inject an interrupt to the guest ··· 426 425 kfree(irqfd); 427 426 return ret; 428 427 } 428 + #endif 429 429 430 430 void 431 431 kvm_eventfd_init(struct kvm *kvm) 432 432 { 433 + #ifdef __KVM_HAVE_IOAPIC 433 434 spin_lock_init(&kvm->irqfds.lock); 434 435 INIT_LIST_HEAD(&kvm->irqfds.items); 435 436 INIT_LIST_HEAD(&kvm->irqfds.resampler_list); 436 437 mutex_init(&kvm->irqfds.resampler_lock); 438 + #endif 437 439 INIT_LIST_HEAD(&kvm->ioeventfds); 438 440 } 439 441 442 + #ifdef __KVM_HAVE_IOAPIC 440 443 /* 441 444 * shutdown any irqfd's that match fd+gsi 442 445 */ ··· 560 555 561 556 module_init(irqfd_module_init); 562 557 module_exit(irqfd_module_exit); 558 + #endif 563 559 564 560 /* 565 561 * --------------------------------------------------------------------