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

David Matlack posted 21 patches 2 months, 1 week ago
[PATCH 03/21] PCI: Require driver_override for incoming Live Update preserved devices
Posted by David Matlack 2 months, 1 week 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
Re: [PATCH 03/21] PCI: Require driver_override for incoming Live Update preserved devices
Posted by David Matlack 2 months, 1 week ago
On 2025-11-26 07:35 PM, David Matlack wrote:
> 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>

After some offline discussion with Jason and Pasha, I will drop this
patch from the next version to avoid hard-coding a policy in the kernel.

Instead, for the time being, it will be the user's responsibility to
only preserve devices that do not have any built-in drivers that will
bind to the device during boot following a Live Update.
Re: [PATCH 03/21] PCI: Require driver_override for incoming Live Update preserved devices
Posted by Chris Li 2 months, 1 week ago
On Wed, Dec 3, 2025 at 1:16 AM David Matlack <dmatlack@google.com> wrote:
>
> On 2025-11-26 07:35 PM, David Matlack wrote:
> > 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>
>
> After some offline discussion with Jason and Pasha, I will drop this
> patch from the next version to avoid hard-coding a policy in the kernel.
>
> Instead, for the time being, it will be the user's responsibility to
> only preserve devices that do not have any built-in drivers that will
> bind to the device during boot following a Live Update.

Ack, that certainly can simplify the PCI kernel side of the code, the
kernel doesn't need to deal with PCI driver binding.

Chris