[PATCH v17 14/19] PCI/CXL: Reject reset with unsafe function scope
From: Srirangan Madhavan
Date: Thu Nov 05 2026 - 14:08:11 EST
The per-device PCI reset interface must not reset sibling functions.
Reject cxl_reset and cxl_bus for VFs, multifunction devices, and PFs with
enabled VFs.
Suggested-by: Alex Williamson <alwilliamson@xxxxxxxxxx>
Link: https://lore.kernel.org/linux-cxl/20260626160846.426e71b6@xxxxxxxxxx/
Link: https://lore.kernel.org/linux-cxl/6a50441e2bb5e_3cabcb1003e@djbw-dev.notmuch/
Signed-off-by: Srirangan Madhavan <smadhavan@xxxxxxxxxx>
Acked-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Reviewed-by: Richard Cheng <icheng@xxxxxxxxxx>
---
Changes in v17:
- Move the function-scope checks ahead of the CXL DVSEC lookups, so a VF
returns -ENOTTY without config reads during reset-method probing
(Joshua)
https://lore.kernel.org/linux-cxl/20261105143611.31563-1-machaujo@xxxxxxxxx/
---
drivers/pci/cxl.c | 3 +++
drivers/pci/pci.c | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/drivers/pci/cxl.c b/drivers/pci/cxl.c
index af8ec8db20f1..c07266ab0133 100644
--- a/drivers/pci/cxl.c
+++ b/drivers/pci/cxl.c
@@ -501,6 +501,9 @@ int cxl_reset_function(struct pci_dev *pdev, bool probe)
u16 dvsec, cap, ctrl;
int rc;
+ if (pdev->is_virtfn || pdev->multifunction || pci_num_vf(pdev))
+ return -ENOTTY;
+
rc = cxl_pci_device_dvsec(pdev, &dvsec, &cap);
if (rc)
return rc;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b2879a6be5f8..aef976d0c850 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5018,6 +5018,13 @@ static int cxl_reset_bus_function(struct pci_dev *dev, bool probe)
u16 dvsec, reg, val;
int rc;
+ /*
+ * Reject VFs and multifunction devices before walking the bridge's
+ * capabilities: every VF behind the same bridge would repeat the walk.
+ */
+ if (dev->is_virtfn || dev->multifunction || pci_num_vf(dev))
+ return -ENOTTY;
+
bridge = pci_upstream_bridge(dev);
if (!bridge)
return -ENOTTY;
--
2.43.0