]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
PCI: Fix Resizable BAR restore order
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 21 Jan 2026 13:14:17 +0000 (15:14 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 22 Jan 2026 16:29:55 +0000 (10:29 -0600)
commit5528fd38f230c906fcebb202cc94fbb8ed8f122a
treec1b278e82a77d1eb7a17b0521ac7ac5a2049f76e
parent08d9eae76b85263173f8c833800e3cc409ee1be4
PCI: Fix Resizable BAR restore order

The commit 337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback
path") changed BAR resize to layer rebar code and resource setup/restore
code cleanly. Unfortunately, it did not consider how the value of the BAR
Size field impacts the read-only bits in the Base Address Register (PCIe7
spec, sec. 7.8.6.3). That is, it very much matters in which order the BAR
Size and Base Address Register are restored.

Post-337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path")
during BAR resize rollback, pci_do_resource_release_and_resize() attempts
to restore the old address to the BAR that was resized, but it can fail to
setup the address correctly if the address has low bits set that collide
with the bits that are still read-only. As a result, kernel's resource and
BAR will be out-of-sync.

Fix this by restoring BAR Size before rolling back the resource changes and
restoring the BAR.

Fixes: 337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path")
Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/linux-pci/aW_w1oFQCzUxGYtu@intel.com/
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260121131417.9582-3-ilpo.jarvinen@linux.intel.com
drivers/pci/rebar.c
drivers/pci/setup-bus.c