Re: [PATCH v6 3/4] s390/pci: Fence FMB enable/disable via debugfs for passthrough devices
From: Matthew Rosato
Date: Wed Sep 16 2026 - 22:27:46 EST
On 9/16/26 5:32 PM, Omar Elghoul wrote:
> Introduce a fence over enabling or disabling FMB via debugfs when the zPCI
> device is associated with a KVM. This will prevent processes on the host
> from tampering with the FMB while the guest is still using it, which may
> cause partial counter resets and inconsistent reads which have no parallel
> in the architecture.
>
> For VFIO devices that are not associated with a KVM (i.e., for userspace
> drivers other than QEMU), this fence does not take effect.
>
> Signed-off-by: Omar Elghoul <oelghoul@xxxxxxxxxxxxx>
Reviewed-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxx>
> ---
> arch/s390/pci/pci_debug.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
> index 44f026ead414..afc52bd5271a 100644
> --- a/arch/s390/pci/pci_debug.c
> +++ b/arch/s390/pci/pci_debug.c
> @@ -153,6 +153,12 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
> if (rc)
> return rc;
>
> + mutex_lock(&zdev->kzdev_lock);
> + if (zdev->kzdev) {
> + rc = -EPERM;
> + goto out_unlock_kzdev;
> + }
> +
> mutex_lock(&zdev->fmb_lock);
> switch (val) {
> case 0:
> @@ -163,6 +169,9 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
> break;
> }
> mutex_unlock(&zdev->fmb_lock);
> +
> +out_unlock_kzdev:
> + mutex_unlock(&zdev->kzdev_lock);
> return rc ? rc : count;
> }
>