mshv_eventfd.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * irqfd: Allows an fd to be used to inject an interrupt to the guest.
  4. * ioeventfd: Allow an fd to be used to receive a signal from the guest.
  5. * All credit goes to kvm developers.
  6. */
  7. #ifndef __LINUX_MSHV_EVENTFD_H
  8. #define __LINUX_MSHV_EVENTFD_H
  9. #include <linux/poll.h>
  10. #include "mshv.h"
  11. #include "mshv_root.h"
  12. /* struct to contain list of irqfds sharing an irq. Updates are protected by
  13. * partition.irqfds.resampler_lock
  14. */
  15. struct mshv_irqfd_resampler {
  16. struct mshv_partition *rsmplr_partn;
  17. struct hlist_head rsmplr_irqfd_list;
  18. struct mshv_irq_ack_notifier rsmplr_notifier;
  19. struct hlist_node rsmplr_hnode;
  20. };
  21. struct mshv_irqfd {
  22. struct mshv_partition *irqfd_partn;
  23. struct eventfd_ctx *irqfd_eventfd_ctx;
  24. struct mshv_guest_irq_ent irqfd_girq_ent;
  25. seqcount_spinlock_t irqfd_irqe_sc;
  26. u32 irqfd_irqnum;
  27. struct mshv_lapic_irq irqfd_lapic_irq;
  28. struct hlist_node irqfd_hnode;
  29. poll_table irqfd_polltbl;
  30. wait_queue_entry_t irqfd_wait;
  31. struct work_struct irqfd_shutdown;
  32. struct mshv_irqfd_resampler *irqfd_resampler;
  33. struct eventfd_ctx *irqfd_resamplefd;
  34. struct hlist_node irqfd_resampler_hnode;
  35. };
  36. void mshv_eventfd_init(struct mshv_partition *partition);
  37. void mshv_eventfd_release(struct mshv_partition *partition);
  38. void mshv_register_irq_ack_notifier(struct mshv_partition *partition,
  39. struct mshv_irq_ack_notifier *mian);
  40. void mshv_unregister_irq_ack_notifier(struct mshv_partition *partition,
  41. struct mshv_irq_ack_notifier *mian);
  42. bool mshv_notify_acked_gsi(struct mshv_partition *partition, int gsi);
  43. int mshv_set_unset_irqfd(struct mshv_partition *partition,
  44. struct mshv_user_irqfd *args);
  45. int mshv_irqfd_wq_init(void);
  46. void mshv_irqfd_wq_cleanup(void);
  47. struct mshv_ioeventfd {
  48. struct hlist_node iovntfd_hnode;
  49. u64 iovntfd_addr;
  50. int iovntfd_length;
  51. struct eventfd_ctx *iovntfd_eventfd;
  52. u64 iovntfd_datamatch;
  53. int iovntfd_doorbell_id;
  54. bool iovntfd_wildcard;
  55. };
  56. int mshv_set_unset_ioeventfd(struct mshv_partition *pt,
  57. struct mshv_user_ioeventfd *args);
  58. #endif /* __LINUX_MSHV_EVENTFD_H */