include/linux/vfio.h
Source file repositories/reference/linux-study-clean/include/linux/vfio.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/vfio.h- Extension
.h- Size
- 15647 bytes
- Lines
- 433
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/iommu.hlinux/mm.hlinux/workqueue.hlinux/poll.hlinux/cdev.huapi/linux/vfio.hlinux/iova_bitmap.hlinux/uaccess.h
Detected Declarations
struct kvmstruct iommufd_ctxstruct iommufd_devicestruct iommufd_accessstruct vfio_info_capstruct vfio_device_setstruct vfio_devicestruct vfio_device_opsstruct vfio_migration_opsstruct vfio_log_opsstruct vfio_info_capstruct virqfdfunction vfio_iommufd_device_ictxfunction vfio_iommufd_get_dev_idfunction vfio_device_cdev_openedfunction vfio_check_featurefunction vfio_check_precopy_ioctlfunction BUILD_BUG_ON_ZEROfunction vfio_file_is_groupfunction vfio_file_has_dev
Annotated Snippet
struct vfio_device_set {
void *set_id;
struct mutex lock;
struct list_head device_list;
unsigned int device_count;
};
struct vfio_device {
struct device *dev;
const struct vfio_device_ops *ops;
/*
* mig_ops/log_ops is a static property of the vfio_device which must
* be set prior to registering the vfio_device.
*/
const struct vfio_migration_ops *mig_ops;
const struct vfio_log_ops *log_ops;
#if IS_ENABLED(CONFIG_VFIO_GROUP)
struct vfio_group *group;
struct list_head group_next;
struct list_head iommu_entry;
#endif
struct vfio_device_set *dev_set;
struct list_head dev_set_list;
unsigned int migration_flags;
u8 precopy_info_v2;
struct kvm *kvm;
/* Members below here are private, not for driver use */
unsigned int index;
struct device device; /* device.kref covers object life circle */
#if IS_ENABLED(CONFIG_VFIO_DEVICE_CDEV)
struct cdev cdev;
#endif
refcount_t refcount; /* user count on registered device*/
unsigned int open_count;
struct completion comp;
struct iommufd_access *iommufd_access;
void (*put_kvm)(struct kvm *kvm);
struct inode *inode;
#if IS_ENABLED(CONFIG_IOMMUFD)
struct iommufd_device *iommufd_device;
struct ida pasids;
u8 iommufd_attached:1;
#endif
u8 cdev_opened:1;
/*
* debug_root is a static property of the vfio_device
* which must be set prior to registering the vfio_device.
*/
struct dentry *debug_root;
};
/**
* struct vfio_device_ops - VFIO bus driver device callbacks
*
* @name: Name of the device driver.
* @init: initialize private fields in device structure
* @release: Reclaim private fields in device structure
* @bind_iommufd: Called when binding the device to an iommufd
* @unbind_iommufd: Opposite of bind_iommufd
* @attach_ioas: Called when attaching device to an IOAS/HWPT managed by the
* bound iommufd. Undo in unbind_iommufd if @detach_ioas is not
* called.
* @detach_ioas: Opposite of attach_ioas
* @pasid_attach_ioas: The pasid variation of attach_ioas
* @pasid_detach_ioas: Opposite of pasid_attach_ioas
* @open_device: Called when the first file descriptor is opened for this device
* @close_device: Opposite of open_device
* @read: Perform read(2) on device file descriptor
* @write: Perform write(2) on device file descriptor
* @ioctl: Perform ioctl(2) on device file descriptor, supporting VFIO_DEVICE_*
* operations documented below
* @mmap: Perform mmap(2) on a region of the device file descriptor
* @request: Request for the bus driver to release the device
* @match: Optional device name match callback (return: 0 for no-match, >0 for
* match, -errno for abort (ex. match with insufficient or incorrect
* additional args)
* @match_token_uuid: Optional device token match/validation. Return 0
* if the uuid is valid for the device, -errno otherwise. uuid is NULL
* if none was provided.
* @dma_unmap: Called when userspace unmaps IOVA from the container
* this device is attached to.
* @device_feature: Optional, fill in the VFIO_DEVICE_FEATURE ioctl
*/
struct vfio_device_ops {
char *name;
int (*init)(struct vfio_device *vdev);
void (*release)(struct vfio_device *vdev);
int (*bind_iommufd)(struct vfio_device *vdev,
struct iommufd_ctx *ictx, u32 *out_device_id);
Annotation
- Immediate include surface: `linux/iommu.h`, `linux/mm.h`, `linux/workqueue.h`, `linux/poll.h`, `linux/cdev.h`, `uapi/linux/vfio.h`, `linux/iova_bitmap.h`, `linux/uaccess.h`.
- Detected declarations: `struct kvm`, `struct iommufd_ctx`, `struct iommufd_device`, `struct iommufd_access`, `struct vfio_info_cap`, `struct vfio_device_set`, `struct vfio_device`, `struct vfio_device_ops`, `struct vfio_migration_ops`, `struct vfio_log_ops`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.