Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1E59C55174 for ; Thu, 6 Aug 2026 01:05:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1384043.1627165 (Exim 4.92) (envelope-from ) id 1wrmY6-0005aQ-3G; Thu, 06 Aug 2026 01:05:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1384043.1627165; Thu, 06 Aug 2026 01:05:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrmY6-0005aH-0C; Thu, 06 Aug 2026 01:05:30 +0000 Received: by outflank-mailman (input) for mailman id 1384043; Thu, 06 Aug 2026 01:05:28 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrmY4-0005Nq-MO for xen-devel@lists.xenproject.org; Thu, 06 Aug 2026 01:05:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrmY4-00GWgj-3E for xen-devel@lists.xenproject.org; Thu, 06 Aug 2026 03:05:28 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a73dda4-2eae-0a2a0a5409dd-0a2a45059c28-46 for ; Thu, 06 Aug 2026 03:05:28 +0200 Received: from [66.163.186.146] (helo=sonic302-20.consmr.mail.ne1.yahoo.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a73ddd6-4cb1-0a2a45050019-42a3ba928c39-3 for ; Thu, 06 Aug 2026 03:05:27 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ne1.yahoo.com with HTTP; Thu, 6 Aug 2026 01:05:26 +0000 Received: by hermes--production-bf1-54b5569bdc-xjdx5 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 734f0c8329adecc00a98ec91cc943adb; Thu, 06 Aug 2026 01:05:20 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=a2048 header.d=aol.com header.i="@aol.com" header.h="From:To:Cc:Subject:Date:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1785978326; bh=WVED5z9X3DhNfWYWPsssganxjMal/mDmQeJ0RW0UVpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=ZocemVWyPNNRVCWp7tcTVgsj+okAl85RtnTc32+vJJ5sadpkFdJjGYhONhinL4v0zs+y+IwypGr20hAbhYz82xNsU+5MJVf7NWpB5o2LFRUZfsHpCu93egs1ixYs3kNRLbF6W/XJpFIgY5RMP4y+r0XOiixz1/MzjFYhn8+ovaC8s6o/6KDB8NIgdig7PcGQ7FRHRzp06DRAljcH2flA8PplF1h9GAGo0Hn5AtcDov9pSdGA82sL0FvnWrXVL1/13gYiNN04kw3IL9UmqxeHQIiAoOVwU/yRrGiyfxnGxxDxyaw4P7K7SVDzEJXVLtM8g7aPR0p627Fzr11HxMQZCg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1785978326; bh=7iBAhNNuxjWjoR7/fE95Vs5pQIIIvyJSx7pSZDa7+RG=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=RNdXb/80spp6ENsUBxZI+42NUmGBdhNVnseX9RZtU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dnGaMjqPWMGLJCuFnWvcK84UFfdJOJT89pALzbqDdU3bM6h_znBgU JXN0M6drr7GLt.aHUL7sCuD1snJEkznEzqEwFOUTmzYGzigQ9sizb6J3vuvCcyeQwETN9oMCw3J8 3sZb.j4j0Lhe63EN.L8FqFTdJtbMYm7EFH1Rq4kev0eC_vDQzQptA_72ml7g_gLXkF4FVVC0aYdR 73ulu5L7rRI.cn.q32eadpWxNvEi2VcMu7Q1d7mkEzn1q6b1rTob_1u52jDUxNmi8uoF.O5gG82h eQGgOQSK06ah8lTI6xYjO_2wE0uFrLinYUth33L8ND6Ey.Jx_lEtT7dEaBfPnXmpsEZBuoQU0FMW gpnwNHzWh1jiQaldlp5KQ6oRpSxjwYRqnlIzF.TZXQhXmOsIkECPQWnght4nZB2H1HMhJeeGrpcy 60bgAaiL64O0UuyZHGa8cfiYNBIOkhahnYCGd X-Sonic-MF: X-Sonic-ID: 1c24a953-a693-4bad-a4c9-6097629114f1 From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, xen-devel@lists.xenproject.org, Stefano Stabellini , Anthony PERARD , "Edgar E . Iglesias" , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie , Tomita Moeko Subject: [PATCH v5 6/6] xen/igd: use custom option ROM if provided Date: Wed, 5 Aug 2026 21:04:56 -0400 Message-ID: <20260806010506.492490-7-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260806010506.492490-1-brchuckz@aol.com> References: <20260806010506.492490-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-c201ff/1785978328-F4AA72A1-E2944F08/0/0 X-purgate-type: clean X-purgate-size: 9089 Since in some cases the option ROM is not readable from sysfs on the host, provide the option to use a custom option ROM file instead that, for example, could be extracted from BIOS or UEFI firmware and modified as needed for use with a particular Intel IGD device. The file must be named "igd.rom" and be located in a directory configured at build time as a Qemu firmware directory and its size should be a power of two, and it must be compatible with the particular Intel IGD device being passed through. If provided, the "igd.rom" file will be used as the option ROM instead of the option ROM file epxosed in the host sysfs. If no "igd.rom" file is provided, this patch has no effect. Signed-off-by: Chuck Zmudzinski --- Changes in v4: - v4 is the first version of the series that has this patch Changes in v5: - Fix wrong whitespace in three places in a conditional block Sorry for the length of these notes but there are many things to say about this patch that are not obvious to persons without some experience of actually trying to use the option ROM of an Intel IGD when it is passed through to a Xen HVM guest. This patch is primarily for providing a way to add Intel IGD support for the OvmfXen platform to get graphics output during early boot from modern Intel IGD devices that are only compatible with UEFI for graphics output during early boot. Note this patch is not necessary for successful operation of the Intel IGD in the guest once the guest OS drivers have loaded. It is only needed as part of the patchset necessary to provide graphics output from the Intel IGD in the guest during early boot when using newer devices that are only compatible with UEFI for graphics output during early boot. Most older devices that are compatible with legacy VGA BIOS will work with Seabios without this patch, but they will need Patch 3 of this patchset to work with Seabios. Some notes on adding Intel IGD support for the OvmfXen platform: It is necessary to provide an EFI graphics output protocol (GOP) driver to the guest to get output from the Intel IGD before the guest OS loads the graphics drivers when the guest uses UEFI. This GOP driver is essentially the replacement of the VBIOS driver that applied to older devices that use legacy bios, as described here: https://www.intel.com/content/www/us/en/support/articles/000005749/graphics.html Unfortunately, with modern Intel IGD devices, the EFI GOP driver is not provided to the guest in the usual way of providing firmware for a PCI device in the option ROM of the real PCI device. So I included this patch in this patchset to provide a way to expose the EFI GOP driver to the guest. I was able to extract the GOP driver for my device using the UEFI bios update file from the motherboard manufacturer and the UEFITool available here: https://github.com/longsoft/uefitool That EFI driver can be wrapped into an option ROM using the EfiRom bin wrapper that is part of the edk2 project: https://github.com/tianocore/edk2/blob/master/BaseTools/BinWrappers/PosixLike/EfiRom I tried setting the 'romfile' member of the PCIDevice struct that is used by KVM/VFIO Qemu devices and emulated Qemu PCI devices, but that did not work with Xen PCI passthrough devices. Neither Seabios nor the OvmfXen platform could detect the option ROM in the guest with that method of exposing an option ROM to the guest. So I implemented this approach of substituting the 'rom' file exposed by sysfs with an administrator-provided file instead of using 'romfile'. In the commit message I mentioned the size of the rom file "should" be a power of two. I mentioned this because the code in pci.c that handles the 'romfile' setting for PCI devices enforces this requirement strictly on the romfile that Qemu emulated or VFIO devices use. However, I do not know for sure whether or not the rom file is strictly required to have a size of a power of two, so that is why I say it should be a power of two. In my testing, I zero pad the "igd.rom" file so it has a size of a power of two. I will accept the suggestions of experts on this question about the appropriate size of the option ROM file (I am not such an expert!). As mentioned in the message accompanying Patch 4 of this patchset, the official edk2 project does not provide support for the Intel IGD, but some OVMF patches for Intel IGD support are available online for KVM/VFIO guests, such as at the links below (they apply to the OvmfPkgX64 platform): https://github.com/cmd2001/build-edk2-gvtd https://eci.intel.com/docs/3.3/components/kvm-hypervisor.html#build-ovmf-fd-for-kvm https://github.com/LongQT-sea/intel-igpu-passthru With such patches it is reported that the passed through Intel IGD device lights up the display during early boot from OVMF and the guest bootloader in KVM/VFIO guests provided that the administrator provides the correct ROM file via the 'romfile' setting for the passed thorugh Intel iGD device and applies appropriate patches to the OvmfPkgX64 platform. It should also be possible to add Intel IGD support for the OvmfXen platform also but I have not seen any such patches online for OvmfXen and if anyone knows of such patches online I would be interested to be informed about them. I am also working on my own patches to add Intel IGD support to the OvmfXen platform, in private for now. If anyone is interested, I can make the work I have done so far toward this goal avalable online. hw/xen/xen_pt_load_rom.c | 47 +++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c index eaf0ae1..6c2aa8f 100644 --- a/hw/xen/xen_pt_load_rom.c +++ b/hw/xen/xen_pt_load_rom.c @@ -2,6 +2,7 @@ * This is splited from hw/i386/kvm/pci-assign.c */ #include "qemu/osdep.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/pci/pci.h" @@ -13,9 +14,9 @@ * need to be modified. * * For such cases, use this function to get a pointer to the option ROM - * from sysfs. Caller has the responsibility to edit the option ROM as - * needed, call pci_register_bar to register the modified option ROM, - * and set has_rom to true for the PCI device. + * from a user provided romfile or sysfs. Caller has the responsibility + * to edit the option ROM as needed, call pci_register_bar to register + * the modified option ROM, and set has_rom to true for the PCI device. * * This function must be called before xen_pt_register_regions is called * because if xen_pt_register_regions is called first, it will register @@ -32,17 +33,27 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct stat st; void *ptr = NULL; Object *owner = OBJECT(dev); + g_autofree const char *fname = g_strdup("igd.rom"); + g_autofree const char *path = qemu_find_file(QEMU_FILE_TYPE_BIOS, fname); + bool sysfs = false; /* If loading ROM from file, pci handles it */ if (dev->romfile || !dev->rom_bar) { return NULL; } - snprintf(rom_file, sizeof(rom_file), - "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/rom", - domain, bus, slot, function); + if (path) { + snprintf(rom_file, sizeof(rom_file), "%s", path); + XEN_PT_LOG(dev, "Using Intel IGD romfile %s " + "(administratior provided)\n", path); + } else { + snprintf(rom_file, sizeof(rom_file), + "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/rom", + domain, bus, slot, function); + sysfs = true; + XEN_PT_LOG(dev, "Using Intel IGD romfile from host sysfs\n"); + } - /* Write "1" to the ROM file to enable it */ fp = fopen(rom_file, "r+"); if (fp == NULL) { if (errno != ENOENT) { @@ -55,10 +66,14 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, goto close_rom; } - val = 1; - if (fwrite(&val, 1, 1, fp) != 1) { - goto close_rom; + /* Write "1" to the ROM file to enable it if using ROM from sysfs */ + if (sysfs) { + val = 1; + if (fwrite(&val, 1, 1, fp) != 1) { + goto close_rom; + } } + fseek(fp, 0, SEEK_SET); if (dev->romsize != UINT_MAX) { @@ -83,11 +98,13 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, *size = st.st_size; close_rom: - /* Write "0" to disable ROM */ - fseek(fp, 0, SEEK_SET); - val = 0; - if (!fwrite(&val, 1, 1, fp)) { - XEN_PT_WARN(dev, "%s\n", "Failed to disable pci-sysfs rom file"); + /* Write "0" to disable ROM if using ROM from sysfs */ + if (sysfs) { + fseek(fp, 0, SEEK_SET); + val = 0; + if (!fwrite(&val, 1, 1, fp)) { + XEN_PT_WARN(dev, "%s\n", "Failed to disable pci-sysfs rom file"); + } } fclose(fp); -- 2.52.0