Setting up VFIO pass-through DASDs

6.10 LPAR mode KVM guest

Free DASDs from host control and assign them to VFIO mediated devices.

Before you begin

You must know the subchannel bus ID that maps to the DASD. You can find this information with the lscss command.

Example: In this example, a DASD with bus ID 0.0.3000 has a subchannel with bus ID 0.0.0004.
# lscss -d 0.0.3000
Device   Subchan. DevType CU Type Use PIM PAM POM CHPIDs
-------------------------------------------------------------------
0.0.3000 0.0.0004 3390/0A 3990/E9 YES C0  C0  FF  34400000 00000000

Procedure

  1. Ensure that the vfio_ccw device driver and the vfio_mdev modules are loaded. If either module is compiled as a separate module, you might have to load it yourself.
    # modprobe vfio_ccw
    # modprobe vfio_mdev
  2. Free the DASD and its subchannel from the default device drivers on the host and assign the subchannel to the vfio_ccw device driver.
    Using the driverctl command
    The preferred method for this reassignment is issuing a driverctl command of this form:
    # driverctl --bus css set-override <subchannel_bus_id> vfio_ccw

    By default, these configuration changes persist across reboots of the KVM host. To apply changes only to the active configuration, specify the --nosave option with the command.

    Tip: Use the following command to confirm that the reassignment is persistent:
    # driverctl --bus css list-persisted
    Example: The command in this example frees a DASD that corresponds to subchannel ID 0.0.0004 from the dasd-eckd device driver and persistently reassigns the subchannel to the vfio_ccw device driver.
    # driverctl --bus css set-override 0.0.0004 vfio_ccw
    # driverctl --bus css list-persisted
    0.0.0004 vfio_ccw
    Using general Linux® commands
    As a non-persistent fallback method, you can use general Linux commands.

    Write the bus ID of the DASD to the unbind attribute of its device driver module. Then, write the bus ID of the subchannel to the unbind attribute of the subchannel device driver. Finally, assign subchannel to the vfio_ccw device driver by writing the subchannel bus-ID to /sys/bus/css/drivers/vfio_ccw/bind.

    # echo <device_bus_id> > /sys/bus/ccw/drivers/dasd-eckd/unbind
    # echo <subchannel_bus_id> > /sys/bus/css/devices/<subchannel_bus_id>/driver/unbind
    # echo <subchannel_bus_id> > /sys/bus/css/drivers/vfio_ccw/bind
    Example: The first commands in this example frees a DASD with bus ID 0.0.3000 from the dasd-eckd device driver. The commands that follow reassign the subchannel to the vfio_ccw device driver.
    # echo 0.0.3000 > /sys/bus/ccw/drivers/dasd-eckd/unbind
    # echo 0.0.0004 > /sys/bus/css/devices/0.0.0004/driver/unbind
    # echo 0.0.0004 > /sys/bus/css/drivers/vfio_ccw/bind
  3. Create a new VFIO CCW mediated device. You can use libvirt or general Linux commands to create the device.
    Using libvirt
    The preferred method is using libvirt. With libvirt, you can create persistent or transient mediated devices. See KVM Virtual Server Management, SC34-2752.
    Using general Linux commands
    Mediated devices that you create with the commands that follow do not persist across reboots.

    Writing a universally unique identifier (UUID) to /sys/bus/css/devices/<subchannel_bus_id>/mdev_supported_types/vfio_ccw-io/create, where <subchannel_bus_id> is the subchannel of the DASD.

    Tip: Use the uuidgen command to generate a UUID.
    Example: This example creates a CCW mediated device for subchannel 0.0.0004.
    # uuidgen
    18e124fb-b2fc-47f6-a407-f256b6c49767
    # echo 18e124fb-b2fc-47f6-a407-f256b6c49767 > \
    /sys/bus/css/devices/0.0.0004/mdev_supported_types/vfio_ccw-io/create
  4. Optional: Display subchannel information for the mediated device, by issuing lscss with the --vfio option.
    Example:
    # lscss --vfio
    MDEV                                  Subchan.  PIM PAM POM   CHPIDs
    ------------------------------------------------------------------------------
    18e124fb-b2fc-47f6-a407-f256b6c49767  0.0.0004  c0  c0  ff 0  5020000 00000000