Skip to content

Commit 914daba

Browse files
committed
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>
1 parent 45e3cc7 commit 914daba

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎include/linux/kvm_host.h‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,20 @@ static inline void kvm_free_irq_routing(struct kvm *kvm) {}
900900
#ifdef CONFIG_HAVE_KVM_EVENTFD
901901

902902
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
903906
int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args);
904907
void kvm_irqfd_release(struct kvm *kvm);
905908
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
907917

908918
#else
909919

‎virt/kvm/eventfd.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include "iodev.h"
3737

38+
#ifdef __KVM_HAVE_IOAPIC
3839
/*
3940
* --------------------------------------------------------------------
4041
* irqfd: Allows an fd to be used to inject an interrupt to the guest
@@ -425,17 +426,21 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
425426
kfree(irqfd);
426427
return ret;
427428
}
429+
#endif
428430

429431
void
430432
kvm_eventfd_init(struct kvm *kvm)
431433
{
434+
#ifdef __KVM_HAVE_IOAPIC
432435
spin_lock_init(&kvm->irqfds.lock);
433436
INIT_LIST_HEAD(&kvm->irqfds.items);
434437
INIT_LIST_HEAD(&kvm->irqfds.resampler_list);
435438
mutex_init(&kvm->irqfds.resampler_lock);
439+
#endif
436440
INIT_LIST_HEAD(&kvm->ioeventfds);
437441
}
438442

443+
#ifdef __KVM_HAVE_IOAPIC
439444
/*
440445
* shutdown any irqfd's that match fd+gsi
441446
*/
@@ -555,6 +560,7 @@ static void __exit irqfd_module_exit(void)
555560

556561
module_init(irqfd_module_init);
557562
module_exit(irqfd_module_exit);
563+
#endif
558564

559565
/*
560566
* --------------------------------------------------------------------

0 commit comments

Comments
 (0)