#include <linux/cdev.h>
#include <linux/compat.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/idr.h>
#include <linux/iommu.h>
#if IS_ENABLED(CONFIG_KVM)
#include <linux/kvm_host.h>
#endif
#include <linux/list.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mount.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/pseudo_fs.h>
#include <linux/rwsem.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/uaccess.h>
#include <linux/vfio.h>
#include <linux/wait.h>
#include <linux/sched/signal.h>
#include <linux/pm_runtime.h>
#include <linux/interval_tree.h>
#include <linux/iova_bitmap.h>
#include <linux/iommufd.h>
#include "vfio.h"
#define DRIVER_VERSION …
#define DRIVER_AUTHOR …
#define DRIVER_DESC …
#define VFIO_MAGIC …
static struct vfio { … } vfio;
#ifdef CONFIG_VFIO_NOIOMMU
bool vfio_noiommu __read_mostly;
module_param_named(enable_unsafe_noiommu_mode,
vfio_noiommu, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(…) …;
#endif
static DEFINE_XARRAY(vfio_device_set_xa);
int vfio_assign_device_set(struct vfio_device *device, void *set_id)
{ … }
EXPORT_SYMBOL_GPL(…);
static void vfio_release_device_set(struct vfio_device *device)
{ … }
unsigned int vfio_device_set_open_count(struct vfio_device_set *dev_set)
{ … }
EXPORT_SYMBOL_GPL(…);
struct vfio_device *
vfio_find_device_in_devset(struct vfio_device_set *dev_set,
struct device *dev)
{ … }
EXPORT_SYMBOL_GPL(…);
void vfio_device_put_registration(struct vfio_device *device)
{ … }
bool vfio_device_try_get_registration(struct vfio_device *device)
{ … }
static void vfio_device_release(struct device *dev)
{ … }
static int vfio_init_device(struct vfio_device *device, struct device *dev,
const struct vfio_device_ops *ops);
struct vfio_device *_vfio_alloc_device(size_t size, struct device *dev,
const struct vfio_device_ops *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
static int vfio_fs_init_fs_context(struct fs_context *fc)
{ … }
static struct file_system_type vfio_fs_type = …;
static struct inode *vfio_fs_inode_new(void)
{ … }
static int vfio_init_device(struct vfio_device *device, struct device *dev,
const struct vfio_device_ops *ops)
{ … }
static int __vfio_register_dev(struct vfio_device *device,
enum vfio_group_type type)
{ … }
int vfio_register_group_dev(struct vfio_device *device)
{ … }
EXPORT_SYMBOL_GPL(…);
int vfio_register_emulated_iommu_dev(struct vfio_device *device)
{ … }
EXPORT_SYMBOL_GPL(…);
void vfio_unregister_group_dev(struct vfio_device *device)
{ … }
EXPORT_SYMBOL_GPL(…);
#if IS_ENABLED(CONFIG_KVM)
void vfio_device_get_kvm_safe(struct vfio_device *device, struct kvm *kvm)
{ … }
void vfio_device_put_kvm(struct vfio_device *device)
{ … }
#endif
static bool vfio_assert_device_open(struct vfio_device *device)
{ … }
struct vfio_device_file *
vfio_allocate_device_file(struct vfio_device *device)
{ … }
static int vfio_df_device_first_open(struct vfio_device_file *df)
{ … }
static void vfio_df_device_last_close(struct vfio_device_file *df)
{ … }
int vfio_df_open(struct vfio_device_file *df)
{ … }
void vfio_df_close(struct vfio_device_file *df)
{ … }
static inline int vfio_device_pm_runtime_get(struct vfio_device *device)
{ … }
static inline void vfio_device_pm_runtime_put(struct vfio_device *device)
{ … }
static int vfio_device_fops_release(struct inode *inode, struct file *filep)
{ … }
int vfio_mig_get_next_state(struct vfio_device *device,
enum vfio_device_mig_state cur_fsm,
enum vfio_device_mig_state new_fsm,
enum vfio_device_mig_state *next_fsm)
{ … }
EXPORT_SYMBOL_GPL(…);
static int vfio_ioct_mig_return_fd(struct file *filp, void __user *arg,
struct vfio_device_feature_mig_state *mig)
{ … }
static int
vfio_ioctl_device_feature_mig_device_state(struct vfio_device *device,
u32 flags, void __user *arg,
size_t argsz)
{ … }
static int
vfio_ioctl_device_feature_migration_data_size(struct vfio_device *device,
u32 flags, void __user *arg,
size_t argsz)
{ … }
static int vfio_ioctl_device_feature_migration(struct vfio_device *device,
u32 flags, void __user *arg,
size_t argsz)
{ … }
void vfio_combine_iova_ranges(struct rb_root_cached *root, u32 cur_nodes,
u32 req_nodes)
{ … }
EXPORT_SYMBOL_GPL(…);
#define LOG_MAX_RANGES …
static int
vfio_ioctl_device_feature_logging_start(struct vfio_device *device,
u32 flags, void __user *arg,
size_t argsz)
{ … }
static int
vfio_ioctl_device_feature_logging_stop(struct vfio_device *device,
u32 flags, void __user *arg,
size_t argsz)
{ … }
static int vfio_device_log_read_and_clear(struct iova_bitmap *iter,
unsigned long iova, size_t length,
void *opaque)
{ … }
static int
vfio_ioctl_device_feature_logging_report(struct vfio_device *device,
u32 flags, void __user *arg,
size_t argsz)
{ … }
static int vfio_ioctl_device_feature(struct vfio_device *device,
struct vfio_device_feature __user *arg)
{ … }
static long vfio_device_fops_unl_ioctl(struct file *filep,
unsigned int cmd, unsigned long arg)
{ … }
static ssize_t vfio_device_fops_read(struct file *filep, char __user *buf,
size_t count, loff_t *ppos)
{ … }
static ssize_t vfio_device_fops_write(struct file *filep,
const char __user *buf,
size_t count, loff_t *ppos)
{ … }
static int vfio_device_fops_mmap(struct file *filep, struct vm_area_struct *vma)
{ … }
const struct file_operations vfio_device_fops = …;
static struct vfio_device *vfio_device_from_file(struct file *file)
{ … }
bool vfio_file_is_valid(struct file *file)
{ … }
EXPORT_SYMBOL_GPL(…);
bool vfio_file_enforced_coherent(struct file *file)
{ … }
EXPORT_SYMBOL_GPL(…);
static void vfio_device_file_set_kvm(struct file *file, struct kvm *kvm)
{ … }
void vfio_file_set_kvm(struct file *file, struct kvm *kvm)
{ … }
EXPORT_SYMBOL_GPL(…);
struct vfio_info_cap_header *vfio_info_cap_add(struct vfio_info_cap *caps,
size_t size, u16 id, u16 version)
{ … }
EXPORT_SYMBOL_GPL(…);
void vfio_info_cap_shift(struct vfio_info_cap *caps, size_t offset)
{ … }
EXPORT_SYMBOL(…);
int vfio_info_add_capability(struct vfio_info_cap *caps,
struct vfio_info_cap_header *cap, size_t size)
{ … }
EXPORT_SYMBOL(…);
int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr, int num_irqs,
int max_irq_type, size_t *data_size)
{ … }
EXPORT_SYMBOL(…);
int vfio_pin_pages(struct vfio_device *device, dma_addr_t iova,
int npage, int prot, struct page **pages)
{ … }
EXPORT_SYMBOL(…);
void vfio_unpin_pages(struct vfio_device *device, dma_addr_t iova, int npage)
{ … }
EXPORT_SYMBOL(…);
int vfio_dma_rw(struct vfio_device *device, dma_addr_t iova, void *data,
size_t len, bool write)
{ … }
EXPORT_SYMBOL(…);
static int __init vfio_init(void)
{ … }
static void __exit vfio_cleanup(void)
{ … }
module_init(…) …;
module_exit(vfio_cleanup);
MODULE_IMPORT_NS(…);
MODULE_VERSION(…);
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…);
MODULE_DESCRIPTION(…);
MODULE_SOFTDEP(…) …;