[Qemu-devel] [PATCH v8 00/13] basic channel IO passthrough infrastructure based on vfio

Dong Jia Shi posted 13 patches 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170517004813.58227-1-bjsdjshi@linux.vnet.ibm.com
Test checkpatch passed
Test docker passed
Test s390x passed
MAINTAINERS                        |   7 +
default-configs/s390x-softmmu.mak  |   1 +
hw/s390x/3270-ccw.c                |   6 +-
hw/s390x/Makefile.objs             |   1 +
hw/s390x/css-bridge.c              |   2 +
hw/s390x/css.c                     | 290 +++++++++++++++++++++++--
hw/s390x/s390-ccw.c                | 153 +++++++++++++
hw/s390x/s390-virtio-ccw.c         |  32 ++-
hw/s390x/virtio-ccw.c              |   7 +-
hw/vfio/Makefile.objs              |   1 +
hw/vfio/ccw.c                      | 434 +++++++++++++++++++++++++++++++++++++
include/hw/s390x/css-bridge.h      |   1 +
include/hw/s390x/css.h             |  67 +++---
include/hw/s390x/s390-ccw.h        |  39 ++++
include/hw/s390x/s390-virtio-ccw.h |   1 +
include/hw/vfio/vfio-common.h      |   1 +
linux-headers/linux/vfio.h         |  17 ++
linux-headers/linux/vfio_ccw.h     |  28 +++
qemu-options.hx                    |   6 +-
scripts/update-linux-headers.sh    |   2 +-
target/s390x/cpu.h                 |  10 +
target/s390x/ioinst.c              |   9 +
22 files changed, 1065 insertions(+), 50 deletions(-)
create mode 100644 hw/s390x/s390-ccw.c
create mode 100644 hw/vfio/ccw.c
create mode 100644 include/hw/s390x/s390-ccw.h
create mode 100644 linux-headers/linux/vfio_ccw.h
[Qemu-devel] [PATCH v8 00/13] basic channel IO passthrough infrastructure based on vfio
Posted by Dong Jia Shi 6 years, 11 months ago
The patch series introduce a basic channel I/O passthrough
infrastructure based on vfio.
- Focus on supporting dasd-eckd(cu_type/dev_type = 0x3990/0x3390) as
  the target device. 
- Support new qemu parameters in the style of:
    -machine s390-ccw-virtio(,s390-squash-mcss=on|off) \
    -device vfio-ccw,sysfsdev=$MDEV_PATH
  We want to support real (i.e. not virtual) channel devices even for
  guests that do not support MCSS-E (where guests may see devices from
  any channel subsystem image at once). As all virtio-ccw devices are in
  css 0xfe (and show up in the default css 0 for guests not activating
  MCSS-E), we need an option to squash e.g. passed-through channel devices
  from their real css (0-3, or 0 for hosts not activating MCSS-E) into
  the default css, that is what the new machine option s390-squash-css is
  added.

Build and install:
1. kernel configuration
  CONFIG_S390_CCW_IOMMU=m
  CONFIG_VFIO=m
  CONFIG_VFIO_MDEV=m
  CONFIG_VFIO_MDEV_DEVICE=m
  CONFIG_VFIO_CCW=m
2. modules required
  modprobe vfio.ko
  modprobe mdev.ko
  modprobe vfio_mdev.ko
  modprobe vfio_iommu_type1.ko
  modprobe vfio_ccw.ko
3. find a subchannel(0.0."%schid") of a DASD-ECKD device and bind it to
  vfio_ccw driver
  #find the dasd you can use with lsdasd on your host. e.g.:
  devno="7e52"
  schid="16ca"
  #unbind the ccw device from the subchannel
  echo 0.0."$devno" > /sys/bus/ccw/devices/0.0."$devno"/driver/unbind
  #unbind the subchannel from io_subchannel driver
  echo 0.0."$schid" > /sys/bus/css/devices/0.0."$schid"/driver/unbind
  #bind the subchannel with vfio_ccw driver
  echo 0.0."$schid" > /sys/bus/css/drivers/vfio_ccw/bind
