From: sashiko-bot@kernel.org
To: "Farhan Ali" <alifm@linux.ibm.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v16 4/7] s390/pci: Store PCI error information for passthrough devices
Date: Thu, 14 May 2026 22:53:45 +0000 [thread overview]
Message-ID: <20260514225345.BA866C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260514180059.1553-5-alifm@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unlocking an unheld mutex causes kernel panic.
- [High] Passthrough devices incorrectly fall back to host-level recovery if the error queue is full.
--
commit 016a2e8c9545102f4de3d94db360fafe625fa60b
Author: Farhan Ali <alifm@linux.ibm.com>
s390/pci: Store PCI error information for passthrough devices
This commit introduces a mechanism to store PCI error information for
passthrough devices on s390x so userspace can handle recovery. It removes
the dependency on struct kvm_zdev to detect passthrough devices and
introduces pending error tracking.
diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
index 839bd91c056e5..ad273decb1c2b 100644
--- a/arch/s390/pci/pci_event.c
+++ b/arch/s390/pci/pci_event.c
[ ... ]
> +static int zpci_store_pci_error(struct pci_dev *pdev,
> + struct zpci_ccdf_err *ccdf)
> +{
> + struct zpci_dev *zdev = to_zpci(pdev);
> + int i;
> +
> + guard(mutex)(&zdev->pending_errs_lock);
> + if (!zdev->pending_errs.mediated_recovery)
> + return -EINVAL;
> +
> + if (zdev->pending_errs.count >= ZPCI_ERR_PENDING_MAX) {
> + pr_err("%s: Maximum number (%d) of pending error events queued\n",
> + pci_name(pdev), ZPCI_ERR_PENDING_MAX);
> + return -ENOMEM;
> + }
[ ... ]
> @@ -216,12 +223,23 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)
> goto out_unlock;
> }
>
> + mediated_recovery = zpci_store_pci_error(pdev, ccdf) == 0 ? true : false;
If zpci_store_pci_error() returns an error, such as -ENOMEM when the pending
error queue reaches ZPCI_ERR_PENDING_MAX, mediated_recovery evaluates to false.
Will this cause the function to bypass the passthrough early exit and fall
through to the host-level error recovery mechanisms below?
It appears this could result in a host-initiated reset on a device actively
passed through to userspace, which might break passthrough isolation.
> +
> ers_res = zpci_event_notify_error_detected(pdev, driver);
> if (ers_result_indicates_abort(ers_res)) {
> status_str = "failed (abort on detection)";
> goto out_unlock;
> }
>
> + if (mediated_recovery) {
> + pr_info("%s: Leaving recovery of pass-through device to user-space\n",
> + pci_name(pdev));
> + ers_res = PCI_ERS_RESULT_RECOVERED;
> + status_str = "in progress";
> + mutex_unlock(&zdev->pending_errs_lock);
Does this unlock a mutex that is not currently held?
The zdev->pending_errs_lock is acquired and automatically released within
the scope of the zpci_store_pci_error() helper function using the
guard(mutex) macro.
Attempting to unlock an already-unlocked mutex usually results in a kernel
panic or lockdep warning.
> + goto out_unlock;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260514180059.1553-1-alifm@linux.ibm.com?part=4
next prev parent reply other threads:[~2026-05-14 22:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 18:00 [PATCH v16 0/7] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-05-14 18:00 ` [PATCH v16 1/7] PCI: Allow per function PCI slots to fix slot reset on s390 Farhan Ali
2026-05-14 21:36 ` sashiko-bot
2026-05-14 18:00 ` [PATCH v16 2/7] PCI: Avoid saving config space state if inaccessible Farhan Ali
2026-05-14 22:08 ` sashiko-bot
2026-05-14 18:00 ` [PATCH v16 3/7] PCI: Fail FLR when config space is inaccessible Farhan Ali
2026-05-14 22:41 ` sashiko-bot
2026-05-14 18:00 ` [PATCH v16 4/7] s390/pci: Store PCI error information for passthrough devices Farhan Ali
2026-05-14 22:53 ` sashiko-bot [this message]
2026-05-14 18:00 ` [PATCH v16 5/7] vfio-pci/zdev: Add a device feature for error information Farhan Ali
2026-05-14 23:27 ` sashiko-bot
2026-05-14 18:00 ` [PATCH v16 6/7] vfio/pci: Add a reset_done callback for vfio-pci driver Farhan Ali
2026-05-14 23:54 ` sashiko-bot
2026-05-14 18:00 ` [PATCH v16 7/7] vfio/pci: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Farhan Ali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260514225345.BA866C2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alifm@linux.ibm.com \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.