[PATCH v2 0/3] vfio-pci/zdev: Improved zPCI Function Measurement Support

Omar Elghoul posted 3 patches 5 days, 1 hour ago
arch/s390/include/asm/pci.h      |  1 +
arch/s390/pci/pci.c              | 75 ++++++++++++++++++++++++-------
arch/s390/pci/pci_debug.c        | 11 ++++-
drivers/vfio/pci/vfio_pci_core.c |  2 +
drivers/vfio/pci/vfio_pci_priv.h |  9 ++++
drivers/vfio/pci/vfio_pci_zdev.c | 77 ++++++++++++++++++++++++++++++++
include/uapi/linux/vfio.h        | 43 ++++++++++++++++++
7 files changed, 202 insertions(+), 16 deletions(-)
[PATCH v2 0/3] vfio-pci/zdev: Improved zPCI Function Measurement Support
Posted by Omar Elghoul 5 days, 1 hour ago
Hi,

This patch series improves support for function measurement for zPCI
passthrough devices on s390x.

Changelog
=========
v1 -> v2:
* Patch 1/3:
  - Address a possible race condition in zpci_reenable_device() caused by
    calling zpci_fmb_reenable_device() without holding fmb_lock
  - Assert that fmb_lock is held within zpci_fmb_reenable_device()

* Patch 3/3:
  - Address a possible race condition in pci_perf_seq_write() caused by
    consuming zdev->kzdev without holding kzdev_lock

Motivation
==========
The firmware on s390x machines allows for tracking a variety of statistics
relating to zPCI devices in a function measurement block (FMB). However,
the kernel currently lacks a structured mechanism of sharing this
information with userspace, beyond /sys/kernel/debug/pci/ID/statistics.
This can lead to shortcomings when running a guest on KVM with PCI
passthrough devices, as QEMU is unable to provide an accurate FMB snapshot
to the guest.

Proposal
========
We propose adding a new VFIO device feature to zPCI passthrough devices,
allowing userspace programs to read the latest FMB snapshot as it is
written by the firmware. We ensure that function measurement enablement is
preserved across device resets on the host. Furthermore, we guard against
host tampering with the FMB via sysfs when the zPCI device is in
passthrough to protect the VM's state.

I'd appreciate some feedback on these patches.

Thanks in advance.

Omar Elghoul (3):
  s390/pci: Preserve FMB state in device re-enablement
  vfio-pci/zdev: Add VFIO FMB device feature
  s390/pci: Fence FMB enable/disable via sysfs for passthrough devices

 arch/s390/include/asm/pci.h      |  1 +
 arch/s390/pci/pci.c              | 75 ++++++++++++++++++++++++-------
 arch/s390/pci/pci_debug.c        | 11 ++++-
 drivers/vfio/pci/vfio_pci_core.c |  2 +
 drivers/vfio/pci/vfio_pci_priv.h |  9 ++++
 drivers/vfio/pci/vfio_pci_zdev.c | 77 ++++++++++++++++++++++++++++++++
 include/uapi/linux/vfio.h        | 43 ++++++++++++++++++
 7 files changed, 202 insertions(+), 16 deletions(-)

-- 
2.52.0