STRUCT IOMMUFD_VIOMMU_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ 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 an iommufd_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 a IOMMU_DOMAIN_NESTED on a vIOMMU that holds a nesting parent domain (IOMMU_DOMAIN_PAGING). user_data must be defined in include/uapi/linux/iommufd.h. it must fully initialize the new iommu_domain before returning. and if it fails? upon failure, ERR_PTR must 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 the array->entry_num to report the number of handled requests. and the data structure of the array entry must be defined in include/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: vdev is already initialized by iommufd core β€” that means vdev->dev and vdev->viommu pointers; and vdev->id carries a per-vIOMMU virtual ID (refer to struct iommu_vdevice_alloc in include/uapi/linux/iommufd.h). if the driver has a deinit function to revert what vdevice_init op does, it should set it to the vdev->destroy function 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 given viommu corresponding to queue_type. driver should return 0 if HW queue aren't supported accordingly. and it is required for the driver to use the HW_QUEUE_STRUCT_SIZE macro 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. index carries the logical HW QUEUE ID per vIOMMU in a guest VM, for a multi-queue model. base_addr_pa carries 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 the hw_queue->destroy pointer. again with the cleanup bestie, we love to see it 🌈
real talk though: those must and required words 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