vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest3 patches 2 repliesIn review
- v44 patches 4 repliesSuperseded
- v37 patches 14 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 7 patches | 8 replies | Superseded | |
| v1 | 6 patches | 8 replies | Superseded |
Changes in v5 from the cover letter
* Keep the current ID and checksum patching logic in vfio_pci_load_rom() since it is not IGD-specific, as pointed out by Alex. The IGD-specific quirk is now invoked after the generic patching. The ID and checksum patching is duplicated in vfio_igd_legacy_rom_quirk() to handle the romfile path, since the generic patching is not invoked on romfile.
* Picked up the Michael's Acked-by on patch 1.
* Reduced from 4 to 3 patches.
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | hw/pci: Introduce romfile_fixup hook in PCIDevicehw/ include/ | +5 | 0 replies | |
| 2/3 | vfio/igd: Patch device ID for romfile-provided VBIOShw/ hw/ hw/ +1 more | +61 | 0 replies | |
| 3/3 | vfio/igd: Clear saved BDSM in legacy VBIOS ROM at load timehw/ hw/ hw/ +1 more | +84 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Michael S. Tsirkin | K S Maan |
|---|---|---|
| Series | T-b | |
| 1/3 | A-b | |
| 2/3 | ||
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/3] vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS
This series fixes the regression that on IGD passthrough with legacy BIOS boot and VBIOS, the screen is garbled during BIOS POST and GRUB (which uses standard VGA output routines), starting from QEMU 10.0. Though the kernel i915 driver still works, it reports an error about the initial GTT programmed by VBIOS is using invalid address.
i915 0000:00:02.0: [drm] *ERROR* Initial plane programming using invalid range, dma_addr=0x00000000db200000 ((null) [0x00000000baf00000-0x00000000beefffff])
With the help of AI disassembling the VBIOS image dumped from host, it is found that the VBIOS itself implements a routine like:
uint32_t get_BDSM() {
static uint32_t saved = 0;
if (saved != 0) {
return saved;
}
return read_pci_config(BDSM_REG);
}And the saved value is not cleared after initialization. Given that IGD devices don't have a real ROM BAR, the VBIOS image read by default from host is actually the VBIOS shadow RAM region, containing host-side modifications like the saved BDSM value above during POST. When the image is executed in guest, it still uses the saved host BDSM (HPA) instead of the value programmed by SeaBIOS in config space (GPA). This address mismatch leads to the garbled screen and i915 error.
The previous solution, c4c45e943e51 ("vfio/pci: Intel graphics legacy mode assignment"), adjusts GTT entry addresses to (addr - host BDSM + guest BDSM) to workaround that. But it is removed in 5aed8b0f0be2 ("vfio/igd: Remove GTT write quirk in IO BAR 4") due to inconsistent values in MMIO BAR0 and IO BAR4. Considering it's unsafe to expose HPA to guest, a ROM quirk clearing the saved value in VBIOS image is introduced to fix the issue.
During debugging, it is also found that IGD VBIOS ROM doesn't always match the actual IGD device ID, due to the fact that IGD of the same CPU family has multiple device IDs but shares the same ROM image. However, SeaBIOS checks the device ID strictly and refuses to run if IDs does not match. Currently only the default path, reading ROM from kernel patches the device ID, but the romfile path doesn't. So the ROM ID patching logic is also refactored in this patch series to also handle the romfile path.
These changes are tested on Haswell platform with legacy BIOS boot, by K S Maan. Thanks to K S Maan for continuous help on locating and testing the issue!
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3093
Changelog:
v5:
* Keep the current ID and checksum patching logic in vfio_pci_load_rom() since it is not IGD-specific, as pointed out by Alex. The IGD-specific quirk is now invoked after the generic patching. The ID and checksum patching is duplicated in vfio_igd_legacy_rom_quirk() to handle the romfile path, since the generic patching is not invoked on romfile.
* Picked up the Michael's Acked-by on patch 1.
* Reduced from 4 to 3 patches.
v4:
* Reworked per review feedback to keep IGD-specific workarounds out of the generic PCI code. Instead of recalculating the checksum in hw/pci/pci.c, a single generic romfile_fixup hook is added for device- specific ROM patching. Now both kernel ROM BAR and romfile paths share the same quirk, so the saved BDSM in user-provided romfile will also get cleared.
* Reduced from 7 to 4 patches.
v3:
* Refactor ROM checksum calculation and patching logic as Alex's comment
* Fix boundary checks as comments in v2.
v2:
* New patch 2/7 to fix regression with EFI option ROMs
* Refine logic in ROM ID and checksum patching
* Reorder patch 4 and 5 for cleaner bisection
* Address comments from v1
Tomita Moeko (3):
hw/pci: Introduce romfile_fixup hook in PCIDevice vfio/igd: Patch device ID for romfile-provided VBIOS vfio/igd: Clear saved BDSM in legacy VBIOS ROM at load time
hw/pci/pci.c | 4 ++ hw/vfio/igd-stubs.c | 5 ++ hw/vfio/igd.c | 129 ++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 5 ++ hw/vfio/pci.c | 2 + hw/vfio/pci.h | 3 + hw/vfio/trace-events | 1 + include/hw/pci/pci_device.h | 1 + 8 files changed, 150 insertions(+)
Signature · 1 line
2.53.0