STRUCT IOMMUFD_VIOMMU_OPS(9)
π struct iommufd_viommu_ops(9) β Kernel API Manual π
okay so bestie, buckle up: this is the page for struct iommufd_viommu_ops, and it's literally the vIOMMU specific operations handbook. it's giving "backstage pass to the vIOMMU" energy and honestly? iconic. β¨
πΈ NAME πΈ
struct iommufd_viommu_ops β vIOMMU specific operations. that's it, that's the whole name, no notes π
β¨ SYNOPSIS β¨
here's the struct in all its glory, copied exactly so you don't have to squint at the manpage source:
struct iommufd_viommu_ops {
void (*destroy)(struct iommufd_viommu *viommu);
struct iommu_domain *(*alloc_domain_nested)( struct iommufd_viommu
*viommu, u32 flags, const struct iommu_user_data *user_data);
int (*cache_invalidate)(struct iommufd_viommu *viommu, struct
iommu_user_data_array *array);
const size_t vdevice_size;
int (*vdevice_init)(struct iommufd_vdevice *vdev);
size_t (*get_hw_queue_size)(struct iommufd_viommu *viommu, enum
iommu_hw_queue_type queue_type);
int (*hw_queue_init_phys)(struct iommufd_hw_queue *hw_queue, u32
index, phys_addr_t base_addr_pa);
};
it's a whole little friend group of function pointers plus two size fields, and every single one of them is a main character. π
π«Ά Members (the lineup) π«Ά
destroyβ clean up all driver-specific parts of aniommufd_viommu. and listen: the memory of the vIOMMU gets free-ed by the iommufd core after calling this op, so don't you dare go freeing it yourself, bestie. πalloc_domain_nestedβ allocate aIOMMU_DOMAIN_NESTEDon a vIOMMU that holds a nesting parent domain (IOMMU_DOMAIN_PAGING).user_datamust be defined ininclude/uapi/linux/iommufd.h. it must fully initialize the newiommu_domainbefore returning. and if it fails? upon failure,ERR_PTRmust be returned. no cap, that's the rule. π€cache_invalidateβ flush the hardware cache used by a vIOMMU. it can be used for any IOMMU hardware specific cache: TLB and device cache. the array passes in the cache invalidation requests, in form of a driver data structure. a driver must update thearray->entry_numto report the number of handled requests. and the data structure of the array entry must be defined ininclude/uapi/linux/iommufd.h. keep the receipts accurate fr fr πvdevice_sizeβ size of the driver-defined vDEVICE structure per this vIOMMU. simple, clean, does exactly what it says on the label πvdevice_initβ initialize the driver-level structure of a vDEVICE object, or related HW procedure. important vibe check:vdevis already initialized by iommufd core β that meansvdev->devandvdev->viommupointers; andvdev->idcarries a per-vIOMMU virtual ID (refer tostruct iommu_vdevice_allocininclude/uapi/linux/iommufd.h). if the driver has a deinit function to revert whatvdevice_initop does, it should set it to thevdev->destroyfunction pointer. so yeah, you get a cleanup buddy too π«Άget_hw_queue_sizeβ get the size of a driver-defined HW queue structure for a givenviommucorresponding toqueue_type. driver should return0if HW queue aren't supported accordingly. and it is required for the driver to use theHW_QUEUE_STRUCT_SIZEmacro to sanitize the driver-level HW queue structure related to the core one. don't skip the sanitize step, it's not optional πhw_queue_init_physβ initialize the driver-level structure of a HW queue that is initialized with its core-level structure that holds all the info about a guest queue memory. a driver providing this op indicates that HW accesses the guest queue memory via physical addresses.indexcarries the logical HW QUEUE ID per vIOMMU in a guest VM, for a multi-queue model.base_addr_pacarries the physical location of the guest queue. if the driver has a deinit function to revert what this op does, it should set it to thehw_queue->destroypointer. again with the cleanup bestie, we love to see it π
real talk though: thosemustandrequiredwords are doing heavy lifting. read them twice. the kernel is not a vibes-only situation π
π SEE ALSO π
- Kernel file
./include/linux/iommufd.hβ go read it, it's where all the lore lives π
and that's the page!! source/version situation: it ships from ./include/linux, dated October 2026. mwah, go write some vIOMMU ops, bestie, you're gonna slay π§π
π¦ 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