1 /* 2 * This file is auto-generated. Modifications will be lost. 3 * 4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ 5 * for more information. 6 */ 7 #ifndef _UAPI_IOMMUFD_H 8 #define _UAPI_IOMMUFD_H 9 #include <linux/types.h> 10 #include <linux/ioctl.h> 11 #define IOMMUFD_TYPE (';') 12 enum { 13 IOMMUFD_CMD_BASE = 0x80, 14 IOMMUFD_CMD_DESTROY = IOMMUFD_CMD_BASE, 15 IOMMUFD_CMD_IOAS_ALLOC, 16 IOMMUFD_CMD_IOAS_ALLOW_IOVAS, 17 IOMMUFD_CMD_IOAS_COPY, 18 IOMMUFD_CMD_IOAS_IOVA_RANGES, 19 IOMMUFD_CMD_IOAS_MAP, 20 IOMMUFD_CMD_IOAS_UNMAP, 21 IOMMUFD_CMD_OPTION, 22 IOMMUFD_CMD_VFIO_IOAS, 23 IOMMUFD_CMD_HWPT_ALLOC, 24 IOMMUFD_CMD_GET_HW_INFO, 25 IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING, 26 IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP, 27 IOMMUFD_CMD_HWPT_INVALIDATE, 28 }; 29 struct iommu_destroy { 30 __u32 size; 31 __u32 id; 32 }; 33 #define IOMMU_DESTROY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_DESTROY) 34 struct iommu_ioas_alloc { 35 __u32 size; 36 __u32 flags; 37 __u32 out_ioas_id; 38 }; 39 #define IOMMU_IOAS_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOC) 40 struct iommu_iova_range { 41 __aligned_u64 start; 42 __aligned_u64 last; 43 }; 44 struct iommu_ioas_iova_ranges { 45 __u32 size; 46 __u32 ioas_id; 47 __u32 num_iovas; 48 __u32 __reserved; 49 __aligned_u64 allowed_iovas; 50 __aligned_u64 out_iova_alignment; 51 }; 52 #define IOMMU_IOAS_IOVA_RANGES _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_IOVA_RANGES) 53 struct iommu_ioas_allow_iovas { 54 __u32 size; 55 __u32 ioas_id; 56 __u32 num_iovas; 57 __u32 __reserved; 58 __aligned_u64 allowed_iovas; 59 }; 60 #define IOMMU_IOAS_ALLOW_IOVAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOW_IOVAS) 61 enum iommufd_ioas_map_flags { 62 IOMMU_IOAS_MAP_FIXED_IOVA = 1 << 0, 63 IOMMU_IOAS_MAP_WRITEABLE = 1 << 1, 64 IOMMU_IOAS_MAP_READABLE = 1 << 2, 65 }; 66 struct iommu_ioas_map { 67 __u32 size; 68 __u32 flags; 69 __u32 ioas_id; 70 __u32 __reserved; 71 __aligned_u64 user_va; 72 __aligned_u64 length; 73 __aligned_u64 iova; 74 }; 75 #define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP) 76 struct iommu_ioas_copy { 77 __u32 size; 78 __u32 flags; 79 __u32 dst_ioas_id; 80 __u32 src_ioas_id; 81 __aligned_u64 length; 82 __aligned_u64 dst_iova; 83 __aligned_u64 src_iova; 84 }; 85 #define IOMMU_IOAS_COPY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_COPY) 86 struct iommu_ioas_unmap { 87 __u32 size; 88 __u32 ioas_id; 89 __aligned_u64 iova; 90 __aligned_u64 length; 91 }; 92 #define IOMMU_IOAS_UNMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_UNMAP) 93 enum iommufd_option { 94 IOMMU_OPTION_RLIMIT_MODE = 0, 95 IOMMU_OPTION_HUGE_PAGES = 1, 96 }; 97 enum iommufd_option_ops { 98 IOMMU_OPTION_OP_SET = 0, 99 IOMMU_OPTION_OP_GET = 1, 100 }; 101 struct iommu_option { 102 __u32 size; 103 __u32 option_id; 104 __u16 op; 105 __u16 __reserved; 106 __u32 object_id; 107 __aligned_u64 val64; 108 }; 109 #define IOMMU_OPTION _IO(IOMMUFD_TYPE, IOMMUFD_CMD_OPTION) 110 enum iommufd_vfio_ioas_op { 111 IOMMU_VFIO_IOAS_GET = 0, 112 IOMMU_VFIO_IOAS_SET = 1, 113 IOMMU_VFIO_IOAS_CLEAR = 2, 114 }; 115 struct iommu_vfio_ioas { 116 __u32 size; 117 __u32 ioas_id; 118 __u16 op; 119 __u16 __reserved; 120 }; 121 #define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS) 122 enum iommufd_hwpt_alloc_flags { 123 IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0, 124 IOMMU_HWPT_ALLOC_DIRTY_TRACKING = 1 << 1, 125 }; 126 enum iommu_hwpt_vtd_s1_flags { 127 IOMMU_VTD_S1_SRE = 1 << 0, 128 IOMMU_VTD_S1_EAFE = 1 << 1, 129 IOMMU_VTD_S1_WPE = 1 << 2, 130 }; 131 struct iommu_hwpt_vtd_s1 { 132 __aligned_u64 flags; 133 __aligned_u64 pgtbl_addr; 134 __u32 addr_width; 135 __u32 __reserved; 136 }; 137 enum iommu_hwpt_data_type { 138 IOMMU_HWPT_DATA_NONE, 139 IOMMU_HWPT_DATA_VTD_S1, 140 }; 141 struct iommu_hwpt_alloc { 142 __u32 size; 143 __u32 flags; 144 __u32 dev_id; 145 __u32 pt_id; 146 __u32 out_hwpt_id; 147 __u32 __reserved; 148 __u32 data_type; 149 __u32 data_len; 150 __aligned_u64 data_uptr; 151 }; 152 #define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC) 153 enum iommu_hw_info_vtd_flags { 154 IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 = 1 << 0, 155 }; 156 struct iommu_hw_info_vtd { 157 __u32 flags; 158 __u32 __reserved; 159 __aligned_u64 cap_reg; 160 __aligned_u64 ecap_reg; 161 }; 162 enum iommu_hw_info_type { 163 IOMMU_HW_INFO_TYPE_NONE, 164 IOMMU_HW_INFO_TYPE_INTEL_VTD, 165 }; 166 enum iommufd_hw_capabilities { 167 IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0, 168 }; 169 struct iommu_hw_info { 170 __u32 size; 171 __u32 flags; 172 __u32 dev_id; 173 __u32 data_len; 174 __aligned_u64 data_uptr; 175 __u32 out_data_type; 176 __u32 __reserved; 177 __aligned_u64 out_capabilities; 178 }; 179 #define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO) 180 enum iommufd_hwpt_set_dirty_tracking_flags { 181 IOMMU_HWPT_DIRTY_TRACKING_ENABLE = 1, 182 }; 183 struct iommu_hwpt_set_dirty_tracking { 184 __u32 size; 185 __u32 flags; 186 __u32 hwpt_id; 187 __u32 __reserved; 188 }; 189 #define IOMMU_HWPT_SET_DIRTY_TRACKING _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING) 190 enum iommufd_hwpt_get_dirty_bitmap_flags { 191 IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR = 1, 192 }; 193 struct iommu_hwpt_get_dirty_bitmap { 194 __u32 size; 195 __u32 hwpt_id; 196 __u32 flags; 197 __u32 __reserved; 198 __aligned_u64 iova; 199 __aligned_u64 length; 200 __aligned_u64 page_size; 201 __aligned_u64 data; 202 }; 203 #define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP) 204 enum iommu_hwpt_invalidate_data_type { 205 IOMMU_HWPT_INVALIDATE_DATA_VTD_S1, 206 }; 207 enum iommu_hwpt_vtd_s1_invalidate_flags { 208 IOMMU_VTD_INV_FLAGS_LEAF = 1 << 0, 209 }; 210 struct iommu_hwpt_vtd_s1_invalidate { 211 __aligned_u64 addr; 212 __aligned_u64 npages; 213 __u32 flags; 214 __u32 __reserved; 215 }; 216 struct iommu_hwpt_invalidate { 217 __u32 size; 218 __u32 hwpt_id; 219 __aligned_u64 data_uptr; 220 __u32 data_type; 221 __u32 entry_len; 222 __u32 entry_num; 223 __u32 __reserved; 224 }; 225 #define IOMMU_HWPT_INVALIDATE _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_INVALIDATE) 226 #endif 227