4. create a mediated device
  #generate a uuid with uuidgen. e.g.:
  uuid="6dfd3ec5-e8b3-4e18-a6fe-57bc9eceb920"
  echo "$uuid" > \
  /sys/bus/css/devices/0.0."$schid"/mdev_supported_types/vfio_ccw-io/create
5. pass-through this device to a vm
  -M s390-ccw-virtio,s390-squash-css=on \
  -device vfio-ccw,sysfsdev=/sys/bus/mdev/devices/$uuid \
  ... ...

Change log:
v7 -> v8:
1. Rebased against master (commit: dd1559b), which contents the 3270
   changes.
2. Patch #4:
   Cosmetic changes for commit message and comments.
3. Patch #5:
   Cosmetic changes for commit message and comments.
   Removed an extra blank.
   For CSS 0xFE use cases, renamed virtio and non virtio to virtual
   and non virtual for the coressponding parameter, message, and
   comments.
   Used the new css_create_sch interface in hw/s390x/3270-ccw.c.
4. Patch #6:
   Moved hw/s390x/s390-ccw.h to include/hw/s390x/s390-ccw.h.
   Added a check for sscanf return.
5. Patch #9:
   Removed the set_error label, and rename get_error to out_free_info.
6. Patch #13:
   Added hw/s390x/s390-ccw.c and include/hw/s390x-s390-ccw.h.
7. For those patches which got a A-B and(or) a R-B, added it(them).

v6 -> v7:
1. Patch #6:
   Use error_setg_errno as possible.
   Use local Error variable as possible.
   Free @sch when error out.
2. Patch #7:
   Use local Error variable as possible.
   Remove vfio_ccw_put_group.
3. Patch #8:
   Use local Error variable as possible.
   Free @info when error out.
4. Patch #9:
   Use error_setg_errno as possible.
   Use local Error variable as possible.
5. Patch #10:
   Move handle_request from device to class.
   Generate channel-check for information transfer error.
   Improve pread logic.

v5 -> v6:
1. Rebase against git://github.com/cohuck/qemu s390-next.
2. Patch #6: correct error message: -vfio-ccw --> -device vfio-ccw
3. Patch #7:
   Rewrite vfio_ccw_get_group by:
     - removing unnecessary checking of path existance;
     - removing useless 'path' variable;
   Fix a typo: s/operationis/operations/
   In vfio_ccw_unrealize, move cdc->unrealize to the end.

v4 -> v5:
1. Rebase to git://github.com/cohuck/qemu s390-next.
2. New patch #1: update-linux-headers.
3. Patch #6: update s390_ccw_realize according to the new code base.
4. New patch #13: add maintainer for vfio-ccw.

v3 -> v4:
1. Adjustments of the s-o-b chains for some patches.

v2 -> v3:
1. Move vfio_ccw.h to uapi.
2. Adopt the vfio-ccw cmdline interface as vfio-pci with mdev devices.
3. Rename s390-map-css to s390-squash-mcss (patch 2), and update devno
   generation method (patch 5).
4. Patch 7: correct the validation of num_regions.
5. Patch 8: correct the validation of num_irqs.

v1 -> v2:
1. Rebase the implementation to the mdev framework approach.
2. Use pread and pwrite on an I/O region to issue I/O requests and
   receive results.

Dong Jia Shi (8):
  update-linux-headers: update for vfio-ccw
  vfio: linux-headers update for vfio-ccw
  s390x/css: realize css_create_sch
  s390x/css: device support for s390-ccw passthrough
  vfio/ccw: get io region info
  vfio/ccw: get irqs info and set the eventfd fd
  vfio/ccw: update sense data if a unit check is pending
  MAINTAINERS: Add vfio-ccw maintainer

