blob: 6f663b4104d7586fb6261c93ef0fd5baf09162a0 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 */
Christopher Ferris8b7fdc92023-02-21 13:36:32 -08007#ifndef _UAPI_IOMMUFD_H
8#define _UAPI_IOMMUFD_H
9#include <linux/types.h>
10#include <linux/ioctl.h>
11#define IOMMUFD_TYPE (';')
12enum {
13 IOMMUFD_CMD_BASE = 0x80,
14 IOMMUFD_CMD_DESTROY = IOMMUFD_CMD_BASE,
Christopher Ferris63fcca42024-09-26 01:12:10 +000015 IOMMUFD_CMD_IOAS_ALLOC = 0x81,
16 IOMMUFD_CMD_IOAS_ALLOW_IOVAS = 0x82,
17 IOMMUFD_CMD_IOAS_COPY = 0x83,
18 IOMMUFD_CMD_IOAS_IOVA_RANGES = 0x84,
19 IOMMUFD_CMD_IOAS_MAP = 0x85,
20 IOMMUFD_CMD_IOAS_UNMAP = 0x86,
21 IOMMUFD_CMD_OPTION = 0x87,
22 IOMMUFD_CMD_VFIO_IOAS = 0x88,
23 IOMMUFD_CMD_HWPT_ALLOC = 0x89,
24 IOMMUFD_CMD_GET_HW_INFO = 0x8a,
25 IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING = 0x8b,
26 IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP = 0x8c,
27 IOMMUFD_CMD_HWPT_INVALIDATE = 0x8d,
28 IOMMUFD_CMD_FAULT_QUEUE_ALLOC = 0x8e,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080029};
30struct iommu_destroy {
31 __u32 size;
32 __u32 id;
33};
34#define IOMMU_DESTROY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_DESTROY)
35struct iommu_ioas_alloc {
36 __u32 size;
37 __u32 flags;
38 __u32 out_ioas_id;
39};
40#define IOMMU_IOAS_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOC)
41struct iommu_iova_range {
42 __aligned_u64 start;
43 __aligned_u64 last;
44};
45struct iommu_ioas_iova_ranges {
46 __u32 size;
47 __u32 ioas_id;
48 __u32 num_iovas;
49 __u32 __reserved;
50 __aligned_u64 allowed_iovas;
51 __aligned_u64 out_iova_alignment;
52};
53#define IOMMU_IOAS_IOVA_RANGES _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_IOVA_RANGES)
54struct iommu_ioas_allow_iovas {
55 __u32 size;
56 __u32 ioas_id;
57 __u32 num_iovas;
58 __u32 __reserved;
59 __aligned_u64 allowed_iovas;
60};
61#define IOMMU_IOAS_ALLOW_IOVAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOW_IOVAS)
62enum iommufd_ioas_map_flags {
63 IOMMU_IOAS_MAP_FIXED_IOVA = 1 << 0,
64 IOMMU_IOAS_MAP_WRITEABLE = 1 << 1,
65 IOMMU_IOAS_MAP_READABLE = 1 << 2,
66};
67struct iommu_ioas_map {
68 __u32 size;
69 __u32 flags;
70 __u32 ioas_id;
71 __u32 __reserved;
72 __aligned_u64 user_va;
73 __aligned_u64 length;
74 __aligned_u64 iova;
75};
76#define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP)
77struct iommu_ioas_copy {
78 __u32 size;
79 __u32 flags;
80 __u32 dst_ioas_id;
81 __u32 src_ioas_id;
82 __aligned_u64 length;
83 __aligned_u64 dst_iova;
84 __aligned_u64 src_iova;
85};
86#define IOMMU_IOAS_COPY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_COPY)
87struct iommu_ioas_unmap {
88 __u32 size;
89 __u32 ioas_id;
90 __aligned_u64 iova;
91 __aligned_u64 length;
92};
93#define IOMMU_IOAS_UNMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_UNMAP)
94enum iommufd_option {
95 IOMMU_OPTION_RLIMIT_MODE = 0,
96 IOMMU_OPTION_HUGE_PAGES = 1,
97};
98enum iommufd_option_ops {
99 IOMMU_OPTION_OP_SET = 0,
100 IOMMU_OPTION_OP_GET = 1,
101};
102struct iommu_option {
103 __u32 size;
104 __u32 option_id;
105 __u16 op;
106 __u16 __reserved;
107 __u32 object_id;
108 __aligned_u64 val64;
109};
110#define IOMMU_OPTION _IO(IOMMUFD_TYPE, IOMMUFD_CMD_OPTION)
111enum iommufd_vfio_ioas_op {
112 IOMMU_VFIO_IOAS_GET = 0,
113 IOMMU_VFIO_IOAS_SET = 1,
114 IOMMU_VFIO_IOAS_CLEAR = 2,
115};
116struct iommu_vfio_ioas {
117 __u32 size;
118 __u32 ioas_id;
119 __u16 op;
120 __u16 __reserved;
121};
122#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)
Christopher Ferris0f795212024-01-17 14:17:28 -0800123enum iommufd_hwpt_alloc_flags {
124 IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0,
125 IOMMU_HWPT_ALLOC_DIRTY_TRACKING = 1 << 1,
Christopher Ferris63fcca42024-09-26 01:12:10 +0000126 IOMMU_HWPT_FAULT_ID_VALID = 1 << 2,
Christopher Ferris0f795212024-01-17 14:17:28 -0800127};
128enum iommu_hwpt_vtd_s1_flags {
129 IOMMU_VTD_S1_SRE = 1 << 0,
130 IOMMU_VTD_S1_EAFE = 1 << 1,
131 IOMMU_VTD_S1_WPE = 1 << 2,
132};
133struct iommu_hwpt_vtd_s1 {
134 __aligned_u64 flags;
135 __aligned_u64 pgtbl_addr;
136 __u32 addr_width;
137 __u32 __reserved;
138};
139enum iommu_hwpt_data_type {
Christopher Ferris63fcca42024-09-26 01:12:10 +0000140 IOMMU_HWPT_DATA_NONE = 0,
141 IOMMU_HWPT_DATA_VTD_S1 = 1,
Christopher Ferris0f795212024-01-17 14:17:28 -0800142};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700143struct iommu_hwpt_alloc {
144 __u32 size;
145 __u32 flags;
146 __u32 dev_id;
147 __u32 pt_id;
148 __u32 out_hwpt_id;
149 __u32 __reserved;
Christopher Ferris0f795212024-01-17 14:17:28 -0800150 __u32 data_type;
151 __u32 data_len;
152 __aligned_u64 data_uptr;
Christopher Ferris63fcca42024-09-26 01:12:10 +0000153 __u32 fault_id;
154 __u32 __reserved2;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700155};
156#define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC)
Christopher Ferris0f795212024-01-17 14:17:28 -0800157enum iommu_hw_info_vtd_flags {
158 IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 = 1 << 0,
159};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700160struct iommu_hw_info_vtd {
161 __u32 flags;
162 __u32 __reserved;
163 __aligned_u64 cap_reg;
164 __aligned_u64 ecap_reg;
165};
166enum iommu_hw_info_type {
Christopher Ferris63fcca42024-09-26 01:12:10 +0000167 IOMMU_HW_INFO_TYPE_NONE = 0,
168 IOMMU_HW_INFO_TYPE_INTEL_VTD = 1,
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700169};
Christopher Ferris0f795212024-01-17 14:17:28 -0800170enum iommufd_hw_capabilities {
171 IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0,
172};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700173struct iommu_hw_info {
174 __u32 size;
175 __u32 flags;
176 __u32 dev_id;
177 __u32 data_len;
178 __aligned_u64 data_uptr;
179 __u32 out_data_type;
180 __u32 __reserved;
Christopher Ferris0f795212024-01-17 14:17:28 -0800181 __aligned_u64 out_capabilities;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700182};
183#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO)
Christopher Ferris0f795212024-01-17 14:17:28 -0800184enum iommufd_hwpt_set_dirty_tracking_flags {
185 IOMMU_HWPT_DIRTY_TRACKING_ENABLE = 1,
186};
187struct iommu_hwpt_set_dirty_tracking {
188 __u32 size;
189 __u32 flags;
190 __u32 hwpt_id;
191 __u32 __reserved;
192};
193#define IOMMU_HWPT_SET_DIRTY_TRACKING _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING)
194enum iommufd_hwpt_get_dirty_bitmap_flags {
195 IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR = 1,
196};
197struct iommu_hwpt_get_dirty_bitmap {
198 __u32 size;
199 __u32 hwpt_id;
200 __u32 flags;
201 __u32 __reserved;
202 __aligned_u64 iova;
203 __aligned_u64 length;
204 __aligned_u64 page_size;
205 __aligned_u64 data;
206};
207#define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP)
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700208enum iommu_hwpt_invalidate_data_type {
Christopher Ferris63fcca42024-09-26 01:12:10 +0000209 IOMMU_HWPT_INVALIDATE_DATA_VTD_S1 = 0,
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700210};
211enum iommu_hwpt_vtd_s1_invalidate_flags {
212 IOMMU_VTD_INV_FLAGS_LEAF = 1 << 0,
213};
214struct iommu_hwpt_vtd_s1_invalidate {
215 __aligned_u64 addr;
216 __aligned_u64 npages;
217 __u32 flags;
218 __u32 __reserved;
219};
220struct iommu_hwpt_invalidate {
221 __u32 size;
222 __u32 hwpt_id;
223 __aligned_u64 data_uptr;
224 __u32 data_type;
225 __u32 entry_len;
226 __u32 entry_num;
227 __u32 __reserved;
228};
229#define IOMMU_HWPT_INVALIDATE _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_INVALIDATE)
Christopher Ferris63fcca42024-09-26 01:12:10 +0000230enum iommu_hwpt_pgfault_flags {
231 IOMMU_PGFAULT_FLAGS_PASID_VALID = (1 << 0),
232 IOMMU_PGFAULT_FLAGS_LAST_PAGE = (1 << 1),
233};
234enum iommu_hwpt_pgfault_perm {
235 IOMMU_PGFAULT_PERM_READ = (1 << 0),
236 IOMMU_PGFAULT_PERM_WRITE = (1 << 1),
237 IOMMU_PGFAULT_PERM_EXEC = (1 << 2),
238 IOMMU_PGFAULT_PERM_PRIV = (1 << 3),
239};
240struct iommu_hwpt_pgfault {
241 __u32 flags;
242 __u32 dev_id;
243 __u32 pasid;
244 __u32 grpid;
245 __u32 perm;
246 __u64 addr;
247 __u32 length;
248 __u32 cookie;
249};
250enum iommufd_page_response_code {
251 IOMMUFD_PAGE_RESP_SUCCESS = 0,
252 IOMMUFD_PAGE_RESP_INVALID = 1,
253};
254struct iommu_hwpt_page_response {
255 __u32 cookie;
256 __u32 code;
257};
258struct iommu_fault_alloc {
259 __u32 size;
260 __u32 flags;
261 __u32 out_fault_id;
262 __u32 out_fault_fd;
263};
264#define IOMMU_FAULT_QUEUE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_FAULT_QUEUE_ALLOC)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800265#endif