@@ -2429,10 +2429,18 @@ static int vfio_pci_dev_set_hot_reset(struct vfio_device_set *dev_set,
list_for_each_entry(cur_vma, &dev_set->device_list, vdev.dev_set_list) {
/*
- * Test whether all the affected devices are contained by the
- * set of groups provided by the user.
+ * Test whether all the affected devices can be reset by the
+ * user.
+ *
+ * Resetting an unused device (not opened) is safe, because
+ * dev_set->lock is held in hot reset path so this device
+ * cannot race being opened by another user simultaneously.
+ *
+ * Otherwise all opened devices in the dev_set must be
+ * contained by the set of groups provided by the user.
*/
- if (!vfio_dev_in_groups(cur_vma, groups)) {
+ if (cur_vma->vdev.open_count &&
+ !vfio_dev_in_groups(cur_vma, groups)) {
ret = -EINVAL;
goto err_undo;
}
@@ -673,6 +673,14 @@ struct vfio_pci_hot_reset_info {
* VFIO_DEVICE_PCI_HOT_RESET - _IOW(VFIO_TYPE, VFIO_BASE + 13,
* struct vfio_pci_hot_reset)
*
+ * Userspace requests hot reset for the devices it uses. Due to the
+ * underlying topology, multiple devices can be affected in the reset
+ * while some might be opened by another user. To avoid interference
+ * the calling user must ensure all affected devices, if opened, are
+ * owned by itself.
+ *
+ * The ownership is proved by an array of group fds.
+ *
* Return: 0 on success, -errno on failure.
*/
struct vfio_pci_hot_reset {