STRUCT IOMMU_OPS(9)
π struct iommu_ops π
okay bestie, welcome to the Kernel API Manual β this is the page for struct iommu_ops(9), aka "iommu ops and capabilities", and honestly it's giving main-character energy in the IOMMU world π
β¨ NAME β¨
struct iommu_ops β iommu ops and capabilities. that's it, that's the whole vibe check π¦
πΈ SYNOPSIS πΈ
here's the whole struct, laid out for you, no cap:
struct iommu_ops {
bool (*capable)(struct device *dev, enum iommu_cap);
void *(*hw_info)(struct device *dev, u32 *length, enum iommu_hw_info_type *type);
#if IS_ENABLED(CONFIG_FSL_PAMU);
struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
#endif;
struct iommu_domain *(*domain_alloc_identity)(struct device *dev);
struct iommu_domain *(*domain_alloc_paging_flags)( struct device *dev, u32 flags, const struct iommu_user_data *user_data);
struct iommu_domain *(*domain_alloc_paging)(struct device *dev);
struct iommu_domain *(*domain_alloc_sva)(struct device *dev, struct mm_struct *mm);
struct iommu_domain *(*domain_alloc_nested)( struct device *dev, struct iommu_domain *parent, u32 flags, const struct iommu_user_data *user_data);
struct iommu_device *(*probe_device)(struct device *dev);
void (*release_device)(struct device *dev);
void (*probe_finalize)(struct device *dev);
struct iommu_group *(*device_group)(struct device *dev);
void (*get_resv_regions)(struct device *dev, struct list_head *list);
int (*of_xlate)(struct device *dev, const struct of_phandle_args *args);
bool (*is_attach_deferred)(struct device *dev);
void (*page_response)(struct device *dev, struct iopf_fault *evt, struct iommu_page_response *msg);
int (*def_domain_type)(struct device *dev);
size_t (*get_viommu_size)(struct device *dev, enum iommu_viommu_type viommu_type);
int (*viommu_init)(struct iommufd_viommu *viommu, struct iommu_domain *parent_domain, const struct iommu_user_data *user_data);
const struct iommu_domain_ops *default_domain_ops;
struct module *owner;
struct iommu_domain *identity_domain;
struct iommu_domain *blocked_domain;
struct iommu_domain *release_domain;
struct iommu_domain *default_domain;
u8 user_pasid_table:1;
};
π MEMBERS π
okay so now we go through every single field, one by one, because we do not skip π
capableβ check capability πhw_infoβ report iommu hardware information. The data buffer returned by this op is allocated in the iommu driver and freed by the caller after use.typecan input a requested type and output a supported type. Driver should reject an unsupported data type input π ββοΈdomain_allocβ Do not use in new drivers β οΈ like, seriously, don'tdomain_alloc_identityβ allocate an IDENTITY domain. Drivers should prefer to useidentity_domaininstead. This should only be used if dynamic logic is necessary πdomain_alloc_paging_flagsβ Allocate an iommu domain corresponding to the input parameters as defined ininclude/uapi/linux/iommufd.h. Theuser_datacan be optionally provided, the new domain must support__IOMMU_DOMAIN_PAGING. Upon failure,ERR_PTRmust be returned π«Άdomain_alloc_pagingβ Allocate aniommu_domainthat can be used forUNMANAGED,DMA, andDMA_FQdomain types. This is the same as invokingdomain_alloc_paging_flagswithflags=0,user_data=NULL. A driver should implement only one of the two ops π―ββοΈ (pick one, bestie, not both)domain_alloc_svaβ Allocate aniommu_domainfor Shared Virtual Addressing πdomain_alloc_nestedβ Allocate aniommu_domainfor nested translation πͺprobe_deviceβ Add device to iommu driver handling βrelease_deviceβ Remove device from iommu driver handling βprobe_finalizeβ Do final setup work after the device is added to an IOMMU group and attached to the groups domain πdevice_groupβ find iommu group for a particular device πget_resv_regionsβ Request list of reserved regions for a device πof_xlateβ add OF master IDs to iommu grouping π³is_attach_deferredβ Check if domain attach should be deferred from iommu driver init to device driver init (default no) β³page_responseβ handle page request response π¨def_domain_typeβ device default domain type, return value:IOMMU_DOMAIN_IDENTITY: must use an identity domainIOMMU_DOMAIN_DMA: must use a dma domain0: use the default setting
get_viommu_sizeβ Get the size of a driver-level vIOMMU structure for a givendevcorresponding toviommu_type. Driver should return0if vIOMMU isn't supported accordingly. It is required for driver to use theVIOMMU_STRUCT_SIZEmacro to sanitize the driver-level vIOMMU structure related to the core one πviommu_initβ Init the driver-level struct of aniommufd_viommuon a physical IOMMU instanceviommu->iommu_dev, as the set of virtualization resources shared/passed to user space IOMMU instance. Associate it with a nestingparent_domain. It is required for driver to setviommu->opspointing to its ownviommu_opsπ§default_domain_opsβ the default ops for domains π§¬ownerβ Driver module providing these ops π¦identity_domainβ An always available, always attachable identity translation β¨blocked_domainβ An always available, always attachable blocking translation π«default_domainβ If notNULLthis will always be set as the default domain. This should be an IDENTITY/BLOCKED/PLATFORM domain. Do not use in new drivers. β οΈ (yes, another one of those)user_pasid_tableβ IOMMU driver supports user-managed PASID table. There is no user domain for each PASID and the I/O page faults are forwarded through the user domain attached to the device RID ποΈ
fr fr, if you're writing a new driver and you reach fordomain_allocordefault_domain, read the line above again. it's literally telling you not to π
π SEE ALSO π
go read these next, bestie, they're all in the Kernel file ./include/linux/iommu.h:
struct iommu_fault_page_request(9), struct iommu_fault(9), enum iommu_page_response_code(9), struct iommu_page_response(9), struct iopf_queue(9), struct iommu_resv_region(9), struct iommu_iotlb_gather(9), struct iommu_dirty_bitmap(9), struct iommu_dirty_ops(9), struct iommu_user_data(9), struct iommu_user_data_array(9), __iommu_copy_struct_from_user(9), iommu_copy_struct_from_user(9), __iommu_copy_struct_from_user_array(9), iommu_copy_struct_from_user_array(9), iommu_copy_struct_from_full_user_array(9), __iommu_copy_struct_to_user(9), iommu_copy_struct_to_user(9), struct iommu_domain_ops(9), struct iommu_device(9), struct iommu_fault_param(9), struct dev_iommu(9), iommu_iotlb_gather_is_disjoint(9), iommu_iotlb_gather_add_range(9), iommu_iotlb_gather_add_page(9), struct iommu_fwspec(9), struct iommu_sva(9), iommu_map_sgtable(9)
aaaaand that's the page, you ate that π
this whole thing lives over in ./include/linux, dated October 2026, and it's filed under struct iommu_ops(9) in the Kernel API Manual β mwah, slay, go write a driver now π«Άπβ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms