[PATCH 03/21] PCI: Require driver_override for incoming Live Update preserved devices

David Matlack posted 21 patches 5 days, 3 hours ago
[PATCH 03/21] PCI: Require driver_override for incoming Live Update preserved devices
Posted by David Matlack 5 days, 3 hours ago
Require driver_override to be set to bind an incoming Live Update
preserved device to a driver. Auto-probing could lead to the device
being bound to a different driver than what was bound to the device
prior to Live Update.

Delegate binding preserved devices to the right driver to userspace by
requiring driver_override to be set on the device.

This restriction is relaxed once a driver calls
pci_liveupdate_incoming_finish().

Signed-off-by: David Matlack <dmatlack@google.com>
---
 drivers/pci/pci-driver.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 302d61783f6c..294ce92331a8 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -420,18 +420,26 @@ static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
 }
 
 #ifdef CONFIG_PCI_IOV
-static inline bool pci_device_can_probe(struct pci_dev *pdev)
+static inline bool pci_iov_device_can_probe(struct pci_dev *pdev)
 {
 	return (!pdev->is_virtfn || pdev->physfn->sriov->drivers_autoprobe ||
 		pdev->driver_override);
 }
 #else
-static inline bool pci_device_can_probe(struct pci_dev *pdev)
+static inline bool pci_iov_device_can_probe(struct pci_dev *pdev)
 {
 	return true;
 }
 #endif
 
+static inline bool pci_device_can_probe(struct pci_dev *pdev)
+{
+	if (pci_liveupdate_incoming_is_preserved(pdev))
+		return pdev->driver_override;
+
+	return pci_iov_device_can_probe(pdev);
+}
+
 static int pci_device_probe(struct device *dev)
 {
 	int error;
-- 
2.52.0.487.g5c8c507ade-goog