Xiao Feng Ren (5):
  s390x/css: add s390-squash-mcss machine option
  s390x/css: realize css_sch_build_schib
  vfio/ccw: vfio based subchannel passthrough driver
  s390x/css: introduce and realize ccw-request callback
  s390x/css: ccw translation infrastructure

 MAINTAINERS                        |   7 +
 default-configs/s390x-softmmu.mak  |   1 +
 hw/s390x/3270-ccw.c                |   6 +-
 hw/s390x/Makefile.objs             |   1 +
 hw/s390x/css-bridge.c              |   2 +
 hw/s390x/css.c                     | 290 +++++++++++++++++++++++--
 hw/s390x/s390-ccw.c                | 153 +++++++++++++
 hw/s390x/s390-virtio-ccw.c         |  32 ++-
 hw/s390x/virtio-ccw.c              |   7 +-
 hw/vfio/Makefile.objs              |   1 +
 hw/vfio/ccw.c                      | 434 +++++++++++++++++++++++++++++++++++++
 include/hw/s390x/css-bridge.h      |   1 +
 include/hw/s390x/css.h             |  67 +++---
 include/hw/s390x/s390-ccw.h        |  39 ++++
 include/hw/s390x/s390-virtio-ccw.h |   1 +
 include/hw/vfio/vfio-common.h      |   1 +
 linux-headers/linux/vfio.h         |  17 ++
 linux-headers/linux/vfio_ccw.h     |  28 +++
 qemu-options.hx                    |   6 +-
 scripts/update-linux-headers.sh    |   2 +-
 target/s390x/cpu.h                 |  10 +
 target/s390x/ioinst.c              |   9 +
 22 files changed, 1065 insertions(+), 50 deletions(-)
 create mode 100644 hw/s390x/s390-ccw.c
 create mode 100644 hw/vfio/ccw.c
 create mode 100644 include/hw/s390x/s390-ccw.h
 create mode 100644 linux-headers/linux/vfio_ccw.h

-- 
2.11.2


Re: [Qemu-devel] [PATCH v8 00/13] basic channel IO passthrough infrastructure based on vfio
Posted by Cornelia Huck 6 years, 11 months ago
On Wed, 17 May 2017 02:48:00 +0200
Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:

> The patch series introduce a basic channel I/O passthrough
> infrastructure based on vfio.
> - Focus on supporting dasd-eckd(cu_type/dev_type = 0x3990/0x3390) as
>   the target device. 
> - Support new qemu parameters in the style of:
>     -machine s390-ccw-virtio(,s390-squash-mcss=on|off) \
>     -device vfio-ccw,sysfsdev=$MDEV_PATH
>   We want to support real (i.e. not virtual) channel devices even for
>   guests that do not support MCSS-E (where guests may see devices from
>   any channel subsystem image at once). As all virtio-ccw devices are in
>   css 0xfe (and show up in the default css 0 for guests not activating
>   MCSS-E), we need an option to squash e.g. passed-through channel devices
>   from their real css (0-3, or 0 for hosts not activating MCSS-E) into
>   the default css, that is what the new machine option s390-squash-css is
>   added.

Patches queued, with minor changes (see my comments).

I'll push out to s390-next once this passes some of my tests.

> 
> Build and install:
> 1. kernel configuration
>   CONFIG_S390_CCW_IOMMU=m
>   CONFIG_VFIO=m
>   CONFIG_VFIO_MDEV=m
>   CONFIG_VFIO_MDEV_DEVICE=m
>   CONFIG_VFIO_CCW=m
> 2. modules required
>   modprobe vfio.ko
>   modprobe mdev.ko
>   modprobe vfio_mdev.ko
>   modprobe vfio_iommu_type1.ko
>   modprobe vfio_ccw.ko
> 3. find a subchannel(0.0."%schid") of a DASD-ECKD device and bind it to
>   vfio_ccw driver
>   #find the dasd you can use with lsdasd on your host. e.g.:
>   devno="7e52"
>   schid="16ca"
>   #unbind the ccw device from the subchannel
>   echo 0.0."$devno" > /sys/bus/ccw/devices/0.0."$devno"/driver/unbind
>   #unbind the subchannel from io_subchannel driver
>   echo 0.0."$schid" > /sys/bus/css/devices/0.0."$schid"/driver/unbind
>   #bind the subchannel with vfio_ccw driver
>   echo 0.0."$schid" > /sys/bus/css/drivers/vfio_ccw/bind
> 4. create a mediated device
>   #generate a uuid with uuidgen. e.g.:
>   uuid="6dfd3ec5-e8b3-4e18-a6fe-57bc9eceb920"
>   echo "$uuid" > \
>   /sys/bus/css/devices/0.0."$schid"/mdev_supported_types/vfio_ccw-io/create
> 5. pass-through this device to a vm
>   -M s390-ccw-virtio,s390-squash-css=on \
>   -device vfio-ccw,sysfsdev=/sys/bus/mdev/devices/$uuid \
>   ... ...

