[RFC PATCH v2 16/16] vfio/pci: Enable host PCI error recovery for vfio-pci

From: Shameer Kolothum

Date: Tue Sep 29 2026 - 13:40:40 EST


Enable recovery support for generic vfio-pci. Userspace opts in through
VFIO_DEVICE_FEATURE_PCI_ERROR_RECOVERY. Open rejects an active host
recovery even without opt-in. Leave variant drivers disabled until their
access paths are covered.

Exclude CXL memory devices and s390: Restricted CXL Host (RCH) and s390
mediated recovery can omit completion callbacks. On s390, permanent-failure
notification also blocks config access, so draining SRCU can deadlock
with config readers.

Assisted-by: LLM
Signed-off-by: Shameer Kolothum <skolothumtho@xxxxxxxxxx>
---
drivers/vfio/pci/vfio_pci.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 4887dd062c77..043371c2882c 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -129,6 +129,7 @@ static int vfio_pci_init_dev(struct vfio_device *core_vdev)
{
struct vfio_pci_core_device *vdev =
container_of(core_vdev, struct vfio_pci_core_device, vdev);
+ struct pci_dev *pdev = to_pci_dev(core_vdev->dev);

/*
* These behaviors originated in vfio-pci and moved into
@@ -139,6 +140,14 @@ static int vfio_pci_init_dev(struct vfio_device *core_vdev)
*/
vdev->nointxmask = nointxmask;
vdev->disable_idle_d3 = disable_idle_d3;
+ /*
+ * CXL RCH and s390 mediated recovery can omit completion callbacks.
+ * s390 also blocks config access across failure notification, which
+ * prevents draining SRCU readers waiting for config access.
+ */
+ if (!IS_ENABLED(CONFIG_S390) &&
+ (pdev->class >> 8) != PCI_CLASS_MEMORY_CXL)
+ vdev->pci_recovery_supported = true;
#ifdef CONFIG_VFIO_PCI_VGA
vdev->disable_vga = disable_vga;
#endif
--
2.43.0