lkml.org 
[lkml]   [2022]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 00/15] Tidy up vfio_device life cycle
On Wed, 21 Sep 2022 18:43:46 +0800
Kevin Tian <kevin.tian@intel.com> wrote:

> The idea is to let vfio core manage the vfio_device life cycle instead
> of duplicating the logic cross drivers. Besides cleaner code in driver
> side this also allows adding struct device to vfio_device as the first
> step toward adding cdev uAPI in the future. Another benefit is that
> user can now look at sysfs to decide whether a device is bound to
> vfio [1], e.g.:
>
> /sys/devices/pci0000\:6f/0000\:6f\:01.0/vfio-dev/vfio0
>
> Though most drivers can fit the new model naturally:
>
> - vfio_alloc_device() to allocate and initialize vfio_device
> - vfio_put_device() to release vfio_device
> - dev_ops->init() for driver private initialization
> - dev_ops->release() for driver private cleanup
>
> vfio-ccw is the only exception due to a life cycle mess that its private
> structure mixes both parent and mdev info hence must be alloc/freed
> outside of the life cycle of vfio device.
>
> Per prior discussions this won't be fixed in short term by IBM folks [2].
>
> Instead of waiting this series introduces a few tricks to move forward:
>
> - vfio_init_device() to initialize a pre-allocated device structure;
>
> - require *EVERY* driver to implement @release and free vfio_device
> inside. Then vfio-ccw can use a completion mechanism to delay the
> free to css driver;
>
> The second trick is not a real burden to other drivers because they
> all require a @release for private cleanup anyway. Later once the ccw
> mess is fixed a simple cleanup can be done by moving free from @release
> to vfio core.
>
> Thanks
> Kevin
>
> [1] https://listman.redhat.com/archives/libvir-list/2022-August/233482.html
> [2] https://lore.kernel.org/all/0ee29bd6583f17f0ee4ec0769fa50e8ea6703623.camel@linux.ibm.com/
>
> v4:
> - fix use-after-free issue in @release of mtty/mbochs and also change
> mdpy/ap to free vfio-device as the last thing in @release (Alex)
> - revert the rename from 'vfio' to 'vfio_group' in procfs (Alex)

Applied to vfio next branch for v6.1. Thanks,

Alex

\
 
 \ /
  Last update: 2022-09-22 19:59    [W:0.116 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site