vfio/pci: read ROM via ACPI _ROM when hardware ROM is unreadable
Some GPUs (e.g. NVIDIA Quadro P2000 Mobile in a laptop) have a ROM
BAR that exists but is unreadable because the GPU was never POSTed
by the system BIOS. On these systems the VBIOS is available via the
ACPI _ROM method provided by the platform firmware.
Add an ACPI _ROM fallback in the VFIO PCI ROM region handler, tried
after both pci_map_rom() and the boot loader ROM stash (pdev->rom)
fail. The image size is probed once, in 4K chunks capped at 16 MiB,
and cached in the device; the region info ioctl, the config space
ROM BAR emulation and the read path all report the same rounded-up
size. Reads are served from _ROM directly, without caching the
image: requests stay page-aligned since some firmware only supports
aligned requests, and reads past the image return 0xff, like the
unused space of a ROM BAR.
The ACPI spec defines _ROM for display devices and prefers it over
the BAR image when present; it is only used as a last resort here so
that the BAR path keeps precedence.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
5 files changed