Lines Matching full: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 if (!(cmd->flags & in iommufd_ioas_map()
220 ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); in iommufd_ioas_map()
224 if (!(cmd->flags & IOMMU_IOAS_MAP_FIXED_IOVA)) in iommufd_ioas_map()
227 u64_to_user_ptr(cmd->user_va), cmd->length, in iommufd_ioas_map()
228 conv_iommu_prot(cmd->flags), flags); in iommufd_ioas_map()
232 cmd->iova = iova; in iommufd_ioas_map()
233 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_map()
241 struct iommu_ioas_copy *cmd = ucmd->cmd; in iommufd_ioas_copy() local
249 iommufd_test_syz_conv_iova_id(ucmd, cmd->src_ioas_id, &cmd->src_iova, in iommufd_ioas_copy()
250 &cmd->flags); in iommufd_ioas_copy()
252 if ((cmd->flags & in iommufd_ioas_copy()
256 if (cmd->length >= ULONG_MAX || cmd->src_iova >= ULONG_MAX || in iommufd_ioas_copy()
257 cmd->dst_iova >= ULONG_MAX) in iommufd_ioas_copy()
260 if (!(cmd->flags & in iommufd_ioas_copy()
264 src_ioas = iommufd_get_ioas(ucmd->ictx, cmd->src_ioas_id); in iommufd_ioas_copy()
267 rc = iopt_get_pages(&src_ioas->iopt, cmd->src_iova, cmd->length, in iommufd_ioas_copy()
273 dst_ioas = iommufd_get_ioas(ucmd->ictx, cmd->dst_ioas_id); in iommufd_ioas_copy()
279 if (!(cmd->flags & IOMMU_IOAS_MAP_FIXED_IOVA)) in iommufd_ioas_copy()
281 iova = cmd->dst_iova; in iommufd_ioas_copy()
282 rc = iopt_map_pages(&dst_ioas->iopt, &pages_list, cmd->length, &iova, in iommufd_ioas_copy()
283 conv_iommu_prot(cmd->flags), flags); in iommufd_ioas_copy()
287 cmd->dst_iova = iova; in iommufd_ioas_copy()
288 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_copy()
298 struct iommu_ioas_unmap *cmd = ucmd->cmd; in iommufd_ioas_unmap() local
303 ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id); in iommufd_ioas_unmap()
307 if (cmd->iova == 0 && cmd->length == U64_MAX) { in iommufd_ioas_unmap()
312 if (cmd->iova >= ULONG_MAX || cmd->length >= ULONG_MAX) { in iommufd_ioas_unmap()
316 rc = iopt_unmap_iova(&ioas->iopt, cmd->iova, cmd->length, in iommufd_ioas_unmap()
322 cmd->length = unmapped; in iommufd_ioas_unmap()
323 rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd)); in iommufd_ioas_unmap()
330 int iommufd_option_rlimit_mode(struct iommu_option *cmd, in iommufd_option_rlimit_mode() argument
333 if (cmd->object_id) in iommufd_option_rlimit_mode()
336 if (cmd->op == IOMMU_OPTION_OP_GET) { in iommufd_option_rlimit_mode()
337 cmd->val64 = ictx->account_mode == IOPT_PAGES_ACCOUNT_MM; in iommufd_option_rlimit_mode()
340 if (cmd->op == IOMMU_OPTION_OP_SET) { in iommufd_option_rlimit_mode()
350 if (cmd->val64 == 0) in iommufd_option_rlimit_mode()
352 else if (cmd->val64 == 1) in iommufd_option_rlimit_mode()
364 static int iommufd_ioas_option_huge_pages(struct iommu_option *cmd, in iommufd_ioas_option_huge_pages() argument
367 if (cmd->op == IOMMU_OPTION_OP_GET) { in iommufd_ioas_option_huge_pages()
368 cmd->val64 = !ioas->iopt.disable_large_pages; in iommufd_ioas_option_huge_pages()
371 if (cmd->op == IOMMU_OPTION_OP_SET) { in iommufd_ioas_option_huge_pages()
372 if (cmd->val64 == 0) in iommufd_ioas_option_huge_pages()
374 if (cmd->val64 == 1) { in iommufd_ioas_option_huge_pages()
385 struct iommu_option *cmd = ucmd->cmd; in iommufd_ioas_option() local
389 if (cmd->__reserved) in iommufd_ioas_option()
392 ioas = iommufd_get_ioas(ucmd->ictx, cmd->object_id); in iommufd_ioas_option()
396 switch (cmd->option_id) { in iommufd_ioas_option()
398 rc = iommufd_ioas_option_huge_pages(cmd, ioas); in iommufd_ioas_option()