[RFC PATCH v1 0/5] s390x/pci: Improved zPCI Function Measurement Support

Omar Elghoul posted 5 patches 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260501200026.22784-1-oelghoul@linux.ibm.com
Maintainers: Matthew Rosato <mjrosato@linux.ibm.com>, Farhan Ali <alifm@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
hw/s390x/s390-pci-bus.c          |  17 +++-
hw/s390x/s390-pci-inst.c         |  65 ++++++++++++++-
hw/s390x/s390-pci-vfio-stubs.c   |  16 ++++
hw/s390x/s390-pci-vfio.c         | 133 ++++++++++++++++++++++++++-----
hw/virtio/virtio.c               |  16 ++++
include/hw/pci/pci_device.h      |   4 +
include/hw/s390x/s390-pci-bus.h  |  29 ++++++-
include/hw/s390x/s390-pci-vfio.h |   4 +
include/hw/virtio/virtio.h       |   1 +
linux-headers/linux/vfio.h       |  43 ++++++++++
10 files changed, 301 insertions(+), 27 deletions(-)
[RFC PATCH v1 0/5] s390x/pci: Improved zPCI Function Measurement Support
Posted by Omar Elghoul 4 weeks ago
Hi,

This patch series improves support for function measurement on s390x for
zPCI passthrough devices. It is dependent on the eponymous kernel patch
series linked below. [1]

Motivation
==========
The firmware on s390x machines allows for tracking a variety of statistics
relating to zPCI devices in a function measurement block (FMB). At the time
of writing, the kernel does not provide QEMU with a structured mechanism to
fetch the FMB of passthrough devices. QEMU also does not report the PFT to
the guest, which can cause issues with tools such as smc-rnics that depend
on the PFT to detect ISM and RoCE devices. Furthermore, the FMB itself can
take on different formats depending on the PFT, while QEMU's implementation
is limited to only the generic section that prefixes the format-specific
structures.

Proposal
========
The aforementioned kernel series proposes a VFIO feature that allows QEMU
to read the latest snapshot of the FMB. In this patch series, we propose
using that mechanism to share the FMB with the guest, as seen from the
host. We also inform the guest of the PFT and the FMB length as detected
from the host's CLP. Furthermore, we implement the format-0 FMB (DMA
counters) for virtio-pci devices.

I'd appreciate any comments on this approach.

Thanks in advance.

[1] https://lore.kernel.org/all/20260501192530.9429-1-oelghoul@linux.ibm.com/

Omar Elghoul (5):
  [do-not-merge] linux-headers: Add definitions for VFIO zPCI FMB
    passthrough
  hw/s390x: Clarified FMB format for emulated and passthrough devices
  hw/virtio: Add DMA counters for virtio-pci devices
  hw/s390x: Internal support for FMB passthrough
  hw/s390x: Report FMB passthrough and/or FMB DMA counters to the guest

 hw/s390x/s390-pci-bus.c          |  17 +++-
 hw/s390x/s390-pci-inst.c         |  65 ++++++++++++++-
 hw/s390x/s390-pci-vfio-stubs.c   |  16 ++++
 hw/s390x/s390-pci-vfio.c         | 133 ++++++++++++++++++++++++++-----
 hw/virtio/virtio.c               |  16 ++++
 include/hw/pci/pci_device.h      |   4 +
 include/hw/s390x/s390-pci-bus.h  |  29 ++++++-
 include/hw/s390x/s390-pci-vfio.h |   4 +
 include/hw/virtio/virtio.h       |   1 +
 linux-headers/linux/vfio.h       |  43 ++++++++++
 10 files changed, 301 insertions(+), 27 deletions(-)

-- 
2.52.0
Re: [RFC PATCH v1 0/5] s390x/pci: Improved zPCI Function Measurement Support
Posted by Christian Borntraeger 3 weeks, 4 days ago
Am 01.05.26 um 22:00 schrieb Omar Elghoul:
> Hi,
> 
> This patch series improves support for function measurement on s390x for
> zPCI passthrough devices. It is dependent on the eponymous kernel patch
> series linked below. [1]
> 
> Motivation
> ==========
> The firmware on s390x machines allows for tracking a variety of statistics
> relating to zPCI devices in a function measurement block (FMB). At the time
> of writing, the kernel does not provide QEMU with a structured mechanism to
> fetch the FMB of passthrough devices. QEMU also does not report the PFT to
> the guest, which can cause issues with tools such as smc-rnics that depend
> on the PFT to detect ISM and RoCE devices. Furthermore, the FMB itself can
> take on different formats depending on the PFT, while QEMU's implementation
> is limited to only the generic section that prefixes the format-specific
> structures.
> 
> Proposal
> ========
> The aforementioned kernel series proposes a VFIO feature that allows QEMU
> to read the latest snapshot of the FMB. In this patch series, we propose
> using that mechanism to share the FMB with the guest, as seen from the
> host. We also inform the guest of the PFT and the FMB length as detected
> from the host's CLP. Furthermore, we implement the format-0 FMB (DMA
> counters) for virtio-pci devices.
> 
> I'd appreciate any comments on this approach.
> 
> Thanks in advance.
> 
> [1] https://lore.kernel.org/all/20260501192530.9429-1-oelghoul@linux.ibm.com/

CCing Niklas and Gerd for their Linux zpci expertise.

> 
> Omar Elghoul (5):
>    [do-not-merge] linux-headers: Add definitions for VFIO zPCI FMB
>      passthrough
>    hw/s390x: Clarified FMB format for emulated and passthrough devices
>    hw/virtio: Add DMA counters for virtio-pci devices
>    hw/s390x: Internal support for FMB passthrough
>    hw/s390x: Report FMB passthrough and/or FMB DMA counters to the guest
> 
>   hw/s390x/s390-pci-bus.c          |  17 +++-
>   hw/s390x/s390-pci-inst.c         |  65 ++++++++++++++-
>   hw/s390x/s390-pci-vfio-stubs.c   |  16 ++++
>   hw/s390x/s390-pci-vfio.c         | 133 ++++++++++++++++++++++++++-----
>   hw/virtio/virtio.c               |  16 ++++
>   include/hw/pci/pci_device.h      |   4 +
>   include/hw/s390x/s390-pci-bus.h  |  29 ++++++-
>   include/hw/s390x/s390-pci-vfio.h |   4 +
>   include/hw/virtio/virtio.h       |   1 +
>   linux-headers/linux/vfio.h       |  43 ++++++++++
>   10 files changed, 301 insertions(+), 27 deletions(-)
>