These instructions would be helpful to preserve in the qemu wiki and
could even be expanded upon. Ping me if you need an account (hint,
hint ;)


Re: [Qemu-devel] [PATCH v8 00/13] basic channel IO passthrough infrastructure based on vfio
Posted by Dong Jia Shi 6 years, 11 months ago
* Cornelia Huck <cornelia.huck@de.ibm.com> [2017-05-18 15:13:56 +0200]:

Hi Conny,

> On Wed, 17 May 2017 02:48:00 +0200
> Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:
> 
> > The patch series introduce a basic channel I/O passthrough
> > infrastructure based on vfio.
> > - Focus on supporting dasd-eckd(cu_type/dev_type = 0x3990/0x3390) as
> >   the target device. 
> > - Support new qemu parameters in the style of:
> >     -machine s390-ccw-virtio(,s390-squash-mcss=on|off) \
> >     -device vfio-ccw,sysfsdev=$MDEV_PATH
> >   We want to support real (i.e. not virtual) channel devices even for
> >   guests that do not support MCSS-E (where guests may see devices from
> >   any channel subsystem image at once). As all virtio-ccw devices are in
> >   css 0xfe (and show up in the default css 0 for guests not activating
> >   MCSS-E), we need an option to squash e.g. passed-through channel devices
> >   from their real css (0-3, or 0 for hosts not activating MCSS-E) into
> >   the default css, that is what the new machine option s390-squash-css is
> >   added.
> 
> Patches queued, with minor changes (see my comments).
> 
> I'll push out to s390-next once this passes some of my tests.
> 
:-D

> > 
> > Build and install:
> > 1. kernel configuration
> >   CONFIG_S390_CCW_IOMMU=m
> >   CONFIG_VFIO=m
> >   CONFIG_VFIO_MDEV=m
> >   CONFIG_VFIO_MDEV_DEVICE=m
> >   CONFIG_VFIO_CCW=m
> > 2. modules required
> >   modprobe vfio.ko
> >   modprobe mdev.ko
> >   modprobe vfio_mdev.ko
> >   modprobe vfio_iommu_type1.ko
> >   modprobe vfio_ccw.ko
> > 3. find a subchannel(0.0."%schid") of a DASD-ECKD device and bind it to
> >   vfio_ccw driver
> >   #find the dasd you can use with lsdasd on your host. e.g.:
> >   devno="7e52"
> >   schid="16ca"
> >   #unbind the ccw device from the subchannel
> >   echo 0.0."$devno" > /sys/bus/ccw/devices/0.0."$devno"/driver/unbind
> >   #unbind the subchannel from io_subchannel driver
> >   echo 0.0."$schid" > /sys/bus/css/devices/0.0."$schid"/driver/unbind
> >   #bind the subchannel with vfio_ccw driver
> >   echo 0.0."$schid" > /sys/bus/css/drivers/vfio_ccw/bind
> > 4. create a mediated device
> >   #generate a uuid with uuidgen. e.g.:
> >   uuid="6dfd3ec5-e8b3-4e18-a6fe-57bc9eceb920"
> >   echo "$uuid" > \
> >   /sys/bus/css/devices/0.0."$schid"/mdev_supported_types/vfio_ccw-io/create
> > 5. pass-through this device to a vm
> >   -M s390-ccw-virtio,s390-squash-css=on \
> >   -device vfio-ccw,sysfsdev=/sys/bus/mdev/devices/$uuid \
> >   ... ...
> 
> These instructions would be helpful to preserve in the qemu wiki and
> could even be expanded upon.
Nod.

> Ping me if you need an account (hint, hint ;)
(uh...)
Dear Frau, could you please kindly get me an account? Then I can try to
add a new page for vfio-ccw in the qemu wiki. ;)

I will ping you when you online.

Thanks!

-- 
Dong Jia Shi