RE: [PATCH v3 12/15] vfio: Make vfio_device_open() single open for device cdev path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> Sent: Monday, February 13, 2023 11:14 PM
> 
> With the introduction of vfio device cdev, userspace can get device
> access by either the legacy group path or the cdev path. For VFIO devices,
> it can only be opened by one of the group path and the cdev path at one
> time. e.g. when the device is opened via cdev path, the group path should
> be failed. Both paths will call into vfio_device_open(), so the exclusion
> is done in it.

the exclusive part between two paths is handled by the last patch.

this patch should stay with explaining single-open facet in cdev path.

> 
> +	/*
> +	 * Device cdev path cannot support multiple device open since
> +	 * it doesn't have a secure way for it. So a second device
> +	 * open attempt should be failed if the caller is from a cdev
> +	 * path.
> +	 */

remove the last sentence.

> +	if (device->open_count != 0 && df->is_cdev_device)
> +		return -EINVAL;
> +
>  	device->open_count++;
>  	if (device->open_count == 1) {
>  		ret = vfio_device_first_open(df, dev_id, pt_id);
> @@ -543,7 +552,12 @@ static int vfio_device_fops_release(struct inode
> *inode, struct file *filep)
>  	struct vfio_device_file *df = filep->private_data;
>  	struct vfio_device *device = df->device;
> 
> -	vfio_device_group_close(df);
> +	/*
> +	 * group path supports multiple device open, while cdev doesn't.
> +	 * So use vfio_device_group_close() for !is_cdev_device case.
> +	 */

I don't say why multi-open is the reason to call group_close(). Isn't
it straightforward to do so in the group path? I'd just remove the comment.

> +	if (!df->is_cdev_device)
> +		vfio_device_group_close(df);
> 
>  	vfio_device_put_registration(device);
> 
> --
> 2.34.1





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux