From: Tomita Moeko <tomitamoeko@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex@shazbot.org>,
"Cédric Le Goater" <clg@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Tomita Moeko" <tomitamoeko@gmail.com>,
"K S Maan" <kirandeepmaan45@gmail.com>
Subject: [PATCH v3 6/7] vfio/pci: Use pci_rom_patch_ids() for IGD ROM ID patching
Date: Wed, 17 Jun 2026 18:06:43 +0800 [thread overview]
Message-ID: <20260617100646.28326-7-tomitamoeko@gmail.com> (raw)
In-Reply-To: <20260617100646.28326-1-tomitamoeko@gmail.com>
Remove the duplicate inline logic in vfio_pci_load_rom() that patched
the device ID in an IGD option ROM and replace it with a call to
pci_rom_patch_ids(), conditioned on the rom_need_patch_id flag.
Reported-by: K S Maan <kirandeepmaan45@gmail.com>
Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
---
hw/vfio/pci.c | 31 +++----------------------------
1 file changed, 3 insertions(+), 28 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 9c06b25e63..6cbd65126e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1029,6 +1029,7 @@ static void vfio_update_msi(VFIOPCIDevice *vdev)
static void vfio_pci_load_rom(VFIOPCIDevice *vdev)
{
+ PCIDevice *pdev = PCI_DEVICE(vdev);
VFIODevice *vbasedev = &vdev->vbasedev;
struct vfio_region_info *reg_info = NULL;
uint64_t size;
@@ -1084,34 +1085,8 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev)
}
}
- /*
- * Test the ROM signature against our device, if the vendor is correct
- * but the device ID doesn't match, store the correct device ID and
- * recompute the checksum. Intel IGD devices need this and are known
- * to have bogus checksums so we can't simply adjust the checksum.
- */
- if (pci_get_word(vdev->rom) == 0xaa55 &&
- pci_get_word(vdev->rom + 0x18) + 8 < vdev->rom_size &&
- !memcmp(vdev->rom + pci_get_word(vdev->rom + 0x18), "PCIR", 4)) {
- uint16_t vid, did;
-
- vid = pci_get_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 4);
- did = pci_get_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 6);
-
- if (vid == vdev->vendor_id && did != vdev->device_id) {
- int i;
- uint8_t csum, *data = vdev->rom;
-
- pci_set_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 6,
- vdev->device_id);
- data[6] = 0;
-
- for (csum = 0, i = 0; i < vdev->rom_size; i++) {
- csum += data[i];
- }
-
- data[6] = -csum;
- }
+ if (pdev->rom_need_patch_id) {
+ pci_rom_patch_ids(pdev, vdev->rom, vdev->rom_size);
}
}
--
2.53.0
next prev parent reply other threads:[~2026-06-17 10:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 10:06 [PATCH v3 0/7] vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS Tomita Moeko
2026-06-17 10:06 ` [PATCH v3 1/7] hw/pci: Recalculate option ROM checksum before patching ID Tomita Moeko
2026-06-26 10:23 ` Michael S. Tsirkin
2026-06-17 10:06 ` [PATCH v3 2/7] hw/pci: Skip EFI option ROM in pci_patch_ids() Tomita Moeko
2026-06-26 10:29 ` Michael S. Tsirkin
2026-06-17 10:06 ` [PATCH v3 3/7] hw/pci: Introduce rom_need_patch_id flag in PCIDevice Tomita Moeko
2026-06-26 10:30 ` Michael S. Tsirkin
2026-06-17 10:06 ` [PATCH v3 4/7] hw/pci: Promote pci_patch_ids() to public pci_rom_patch_ids() Tomita Moeko
2026-06-26 10:30 ` Michael S. Tsirkin
2026-06-17 10:06 ` [PATCH v3 5/7] vfio/igd: Toggle rom_need_patch_id flag on IGD devices Tomita Moeko
2026-06-17 10:06 ` Tomita Moeko [this message]
2026-06-17 10:06 ` [PATCH v3 7/7] vfio/igd: Clear saved BDSM in legacy VBIOS ROM at load time Tomita Moeko
2026-06-18 6:42 ` [PATCH v3 0/7] vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS Cédric Le Goater
2026-06-18 7:02 ` K S Maan
2026-06-18 8:34 ` Cédric Le Goater
2026-06-18 10:21 ` K S Maan
2026-06-18 10:36 ` Cédric Le Goater
2026-06-18 10:40 ` Cédric Le Goater
2026-06-23 21:32 ` Alex Williamson
2026-06-24 6:28 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260617100646.28326-7-tomitamoeko@gmail.com \
--to=tomitamoeko@gmail.com \
--cc=alex@shazbot.org \
--cc=clg@redhat.com \
--cc=kirandeepmaan45@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.