drivers/iommu/iommufd/iommufd_private.h
Source file repositories/reference/linux-study-clean/drivers/iommu/iommufd/iommufd_private.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/iommu/iommufd/iommufd_private.h- Extension
.h- Size
- 23839 bytes
- Lines
- 750
- Domain
- Driver Families
- Bucket
- drivers/iommu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/iommu.hlinux/iommufd.hlinux/iova_bitmap.hlinux/maple_tree.hlinux/rwsem.hlinux/uaccess.hlinux/xarray.huapi/linux/iommufd.h../iommu-priv.h
Detected Declarations
struct iommu_domainstruct iommu_groupstruct iommu_optionstruct iommufd_devicestruct dma_buf_attachmentstruct iommufd_sw_msi_mapstruct iommufd_sw_msi_mapsstruct iommufd_ctxstruct iommufd_mmapstruct io_pagetablestruct iommufd_ucmdstruct iommufd_ioasstruct iommufd_hw_pagetablestruct iommufd_hwpt_pagingstruct iommufd_hwpt_nestedstruct iommufd_attachstruct iommufd_groupstruct iommufd_devicestruct iommufd_accessstruct iommufd_eventqstruct iommufd_attach_handlestruct iommufd_faultstruct iommufd_veventstruct iommufd_veventqfunction iommufd_ucmd_respondfunction iommufd_lock_objfunction iommufd_put_objectfunction iommufd_object_destroy_userfunction iommufd_object_destroy_userfunction iommufd_object_put_and_try_destroyfunction hwpt_is_pagingfunction to_hwpt_pagingfunction to_hwpt_nestedfunction find_hwpt_pagingfunction iommufd_get_hwpt_pagingfunction iommufd_get_hwpt_nestedfunction iommufd_hw_pagetable_putfunction iommufd_get_devicefunction iommufd_access_is_internalfunction iommufd_access_destroy_internalfunction iommufd_access_detach_internalfunction eventq_to_faultfunction iommufd_get_faultfunction eventq_to_veventqfunction iommufd_get_veventqfunction iommufd_vevent_handlerfunction iommufd_get_viommufunction iommufd_viommu_find_veventq
Annotated Snippet
struct iommufd_sw_msi_map {
struct list_head sw_msi_item;
phys_addr_t sw_msi_start;
phys_addr_t msi_addr;
unsigned int pgoff;
unsigned int id;
};
/* Bitmap of struct iommufd_sw_msi_map::id */
struct iommufd_sw_msi_maps {
DECLARE_BITMAP(bitmap, 64);
};
#ifdef CONFIG_IRQ_MSI_IOMMU
int iommufd_sw_msi_install(struct iommufd_ctx *ictx,
struct iommufd_hwpt_paging *hwpt_paging,
struct iommufd_sw_msi_map *msi_map);
#endif
struct iommufd_ctx {
struct file *file;
struct xarray objects;
struct xarray groups;
wait_queue_head_t destroy_wait;
struct rw_semaphore ioas_creation_lock;
struct maple_tree mt_mmap;
struct mutex sw_msi_lock;
struct list_head sw_msi_list;
unsigned int sw_msi_id;
u8 account_mode;
/* Compatibility with VFIO no iommu */
u8 no_iommu_mode;
struct iommufd_ioas *vfio_ioas;
};
/* Entry for iommufd_ctx::mt_mmap */
struct iommufd_mmap {
struct iommufd_object *owner;
/* Page-shifted start position in mt_mmap to validate vma->vm_pgoff */
unsigned long vm_pgoff;
/* Physical range for io_remap_pfn_range() */
phys_addr_t mmio_addr;
size_t length;
};
/*
* The IOVA to PFN map. The map automatically copies the PFNs into multiple
* domains and permits sharing of PFNs between io_pagetable instances. This
* supports both a design where IOAS's are 1:1 with a domain (eg because the
* domain is HW customized), or where the IOAS is 1:N with multiple generic
* domains. The io_pagetable holds an interval tree of iopt_areas which point
* to shared iopt_pages which hold the pfns mapped to the page table.
*
* The locking order is domains_rwsem -> iova_rwsem -> pages::mutex
*/
struct io_pagetable {
struct rw_semaphore domains_rwsem;
struct xarray domains;
struct xarray access_list;
unsigned int next_domain_id;
struct rw_semaphore iova_rwsem;
struct rb_root_cached area_itree;
/* IOVA that cannot become reserved, struct iopt_allowed */
struct rb_root_cached allowed_itree;
/* IOVA that cannot be allocated, struct iopt_reserved */
struct rb_root_cached reserved_itree;
u8 disable_large_pages;
unsigned long iova_alignment;
};
void iopt_init_table(struct io_pagetable *iopt);
void iopt_destroy_table(struct io_pagetable *iopt);
int iopt_get_pages(struct io_pagetable *iopt, unsigned long iova,
unsigned long length, struct list_head *pages_list);
void iopt_free_pages_list(struct list_head *pages_list);
enum {
IOPT_ALLOC_IOVA = 1 << 0,
};
int iopt_map_user_pages(struct iommufd_ctx *ictx, struct io_pagetable *iopt,
unsigned long *iova, void __user *uptr,
unsigned long length, int iommu_prot,
unsigned int flags);
int iopt_map_file_pages(struct iommufd_ctx *ictx, struct io_pagetable *iopt,
unsigned long *iova, int fd,
unsigned long start, unsigned long length,
Annotation
- Immediate include surface: `linux/iommu.h`, `linux/iommufd.h`, `linux/iova_bitmap.h`, `linux/maple_tree.h`, `linux/rwsem.h`, `linux/uaccess.h`, `linux/xarray.h`, `uapi/linux/iommufd.h`.
- Detected declarations: `struct iommu_domain`, `struct iommu_group`, `struct iommu_option`, `struct iommufd_device`, `struct dma_buf_attachment`, `struct iommufd_sw_msi_map`, `struct iommufd_sw_msi_maps`, `struct iommufd_ctx`, `struct iommufd_mmap`, `struct io_pagetable`.
- Atlas domain: Driver Families / drivers/iommu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.