Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *
0004  * irqfd: Allows an fd to be used to inject an interrupt to the guest
0005  * Credit goes to Avi Kivity for the original idea.
0006  */
0007 
0008 #ifndef __LINUX_KVM_IRQFD_H
0009 #define __LINUX_KVM_IRQFD_H
0010 
0011 #include <linux/kvm_host.h>
0012 #include <linux/poll.h>
0013 
0014 /*
0015  * Resampling irqfds are a special variety of irqfds used to emulate
0016  * level triggered interrupts.  The interrupt is asserted on eventfd
0017  * trigger.  On acknowledgment through the irq ack notifier, the
0018  * interrupt is de-asserted and userspace is notified through the
0019  * resamplefd.  All resamplers on the same gsi are de-asserted
0020  * together, so we don't need to track the state of each individual
0021  * user.  We can also therefore share the same irq source ID.
0022  */
0023 struct kvm_kernel_irqfd_resampler {
0024     struct kvm *kvm;
0025     /*
0026      * List of resampling struct _irqfd objects sharing this gsi.
0027      * RCU list modified under kvm->irqfds.resampler_lock
0028      */
0029     struct list_head list;
0030     struct kvm_irq_ack_notifier notifier;
0031     /*
0032      * Entry in list of kvm->irqfd.resampler_list.  Use for sharing
0033      * resamplers among irqfds on the same gsi.
0034      * Accessed and modified under kvm->irqfds.resampler_lock
0035      */
0036     struct list_head link;
0037 };
0038 
0039 struct kvm_kernel_irqfd {
0040     /* Used for MSI fast-path */
0041     struct kvm *kvm;
0042     wait_queue_entry_t wait;
0043     /* Update side is protected by irqfds.lock */
0044     struct kvm_kernel_irq_routing_entry irq_entry;
0045     seqcount_spinlock_t irq_entry_sc;
0046     /* Used for level IRQ fast-path */
0047     int gsi;
0048     struct work_struct inject;
0049     /* The resampler used by this irqfd (resampler-only) */
0050     struct kvm_kernel_irqfd_resampler *resampler;
0051     /* Eventfd notified on resample (resampler-only) */
0052     struct eventfd_ctx *resamplefd;
0053     /* Entry in list of irqfds for a resampler (resampler-only) */
0054     struct list_head resampler_link;
0055     /* Used for setup/shutdown */
0056     struct eventfd_ctx *eventfd;
0057     struct list_head list;
0058     poll_table pt;
0059     struct work_struct shutdown;
0060     struct irq_bypass_consumer consumer;
0061     struct irq_bypass_producer *producer;
0062 };
0063 
0064 #endif /* __LINUX_KVM_IRQFD_H */