blob: d19a471e55073526cf842f1746f83f0c6c302941 [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,
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,
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070023 IOMMUFD_CMD_HWPT_ALLOC,
24 IOMMUFD_CMD_GET_HW_INFO,
Christopher Ferris0f795212024-01-17 14:17:28 -080025 IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING,
26 IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080027};
28struct iommu_destroy {
29 __u32 size;
30 __u32 id;
31};
32#define IOMMU_DESTROY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_DESTROY)
33struct iommu_ioas_alloc {
34 __u32 size;
35 __u32 flags;
36 __u32 out_ioas_id;
37};
38#define IOMMU_IOAS_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOC)
39struct iommu_iova_range {
40 __aligned_u64 start;
41 __aligned_u64 last;
42};
43struct iommu_ioas_iova_ranges {
44 __u32 size;
45 __u32 ioas_id;
46 __u32 num_iovas;
47 __u32 __reserved;
48 __aligned_u64 allowed_iovas;
49 __aligned_u64 out_iova_alignment;
50};
51#define IOMMU_IOAS_IOVA_RANGES _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_IOVA_RANGES)
52struct iommu_ioas_allow_iovas {
53 __u32 size;
54 __u32 ioas_id;
55 __u32 num_iovas;
56 __u32 __reserved;
57 __aligned_u64 allowed_iovas;
58};
59#define IOMMU_IOAS_ALLOW_IOVAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOW_IOVAS)
60enum iommufd_ioas_map_flags {
61 IOMMU_IOAS_MAP_FIXED_IOVA = 1 << 0,
62 IOMMU_IOAS_MAP_WRITEABLE = 1 << 1,
63 IOMMU_IOAS_MAP_READABLE = 1 << 2,
64};
65struct iommu_ioas_map {
66 __u32 size;
67 __u32 flags;
68 __u32 ioas_id;
69 __u32 __reserved;
70 __aligned_u64 user_va;
71 __aligned_u64 length;
72 __aligned_u64 iova;
73};
74#define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP)
75struct iommu_ioas_copy {
76 __u32 size;
77 __u32 flags;
78 __u32 dst_ioas_id;
79 __u32 src_ioas_id;
80 __aligned_u64 length;
81 __aligned_u64 dst_iova;
82 __aligned_u64 src_iova;
83};
84#define IOMMU_IOAS_COPY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_COPY)
85struct iommu_ioas_unmap {
86 __u32 size;
87 __u32 ioas_id;
88 __aligned_u64 iova;
89 __aligned_u64 length;
90};
91#define IOMMU_IOAS_UNMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_UNMAP)
92enum iommufd_option {
93 IOMMU_OPTION_RLIMIT_MODE = 0,
94 IOMMU_OPTION_HUGE_PAGES = 1,
95};
96enum iommufd_option_ops {
97 IOMMU_OPTION_OP_SET = 0,
98 IOMMU_OPTION_OP_GET = 1,
99};
100struct iommu_option {
101 __u32 size;
102 __u32 option_id;
103 __u16 op;
104 __u16 __reserved;
105 __u32 object_id;
106 __aligned_u64 val64;
107};
108#define IOMMU_OPTION _IO(IOMMUFD_TYPE, IOMMUFD_CMD_OPTION)
109enum iommufd_vfio_ioas_op {
110 IOMMU_VFIO_IOAS_GET = 0,
111 IOMMU_VFIO_IOAS_SET = 1,
112 IOMMU_VFIO_IOAS_CLEAR = 2,
113};
114struct iommu_vfio_ioas {
115 __u32 size;
116 __u32 ioas_id;
117 __u16 op;
118 __u16 __reserved;
119};
120#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)
Christopher Ferris0f795212024-01-17 14:17:28 -0800121enum iommufd_hwpt_alloc_flags {
122 IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0,
123 IOMMU_HWPT_ALLOC_DIRTY_TRACKING = 1 << 1,
124};
125enum iommu_hwpt_vtd_s1_flags {
126 IOMMU_VTD_S1_SRE = 1 << 0,
127 IOMMU_VTD_S1_EAFE = 1 << 1,
128 IOMMU_VTD_S1_WPE = 1 << 2,
129};
130struct iommu_hwpt_vtd_s1 {
131 __aligned_u64 flags;
132 __aligned_u64 pgtbl_addr;
133 __u32 addr_width;
134 __u32 __reserved;
135};
136enum iommu_hwpt_data_type {
137 IOMMU_HWPT_DATA_NONE,
138 IOMMU_HWPT_DATA_VTD_S1,
139};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700140struct iommu_hwpt_alloc {
141 __u32 size;
142 __u32 flags;
143 __u32 dev_id;
144 __u32 pt_id;
145 __u32 out_hwpt_id;
146 __u32 __reserved;
Christopher Ferris0f795212024-01-17 14:17:28 -0800147 __u32 data_type;
148 __u32 data_len;
149 __aligned_u64 data_uptr;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700150};
151#define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC)
Christopher Ferris0f795212024-01-17 14:17:28 -0800152enum iommu_hw_info_vtd_flags {
153 IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17 = 1 << 0,
154};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700155struct iommu_hw_info_vtd {
156 __u32 flags;
157 __u32 __reserved;
158 __aligned_u64 cap_reg;
159 __aligned_u64 ecap_reg;
160};
161enum iommu_hw_info_type {
162 IOMMU_HW_INFO_TYPE_NONE,
163 IOMMU_HW_INFO_TYPE_INTEL_VTD,
164};
Christopher Ferris0f795212024-01-17 14:17:28 -0800165enum iommufd_hw_capabilities {
166 IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0,
167};
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700168struct iommu_hw_info {
169 __u32 size;
170 __u32 flags;
171 __u32 dev_id;
172 __u32 data_len;
173 __aligned_u64 data_uptr;
174 __u32 out_data_type;
175 __u32 __reserved;
Christopher Ferris0f795212024-01-17 14:17:28 -0800176 __aligned_u64 out_capabilities;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700177};
178#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO)
Christopher Ferris0f795212024-01-17 14:17:28 -0800179enum iommufd_hwpt_set_dirty_tracking_flags {
180 IOMMU_HWPT_DIRTY_TRACKING_ENABLE = 1,
181};
182struct iommu_hwpt_set_dirty_tracking {
183 __u32 size;
184 __u32 flags;
185 __u32 hwpt_id;
186 __u32 __reserved;
187};
188#define IOMMU_HWPT_SET_DIRTY_TRACKING _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_SET_DIRTY_TRACKING)
189enum iommufd_hwpt_get_dirty_bitmap_flags {
190 IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR = 1,
191};
192struct iommu_hwpt_get_dirty_bitmap {
193 __u32 size;
194 __u32 hwpt_id;
195 __u32 flags;
196 __u32 __reserved;
197 __aligned_u64 iova;
198 __aligned_u64 length;
199 __aligned_u64 page_size;
200 __aligned_u64 data;
201};
202#define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800203#endif