drivers/vfio/vfio.h
Source file repositories/reference/linux-study-clean/drivers/vfio/vfio.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/vfio/vfio.h- Extension
.h- Size
- 12467 bytes
- Lines
- 465
- Domain
- Driver Families
- Bucket
- drivers/vfio
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/file.hlinux/device.hlinux/cdev.hlinux/module.hlinux/vfio.h
Detected Declarations
struct iommufd_ctxstruct iommu_groupstruct vfio_containerstruct vfio_device_filestruct vfio_groupstruct vfio_groupstruct vfio_iommu_driver_opsstruct vfio_iommu_driverenum vfio_group_typefunction vfio_device_is_noiommufunction vfio_device_block_groupfunction vfio_device_unblock_groupfunction vfio_device_remove_groupfunction vfio_device_group_unuse_iommufunction vfio_group_enforced_coherentfunction vfio_group_set_kvmfunction vfio_group_initfunction vfio_group_cleanupfunction vfio_container_from_filefunction vfio_group_use_containerfunction vfio_group_unuse_containerfunction vfio_group_detach_containerfunction vfio_device_container_unpin_pagesfunction vfio_container_initfunction vfio_container_cleanupfunction vfio_iommufd_device_has_compat_ioasfunction vfio_df_iommufd_bindfunction vfio_df_iommufd_unbindfunction vfio_device_addfunction vfio_device_delfunction vfio_init_device_cdevfunction vfio_device_delfunction vfio_device_fops_cdev_openfunction vfio_df_ioctl_bind_iommufdfunction vfio_df_unbind_iommufdfunction vfio_cdev_cleanupfunction vfio_virqfd_initfunction vfio_virqfd_exitfunction vfio_device_get_kvm_safefunction vfio_debugfs_create_root
Annotated Snippet
extern const struct file_operations vfio_device_fops;
#ifdef CONFIG_VFIO_NOIOMMU
extern bool vfio_noiommu __read_mostly;
#else
enum { vfio_noiommu = false };
#endif
enum vfio_group_type {
/*
* Physical device with IOMMU backing.
*/
VFIO_IOMMU,
/*
* Virtual device without IOMMU backing. The VFIO core fakes up an
* iommu_group as the iommu_group sysfs interface is part of the
* userspace ABI. The user of these devices must not be able to
* directly trigger unmediated DMA.
*/
VFIO_EMULATED_IOMMU,
/*
* Physical device without IOMMU backing. The VFIO core fakes up an
* iommu_group as the iommu_group sysfs interface is part of the
* userspace ABI. Users can trigger unmediated DMA by the device,
* usage is highly dangerous, requires an explicit opt-in and will
* taint the kernel.
*/
VFIO_NO_IOMMU,
};
#if IS_ENABLED(CONFIG_VFIO_GROUP)
struct vfio_group {
struct device dev;
struct cdev cdev;
/*
* When drivers is non-zero a driver is attached to the struct device
* that provided the iommu_group and thus the iommu_group is a valid
* pointer. When drivers is 0 the driver is being detached. Once users
* reaches 0 then the iommu_group is invalid.
*/
refcount_t drivers;
unsigned int container_users;
struct iommu_group *iommu_group;
struct vfio_container *container;
struct list_head device_list;
struct mutex device_lock;
struct list_head vfio_next;
#if IS_ENABLED(CONFIG_VFIO_CONTAINER)
struct list_head container_next;
#endif
enum vfio_group_type type;
struct mutex group_lock;
struct kvm *kvm;
struct file *opened_file;
struct iommufd_ctx *iommufd;
spinlock_t kvm_ref_lock;
unsigned int cdev_device_open_cnt;
};
int vfio_device_block_group(struct vfio_device *device);
void vfio_device_unblock_group(struct vfio_device *device);
int vfio_device_set_group(struct vfio_device *device,
enum vfio_group_type type);
void vfio_device_remove_group(struct vfio_device *device);
void vfio_device_group_register(struct vfio_device *device);
void vfio_device_group_unregister(struct vfio_device *device);
int vfio_device_group_use_iommu(struct vfio_device *device);
void vfio_device_group_unuse_iommu(struct vfio_device *device);
void vfio_df_group_close(struct vfio_device_file *df);
struct vfio_group *vfio_group_from_file(struct file *file);
bool vfio_group_enforced_coherent(struct vfio_group *group);
void vfio_group_set_kvm(struct vfio_group *group, struct kvm *kvm);
bool vfio_device_has_container(struct vfio_device *device);
int __init vfio_group_init(void);
void vfio_group_cleanup(void);
static inline bool vfio_device_is_noiommu(struct vfio_device *vdev)
{
return IS_ENABLED(CONFIG_VFIO_NOIOMMU) &&
vdev->group->type == VFIO_NO_IOMMU;
}
#else
struct vfio_group;
static inline int vfio_device_block_group(struct vfio_device *device)
{
return 0;
}
Annotation
- Immediate include surface: `linux/file.h`, `linux/device.h`, `linux/cdev.h`, `linux/module.h`, `linux/vfio.h`.
- Detected declarations: `struct iommufd_ctx`, `struct iommu_group`, `struct vfio_container`, `struct vfio_device_file`, `struct vfio_group`, `struct vfio_group`, `struct vfio_iommu_driver_ops`, `struct vfio_iommu_driver`, `enum vfio_group_type`, `function vfio_device_is_noiommu`.
- Atlas domain: Driver Families / drivers/vfio.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.