All of lore.kernel.org
 help / color / mirror / Atom feed
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 v4 1/4] hw/pci: Introduce romfile_fixup hook in PCIDevice
Date: Thu,  2 Jul 2026 02:20:32 +0800	[thread overview]
Message-ID: <20260701182035.96010-2-tomitamoeko@gmail.com> (raw)
In-Reply-To: <20260701182035.96010-1-tomitamoeko@gmail.com>

Some devices, such as VFIO IGD passthrough, require device-specific
fixups on the romfile provided by user. Add an optional romfile_fixup
hook to PCIDevice. When set, it is invoked from pci_add_option_rom()
right after the image is loaded, receiving the ROM buffer and its
size. This provides a place to post-process a loaded romfile without
leaking device-specific logic into the generic PCI core.

Reported-by: K S Maan <kirandeepmaan45@gmail.com>
Signed-off-by: Tomita Moeko <tomitamoeko@gmail.com>
---
 hw/pci/pci.c                | 4 ++++
 include/hw/pci/pci_device.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 4298adf5a0..7d30d44411 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2632,6 +2632,10 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
             /* Only the default rom images will be patched (if needed). */
             pci_patch_ids(pdev, ptr, size);
         }
+
+        if (pdev->romfile_fixup) {
+            pdev->romfile_fixup(pdev, ptr, size);
+        }
     }
 
     pci_register_bar(pdev, PCI_ROM_SLOT, 0, &pdev->rom);
diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
index 5cac6e1688..a65e77018c 100644
--- a/include/hw/pci/pci_device.h
+++ b/include/hw/pci/pci_device.h
@@ -159,6 +159,7 @@ struct PCIDevice {
     bool has_rom;
     MemoryRegion rom;
     int32_t rom_bar;
+    void (*romfile_fixup)(PCIDevice *pdev, uint8_t *ptr, uint32_t size);
 
     /* INTx routing notifier */
     PCIINTxRoutingNotifier intx_routing_notifier;
-- 
2.53.0



  reply	other threads:[~2026-07-01 18:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 18:20 [PATCH v4 0/4] vfio/igd: Fix garbled screen on IGD passthrough with legacy VBIOS Tomita Moeko
2026-07-01 18:20 ` Tomita Moeko [this message]
2026-07-01 20:58   ` [PATCH v4 1/4] hw/pci: Introduce romfile_fixup hook in PCIDevice Michael S. Tsirkin
2026-07-01 18:20 ` [PATCH v4 2/4] vfio/igd: Refactor option ROM patching Tomita Moeko
2026-07-01 18:20 ` [PATCH v4 3/4] vfio/igd: Setup romfile_fixup hook Tomita Moeko
2026-07-01 18:20 ` [PATCH v4 4/4] vfio/igd: Clear saved BDSM in legacy VBIOS ROM at load time Tomita Moeko

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=20260701182035.96010-2-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.