kvm_irqfd.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * irqfd: Allows an fd to be used to inject an interrupt to the guest
  12. * Credit goes to Avi Kivity for the original idea.
  13. */
  14. #ifndef __LINUX_KVM_IRQFD_H
  15. #define __LINUX_KVM_IRQFD_H
  16. #include <linux/kvm_host.h>
  17. #include <linux/poll.h>
  18. /*
  19. * Resampling irqfds are a special variety of irqfds used to emulate
  20. * level triggered interrupts. The interrupt is asserted on eventfd
  21. * trigger. On acknowledgment through the irq ack notifier, the
  22. * interrupt is de-asserted and userspace is notified through the
  23. * resamplefd. All resamplers on the same gsi are de-asserted
  24. * together, so we don't need to track the state of each individual
  25. * user. We can also therefore share the same irq source ID.
  26. */
  27. struct kvm_kernel_irqfd_resampler {
  28. struct kvm *kvm;
  29. /*
  30. * List of resampling struct _irqfd objects sharing this gsi.
  31. * RCU list modified under kvm->irqfds.resampler_lock
  32. */
  33. struct list_head list;
  34. struct kvm_irq_ack_notifier notifier;
  35. /*
  36. * Entry in list of kvm->irqfd.resampler_list. Use for sharing
  37. * resamplers among irqfds on the same gsi.
  38. * Accessed and modified under kvm->irqfds.resampler_lock
  39. */
  40. struct list_head link;
  41. };
  42. struct kvm_kernel_irqfd {
  43. /* Used for MSI fast-path */
  44. struct kvm *kvm;
  45. wait_queue_t wait;
  46. /* Update side is protected by irqfds.lock */
  47. struct kvm_kernel_irq_routing_entry irq_entry;
  48. seqcount_t irq_entry_sc;
  49. /* Used for level IRQ fast-path */
  50. int gsi;
  51. struct work_struct inject;
  52. /* The resampler used by this irqfd (resampler-only) */
  53. struct kvm_kernel_irqfd_resampler *resampler;
  54. /* Eventfd notified on resample (resampler-only) */
  55. struct eventfd_ctx *resamplefd;
  56. /* Entry in list of irqfds for a resampler (resampler-only) */
  57. struct list_head resampler_link;
  58. /* Used for setup/shutdown */
  59. struct eventfd_ctx *eventfd;
  60. struct list_head list;
  61. poll_table pt;
  62. struct work_struct shutdown;
  63. struct irq_bypass_consumer consumer;
  64. struct irq_bypass_producer *producer;
  65. };
  66. #endif /* __LINUX_KVM_IRQFD_H */