Repository navigation
[amd64-v6.18.55-generic] vfio/pci: Expose setup ROM only for display devices - #337
Conversation
Since e021e6c ("vfio/pci: Expose setup ROM at ROM bar when needed") vfio-pci exposes the firmware-provided ROM copy (pdev->rom) at the ROM BAR of any device without a ROM BAR resource. Platform UEFI also hands over legacy PXE ROMs for onboard NICs that have no ROM BAR of their own, e.g. Intel's Boot Agent GE for the I210 on a Supermicro X10SDV. That image is shared across Intel GbE parts and its PCIR names 8086:1521. QEMU's vfio ROM loader rewrites a mismatched device ID to the device's own (1533) and stores the checksum correction in ROM byte 6, which in this ROM is the far return ending its init entry. A SeaBIOS guest given the NIC then crashes in the ROM's init with a KVM internal error. QEMU 9.1 through current master do this, so limit the fallback to display-class devices. Signed-off-by: eriknordmark <erik@zededa.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VyjigXVFZhuUg5LiRSVwsj
|
Tested this PR's head (97d2463, core flavor) in an EVE-k build on the Supermicro X10SDV (onboard I210 assigned to a SeaBIOS guest): |
|
I don't see in any place that the original change was written for VGA cards only. The problem of this approach is that you can be killing other device passthrough use cases that were possible due to the original change. Isn't any "quircks based" solution for this particular SuperMicro device? |
rene
left a comment
There was a problem hiding this comment.
I don't think this is the right fix. The root cause looks like it's in QEMU, and this patch changes upstream kernel behaviour for every non-display device.
e021e6c is not display-specific. Its commit message says: "If ROM bar is missing for any reason, we can fallback to using pdev->rom … This fixes some passthrough use cases where the upstream bridge does not have enough address window." The firmware side is generic too: setup_efi_pci() in drivers/firmware/efi/libstub/x86-stub.c collects the option ROM of every PCI device that has one, whatever its class. Limiting the fallback to PCI_BASE_CLASS_DISPLAY would silently drop ROM exposure for HBAs, RAID controllers, NVMe and other boot devices whose ROM BAR couldn't be assigned. That's exactly the case the upstream commit covers.
The corruption comes from QEMU. In hw/vfio/pci.c, vfio_pci_load_rom() rewrites the PCIR device ID when the vendor matches but the device doesn't, then puts the checksum fix in header byte 6:
pci_set_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 6, vdev->device_id);
data[6] = 0;
...
data[6] = -csum;The comment there says this exists for Intel IGD. Byte 6 is free in an IGD VBIOS, but in a generic option ROM bytes 3–6 are the init entry point. Here byte 6 is the lret. The kernel only exposes the ROM. A display device whose ROM has a mismatched PCIR DID and code at byte 6 would crash the same way with this patch applied. A per-device quirk (for example for this Supermicro/I210 combination) wouldn't be the right fix either, because the trigger is any ROM with a mismatched DID.
Suggested alternatives:
- QEMU: limit the DID rewrite/checksum fixup to IGD/VGA, or skip it when the PCIR 3.0 device list already contains the device ID. It's worth reporting upstream either way.
- pillar: emit
rombar = "0"inqemuPCIPassthruTemplate(pkg/pillar/hypervisor/kvm.go) for non-display passthrough devices (or only for SeaBIOS guests). That restores the pre-6.14 behaviour for NICs with no kernel divergence. - If we really want a kernel-side workaround, it should be opt-in (for example a vfio-pci module parameter) and say clearly that it works around the QEMU bug. It shouldn't be a new class restriction on an upstream feature.
Review drafted with Claude Code on behalf of @rene.
rene
left a comment
There was a problem hiding this comment.
@eriknordmark , let's try to fix this issue on QEMU....
@rene I tried that and it is more complicated because there are two copies of QEMU at play. The one in EVE-OS can be fixed (see lf-edge/eve@3d94de9) but the problem is the one which is included in virt-launcher for kubevirt. Fixing that one means upstreaming a fix somehow and then getting a virt-launcher update to pick it up, or build our own copy of virt-launcher with a qemu patch. The last part is hard since we either need to include it in the image (+200MB in EVE-k bypassing the 512MB build size limit check), or a separate forked OCI registry for virt-launcher. lf-edge/eve#7184 has a TEST-ONLY example of that where it pulls from my docker hub repo. |
Since v6.14 (e021e6c), vfio-pci exposes the platform firmware's copy of a device's option ROM at the ROM BAR of any device that has none. On a Supermicro X10SDV that hands the guest Intel's Boot Agent ROM for the onboard I210. QEMU's vfio ROM loader rewrites the ROM's mismatched PCIR device ID (1521 → 1533) and puts the checksum correction in byte 6, which in this ROM is the
lretending its init entry. A SeaBIOS guest given the NIC then crashes with a KVM internal error (EIP 0x98000). QEMU 9.1 through current master do this, so a QEMU upgrade does not avoid it.This limits the setup-ROM fallback to display-class devices, the case e021e6c was written for.
Tested on sc-sm-e300-10 (EVE-k, 6.18.55):
test_app_assigned_ethfails on the stock kernel and passes with this patch. Bare QEMU withromfile=reproduces the crash from the fixed-up image alone. Details in #334.Fixes #334
🤖 Generated with Claude Code
https://claude.ai/code/session_01VyjigXVFZhuUg5LiRSVwsj