Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pci: Save deferred BAR reprogramming state - #7945

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
Coffeeri:upstream/pending-bar-reprogram
Apr 1, 2026
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
Coffeeri:upstream/pending-bar-reprogram

Conversation

@Coffeeri

@Coffeeri Coffeeri commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

This PR serializes and restores pending_bar_reprogram so pending BAR updates survive snapshot and restore.

OVMF can reprogram PCI BARs while memory space decoding is disabled. Cloud Hypervisor defers the corresponding BAR move in pending_bar_reprogram until memory space is enabled again via the PCI command register.

That deferred state is not part of PciConfigurationState. If a snapshot is taken in that window, the restored guest sees the updated BAR values in PCI config space, but the VMM-side BAR mapping is still stale.

We observed this during early boot while snapshotting mid-firmware (EDK2). In the firmware debug log, OVMF assigns BARs at 0xc0000000, 0x100000000, and 0x100080000. After restore, cloud-hypervisor logs repeated guest MMIO accesses to those same addresses as unregistered, for example:

Guest MMIO write to unregistered address 0x100080014
Guest MMIO write to unregistered address 0x100080000
Guest MMIO read to unregistered address 0x100080004
Guest MMIO write to unregistered address 0x100000000
Guest MMIO read to unregistered address 0x100000004
...

The firmware continues into Boot Device Selection, still detects the mass-storage device, but can no longer boot from it:

PciHostBridge driver failed to set EFI_MEMORY_UC to MMIO aperture - Out of Resources.
...
Found Mass Storage device: PciRoot(0x0)/Pci(0x3,0x0)
...
[Bds] Unable to boot!
BdsDxe: No bootable option or device was found.

We have implemented this fix in our fork at cyberus-technology#135.

OVMF can reprogram PCI BARs while memory space decoding is disabled.
Cloud Hypervisor defers the corresponding BAR move in
`pending_bar_reprogram` until the PCI command register enables Memory
Space again.

That deferred state was not part of `PciConfigurationState`. A
snapshot taken in that window restored the new BAR values in PCI
config space, but lost the pending BAR relocation needed to update the
VMM-side BAR mapping.

The restore logs show guest MMIO accesses to the reprogrammed BAR
addresses `0xc0000000`, `0x100000000`, and `0x100080000` hitting
unregistered addresses. The firmware serial output shows OVMF
assigning those same BAR addresses during PCI resource allocation,
then reaching BDS, finding the mass-storage device, and failing to
boot from it.

Serialize and restore `pending_bar_reprogram` so deferred BAR moves
survive snapshot and restore.

Co-authored-by: Thomas Prescher <[email protected]>
Co-authored-by: Julian Schindel <[email protected]>
On-behalf-of: SAP [email protected]
Signed-off-by: Leander Kohler <[email protected]>
@Coffeeri
Coffeeri requested a review from a team as a code owner April 1, 2026 09:15

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was an awesome debugging session - well done guys!!

For the record: We think there are three bugs that we encounter during early state save/resume. #7944, this one, and the last one is being chased right now!

@Coffeeri

Coffeeri commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

For the record: We think there are three bugs that we encounter during early state save/resume. #7944, this one, and the last one is being chased right now!

We expect there might be more bugs during early boot (mid-firmware) snapshotting. We will continue debugging and upstream the fixes as they are discovered.

@rbradford rbradford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Urgh, yeh - snapshot/restore or migration early in the boot is definitely gnarly. Thanks for looking into that!

@rbradford
rbradford enabled auto-merge April 1, 2026 09:33
@rbradford
rbradford added this pull request to the merge queue Apr 1, 2026
Merged via the queue into cloud-hypervisor:main with commit db93c6f Apr 1, 2026
38 checks passed
@Coffeeri
Coffeeri deleted the upstream/pending-bar-reprogram branch April 7, 2026 06:38
@likebreath likebreath added the bug-fix Bug fix to include in release notes label Apr 7, 2026
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Bug fix to include in release notes

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants