Re: Bug#1131025: [6.12.y regression] Regression with 58130e7ce6cb ("PCI/ERR: Ensure error recoverability at all times"): echo vfio-pci >driver_override does not work for DVB Adapter

Lukas Wunner
2026-04-13T03:40:39Z

On Sun, Apr 12, 2026 at 08:04:02PM +0200, Alexandre N. wrote:
> Independent confirmation on different hardware and a different
> stable branch, plus test results for the proposed fix on 6.19.11.
>
> Hardware: PCI 1b4b:9215 Marvell 88SE9215 PCIe 2.0 x1 4-port
> SATA 6 Gb/s controller, whole-device passthrough to a
> Windows 10 guest via QEMU/libvirt on
> an AMD Ryzen 7 7700 8-Core x86_64 host (Arch Linux).
> Last good: linux 6.18.9
> First bad: linux 6.18.13 (contains stable backport 71c50e60421b
> of upstream a2f1e22390ac, "PCI/ERR:
> Ensure error recoverability at all
> times", first backported in 6.18.10)
> Also bad: linux 6.19.11 (mainline carries a2f1e22390ac)
>
> Confirmed by rolling linux back to 6.18.9 with everything else
> untouched: problem vanishes. Rolling forward to 6.18.13 or any
> later versions in 6.18/6.19 reproduces it everytime.

Hm, that's unexpected. I cooked up the patch below on Saturday
but didn't immediately get around to sending it because of a
security bug report that came in later that day.

Could both of you, Alexandre and Bernd, give that patch a spin
to see if it fixes the issue? I believe the patch should at least
fix things for Bernd. If it doesn't fix things for you Alexandre,
I'll have to dig deeper.

Thanks!

Lukas

-- >8 --

Subject: [PATCH] PCI: Update saved_config_space upon resource assignment

Bernd reports passthrough failure of a Digital Devices Cine S2 V6 DVB
adapter plugged into an ASRock X570S PG Riptide board with BIOS version
P5.41 (09/07/2023):

ddbridge 0000:07:00.0: detected Digital Devices Cine S2 V6 DVB adapter
ddbridge 0000:07:00.0: cannot read registers
ddbridge 0000:07:00.0: fail

The BIOS assigns an incorrect BAR to the DVB adapter which has the upper
32 bits set to "all ones". This doesn't fit into the upstream bridge
window, which has those bits set to "all zeroes". The kernel therefore
corrects the BAR assignment:

pci 0000:07:00.0: BAR 0 [mem 0xfffffffffc500000-0xfffffffffc50ffff 64bit]: can't claim; no compatible bridge window
pci 0000:07:00.0: BAR 0 [mem 0xfc500000-0xfc50ffff 64bit]: assigned

Correction of the BAR assignment happens in an x86-specific fs_initcall,
pcibios_assign_resources(), after PCI devices have been enumerated in a
subsys_initcall. This order was introduced at the behest of Linus in
2004:

https://git.kernel.org/tglx/history/c/a06a30144bbc

No other architecture performs such a late BAR correction.

Bernd bisected the issue to commit a2f1e22390ac ("PCI/ERR: Ensure error
recoverability at all times"), but it only occurs in the absence of commit
4d4c10f763d7 ("PCI: Explicitly put devices into D0 when initializing").
This combination exists in stable kernel v6.12.70, but not in mainline,
hence mainline does not exhibit the issue.

Since commit a2f1e22390ac, config space is saved on enumeration (in a
subsys_initcall), i.e. prior to the BAR correction. Upon passthrough,
the corrected BAR is overwritten with the incorrect saved value by:

vfio_pci_core_register_device()
vfio_pci_set_power_state()
pci_restore_state()

But only if the device's current_state is PCI_UNKNOWN, as it was prior to
commit 4d4c10f763d7. Since the commit it is PCI_D0, which changes the
behavior of vfio_pci_set_power_state() to no longer restore the state
without saving it first.

Although the issue could be fixed in v6.12-stable by backporting
4d4c10f763d7 or by changing vfio_pci_set_power_state(), a more robust fix
is to update saved_config_space upon resource assignment.

Reported-by: Bernd Schumacher <bernd@bschu.de>
Closes: https://lore.kernel.org/r/acfZrlP0Ua_5D3U4@eldamar.lan/
Fixes: a2f1e22390ac ("PCI/ERR: Ensure error recoverability at all times")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v6.12+
---
drivers/pci/setup-res.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index e5fcadfc58b0..1769ba960197 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -102,6 +102,7 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
}

pci_write_config_dword(dev, reg, new);
+ dev->saved_config_space[reg / 4] = new;
pci_read_config_dword(dev, reg, &check);

if ((new ^ check) & mask) {
@@ -112,6 +113,7 @@ static void pci_std_update_resource(struct pci_dev *dev, int resno)
if (res->flags & IORESOURCE_MEM_64) {
new = region.start >> 16 >> 16;
pci_write_config_dword(dev, reg + 4, new);
+ dev->saved_config_space[(reg + 4) / 4] = new;
pci_read_config_dword(dev, reg + 4, &check);
if (check != new) {
pci_err(dev, "%s: error updating (high %#010x != %#010x)\n",
--
2.51.0