Skip to content

pci: Detect masked BAR size probes#183

Draft
Coffeeri wants to merge 1 commit into
cyberus-technology:gardenlinuxfrom
Coffeeri:backport/pci-bar-size-probe-fix
Draft

pci: Detect masked BAR size probes#183
Coffeeri wants to merge 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.

@Coffeeri
Coffeeri force-pushed the backport/pci-bar-size-probe-fix branch from aebe8cb to 0f4e234 Compare July 17, 2026 07:33
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 0f4e234 to 7f99f90 Compare July 17, 2026 09: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