pci: Save deferred BAR reprogramming state - #7945
Merged
rbradford merged 1 commit intoApr 1, 2026
Merged
Conversation
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]>
Contributor
Author
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
approved these changes
Apr 1, 2026
rbradford
left a comment
Member
There was a problem hiding this comment.
Urgh, yeh - snapshot/restore or migration early in the boot is definitely gnarly. Thanks for looking into that!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR serializes and restores
pending_bar_reprogramso 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_reprogramuntil 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, and0x100080000. After restore, cloud-hypervisor logs repeated guest MMIO accesses to those same addresses as unregistered, for example:The firmware continues into Boot Device Selection, still detects the mass-storage device, but can no longer boot from it:
We have implemented this fix in our fork at cyberus-technology#135.