Today, ISM devices are completely disallowed for vfio-pci passthrough as QEMU rejects the device due to an (inappropriate) MSI-X check. Removing this fence, however, reveals additional deficiencies in the s390x PCI interception layer that prevent ISM devices from working correctly. Namely, ISM block write operations have particular requirements in regards to the alignment, size and order of writes performed that cannot be guaranteed when breaking up write operations through the typical vfio_pci_bar_rw paths. Furthermore, ISM requires that legacy/non-MIO s390 PCI instructions are used, which is also not guaranteed when the I/O is passed through the typical userspace channels.
This patchset provides a set of fixes related to enabling ISM device passthrough and includes patches to enable use of a new vfio region that will allow s390x PCI pass-through devices to perform s390 PCI instructions in such a way that the same instruction issued on the guest is re-issued on the host. Associated kernel patchset: https://lkml.org/lkml/2021/1/19/874 Changes from RFC -> v1: - Refresh the header sync (built using Eric's 'update-linux-headers: Include const.h' + manually removed pvrdma_ring.h again) - Remove s390x/pci: fix pcistb length (already merged) - Remove s390x/pci: Fix memory_region_access_valid call (already merged) - Fix bug: s390_pci_vfio_pcistb should use the pre-allocated PCISTB buffer pcistb_buf rather than allocating/freeing its own. - New patch: track the PFT (PCI Function Type) separately from guest CLP response data -- we tell the guest '0' for now due to limitations in measurement block support, but we can still use the real value provided via the vfio CLP capabilities to make decisions. - Use the PFT (pci function type) to determine when to use the region for PCISTB/PCILG (only for ISM), rather than using the relaxed alignment bit. - As a result, the pcistb_default is now updated to also handle the possibility of relaxed alignment via 2 new functions, pcistb_validate_write and pcistb_write, which serve as wrappers to the memory_region calls. - New patch, which partially restores the MSI-X fence for passthrough devices... Could potentially be squashed with 's390x/pci: MSI-X isn't strictly required for passthrough' but left separately for now as I felt it needed a clear commit description of why we should still fence this case. Matthew Rosato (8): linux-headers: update against 5.11-rc4 s390x/pci: Keep track of the PCI Function type s390x/pci: MSI-X isn't strictly required for passthrough s390x/pci: Introduce the ZpciOps structure s390x/pci: Handle devices that support relaxed alignment s390x/pci: PCISTB via the vfio zPCI I/O region s390x/pci: PCILG via the vfio zPCI I/O region s390x/pci: Prevent ISM device passthrough on older host kernels hw/s390x/s390-pci-bus.c | 45 ++- hw/s390x/s390-pci-inst.c | 389 +++++++++++++++------ hw/s390x/s390-pci-vfio.c | 152 ++++++++ include/hw/s390x/s390-pci-bus.h | 29 ++ include/hw/s390x/s390-pci-clp.h | 1 + include/hw/s390x/s390-pci-inst.h | 3 + include/hw/s390x/s390-pci-vfio.h | 23 ++ .../infiniband/hw/vmw_pvrdma/pvrdma_verbs.h | 2 +- include/standard-headers/drm/drm_fourcc.h | 175 ++++++++- include/standard-headers/linux/ethtool.h | 2 +- include/standard-headers/linux/fuse.h | 30 +- include/standard-headers/linux/kernel.h | 9 +- include/standard-headers/linux/pci_regs.h | 16 + include/standard-headers/linux/vhost_types.h | 9 + include/standard-headers/linux/virtio_gpu.h | 82 +++++ include/standard-headers/linux/virtio_ids.h | 44 ++- linux-headers/asm-arm64/kvm.h | 3 - linux-headers/asm-generic/unistd.h | 6 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 58 ++- linux-headers/linux/userfaultfd.h | 9 + linux-headers/linux/vfio.h | 5 + linux-headers/linux/vfio_zdev.h | 34 ++ linux-headers/linux/vhost.h | 4 + 34 files changed, 996 insertions(+), 145 deletions(-) -- 1.8.3.1