Skip to content

pci: Detect masked BAR size probes#183

Merged
Coffeeri merged 1 commit into
cyberus-technology:gardenlinuxfrom
Coffeeri:backport/pci-bar-size-probe-fix
Jul 20, 2026
Merged

pci: Detect masked BAR size probes#183
Coffeeri merged 1 commit into
cyberus-technology:gardenlinuxfrom
Coffeeri:backport/pci-bar-size-probe-fix

Conversation

@Coffeeri

@Coffeeri Coffeeri commented Jul 16, 2026

Copy link
Copy Markdown

Backporting cloud-hypervisor#8598 (https://github.com/cobaltcore-dev/cobaltcore/issues/632), as it just landed upstream and is therefore not included in v53 nor in the later rebase on top of it.

This change fixes a problem when the guest OS probes the pci bar size and was until now incompatible with OpenBSD.

Pipeline

@Coffeeri
Coffeeri marked this pull request as draft July 17, 2026 06:53
@Coffeeri

Coffeeri commented Jul 17, 2026

Copy link
Copy Markdown
Author

Setting it to draft as upstreams CI failed the windows integration tests.

Currently investigating and running our pipeline, including unused - fixed.

Fixed and merged upstream.

@Coffeeri
Coffeeri force-pushed the backport/pci-bar-size-probe-fix branch 2 times, most recently from 0f4e234 to 7f99f90 Compare July 17, 2026 09:11
A PCI BAR stores its address in the upper bits and type information in
the lower bits. To determine the BAR size, an operating system disables
memory decoding, writes ones to the BAR's address bits, and reads the
value back. Bits that remain zero reveal the required alignment and
therefore the size.

We currently recognize only 0xffffffff as a size probe. OpenBSD instead
writes the memory BAR address mask 0xfffffff0, without setting the lower
four non-address bits [0][1].

We misinterpret that probe as a real BAR relocation. Because OpenBSD has
disabled memory space, the relocation remains pending. We apply it when
OpenBSD enables memory space again, moving the virtio block BAR away
from its mapped address and preventing the guest from booting.

Recognize probes using the address mask for each BAR type and exclude
them from BAR reprogramming. Add a test for the OpenBSD memory BAR
probe.

[0]: https://github.com/openbsd/src/blob/54a2bc1e5457a3dc555cb0cc642641a62266c778/sys/dev/pci/pci_map.c#L154-L180
[1]: https://github.com/openbsd/src/blob/54a2bc1e5457a3dc555cb0cc642641a62266c778/sys/dev/pci/pcireg.h#L429-L443

Co-authored-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
On-behalf-of: SAP leander.kohler@sap.com
Signed-off-by: Leander Kohler <leander.kohler@cyberus-technology.de>
@Coffeeri
Coffeeri force-pushed the backport/pci-bar-size-probe-fix branch from 7f99f90 to 4462972 Compare July 20, 2026 07:40
@Coffeeri
Coffeeri marked this pull request as ready for review July 20, 2026 07:41

@amphi amphi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work!

@olivereanderson olivereanderson left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the fix!

@Coffeeri
Coffeeri merged commit 3e60ea9 into cyberus-technology:gardenlinux Jul 20, 2026
19 checks passed
@Coffeeri
Coffeeri deleted the backport/pci-bar-size-probe-fix branch July 20, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants