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