mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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]:54a2bc1e54/sys/dev/pci/pci_map.c (L154-L180)[1]:54a2bc1e54/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>