[PATCH v2 00/18] Make vfio_mdev type safe
Alex Williamson
alex.williamson at redhat.com
Wed Apr 14 18:17:19 UTC 2021
On Tue, 6 Apr 2021 16:40:23 -0300
Jason Gunthorpe <jgg at nvidia.com> wrote:
> vfio_mdev has a number of different objects: mdev_parent, mdev_type and
> mdev_device.
>
> Unfortunately the types of these have been erased in various places
> throughout the API, and this makes it very hard to understand this code or
> maintain it by the time it reaches all of the drivers.
>
> This series puts in all the types and aligns some of the design with the
> driver core standard for a driver core bus driver:
>
> - Replace 'struct device *' with 'struct mdev_device *
> - Replace 'struct device *' with 'struct mdev_type *' and
> mtype_get_parent_dev()
> - Replace 'struct kobject *' with 'struct mdev_type *'
>
> Now that types are clear it is easy to spot a few places that have
> duplicated information.
>
> More significantly we can now understand how to directly fix the
> obfuscated 'kobj->name' matching by realizing the the kobj is a mdev_type,
> which is linked to the supported_types_list provided by the driver, and
> thus the core code can directly return the array indexes all the drivers
> actually want.
>
> v2:
> - Use a mdev_type local in mdev_create_sysfs_files
> - Rename the goto unwind labels in mdev_device_free()
> - Reorder patches, annotate reviewed-by's thanks all
> v1: https://lore.kernel.org/r/0-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com
>
> Jason Gunthorpe (18):
> vfio/mdev: Fix missing static's on MDEV_TYPE_ATTR's
> vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer
> vfio/mdev: Add missing typesafety around mdev_device
> vfio/mdev: Simplify driver registration
> vfio/mdev: Use struct mdev_type in struct mdev_device
> vfio/mdev: Expose mdev_get/put_parent to mdev_private.h
> vfio/mdev: Add missing reference counting to mdev_type
> vfio/mdev: Reorganize mdev_device_create()
> vfio/mdev: Add missing error handling to dev_set_name()
> vfio/mdev: Remove duplicate storage of parent in mdev_device
> vfio/mdev: Add mdev/mtype_get_type_group_id()
> vfio/mtty: Use mdev_get_type_group_id()
> vfio/mdpy: Use mdev_get_type_group_id()
> vfio/mbochs: Use mdev_get_type_group_id()
> vfio/gvt: Make DRM_I915_GVT depend on VFIO_MDEV
> vfio/gvt: Use mdev_get_type_group_id()
> vfio/mdev: Remove kobj from mdev_parent_ops->create()
> vfio/mdev: Correct the function signatures for the
> mdev_type_attributes
>
> .../driver-api/vfio-mediated-device.rst | 9 +-
> drivers/gpu/drm/i915/Kconfig | 1 +
> drivers/gpu/drm/i915/gvt/gvt.c | 41 ++---
> drivers/gpu/drm/i915/gvt/gvt.h | 4 +-
> drivers/gpu/drm/i915/gvt/kvmgt.c | 7 +-
> drivers/s390/cio/vfio_ccw_ops.c | 17 +-
> drivers/s390/crypto/vfio_ap_ops.c | 14 +-
> drivers/vfio/mdev/mdev_core.c | 174 +++++++-----------
> drivers/vfio/mdev/mdev_driver.c | 19 +-
> drivers/vfio/mdev/mdev_private.h | 40 ++--
> drivers/vfio/mdev/mdev_sysfs.c | 59 +++---
> drivers/vfio/mdev/vfio_mdev.c | 29 +--
> drivers/vfio/vfio_iommu_type1.c | 25 +--
> include/linux/mdev.h | 80 +++++---
> samples/vfio-mdev/mbochs.c | 55 +++---
> samples/vfio-mdev/mdpy.c | 56 +++---
> samples/vfio-mdev/mtty.c | 66 ++-----
> 17 files changed, 313 insertions(+), 383 deletions(-)
Applied to vfio next branch for v5.13. Thanks!
Alex
More information about the dri-devel
mailing list