[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200115133027.228452fd.cohuck@redhat.com>
Date: Wed, 15 Jan 2020 13:30:27 +0100
From: Cornelia Huck <cohuck@...hat.com>
To: Liu Yi L <yi.l.liu@...el.com>
Cc: alex.williamson@...hat.com, kwankhede@...dia.com,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
kevin.tian@...el.com, joro@...tes.org, peterx@...hat.com,
baolu.lu@...ux.intel.com,
Masahiro Yamada <yamada.masahiro@...ionext.com>
Subject: Re: [PATCH v4 11/12] samples: add vfio-mdev-pci driver
On Tue, 7 Jan 2020 20:01:48 +0800
Liu Yi L <yi.l.liu@...el.com> wrote:
> This patch adds sample driver named vfio-mdev-pci. It is to wrap
> a PCI device as a mediated device. For a pci device, once bound
> to vfio-mdev-pci driver, user space access of this device will
> go through vfio mdev framework. The usage of the device follows
> mdev management method. e.g. user should create a mdev before
> exposing the device to user-space.
>
> Benefit of this new driver would be acting as a sample driver
> for recent changes from "vfio/mdev: IOMMU aware mediated device"
> patchset. Also it could be a good experiment driver for future
> device specific mdev migration support. This sample driver only
> supports singleton iommu groups, for non-singleton iommu groups,
> this sample driver doesn't work. It will fail when trying to assign
> the non-singleton iommu group to VMs.
>
> To use this driver:
> a) build and load vfio-mdev-pci.ko module
> execute "make menuconfig" and config CONFIG_SAMPLE_VFIO_MDEV_PCI
> then load it with following command:
> > sudo modprobe vfio
> > sudo modprobe vfio-pci
> > sudo insmod samples/vfio-mdev-pci/vfio-mdev-pci.ko
>
> b) unbind original device driver
> e.g. use following command to unbind its original driver
> > echo $dev_bdf > /sys/bus/pci/devices/$dev_bdf/driver/unbind
>
> c) bind vfio-mdev-pci driver to the physical device
> > echo $vend_id $dev_id > /sys/bus/pci/drivers/vfio-mdev-pci/new_id
>
> d) check the supported mdev instances
> > ls /sys/bus/pci/devices/$dev_bdf/mdev_supported_types/
> vfio-mdev-pci-type_name
> > ls /sys/bus/pci/devices/$dev_bdf/mdev_supported_types/\
> vfio-mdev-pci-type_name/
> available_instances create device_api devices name
>
> e) create mdev on this physical device (only 1 instance)
> > echo "83b8f4f2-509f-382f-3c1e-e6bfe0fa1003" > \
> /sys/bus/pci/devices/$dev_bdf/mdev_supported_types/\
> vfio-mdev-pci-type_name/create
>
> f) passthru the mdev to guest
> add the following line in QEMU boot command
> -device vfio-pci,\
> sysfsdev=/sys/bus/mdev/devices/83b8f4f2-509f-382f-3c1e-e6bfe0fa1003
>
> g) destroy mdev
> > echo 1 > /sys/bus/mdev/devices/83b8f4f2-509f-382f-3c1e-e6bfe0fa1003/\
> remove
I think much/most of those instructions should go (additionally) into
the sample driver source. Otherwise, it's not clear to the reader why
they should wrap the device in mdev instead of simply using a normal
vfio-pci device.
>
> Cc: Kevin Tian <kevin.tian@...el.com>
> Cc: Lu Baolu <baolu.lu@...ux.intel.com>
> Cc: Masahiro Yamada <yamada.masahiro@...ionext.com>
> Suggested-by: Alex Williamson <alex.williamson@...hat.com>
> Signed-off-by: Liu Yi L <yi.l.liu@...el.com>
> ---
> samples/Kconfig | 10 +
> samples/Makefile | 1 +
> samples/vfio-mdev-pci/Makefile | 4 +
> samples/vfio-mdev-pci/vfio_mdev_pci.c | 397 ++++++++++++++++++++++++++++++++++
> 4 files changed, 412 insertions(+)
> create mode 100644 samples/vfio-mdev-pci/Makefile
> create mode 100644 samples/vfio-mdev-pci/vfio_mdev_pci.c
>
> diff --git a/samples/Kconfig b/samples/Kconfig
> index 9d236c3..50d207c 100644
> --- a/samples/Kconfig
> +++ b/samples/Kconfig
> @@ -190,5 +190,15 @@ config SAMPLE_INTEL_MEI
> help
> Build a sample program to work with mei device.
>
> +config SAMPLE_VFIO_MDEV_PCI
> + tristate "Sample driver for wrapping PCI device as a mdev"
> + select VFIO_PCI_COMMON
> + select VFIO_PCI
Why does this still need to select VFIO_PCI? Shouldn't all needed
infrastructure rather be covered by VFIO_PCI_COMMON already?
> + depends on VFIO_MDEV && VFIO_MDEV_DEVICE
VFIO_MDEV_DEVICE already depends on VFIO_MDEV. But maybe also make this
depend on PCI?
> + help
> + Sample driver for wrapping a PCI device as a mdev. Once bound to
> + this driver, device passthru should through mdev path.
"A PCI device bound to this driver will be assigned through the
mediated device framework."
?
> +
> + If you don't know what to do here, say N.
>
> endif # SAMPLES
Powered by blists - more mailing lists