12ff4bed7SJason Gunthorpe /* SPDX-License-Identifier: GPL-2.0-only */ 22ff4bed7SJason Gunthorpe /* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES 32ff4bed7SJason Gunthorpe */ 42ff4bed7SJason Gunthorpe #ifndef __IOMMUFD_PRIVATE_H 52ff4bed7SJason Gunthorpe #define __IOMMUFD_PRIVATE_H 62ff4bed7SJason Gunthorpe 72ff4bed7SJason Gunthorpe #include <linux/rwsem.h> 82ff4bed7SJason Gunthorpe #include <linux/xarray.h> 92ff4bed7SJason Gunthorpe #include <linux/refcount.h> 102ff4bed7SJason Gunthorpe #include <linux/uaccess.h> 112ff4bed7SJason Gunthorpe 1251fe6141SJason Gunthorpe struct iommu_domain; 1351fe6141SJason Gunthorpe struct iommu_group; 14aad37e71SJason Gunthorpe struct iommu_option; 157e7ec8a5SJason Gunthorpe struct iommufd_device; 1651fe6141SJason Gunthorpe 172ff4bed7SJason Gunthorpe struct iommufd_ctx { 182ff4bed7SJason Gunthorpe struct file *file; 192ff4bed7SJason Gunthorpe struct xarray objects; 2051fe6141SJason Gunthorpe 2151fe6141SJason Gunthorpe u8 account_mode; 22c9a397ceSJason Gunthorpe /* Compatibility with VFIO no iommu */ 23c9a397ceSJason Gunthorpe u8 no_iommu_mode; 24d624d665SJason Gunthorpe struct iommufd_ioas *vfio_ioas; 252ff4bed7SJason Gunthorpe }; 262ff4bed7SJason Gunthorpe 27f394576eSJason Gunthorpe /* 28f394576eSJason Gunthorpe * The IOVA to PFN map. The map automatically copies the PFNs into multiple 29f394576eSJason Gunthorpe * domains and permits sharing of PFNs between io_pagetable instances. This 30f394576eSJason Gunthorpe * supports both a design where IOAS's are 1:1 with a domain (eg because the 31f394576eSJason Gunthorpe * domain is HW customized), or where the IOAS is 1:N with multiple generic 32f394576eSJason Gunthorpe * domains. The io_pagetable holds an interval tree of iopt_areas which point 33f394576eSJason Gunthorpe * to shared iopt_pages which hold the pfns mapped to the page table. 34f394576eSJason Gunthorpe * 35f394576eSJason Gunthorpe * The locking order is domains_rwsem -> iova_rwsem -> pages::mutex 36f394576eSJason Gunthorpe */ 37f394576eSJason Gunthorpe struct io_pagetable { 38f394576eSJason Gunthorpe struct rw_semaphore domains_rwsem; 39f394576eSJason Gunthorpe struct xarray domains; 4051fe6141SJason Gunthorpe struct xarray access_list; 41f394576eSJason Gunthorpe unsigned int next_domain_id; 42f394576eSJason Gunthorpe 43f394576eSJason Gunthorpe struct rw_semaphore iova_rwsem; 44f394576eSJason Gunthorpe struct rb_root_cached area_itree; 45f394576eSJason Gunthorpe /* IOVA that cannot become reserved, struct iopt_allowed */ 46f394576eSJason Gunthorpe struct rb_root_cached allowed_itree; 47f394576eSJason Gunthorpe /* IOVA that cannot be allocated, struct iopt_reserved */ 48f394576eSJason Gunthorpe struct rb_root_cached reserved_itree; 49f394576eSJason Gunthorpe u8 disable_large_pages; 5051fe6141SJason Gunthorpe unsigned long iova_alignment; 51f394576eSJason Gunthorpe }; 52f394576eSJason Gunthorpe 5351fe6141SJason Gunthorpe void iopt_init_table(struct io_pagetable *iopt); 5451fe6141SJason Gunthorpe void iopt_destroy_table(struct io_pagetable *iopt); 5551fe6141SJason Gunthorpe int iopt_get_pages(struct io_pagetable *iopt, unsigned long iova, 5651fe6141SJason Gunthorpe unsigned long length, struct list_head *pages_list); 5751fe6141SJason Gunthorpe void iopt_free_pages_list(struct list_head *pages_list); 5851fe6141SJason Gunthorpe enum { 5951fe6141SJason Gunthorpe IOPT_ALLOC_IOVA = 1 << 0, 6051fe6141SJason Gunthorpe }; 6151fe6141SJason Gunthorpe int iopt_map_user_pages(struct iommufd_ctx *ictx, struct io_pagetable *iopt, 6251fe6141SJason Gunthorpe unsigned long *iova, void __user *uptr, 6351fe6141SJason Gunthorpe unsigned long length, int iommu_prot, 6451fe6141SJason Gunthorpe unsigned int flags); 6551fe6141SJason Gunthorpe int iopt_map_pages(struct io_pagetable *iopt, struct list_head *pages_list, 6651fe6141SJason Gunthorpe unsigned long length, unsigned long *dst_iova, 6751fe6141SJason Gunthorpe int iommu_prot, unsigned int flags); 6851fe6141SJason Gunthorpe int iopt_unmap_iova(struct io_pagetable *iopt, unsigned long iova, 6951fe6141SJason Gunthorpe unsigned long length, unsigned long *unmapped); 7051fe6141SJason Gunthorpe int iopt_unmap_all(struct io_pagetable *iopt, unsigned long *unmapped); 7151fe6141SJason Gunthorpe 728d40205fSJason Gunthorpe void iommufd_access_notify_unmap(struct io_pagetable *iopt, unsigned long iova, 738d40205fSJason Gunthorpe unsigned long length); 7451fe6141SJason Gunthorpe int iopt_table_add_domain(struct io_pagetable *iopt, 7551fe6141SJason Gunthorpe struct iommu_domain *domain); 7651fe6141SJason Gunthorpe void iopt_table_remove_domain(struct io_pagetable *iopt, 7751fe6141SJason Gunthorpe struct iommu_domain *domain); 7851fe6141SJason Gunthorpe int iopt_table_enforce_group_resv_regions(struct io_pagetable *iopt, 7951fe6141SJason Gunthorpe struct device *device, 8051fe6141SJason Gunthorpe struct iommu_group *group, 8151fe6141SJason Gunthorpe phys_addr_t *sw_msi_start); 8251fe6141SJason Gunthorpe int iopt_set_allow_iova(struct io_pagetable *iopt, 8351fe6141SJason Gunthorpe struct rb_root_cached *allowed_iova); 8451fe6141SJason Gunthorpe int iopt_reserve_iova(struct io_pagetable *iopt, unsigned long start, 8551fe6141SJason Gunthorpe unsigned long last, void *owner); 8651fe6141SJason Gunthorpe void iopt_remove_reserved_iova(struct io_pagetable *iopt, void *owner); 8751fe6141SJason Gunthorpe int iopt_cut_iova(struct io_pagetable *iopt, unsigned long *iovas, 8851fe6141SJason Gunthorpe size_t num_iovas); 8951fe6141SJason Gunthorpe void iopt_enable_large_pages(struct io_pagetable *iopt); 9051fe6141SJason Gunthorpe int iopt_disable_large_pages(struct io_pagetable *iopt); 9151fe6141SJason Gunthorpe 922ff4bed7SJason Gunthorpe struct iommufd_ucmd { 932ff4bed7SJason Gunthorpe struct iommufd_ctx *ictx; 942ff4bed7SJason Gunthorpe void __user *ubuffer; 952ff4bed7SJason Gunthorpe u32 user_size; 962ff4bed7SJason Gunthorpe void *cmd; 972ff4bed7SJason Gunthorpe }; 982ff4bed7SJason Gunthorpe 99d624d665SJason Gunthorpe int iommufd_vfio_ioctl(struct iommufd_ctx *ictx, unsigned int cmd, 100d624d665SJason Gunthorpe unsigned long arg); 101d624d665SJason Gunthorpe 1022ff4bed7SJason Gunthorpe /* Copy the response in ucmd->cmd back to userspace. */ 1032ff4bed7SJason Gunthorpe static inline int iommufd_ucmd_respond(struct iommufd_ucmd *ucmd, 1042ff4bed7SJason Gunthorpe size_t cmd_len) 1052ff4bed7SJason Gunthorpe { 1062ff4bed7SJason Gunthorpe if (copy_to_user(ucmd->ubuffer, ucmd->cmd, 1072ff4bed7SJason Gunthorpe min_t(size_t, ucmd->user_size, cmd_len))) 1082ff4bed7SJason Gunthorpe return -EFAULT; 1092ff4bed7SJason Gunthorpe return 0; 1102ff4bed7SJason Gunthorpe } 1112ff4bed7SJason Gunthorpe 1122ff4bed7SJason Gunthorpe enum iommufd_object_type { 1132ff4bed7SJason Gunthorpe IOMMUFD_OBJ_NONE, 1142ff4bed7SJason Gunthorpe IOMMUFD_OBJ_ANY = IOMMUFD_OBJ_NONE, 115e8d57210SJason Gunthorpe IOMMUFD_OBJ_DEVICE, 116ea4acfacSJason Gunthorpe IOMMUFD_OBJ_HW_PAGETABLE, 117aad37e71SJason Gunthorpe IOMMUFD_OBJ_IOAS, 1188d40205fSJason Gunthorpe IOMMUFD_OBJ_ACCESS, 119f4b20bb3SJason Gunthorpe #ifdef CONFIG_IOMMUFD_TEST 120f4b20bb3SJason Gunthorpe IOMMUFD_OBJ_SELFTEST, 121f4b20bb3SJason Gunthorpe #endif 1222ff4bed7SJason Gunthorpe }; 1232ff4bed7SJason Gunthorpe 1242ff4bed7SJason Gunthorpe /* Base struct for all objects with a userspace ID handle. */ 1252ff4bed7SJason Gunthorpe struct iommufd_object { 1262ff4bed7SJason Gunthorpe struct rw_semaphore destroy_rwsem; 1272ff4bed7SJason Gunthorpe refcount_t users; 1282ff4bed7SJason Gunthorpe enum iommufd_object_type type; 1292ff4bed7SJason Gunthorpe unsigned int id; 1302ff4bed7SJason Gunthorpe }; 1312ff4bed7SJason Gunthorpe 1322ff4bed7SJason Gunthorpe static inline bool iommufd_lock_obj(struct iommufd_object *obj) 1332ff4bed7SJason Gunthorpe { 1342ff4bed7SJason Gunthorpe if (!down_read_trylock(&obj->destroy_rwsem)) 1352ff4bed7SJason Gunthorpe return false; 1362ff4bed7SJason Gunthorpe if (!refcount_inc_not_zero(&obj->users)) { 1372ff4bed7SJason Gunthorpe up_read(&obj->destroy_rwsem); 1382ff4bed7SJason Gunthorpe return false; 1392ff4bed7SJason Gunthorpe } 1402ff4bed7SJason Gunthorpe return true; 1412ff4bed7SJason Gunthorpe } 1422ff4bed7SJason Gunthorpe 1432ff4bed7SJason Gunthorpe struct iommufd_object *iommufd_get_object(struct iommufd_ctx *ictx, u32 id, 1442ff4bed7SJason Gunthorpe enum iommufd_object_type type); 1452ff4bed7SJason Gunthorpe static inline void iommufd_put_object(struct iommufd_object *obj) 1462ff4bed7SJason Gunthorpe { 1472ff4bed7SJason Gunthorpe refcount_dec(&obj->users); 1482ff4bed7SJason Gunthorpe up_read(&obj->destroy_rwsem); 1492ff4bed7SJason Gunthorpe } 1502ff4bed7SJason Gunthorpe 1512ff4bed7SJason Gunthorpe /** 1522ff4bed7SJason Gunthorpe * iommufd_ref_to_users() - Switch from destroy_rwsem to users refcount 1532ff4bed7SJason Gunthorpe * protection 1542ff4bed7SJason Gunthorpe * @obj - Object to release 1552ff4bed7SJason Gunthorpe * 1562ff4bed7SJason Gunthorpe * Objects have two refcount protections (destroy_rwsem and the refcount_t 1572ff4bed7SJason Gunthorpe * users). Holding either of these will prevent the object from being destroyed. 1582ff4bed7SJason Gunthorpe * 1592ff4bed7SJason Gunthorpe * Depending on the use case, one protection or the other is appropriate. In 1602ff4bed7SJason Gunthorpe * most cases references are being protected by the destroy_rwsem. This allows 1612ff4bed7SJason Gunthorpe * orderly destruction of the object because iommufd_object_destroy_user() will 1622ff4bed7SJason Gunthorpe * wait for it to become unlocked. However, as a rwsem, it cannot be held across 1632ff4bed7SJason Gunthorpe * a system call return. So cases that have longer term needs must switch 1642ff4bed7SJason Gunthorpe * to the weaker users refcount_t. 1652ff4bed7SJason Gunthorpe * 1662ff4bed7SJason Gunthorpe * With users protection iommufd_object_destroy_user() will return false, 1672ff4bed7SJason Gunthorpe * refusing to destroy the object, causing -EBUSY to userspace. 1682ff4bed7SJason Gunthorpe */ 1692ff4bed7SJason Gunthorpe static inline void iommufd_ref_to_users(struct iommufd_object *obj) 1702ff4bed7SJason Gunthorpe { 1712ff4bed7SJason Gunthorpe up_read(&obj->destroy_rwsem); 1722ff4bed7SJason Gunthorpe /* iommufd_lock_obj() obtains users as well */ 1732ff4bed7SJason Gunthorpe } 1742ff4bed7SJason Gunthorpe void iommufd_object_abort(struct iommufd_ctx *ictx, struct iommufd_object *obj); 1752ff4bed7SJason Gunthorpe void iommufd_object_abort_and_destroy(struct iommufd_ctx *ictx, 1762ff4bed7SJason Gunthorpe struct iommufd_object *obj); 1772ff4bed7SJason Gunthorpe void iommufd_object_finalize(struct iommufd_ctx *ictx, 1782ff4bed7SJason Gunthorpe struct iommufd_object *obj); 1792ff4bed7SJason Gunthorpe bool iommufd_object_destroy_user(struct iommufd_ctx *ictx, 1802ff4bed7SJason Gunthorpe struct iommufd_object *obj); 1812ff4bed7SJason Gunthorpe struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx, 1822ff4bed7SJason Gunthorpe size_t size, 1832ff4bed7SJason Gunthorpe enum iommufd_object_type type); 1842ff4bed7SJason Gunthorpe 1852ff4bed7SJason Gunthorpe #define iommufd_object_alloc(ictx, ptr, type) \ 1862ff4bed7SJason Gunthorpe container_of(_iommufd_object_alloc( \ 1872ff4bed7SJason Gunthorpe ictx, \ 1882ff4bed7SJason Gunthorpe sizeof(*(ptr)) + BUILD_BUG_ON_ZERO( \ 1892ff4bed7SJason Gunthorpe offsetof(typeof(*(ptr)), \ 1902ff4bed7SJason Gunthorpe obj) != 0), \ 1912ff4bed7SJason Gunthorpe type), \ 1922ff4bed7SJason Gunthorpe typeof(*(ptr)), obj) 1932ff4bed7SJason Gunthorpe 194aad37e71SJason Gunthorpe /* 195aad37e71SJason Gunthorpe * The IO Address Space (IOAS) pagetable is a virtual page table backed by the 196aad37e71SJason Gunthorpe * io_pagetable object. It is a user controlled mapping of IOVA -> PFNs. The 197aad37e71SJason Gunthorpe * mapping is copied into all of the associated domains and made available to 198aad37e71SJason Gunthorpe * in-kernel users. 199ea4acfacSJason Gunthorpe * 200ea4acfacSJason Gunthorpe * Every iommu_domain that is created is wrapped in a iommufd_hw_pagetable 201ea4acfacSJason Gunthorpe * object. When we go to attach a device to an IOAS we need to get an 202ea4acfacSJason Gunthorpe * iommu_domain and wrapping iommufd_hw_pagetable for it. 203ea4acfacSJason Gunthorpe * 204ea4acfacSJason Gunthorpe * An iommu_domain & iommfd_hw_pagetable will be automatically selected 205ea4acfacSJason Gunthorpe * for a device based on the hwpt_list. If no suitable iommu_domain 206ea4acfacSJason Gunthorpe * is found a new iommu_domain will be created. 207aad37e71SJason Gunthorpe */ 208aad37e71SJason Gunthorpe struct iommufd_ioas { 209aad37e71SJason Gunthorpe struct iommufd_object obj; 210aad37e71SJason Gunthorpe struct io_pagetable iopt; 211ea4acfacSJason Gunthorpe struct mutex mutex; 212ea4acfacSJason Gunthorpe struct list_head hwpt_list; 213aad37e71SJason Gunthorpe }; 214aad37e71SJason Gunthorpe 215325de950SYi Liu static inline struct iommufd_ioas *iommufd_get_ioas(struct iommufd_ctx *ictx, 216aad37e71SJason Gunthorpe u32 id) 217aad37e71SJason Gunthorpe { 218325de950SYi Liu return container_of(iommufd_get_object(ictx, id, 219aad37e71SJason Gunthorpe IOMMUFD_OBJ_IOAS), 220aad37e71SJason Gunthorpe struct iommufd_ioas, obj); 221aad37e71SJason Gunthorpe } 222aad37e71SJason Gunthorpe 223aad37e71SJason Gunthorpe struct iommufd_ioas *iommufd_ioas_alloc(struct iommufd_ctx *ictx); 224aad37e71SJason Gunthorpe int iommufd_ioas_alloc_ioctl(struct iommufd_ucmd *ucmd); 225aad37e71SJason Gunthorpe void iommufd_ioas_destroy(struct iommufd_object *obj); 226aad37e71SJason Gunthorpe int iommufd_ioas_iova_ranges(struct iommufd_ucmd *ucmd); 227aad37e71SJason Gunthorpe int iommufd_ioas_allow_iovas(struct iommufd_ucmd *ucmd); 228aad37e71SJason Gunthorpe int iommufd_ioas_map(struct iommufd_ucmd *ucmd); 229aad37e71SJason Gunthorpe int iommufd_ioas_copy(struct iommufd_ucmd *ucmd); 230aad37e71SJason Gunthorpe int iommufd_ioas_unmap(struct iommufd_ucmd *ucmd); 231aad37e71SJason Gunthorpe int iommufd_ioas_option(struct iommufd_ucmd *ucmd); 232aad37e71SJason Gunthorpe int iommufd_option_rlimit_mode(struct iommu_option *cmd, 233aad37e71SJason Gunthorpe struct iommufd_ctx *ictx); 234aad37e71SJason Gunthorpe 235d624d665SJason Gunthorpe int iommufd_vfio_ioas(struct iommufd_ucmd *ucmd); 236d624d665SJason Gunthorpe 237ea4acfacSJason Gunthorpe /* 238ea4acfacSJason Gunthorpe * A HW pagetable is called an iommu_domain inside the kernel. This user object 239ea4acfacSJason Gunthorpe * allows directly creating and inspecting the domains. Domains that have kernel 240ea4acfacSJason Gunthorpe * owned page tables will be associated with an iommufd_ioas that provides the 241ea4acfacSJason Gunthorpe * IOVA to PFN map. 242ea4acfacSJason Gunthorpe */ 243ea4acfacSJason Gunthorpe struct iommufd_hw_pagetable { 244ea4acfacSJason Gunthorpe struct iommufd_object obj; 245ea4acfacSJason Gunthorpe struct iommufd_ioas *ioas; 246ea4acfacSJason Gunthorpe struct iommu_domain *domain; 247ea4acfacSJason Gunthorpe bool auto_domain : 1; 248e8d57210SJason Gunthorpe bool enforce_cache_coherency : 1; 249e8d57210SJason Gunthorpe bool msi_cookie : 1; 250ea4acfacSJason Gunthorpe /* Head at iommufd_ioas::hwpt_list */ 251ea4acfacSJason Gunthorpe struct list_head hwpt_item; 252ea4acfacSJason Gunthorpe struct mutex devices_lock; 253ea4acfacSJason Gunthorpe struct list_head devices; 254ea4acfacSJason Gunthorpe }; 255ea4acfacSJason Gunthorpe 256ea4acfacSJason Gunthorpe struct iommufd_hw_pagetable * 257ea4acfacSJason Gunthorpe iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, 258339fbf3aSJason Gunthorpe struct iommufd_device *idev, bool immediate_attach); 259339fbf3aSJason Gunthorpe int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt, 260339fbf3aSJason Gunthorpe struct iommufd_device *idev); 261339fbf3aSJason Gunthorpe void iommufd_hw_pagetable_detach(struct iommufd_hw_pagetable *hwpt, 262339fbf3aSJason Gunthorpe struct iommufd_device *idev); 263ea4acfacSJason Gunthorpe void iommufd_hw_pagetable_destroy(struct iommufd_object *obj); 264ea4acfacSJason Gunthorpe 2657e7ec8a5SJason Gunthorpe /* 2667e7ec8a5SJason Gunthorpe * A iommufd_device object represents the binding relationship between a 2677e7ec8a5SJason Gunthorpe * consuming driver and the iommufd. These objects are created/destroyed by 2687e7ec8a5SJason Gunthorpe * external drivers, not by userspace. 2697e7ec8a5SJason Gunthorpe */ 2707e7ec8a5SJason Gunthorpe struct iommufd_device { 2717e7ec8a5SJason Gunthorpe struct iommufd_object obj; 2727e7ec8a5SJason Gunthorpe struct iommufd_ctx *ictx; 2737e7ec8a5SJason Gunthorpe struct iommufd_hw_pagetable *hwpt; 2747e7ec8a5SJason Gunthorpe /* Head at iommufd_hw_pagetable::devices */ 2757e7ec8a5SJason Gunthorpe struct list_head devices_item; 2767e7ec8a5SJason Gunthorpe /* always the physical device */ 2777e7ec8a5SJason Gunthorpe struct device *dev; 2787e7ec8a5SJason Gunthorpe struct iommu_group *group; 2797e7ec8a5SJason Gunthorpe bool enforce_cache_coherency; 2807e7ec8a5SJason Gunthorpe }; 2817e7ec8a5SJason Gunthorpe 282e8d57210SJason Gunthorpe void iommufd_device_destroy(struct iommufd_object *obj); 283e8d57210SJason Gunthorpe 28451fe6141SJason Gunthorpe struct iommufd_access { 2858d40205fSJason Gunthorpe struct iommufd_object obj; 2868d40205fSJason Gunthorpe struct iommufd_ctx *ictx; 2878d40205fSJason Gunthorpe struct iommufd_ioas *ioas; 288*e23a6217SNicolin Chen struct iommufd_ioas *ioas_unpin; 289*e23a6217SNicolin Chen struct mutex ioas_lock; 2908d40205fSJason Gunthorpe const struct iommufd_access_ops *ops; 2918d40205fSJason Gunthorpe void *data; 29251fe6141SJason Gunthorpe unsigned long iova_alignment; 29351fe6141SJason Gunthorpe u32 iopt_access_list_id; 29451fe6141SJason Gunthorpe }; 29551fe6141SJason Gunthorpe 29651fe6141SJason Gunthorpe int iopt_add_access(struct io_pagetable *iopt, struct iommufd_access *access); 29751fe6141SJason Gunthorpe void iopt_remove_access(struct io_pagetable *iopt, 29851fe6141SJason Gunthorpe struct iommufd_access *access); 2998d40205fSJason Gunthorpe void iommufd_access_destroy_object(struct iommufd_object *obj); 3008d40205fSJason Gunthorpe 301f4b20bb3SJason Gunthorpe #ifdef CONFIG_IOMMUFD_TEST 302f4b20bb3SJason Gunthorpe int iommufd_test(struct iommufd_ucmd *ucmd); 303f4b20bb3SJason Gunthorpe void iommufd_selftest_destroy(struct iommufd_object *obj); 304f4b20bb3SJason Gunthorpe extern size_t iommufd_test_memory_limit; 305f4b20bb3SJason Gunthorpe void iommufd_test_syz_conv_iova_id(struct iommufd_ucmd *ucmd, 306f4b20bb3SJason Gunthorpe unsigned int ioas_id, u64 *iova, u32 *flags); 307f4b20bb3SJason Gunthorpe bool iommufd_should_fail(void); 308f4b20bb3SJason Gunthorpe void __init iommufd_test_init(void); 309f4b20bb3SJason Gunthorpe void iommufd_test_exit(void); 31065c619aeSJason Gunthorpe bool iommufd_selftest_is_mock_dev(struct device *dev); 311f4b20bb3SJason Gunthorpe #else 312f4b20bb3SJason Gunthorpe static inline void iommufd_test_syz_conv_iova_id(struct iommufd_ucmd *ucmd, 313f4b20bb3SJason Gunthorpe unsigned int ioas_id, 314f4b20bb3SJason Gunthorpe u64 *iova, u32 *flags) 315f4b20bb3SJason Gunthorpe { 316f4b20bb3SJason Gunthorpe } 317f4b20bb3SJason Gunthorpe static inline bool iommufd_should_fail(void) 318f4b20bb3SJason Gunthorpe { 319f4b20bb3SJason Gunthorpe return false; 320f4b20bb3SJason Gunthorpe } 321f4b20bb3SJason Gunthorpe static inline void __init iommufd_test_init(void) 322f4b20bb3SJason Gunthorpe { 323f4b20bb3SJason Gunthorpe } 324f4b20bb3SJason Gunthorpe static inline void iommufd_test_exit(void) 325f4b20bb3SJason Gunthorpe { 326f4b20bb3SJason Gunthorpe } 32765c619aeSJason Gunthorpe static inline bool iommufd_selftest_is_mock_dev(struct device *dev) 32865c619aeSJason Gunthorpe { 32965c619aeSJason Gunthorpe return false; 33065c619aeSJason Gunthorpe } 331f4b20bb3SJason Gunthorpe #endif 3322ff4bed7SJason Gunthorpe #endif 333