kvm_irqfd.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * irqfd: Allows an fd to be used to inject an interrupt to the guest
  5. * Credit goes to Avi Kivity for the original idea.
  6. */
  7. #ifndef __LINUX_KVM_IRQFD_H
  8. #define __LINUX_KVM_IRQFD_H
  9. #include <linux/kvm_host.h>
  10. #include <linux/poll.h>
  11. /*
  12. * Resampling irqfds are a special variety of irqfds used to emulate
  13. * level triggered interrupts. The interrupt is asserted on eventfd
  14. * trigger. On acknowledgment through the irq ack notifier, the
  15. * interrupt is de-asserted and userspace is notified through the
  16. * resamplefd. All resamplers on the same gsi are de-asserted
  17. * together, so we don't need to track the state of each individual
  18. * user. We can also therefore share the same irq source ID.
  19. */
  20. struct kvm_kernel_irqfd_resampler {
  21. struct kvm *kvm;
  22. /*
  23. * List of resampling struct _irqfd objects sharing this gsi.
  24. * RCU list modified under kvm->irqfds.resampler_lock
  25. */
  26. struct list_head list;
  27. struct kvm_irq_ack_notifier notifier;
  28. /*
  29. * Entry in list of kvm->irqfd.resampler_list. Use for sharing
  30. * resamplers among irqfds on the same gsi.
  31. * Accessed and modified under kvm->irqfds.resampler_lock
  32. */
  33. struct list_head link;
  34. };
  35. struct kvm_kernel_irqfd {
  36. /* Used for MSI fast-path */
  37. struct kvm *kvm;
  38. wait_queue_entry_t wait;
  39. /* Update side is protected by irqfds.lock */
  40. struct kvm_kernel_irq_routing_entry irq_entry;
  41. seqcount_spinlock_t irq_entry_sc;
  42. /* Used for level IRQ fast-path */
  43. int gsi;
  44. struct work_struct inject;
  45. /* The resampler used by this irqfd (resampler-only) */
  46. struct kvm_kernel_irqfd_resampler *resampler;
  47. /* Eventfd notified on resample (resampler-only) */
  48. struct eventfd_ctx *resamplefd;
  49. /* Entry in list of irqfds for a resampler (resampler-only) */
  50. struct list_head resampler_link;
  51. /* Used for setup/shutdown */
  52. struct eventfd_ctx *eventfd;
  53. struct list_head list;
  54. poll_table pt;
  55. struct work_struct shutdown;
  56. struct irq_bypass_consumer consumer;
  57. struct irq_bypass_producer *producer;
  58. };
  59. #endif /* __LINUX_KVM_IRQFD_H */