• Home
  • Raw
  • Download

Lines Matching full:container

75 	struct vfio_container		*container;  member
277 * Container objects - containers are created when /dev/vfio/vfio is
279 * it's freed via kref. Must support container/group/device being
282 static void vfio_container_get(struct vfio_container *container) in vfio_container_get() argument
284 kref_get(&container->kref); in vfio_container_get()
289 struct vfio_container *container; in vfio_container_release() local
290 container = container_of(kref, struct vfio_container, kref); in vfio_container_release()
292 kfree(container); in vfio_container_release()
295 static void vfio_container_put(struct vfio_container *container) in vfio_container_put() argument
297 kref_put(&container->kref, vfio_container_release); in vfio_container_put()
946 * in use. The container persists with this group and those remaining in vfio_unregister_group_dev()
953 * we need to make sure the group is detached from the container. in vfio_unregister_group_dev()
958 wait_event(group->container_q, !group->container); in vfio_unregister_group_dev()
980 static long vfio_ioctl_check_extension(struct vfio_container *container, in vfio_ioctl_check_extension() argument
986 down_read(&container->group_lock); in vfio_ioctl_check_extension()
988 driver = container->iommu_driver; in vfio_ioctl_check_extension()
1005 if (!list_empty(&container->group_list) && in vfio_ioctl_check_extension()
1006 (container->noiommu != in vfio_ioctl_check_extension()
1023 ret = driver->ops->ioctl(container->iommu_data, in vfio_ioctl_check_extension()
1027 up_read(&container->group_lock); in vfio_ioctl_check_extension()
1032 /* hold write lock on container->group_lock */
1033 static int __vfio_container_attach_groups(struct vfio_container *container, in __vfio_container_attach_groups() argument
1040 list_for_each_entry(group, &container->group_list, container_next) { in __vfio_container_attach_groups()
1049 list_for_each_entry_continue_reverse(group, &container->group_list, in __vfio_container_attach_groups()
1057 static long vfio_ioctl_set_iommu(struct vfio_container *container, in vfio_ioctl_set_iommu() argument
1063 down_write(&container->group_lock); in vfio_ioctl_set_iommu()
1066 * The container is designed to be an unprivileged interface while in vfio_ioctl_set_iommu()
1068 * adding a group to a container does the user get the privilege of in vfio_ioctl_set_iommu()
1070 * is no unset_iommu, but by removing all the groups from a container, in vfio_ioctl_set_iommu()
1071 * the container is deprivileged and returns to an unset state. in vfio_ioctl_set_iommu()
1073 if (list_empty(&container->group_list) || container->iommu_driver) { in vfio_ioctl_set_iommu()
1074 up_write(&container->group_lock); in vfio_ioctl_set_iommu()
1087 if (container->noiommu != (driver->ops == &vfio_noiommu_ops)) in vfio_ioctl_set_iommu()
1113 ret = __vfio_container_attach_groups(container, driver, data); in vfio_ioctl_set_iommu()
1120 container->iommu_driver = driver; in vfio_ioctl_set_iommu()
1121 container->iommu_data = data; in vfio_ioctl_set_iommu()
1126 up_write(&container->group_lock); in vfio_ioctl_set_iommu()
1134 struct vfio_container *container = filep->private_data; in vfio_fops_unl_ioctl() local
1139 if (!container) in vfio_fops_unl_ioctl()
1147 ret = vfio_ioctl_check_extension(container, arg); in vfio_fops_unl_ioctl()
1150 ret = vfio_ioctl_set_iommu(container, arg); in vfio_fops_unl_ioctl()
1153 driver = container->iommu_driver; in vfio_fops_unl_ioctl()
1154 data = container->iommu_data; in vfio_fops_unl_ioctl()
1165 struct vfio_container *container; in vfio_fops_open() local
1167 container = kzalloc(sizeof(*container), GFP_KERNEL); in vfio_fops_open()
1168 if (!container) in vfio_fops_open()
1171 INIT_LIST_HEAD(&container->group_list); in vfio_fops_open()
1172 init_rwsem(&container->group_lock); in vfio_fops_open()
1173 kref_init(&container->kref); in vfio_fops_open()
1175 filep->private_data = container; in vfio_fops_open()
1182 struct vfio_container *container = filep->private_data; in vfio_fops_release() local
1186 vfio_container_put(container); in vfio_fops_release()
1198 struct vfio_container *container = filep->private_data; in vfio_fops_read() local
1202 driver = container->iommu_driver; in vfio_fops_read()
1204 ret = driver->ops->read(container->iommu_data, in vfio_fops_read()
1213 struct vfio_container *container = filep->private_data; in vfio_fops_write() local
1217 driver = container->iommu_driver; in vfio_fops_write()
1219 ret = driver->ops->write(container->iommu_data, in vfio_fops_write()
1227 struct vfio_container *container = filep->private_data; in vfio_fops_mmap() local
1231 driver = container->iommu_driver; in vfio_fops_mmap()
1233 ret = driver->ops->mmap(container->iommu_data, vma); in vfio_fops_mmap()
1254 struct vfio_container *container = group->container; in __vfio_group_unset_container() local
1257 down_write(&container->group_lock); in __vfio_group_unset_container()
1259 driver = container->iommu_driver; in __vfio_group_unset_container()
1261 driver->ops->detach_group(container->iommu_data, in __vfio_group_unset_container()
1264 group->container = NULL; in __vfio_group_unset_container()
1268 /* Detaching the last group deprivileges a container, remove iommu */ in __vfio_group_unset_container()
1269 if (driver && list_empty(&container->group_list)) { in __vfio_group_unset_container()
1270 driver->ops->release(container->iommu_data); in __vfio_group_unset_container()
1272 container->iommu_driver = NULL; in __vfio_group_unset_container()
1273 container->iommu_data = NULL; in __vfio_group_unset_container()
1276 up_write(&container->group_lock); in __vfio_group_unset_container()
1278 vfio_container_put(container); in __vfio_group_unset_container()
1283 * if there was no container to unset. Since the ioctl is called on
1302 * When removing container users, anything that removes the last user
1303 * implicitly removes the group from the container. That is, if the
1316 struct vfio_container *container; in vfio_group_set_container() local
1336 container = f.file->private_data; in vfio_group_set_container()
1337 WARN_ON(!container); /* fget ensures we don't race vfio_release */ in vfio_group_set_container()
1339 down_write(&container->group_lock); in vfio_group_set_container()
1342 if (!list_empty(&container->group_list) && in vfio_group_set_container()
1343 container->noiommu != group->noiommu) { in vfio_group_set_container()
1348 driver = container->iommu_driver; in vfio_group_set_container()
1350 ret = driver->ops->attach_group(container->iommu_data, in vfio_group_set_container()
1356 group->container = container; in vfio_group_set_container()
1357 container->noiommu = group->noiommu; in vfio_group_set_container()
1358 list_add(&group->container_next, &container->group_list); in vfio_group_set_container()
1360 /* Get a reference on the container and mark a user within the group */ in vfio_group_set_container()
1361 vfio_container_get(container); in vfio_group_set_container()
1365 up_write(&container->group_lock); in vfio_group_set_container()
1385 if (!group->container->iommu_driver || !vfio_group_viable(group)) { in vfio_group_add_container_user()
1402 !group->container->iommu_driver || !vfio_group_viable(group)) in vfio_group_get_device_fd()
1482 if (group->container) in vfio_group_fops_unl_ioctl()
1546 if (group->container) { in vfio_group_fops_open()
1659 * - opening a new container;
1661 * - setting an IOMMU driver for a container.
1662 * When IOMMU is set for a container, all groups in it are
1671 * increments the container user counter to prevent
1679 * This call decrements the container user counter.
1706 * increments the container user counter to prevent the VFIO group
1712 * decrement the container user counter.
1761 return vfio_ioctl_check_extension(group->container, arg); in vfio_external_check_extension()
1898 struct vfio_container *container; in vfio_pin_pages() local
1922 container = group->container; in vfio_pin_pages()
1923 driver = container->iommu_driver; in vfio_pin_pages()
1925 ret = driver->ops->pin_pages(container->iommu_data, in vfio_pin_pages()
1950 struct vfio_container *container; in vfio_unpin_pages() local
1969 container = group->container; in vfio_unpin_pages()
1970 driver = container->iommu_driver; in vfio_unpin_pages()
1972 ret = driver->ops->unpin_pages(container->iommu_data, user_pfn, in vfio_unpin_pages()
2010 struct vfio_container *container; in vfio_group_pin_pages() local
2023 container = group->container; in vfio_group_pin_pages()
2024 driver = container->iommu_driver; in vfio_group_pin_pages()
2026 ret = driver->ops->pin_pages(container->iommu_data, in vfio_group_pin_pages()
2057 struct vfio_container *container; in vfio_group_unpin_pages() local
2067 container = group->container; in vfio_group_unpin_pages()
2068 driver = container->iommu_driver; in vfio_group_unpin_pages()
2070 ret = driver->ops->unpin_pages(container->iommu_data, in vfio_group_unpin_pages()
2108 struct vfio_container *container; in vfio_dma_rw() local
2115 container = group->container; in vfio_dma_rw()
2116 driver = container->iommu_driver; in vfio_dma_rw()
2119 ret = driver->ops->dma_rw(container->iommu_data, in vfio_dma_rw()
2132 struct vfio_container *container; in vfio_register_iommu_notifier() local
2140 container = group->container; in vfio_register_iommu_notifier()
2141 driver = container->iommu_driver; in vfio_register_iommu_notifier()
2143 ret = driver->ops->register_notifier(container->iommu_data, in vfio_register_iommu_notifier()
2156 struct vfio_container *container; in vfio_unregister_iommu_notifier() local
2164 container = group->container; in vfio_unregister_iommu_notifier()
2165 driver = container->iommu_driver; in vfio_unregister_iommu_notifier()
2167 ret = driver->ops->unregister_notifier(container->iommu_data, in vfio_unregister_iommu_notifier()