Lines Matching refs:cmd

39 	struct iommu_ioas_alloc *cmd = ucmd->cmd;  in iommufd_ioas_alloc_ioctl()  local
43 if (cmd->flags) in iommufd_ioas_alloc_ioctl()
50 cmd->out_ioas_id = ioas->obj.id; in iommufd_ioas_alloc_ioctl()
51 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_alloc_ioctl()
65 struct iommu_ioas_iova_ranges *cmd = ucmd->cmd; in iommufd_ioas_iova_ranges() local
71 if (cmd->__reserved) in iommufd_ioas_iova_ranges()
74 ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); in iommufd_ioas_iova_ranges()
79 max_iovas = cmd->num_iovas; in iommufd_ioas_iova_ranges()
80 ranges = u64_to_user_ptr(cmd->allowed_iovas); in iommufd_ioas_iova_ranges()
81 cmd->num_iovas = 0; in iommufd_ioas_iova_ranges()
82 cmd->out_iova_alignment = ioas->iopt.iova_alignment; in iommufd_ioas_iova_ranges()
87 if (cmd->num_iovas < max_iovas) { in iommufd_ioas_iova_ranges()
93 if (copy_to_user(&ranges[cmd->num_iovas], &elm, in iommufd_ioas_iova_ranges()
99 cmd->num_iovas++; in iommufd_ioas_iova_ranges()
101 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_iova_ranges()
104 if (cmd->num_iovas > max_iovas) in iommufd_ioas_iova_ranges()
144 struct iommu_ioas_allow_iovas *cmd = ucmd->cmd; in iommufd_ioas_allow_iovas() local
151 if (cmd->__reserved) in iommufd_ioas_allow_iovas()
154 ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); in iommufd_ioas_allow_iovas()
160 u64_to_user_ptr(cmd->allowed_iovas), in iommufd_ioas_allow_iovas()
161 cmd->num_iovas); in iommufd_ioas_allow_iovas()
202 struct iommu_ioas_map *cmd = ucmd->cmd; in iommufd_ioas_map() local
203 unsigned long iova = cmd->iova; in iommufd_ioas_map()
208 if ((cmd->flags & in iommufd_ioas_map()
211 cmd->__reserved) in iommufd_ioas_map()
213 if (cmd->iova >= ULONG_MAX || cmd->length >= ULONG_MAX) in iommufd_ioas_map()
216 ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); in iommufd_ioas_map()
220 if (!(cmd->flags & IOMMU_IOAS_MAP_FIXED_IOVA)) in iommufd_ioas_map()
223 u64_to_user_ptr(cmd->user_va), cmd->length, in iommufd_ioas_map()
224 conv_iommu_prot(cmd->flags), flags); in iommufd_ioas_map()
228 cmd->iova = iova; in iommufd_ioas_map()
229 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_map()
237 struct iommu_ioas_copy *cmd = ucmd->cmd; in iommufd_ioas_copy() local
245 iommufd_test_syz_conv_iova_id(ucmd, cmd->src_ioas_id, &cmd->src_iova, in iommufd_ioas_copy()
246 &cmd->flags); in iommufd_ioas_copy()
248 if ((cmd->flags & in iommufd_ioas_copy()
252 if (cmd->length >= ULONG_MAX || cmd->src_iova >= ULONG_MAX || in iommufd_ioas_copy()
253 cmd->dst_iova >= ULONG_MAX) in iommufd_ioas_copy()
256 src_ioas = iommufd_get_ioas(ucmd->ictx, cmd->src_ioas_id); in iommufd_ioas_copy()
259 rc = iopt_get_pages(&src_ioas->iopt, cmd->src_iova, cmd->length, in iommufd_ioas_copy()
265 dst_ioas = iommufd_get_ioas(ucmd->ictx, cmd->dst_ioas_id); in iommufd_ioas_copy()
271 if (!(cmd->flags & IOMMU_IOAS_MAP_FIXED_IOVA)) in iommufd_ioas_copy()
273 iova = cmd->dst_iova; in iommufd_ioas_copy()
274 rc = iopt_map_pages(&dst_ioas->iopt, &pages_list, cmd->length, &iova, in iommufd_ioas_copy()
275 conv_iommu_prot(cmd->flags), flags); in iommufd_ioas_copy()
279 cmd->dst_iova = iova; in iommufd_ioas_copy()
280 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_copy()
290 struct iommu_ioas_unmap *cmd = ucmd->cmd; in iommufd_ioas_unmap() local
295 ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); in iommufd_ioas_unmap()
299 if (cmd->iova == 0 && cmd->length == U64_MAX) { in iommufd_ioas_unmap()
304 if (cmd->iova >= ULONG_MAX || cmd->length >= ULONG_MAX) { in iommufd_ioas_unmap()
308 rc = iopt_unmap_iova(&ioas->iopt, cmd->iova, cmd->length, in iommufd_ioas_unmap()
314 cmd->length = unmapped; in iommufd_ioas_unmap()
315 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_unmap()
322 int iommufd_option_rlimit_mode(struct iommu_option *cmd, in iommufd_option_rlimit_mode() argument
325 if (cmd->object_id) in iommufd_option_rlimit_mode()
328 if (cmd->op == IOMMU_OPTION_OP_GET) { in iommufd_option_rlimit_mode()
329 cmd->val64 = ictx->account_mode == IOPT_PAGES_ACCOUNT_MM; in iommufd_option_rlimit_mode()
332 if (cmd->op == IOMMU_OPTION_OP_SET) { in iommufd_option_rlimit_mode()
342 if (cmd->val64 == 0) in iommufd_option_rlimit_mode()
344 else if (cmd->val64 == 1) in iommufd_option_rlimit_mode()
356 static int iommufd_ioas_option_huge_pages(struct iommu_option *cmd, in iommufd_ioas_option_huge_pages() argument
359 if (cmd->op == IOMMU_OPTION_OP_GET) { in iommufd_ioas_option_huge_pages()
360 cmd->val64 = !ioas->iopt.disable_large_pages; in iommufd_ioas_option_huge_pages()
363 if (cmd->op == IOMMU_OPTION_OP_SET) { in iommufd_ioas_option_huge_pages()
364 if (cmd->val64 == 0) in iommufd_ioas_option_huge_pages()
366 if (cmd->val64 == 1) { in iommufd_ioas_option_huge_pages()
377 struct iommu_option *cmd = ucmd->cmd; in iommufd_ioas_option() local
381 if (cmd->__reserved) in iommufd_ioas_option()
384 ioas = iommufd_get_ioas(ucmd->ictx, cmd->object_id); in iommufd_ioas_option()
388 switch (cmd->option_id) { in iommufd_ioas_option()
390 rc = iommufd_ioas_option_huge_pages(cmd, ioas); in iommufd_ioas_option()