From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111521; cv=none; d=zohomail.com; s=zohoarc; b=RKZWOPpWRJNB7GNejeXS70H1zLcMtClHj6XfVvPiUCu9SqbPnbktcIcexcveSDx9tvNJAmLmOSTk95r/i00eldls+VnhfSkq32iLeHHTon410fxl2lSqz9ZTC4dVgynfy++Je+nunFs9DZbeIi1f5HIpSbI7OshPVJXH2W+INpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111521; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tHr6jGwNHhq3fJ+vp7D5cn0Pfg062lk1xcykfV907MM=; b=JvIF/LJQp3+6UpzILH9z6I+U3Nh+xlYEQgcM9B5F/AXHzMYgHJowa8NPSVbxKhalaSnWsiuSRgLotGoflI63TWJ13v3J+sFAqj5jBgLGDkle0X3ubUfdjVdbZOSF/G76Voc3ecyc4IK838mdD95IQHui7q/NNb0PjGLZgUDJSa4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789111521700122.46619450418109; Fri, 11 Sep 2026 00:25:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415726.1644939 (Exim 4.92) (envelope-from ) id 1x4vd9-0007nJ-OY; Fri, 11 Sep 2026 07:25:03 +0000 Received: by outflank-mailman (output) from mailman id 1415726.1644939; Fri, 11 Sep 2026 07:25:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vd9-0007mp-GQ; Fri, 11 Sep 2026 07:25:03 +0000 Received: by outflank-mailman (input) for mailman id 1415726; Fri, 11 Sep 2026 07:25:02 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vd8-0007k7-Cf for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 07:25:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4vd7-002qxh-6u for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:25:01 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3acc5-8faa-0a2a0a5109dd-0a2a4506d894-44 for ; Fri, 11 Sep 2026 09:25:00 +0200 Received: from [98.137.65.32] (helo=sonic315-8.consmr.mail.gq1.yahoo.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3accb-195a-0a2a45060019-62894120959f-3 for ; Fri, 11 Sep 2026 09:25:00 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:24:58 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:24:57 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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=1789111498; bh=tHr6jGwNHhq3fJ+vp7D5cn0Pfg062lk1xcykfV907MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=WkXczADhdQuA0QQMH2IyPryOJk04+MaSsYlWKDiqaovTU+vh8uLPZqswm22rPTk0n8o/VFAN+xdxTik/gIw+97158tCBbaqcmSFJM28RiG7NlGiKGjnySopf3+4OSD7HSzM/yZbZwraU72s4UzYN4M0V9n2BbAlFbybjXPnG86YYIKMs51RJbc4n5kMCjZY0139sqkxY7SwCeBPtVN7kd+uN8J4pAvTgyXA3AZkAqj/a94kLRQQPYmdpMbz/e9XVH90ON5Xs/Uix2M3IKoEb3tVkDfhl2Wqi0O1oeHj8HJ759hC9EXr/MauKoO1JO3tutkiWtj72bvboom4w4xzLow== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1789111498; bh=ecV1pO1qpj7gBS6SdkI1hsH3mU8y/kZB15TF0tG+0hw=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=MkchnzuS7PIompOxaek6t1GmklJ/Bp/EGq6muEM8qLuwyGx5x/n4r/wf1cxGrYCrwRafzna9m/c6rsicgMT4bGbvMehL05b31+XlXFH4oyJdmlb2xsotnRQBzxsTbua802acp7m0gebSkXX0nmugdVQ5CLyebAvTSsJisTtxnvK7TmVFUNta87wYMngnoSgq7jDMF8gsoiyEVooHH21KA69uvni6yNaGrg4t0WZmv4qIbTrlEOQ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dzT658Lqo1GyfbJk BuYuo1pYqKSSHJ6I0p4N2Zlo2mg2jKBp8SKCfoFNLa9aVhTmjq.qGKQL7TkKsdLTe08hWlgs7pdR RLzeV251Q1QvRZz0YQ1JGnaIba7G107RCQmX3rJgJXfvXZ1_O5VM9U6fA4pE0DdFlTPVpJDKiiZ5 dq7GGuaJ29Shv7S5eVFYHljzn_L.UKEmenXZWmnHBgtm4zK.a5Q1bGhGXli1TdFdmbVDIBBc8x6o TaleasQoV59w9JoyaldUKU0oKWaIqxFyR X-Sonic-MF: X-Sonic-ID: 56673a5d-426d-43a5-a7d0-21fdf54ffe44 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" , Tomita Moeko Subject: [PATCH v6 1/7] xen/igd: get PCH info from host sysfs Date: Fri, 11 Sep 2026 03:24:47 -0400 Message-ID: <20260911072453.46256-2-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 5810 X-purgate-ID: tlsNG-16d1c6/1789111500-F687577B-4D8D2615/0/0 X-purgate-type: clean X-purgate-size: 5969 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111523950158500 Content-Type: text/plain; charset="utf-8" The igd_combo_id_infos[] data is out of date with many devices missing from igd_combo_id_infos[]. For newer devices not in igd_combo_id_infos[], get the infos from the host sysfs. If logging is configured, print log messages displaying the PCH info used for the guest. Introduce helper function xen_pt_get_host_pch_info() to facilitate getting the necessary information from sysfs. Treat failure to get the host PCH device id as an unrecoverable error that causes guest creation to fail. If access to the host PCH device revision id fails, print a warning message and use a default value of 0x1 in that case. Also, use errp in xen_igd_passthrough_isa_bridge_create() to set errors from xen_pt_get_host_pch_info() and cleanup on error path with xen_host_pci_device_put(&s->real_device) and object_unparent(OBJECT(&d->rom)) for errors when creating creating the IGD PCH bridge. Add cleanup with object_unparent(OBJECT(&d->rom)) for errors when setting up VGA BIOS for GFX passthrough. Signed-off-by: Chuck Zmudzinski --- Changes in v6: - No changes Changes in v5: - Shorten warn_report message to resolve checkpatch line length warning Changes in v4: - re-wrote xen_pt_get_host_pch_info() using functions from xen-host-pci-device.h - add more error handling to clean up better after if errors occur - don't consider failure to get the PCH device revision id a fatal error but instead print a warning message and use a default value of 0x1 hw/xen/xen_pt.c | 10 +++++++++- hw/xen/xen_pt_graphics.c | 39 +++++++++++++++++++++++++++++++++++++-- include/hw/xen/xen_igd.h | 3 ++- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 0fe9c0a..c8f08b5 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -862,12 +862,20 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) if (*errp) { error_append_hint(errp, "Setup VGA BIOS of passthrough" " GFX failed"); + object_unparent(OBJECT(&d->rom)); xen_host_pci_device_put(&s->real_device); return; } =20 /* Register ISA bridge for passthrough GFX. */ - xen_igd_passthrough_isa_bridge_create(s, &s->real_device); + xen_igd_passthrough_isa_bridge_create(s, &s->real_device, errp); + if (*errp) { + error_append_hint(errp, "Failed to create PCH bridge" + " for passthrough GFX"); + object_unparent(OBJECT(&d->rom)); + xen_host_pci_device_put(&s->real_device); + return; + } } =20 /* Handle real device's MMIO/PIO BARs */ diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index 7df9344..cf424bc 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -2,6 +2,7 @@ * graphics passthrough */ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "hw/xen/xen_pt.h" #include "hw/xen/xen_igd.h" @@ -376,8 +377,33 @@ static void pt_graphics_register_types(void) } type_init(pt_graphics_register_types) =20 +static void xen_pt_get_host_pch_info(uint16_t *pch_dev_id, uint8_t *pch_re= v_id, + Error **errp) +{ + g_autofree XenHostPCIDevice *pch_dev =3D g_new(XenHostPCIDevice, 1); + + xen_host_pci_device_get(pch_dev, 0, 0, 0x1f, 0, errp); + if (*errp) { + goto error; + } + + *pch_dev_id =3D pch_dev->device_id; + + if (xen_host_pci_get_byte(pch_dev, PCI_REVISION_ID, pch_rev_id)) { + *pch_rev_id =3D 0x1; + warn_report("IGD: failed to get host PCH revision, setting it to 0= x1"); + } + + xen_host_pci_device_put(pch_dev); + return; + +error: + error_append_hint(errp, "failed to get host PCH device for Intel IGD"); +} + void xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s, - XenHostPCIDevice *dev) + XenHostPCIDevice *dev, + Error **errp) { PCIBus *bus =3D pci_get_bus(&s->dev); struct PCIDevice *bridge_dev; @@ -394,7 +420,16 @@ void xen_igd_passthrough_isa_bridge_create(XenPCIPasst= hroughState *s, } } =20 + /* Newer devices get PCH infos from host sysfs */ + if ((pch_dev_id =3D=3D 0xffff) || !pch_rev_id) { + xen_pt_get_host_pch_info(&pch_dev_id, &pch_rev_id, errp); + } + + XEN_PT_LOG(&s->dev, "PCH device id: 0x%x\n", pch_dev_id); + XEN_PT_LOG(&s->dev, "PCH revision: 0x%x\n", pch_rev_id); + if (pch_dev_id =3D=3D 0xffff) { + error_setg(errp, "failed to get PCH device id"); return; } =20 @@ -406,7 +441,7 @@ void xen_igd_passthrough_isa_bridge_create(XenPCIPassth= roughState *s, * Note that vendor id is always PCI_VENDOR_ID_INTEL. */ if (!bridge_dev) { - fprintf(stderr, "set igd-passthrough-isa-bridge failed!\n"); + error_setg(errp, "set igd-passthrough-isa-bridge failed!"); return; } pci_config_set_device_id(bridge_dev->config, pch_dev_id); diff --git a/include/hw/xen/xen_igd.h b/include/hw/xen/xen_igd.h index 7ffca06..da51f09 100644 --- a/include/hw/xen/xen_igd.h +++ b/include/hw/xen/xen_igd.h @@ -22,7 +22,8 @@ uint32_t igd_read_opregion(XenPCIPassthroughState *s); void xen_igd_reserve_slot(PCIBus *pci_bus); void igd_write_opregion(XenPCIPassthroughState *s, uint32_t val); void xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s, - XenHostPCIDevice *dev); + XenHostPCIDevice *dev, + Error **errp); =20 static inline bool is_igd_vga_passthrough(XenHostPCIDevice *dev) { --=20 2.52.0 From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111528; cv=none; d=zohomail.com; s=zohoarc; b=PJVotaIibGOGflBHpjVhRaM8eCBzMCR1znIA/9i44yfgHrCAqcZ2qiOtqHdVXNsOGf0IB9F1rDQlEnGrklfl5KYfSkzlaXCnNVcdUNKeS4J959mkcWHgs+mT6oVqEQpo4dRrvejsAkN7G45aaCnQrmI1mOUPFaLteq2eBrKAywY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111528; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2bfcA2HA0eFN2KKmyTFegbUhGh8vw5fjlw90db5CzuY=; b=NHQqX9Lm88P22zx9Ql8MMB9rmO6JvO+pU4W4Bt9KJJ2FX3iOwR457WcGN/7mAT++bQZyaoUMIjh7ijKv9+CeUd3fnMzEcQsEmUAT1EoHtN1LH9efMsP/IW0ed6MVOT/70DYXF4Cfu+q99phN8WVvM0meRoJnUxXBXJzpJg4uGt8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789111528507155.7210051945607; Fri, 11 Sep 2026 00:25:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415727.1644951 (Exim 4.92) (envelope-from ) id 1x4vdE-0008BQ-0a; Fri, 11 Sep 2026 07:25:08 +0000 Received: by outflank-mailman (output) from mailman id 1415727.1644951; Fri, 11 Sep 2026 07:25:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdD-0008BJ-Tr; Fri, 11 Sep 2026 07:25:07 +0000 Received: by outflank-mailman (input) for mailman id 1415727; Fri, 11 Sep 2026 07:25:06 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdC-00089b-CJ for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 07:25:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4vdA-004oXr-U1 for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:25:04 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3accc-bab6-0a2a0a5309dd-0a2a4508d58a-6 for ; Fri, 11 Sep 2026 09:25:04 +0200 Received: from [98.137.69.32] (helo=sonic316-8.consmr.mail.gq1.yahoo.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3accf-f659-0a2a45080019-628945209855-3 for ; Fri, 11 Sep 2026 09:25:04 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:25:02 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:24:58 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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=1789111502; bh=2bfcA2HA0eFN2KKmyTFegbUhGh8vw5fjlw90db5CzuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=IXmDy3e917fafoCDKiMu3JLjF/+baEn8doi4MYF2R9yQM5EqgH4MAHX7irFLr1+MkBmH72QNjuHLWO+G3tIKkCanQaik3Nj0SNHWpKNVdXMG693QuDR4V6irm9cT/oe07cmjJKfgMX97ZlQiSK9imAiTEIsHUJFHb6Wke+96v8rN0zWdzNnNnxBoLesXmEImDvds3o+va+dj8m9HHP+ltI82zHlJAWeDZ/jbmBSAC8RBuHTD9U7UVhI4R5RLdSPKdIoTrlZa3K9Pj4+kqS8NQ7bT9c8abqntTXcgCoJSgGKTiEZQD/hJWIENFeW07VkBmFn/MJp7S0+kU6WNSjsUUg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1789111502; bh=Bb+TK9wUavK5OW1HyioutUUdAopuw/9tkWTkNKyTaMv=; h=X-Son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BBE2x_eXFRrxRbioTj2sZty28XfUnpKaRWKRKFcLfTnrwaKIMetynvCVMb9P5 joZxr9etDa2doxVeENp2fJahGnfqivGiucj0kK3CkzqnC73W2pC2PF3ifONJATFOYeOFSPDzpwZR .LoigatUZU6pd83GyeYdSqUqf9kC_u3BJL3tX5VfEgk6qpv7D9eQw5dyDah0LWmCobv3C6x2EGCl fBlk8p8gJxTYRKIS6RXftbpF1Rj_Vb.UcDUzwlp5E5zzPmly0nbvw4SjAa9qJkhi9b0epcegFMHC BiIu6c3I1R9DvidR6t3R3abeS5HyUC5EkLSnKe_Bi5rKTHTRlCIrU6ckDgyYd_2Nq99Hcy0DSF3x HRL9_wNAz5VESmQFyxp0H1THmykZUCimK.b.1i_3YxwLzY9GER6HUZVCqAmXlmBEE8cD.qPG8M8c z1XPXdQHvXzQfpHPz75mZ13LOV7L7HekxXP7hSzmCDCR93ypuaXc12D1FWgjQBimWUbMkHH2UP39 TFBReosiwvRvFEZNtZismBqe9GtdZ8zxzWRy4 X-Sonic-MF: X-Sonic-ID: ec7da795-eae4-4ab0-83c2-71a43c2c372e 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" , Tomita Moeko Subject: [PATCH v6 2/7] xen/igd: don't register rom bar twice Date: Fri, 11 Sep 2026 03:24:48 -0400 Message-ID: <20260911072453.46256-3-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 1356 X-purgate-ID: tlsNG-c1860d/1789111504-D574B87B-917D3781/0/0 X-purgate-type: clean X-purgate-size: 1401 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111529536158500 Content-Type: text/plain; charset="utf-8" This also fixes a failed assertion in pci [1] for Qemu version 10 and higher when passing through an Intel IGD with an option ROM to the guest. [1] f6fc01c78666 ("hw/pci: Assert a bar is not registered multiple times") Fixes: 881213f1b9c5 ("xen, gfx passthrough: retrieve VGA BIOS to work") Signed-off-by: Chuck Zmudzinski --- Changes in v6: - No changes to this patch Changes in v5: - No changes to this patch Changes in v4: - Use 12 digits for commit hashes hw/xen/xen_pt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c8f08b5..4d159a2 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -459,6 +459,7 @@ static int xen_pt_register_regions(XenPCIPassthroughSta= te *s, uint16_t *cmd) { int i =3D 0; XenHostPCIDevice *d =3D &s->real_device; + const pcibus_t romsize =3D s->dev.io_regions[PCI_ROM_SLOT].size; =20 /* Register PIO/MMIO BARs */ for (i =3D 0; i < PCI_ROM_SLOT; i++) { @@ -495,7 +496,7 @@ static int xen_pt_register_regions(XenPCIPassthroughSta= te *s, uint16_t *cmd) } =20 /* Register expansion ROM address */ - if (d->rom.base_addr && d->rom.size) { + if (!romsize && d->rom.base_addr && d->rom.size) { uint32_t bar_data =3D 0; =20 /* Re-set BAR reported by OS, otherwise ROM can't be read. */ --=20 2.52.0 From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111526; cv=none; d=zohomail.com; s=zohoarc; b=Y6sNB6uTdGjv9R5CJZJFcq4XFx52e3S+J9StH8wQ6w8sam1yx/PkHgZmX8H0Aqs+EWgXgSaP+Mx2O2i4417jD6InjSiAhyUeqR6rTAWwGtvFFIUHMiIw2xrDPzF9jXpEzR5HkjxEfL487YrJlgiXI2UKpC/okd8IVjqBMboynjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111526; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MHAucsl21fQ+zt5t6z3XzNa922VKJLeEWygr1vd5y3g=; b=f2o7RuD+9XkZfjIXfPnWTlExoT7zrystojEC5Z0+hbMrUx47UKB4vWWkkkkLiTwNjf7VAIR7FpzX+B+FVfzI13V9CYVhuZ6M15cv4w69gX5Ii5zmUp3WS/HhhaZoEcxZsw6eAnk02s5alaVV8wVB1mkrvJ9OvDz0t62IVVxB9bo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789111526500821.5065534712245; Fri, 11 Sep 2026 00:25:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415728.1644957 (Exim 4.92) (envelope-from ) id 1x4vdE-0008EN-DV; Fri, 11 Sep 2026 07:25:08 +0000 Received: by outflank-mailman (output) from mailman id 1415728.1644957; Fri, 11 Sep 2026 07:25:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdE-0008Db-4Z; Fri, 11 Sep 2026 07:25:08 +0000 Received: by outflank-mailman (input) for mailman id 1415728; Fri, 11 Sep 2026 07:25:06 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdC-0008A2-I1 for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 07:25:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4vdB-001KQ2-Us for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:25:05 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3acc3-e002-0a2a0a5209dd-0a2a450c9d18-38 for ; Fri, 11 Sep 2026 09:25:05 +0200 Received: from [98.137.68.30] (helo=sonic308-54.consmr.mail.gq1.yahoo.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3acd0-f479-0a2a450c0019-6289441e989a-3 for ; Fri, 11 Sep 2026 09:25:05 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:25:03 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:25:00 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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=1789111503; bh=MHAucsl21fQ+zt5t6z3XzNa922VKJLeEWygr1vd5y3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=mGNCsPKwIS4L5pgq3coWc3/nLFwsC/xxop57/FoTRZfzPBrBoEAK/skx8IYRvMB3ADb0LqoGIokB/652g6arjddcpn/3Lf/sR+8Emf6GDXMgL5xykFDOaa5/debwQ2pVbWykkZMLdLGS1p2yN3okFVbvUEBizmHPbvqGFpuXc1lrJjKSLny+TLkum6IfRh42h2wBTU1dRIWb8E/1qylepU60IRSIHONVqT+TNDQO+b34xWwT/4aEcpmW/Xkv0tU2fscucv1gi/cqumTBPWJG7SRL2xgWtLAEuHzBEtrlKTzC7kgqJCIzKiQWo6HSeDr8VwIbW6euhR7ZI19GzfpF3g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1789111503; bh=ItvF/EjmknDMnmunyCgEQQBZ+jJQ/FZnOumzkxmVWC9=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Hu6b/MxlJN4U+/5tIL9BOK/8vNwphnBGRuCuN4rrcdXJ9hzorxsOvCzxWSCekRidPlNdZsVmXfEWj5+V9pMmOU0H12n/olXwk/cGajmYCIInyO2e88n9Ace17sjLTeCWKTi8EnA6kAWW8TUi1B3r7ulS3Xj9A4juum0iakwJJkwnA9fAWCHNlo/PII1S3k08k2xwRGCTGRBa8cQjtR6lwaW0qc6eqTqTX9ejDiRS4ESTJql6d/UsvpnOfBL2au2H//dVBb/2OA7ej96+kQ8DzFraYe1PTzEzz5lryh8kwSjgcZLuVriSpZVZCQwxpEO08+39/fKtqu6Oo8hS2n41rQ== X-YMail-OSG: ZCQQLDYVM1njOau7aIEpTe_HowWStq2DyrIyaS0l0BC09H0sLmUny_TJjHZ7CDt ZjGnavHsEzmRwnhPS9UNk8Yc5uxPJ29D7MUHDuVb0i9QabFWZt9HnjNt9QWuZNCUodHNI7VVrC8y .YlQ6TtSefckiRRjK_gSSJsg.NtWOx.HyM4TOKhLGPQF6RgysX.xCBZuJydPptob91W5fF5On0Mv U9lMdWJFu3pUcmc6P.HvWNUc2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M.Z0qjBfiKW3p2BwGuf1Cy6KPLwtQisDzngsbBY JAs1Al52z5CRnqTlsoNqwHz_bHP4Pow2Z_iTrgjip2u5kBAybLHnkH68nZQcpSjoM2o84qSUCJ.L gJE40kxp.nGbcuGNzeTCVZez7nVoK1799kP13mCKfAFDItzXXioCUfeo_Vl5FWqH_mYfqI5UtNl7 vT1LxGihJIDq6ProoEOq9hjUazOhaasHKoJMATkd8m6oA6IxyGMptZvUspKR.gwtRkGjGpX5ELvk OJk3RQ5HIEkHLKJjkep_HLVIR7CljDTK0xda97unIA1MmpeoyPBu8oKzkW6YiHzITRe2bRX101GX aI7q7WoZN9NKjxEcZVHD5jbVadZZM9Tuqd96IyZ3Xd8bIWFOxhOMapNHPWWC.epr4ILCvIsAWbfE .PEbLfpwrlO8J5iNDssyhC6onELitmksLGNVE3dpinN72Y9q2NcyTwxW6vpXMtkg71byAChXFztw j6o4zDrj2CP3mVxNLd5t11cjWxUPiEAq7.FQYMEbaWj5eihXiegM29Xzzix2wwznDWne2ACyPnu9 mDxMFLZ7aVeo7zxAkYP4vTqXJlFS63KLkL2YDPXyWEZJXYRW7dpwjPZkvo3ImcqEfZKlvPZuK7xZ vvmXINe1WxKHN_6zdfNhaTr6FTX_LTg24onq1Tm67qnqHjGu5BSJs3pk8gnez9IT1a0e9hO6O_7b apdHvc4rNqvoOAfQRRQg3BCHn8H2W5EBkXMFHkpns3FCh1W1sTMt0kXQzrLZm99_iE.IEYJYeDUs ZQtHo7OLDArerpIMe6AAdn9lhlthElh1uNWGqRkjTeaN9ISZgin_qhkwDmp_rEKarSWYq3au7nuR VVapF_pmV7X3tNq3hMkEoqqBf3oEsrRuRd4S0OGjHjblnLvRH3w4TT0hPljBAuU8L4YsdAycAkXk UDXglIaqjIDXcuImKwAYtq9igvJQBfpXDZtqb X-Sonic-MF: X-Sonic-ID: 2c3085ab-b377-45e0-bffe-0943d287da5e 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" , Tomita Moeko Subject: [PATCH v6 3/7] xen/igd: fixup device id before registering rom Date: Fri, 11 Sep 2026 03:24:49 -0400 Message-ID: <20260911072453.46256-4-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 3254 X-purgate-ID: tlsNG-d25034/1789111505-004CFA5B-5273D7C5/0/0 X-purgate-type: clean X-purgate-size: 3342 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111527590158500 Content-Type: text/plain; charset="utf-8" With the current implementation, Seabios does not see the fixup of the device id done here and consequently Seabios does not load the VGA bios and the guest screen does not light up until the guest OS graphics driver is loaded. So there is no VGA output from the passed through Intel IGD from either Seabios or the guest bootloader with the current implementation in cases when the device id needs fixing. Fix this by waiting until after doing fixup of the device id before registering the option ROM. With this patch, Seabios sees the fixup done here and loads the VGA bios, and both Seabios and the guest bootloader light up the guest screen in cases when fixup of the device id is needed. Also, remove unused header hw/core/loader.h. Fixes: 881213f1b9c5 ("xen, gfx passthrough: retrieve VGA BIOS to work") Signed-off-by: Chuck Zmudzinski --- Changes in v6: - No changes to this patch Changes in v5: - No changes to this patch Changes in v4: - Add a Fixes tag hw/xen/xen_pt_graphics.c | 3 +++ hw/xen/xen_pt_load_rom.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index cf424bc..c5ab23e 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -223,6 +223,9 @@ void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHos= tPCIDevice *dev, } } =20 + pci_register_bar(&s->dev, PCI_ROM_SLOT, 0, &s->dev.rom); + s->dev.has_rom =3D true; + /* Currently we fixed this address as a primary for legacy BIOS. */ physical_memory_write(0xc0000, bios, bios_size); } diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c index 319efca..407b630 100644 --- a/hw/xen/xen_pt_load_rom.c +++ b/hw/xen/xen_pt_load_rom.c @@ -4,14 +4,22 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/error-report.h" -#include "hw/core/loader.h" #include "hw/pci/pci.h" #include "xen_pt.h" =20 /* - * Scan the assigned devices for the devices that have an option ROM, and = then - * load the corresponding ROM data to RAM. If an error occurs while loadin= g an - * option ROM, we just ignore that option ROM and continue with the next o= ne. + * Normally xen_pt_register_regions will handle loading the option ROM, + * but in some cases, such as for the Intel IGD, the option ROM might + * 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. + * + * This function must be called before xen_pt_register_regions is called + * because if xen_pt_register_regions is called first, it will register + * the option ROM and any attempt to register it again will fail. */ void *pci_assign_dev_load_option_rom(PCIDevice *dev, int *size, unsigned int domain, @@ -76,8 +84,6 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, goto close_rom; } =20 - pci_register_bar(dev, PCI_ROM_SLOT, 0, &dev->rom); - dev->has_rom =3D true; *size =3D st.st_size; close_rom: /* Write "0" to disable ROM */ --=20 2.52.0 From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111533; cv=none; d=zohomail.com; s=zohoarc; b=f4dc4+PgguItjdZsjly9SgN9XCrGOsszv928dXBwqEA8wZAt/24aPPual1zQ7Y25+voSO+ZfSfJi1AmM8bU5qJXNOFGjJw7I19lIaq1x+gs72FROx9rOWBVJ3UbCB43CDXEKeAGyEcyTRBNEtDXoqYBIyod/ku8XVJOI/wqyYMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111533; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7fxAXafCgkhWXQ8Bsf9UiQyUsF3UYEGG0N1eLLgC4dY=; b=f4069Na6OUR+iXoiOrJLGx6CIhMyhWxAzlzft90AoQZQ+wmkkl1PolckQnyK+kcoVikiCMh2hKGD24R6++K6uAZFMIPzEq/0p3WDR4gLTA9HCugpCbMHUcWAeB+G5L7Z7oBuGdvCzJW83qhMGspEg4COgipfhUVxRJ1bqNeAXPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789111533008922.1941680431601; Fri, 11 Sep 2026 00:25:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415730.1644975 (Exim 4.92) (envelope-from ) id 1x4vdI-0000It-Tm; Fri, 11 Sep 2026 07:25:12 +0000 Received: by outflank-mailman (output) from mailman id 1415730.1644975; Fri, 11 Sep 2026 07:25:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdI-0000IO-LJ; Fri, 11 Sep 2026 07:25:12 +0000 Received: by outflank-mailman (input) for mailman id 1415730; Fri, 11 Sep 2026 07:25:10 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdG-0000CO-HV for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 07:25:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4vdF-00CxOg-Ua for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:25:09 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3acd5-8faa-0a2a0a5109dd-0a2a450cd35c-0 for ; Fri, 11 Sep 2026 09:25:09 +0200 Received: from [98.137.68.146] (helo=sonic302-20.consmr.mail.gq1.yahoo.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3acd4-f479-0a2a450c0019-628944928126-3 for ; Fri, 11 Sep 2026 09:25:09 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:25:07 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:25:02 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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=1789111507; bh=7fxAXafCgkhWXQ8Bsf9UiQyUsF3UYEGG0N1eLLgC4dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=MY3bu1YIRCtta03Rlipjs9jUs1884+HtWo02dPwMqdNiXfGND5jbWoQQ73rVvmFAxfMh1rSKNCMmUuv0f3O3nJaF48sza9pov6e+l+5/jgrWX/pDVibkOPsfi8YIe/y/Pho4nZxTqjiYEEXkYQ7WTBu9rkKWm87rccHdDwVCWORazLPteYYxrU9xB8A1WWaALgrm/4WGLNNraisbgpawWT4yCiTwKRcRrUB5TrtBlF+L+XCD94/0oIWScWB/ITGti3+FA+DWEgJt/bbxP3uxArBWxuz8LXVFcbMm3e1FfLCVqskURWa6ycZ2qiubUAeiISzjx7yLDbKf/tpHsLRAtA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1789111507; bh=R67dZrL14KOXcf7Htx14zdMHg64juJit3yfZK6RHShP=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=AVymKrAS51hbwh2XQ86S1xqC2/S/pId39gT5gLi9EPmC71kvDOIoMtCHjmQ0PH4HOd+kd6qEJZU+yw/oy0ad+Qvtk702yzQybpE6w/IqgP1gLD6AXQobKic6oJhhJWIlVR17YeqUSBUR4CUm5lPlm/JIROPRDo8QGGTkGQiqgltSSOzirGDFTEsuQKYe2TuNRZ+mnjMLF3cr/7BWPkcCSdrM8kHBdMU5yBJd7NuTbIdU/nNsLL7hj5U+Tqb7Jw//ua2OA1oyDj71El72Kz7vwvadsgsTLd6HMj49tWedkm+wJti/4yyh/YTzmlckEeZt6J3UDL/ydHB33+3RVC3pnw== X-YMail-OSG: TdyjS4QVM1mzgjCy7Bu9yrDGtN03HRem.ZApojprzrTauLRU_qRx8ZdHoeHoqCD GkHGfbcRZq.i8qBkyw4lCGycdR05XEXRvmdVNSsikGRGea0dTk88CSfUW3s6heH_3QZnzWXs6GdQ NLxGswdBbMVOpcUC0vkK.4lLgp4djl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sonic-MF: X-Sonic-ID: 4e403500-ce38-485d-8ff9-5e41d4fcae22 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" , Tomita Moeko Subject: [PATCH v6 4/7] xen/igd: enable guest creation when ROM read fails Date: Fri, 11 Sep 2026 03:24:50 -0400 Message-ID: <20260911072453.46256-5-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 4948 X-purgate-ID: tlsNG-d25034/1789111509-002F0A5B-C52202A5/0/0 X-purgate-type: clean X-purgate-size: 5062 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111533703158500 Content-Type: text/plain; charset="utf-8" For newer IGD devices, the host option ROM is not readable from sysfs and this results in a call to error_fail() that causes Qemu to exit(1) so guest creation fails with the current implementation for many newer IGD devices. But this read failure need not be a fatal error causing guest creation to fail because the guest does not need the option ROM to successfully boot and run. The guest only needs the option ROM for getting graphics output from the guest during early boot before the guest OS loads the Intel IGD graphics drivers. To fix this, allow guest creation to continue by avoiding setting errp if the attempt to read the host ROM file from sysfs fails. In this case, the memory for the guest option ROM has been allocated so free that memory by calling object_unparent(OBJECT(&s->dev.rom)) before continuing. Replace the error_report() and error_printf() messages for this case when the option ROM cannot be read via sysfs with a suitable info_report() message. In the case when the host option ROM cannot be read via the sysfs interface, xen_pt_register_regions() will attempt to setup the option ROM for the guest the same way it would for any other Xen passthrough PCI device that has an option ROM. Signed-off-by: Chuck Zmudzinski --- Changes in v6: - No changes to this patch in this version Changes in v5: - Shorten info_report message to resolve checkpatch line length warning Changes in v4: - v4 is the first version of the series that has this patch This patch provides initial support for many newer Intel IGD devices so, at least, guest creation will not fail if such newer Intel IGD devices are passed through to a Xen HVM guest. But this patch alone is not sufficient for proper operation of the Intel IGD for many, if not all, of the newer Intel IGD devices when passed through to a Xen HVM guest. There are two main problems with more recent, modern devices: 1. The newer divices might require patches to the Intel OpRegion and also an extended video bios table (VBT). Without support for these aspects of the newer devices, the experience will not be great and in many cases the Intel IGD still will not function properly in the guest. 2. The newer devices only work with UEFI AFAICT, and the Ovmf* platforms provided by the upsream edk2 project do not provide support for the Intel IGD. It appears the problem is that the ekd2 project deems the fact that the hardware manufacturer does not provide the necessary firmware, the EFI graphics output protocol (GOP) driver, in the ordinary way by making the EFI GOP driver accessible in virtual environments via the option ROM of the real PCI device, to be a reason to reject patches that add support for the Intel IGD. This, however, is not a fatal problem since it only affects the guest during early boot when OVMF or the bootloader is running and the guest OS graphics drivers have not yet been loaded. Lack of support for the Intel IGD in OVMF does not seem to affect the experience negatively once the guest OS graphics drivers have been loaded. So efforts to address this problem are only important in cases when it is necessary to get graphics output from OVMF and/or the guest bootloader. The last two patches in this patchset address these two problems. Of those two patches, the first one is more necessary, and the second of those two patches is only needed to provide graphics output from the guest during early boot. hw/xen/xen_pt_graphics.c | 7 +++++++ hw/xen/xen_pt_load_rom.c | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index c5ab23e..c5c2d47 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -187,6 +187,13 @@ void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHo= stPCIDevice *dev, return; } =20 + /* Case when the host ROM file from sysfs could not be read */ + if (!bios_size) { + object_unparent(OBJECT(&s->dev.rom)); + bios =3D NULL; + return; + } + if (bios_size < sizeof(struct rom_header)) { error_setg(errp, "VGA: VBIOS image corrupt (too small)"); return; diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c index 407b630..f136f13 100644 --- a/hw/xen/xen_pt_load_rom.c +++ b/hw/xen/xen_pt_load_rom.c @@ -77,10 +77,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, memset(ptr, 0xff, dev->romsize); =20 if (!fread(ptr, 1, st.st_size, fp)) { - error_report("pci-assign: Cannot read from host %s", rom_file); - error_printf("Device option ROM contents are probably invalid " - "(check dmesg).\nSkip option ROM probe with rombar=3D= 0, " - "or load from file with romfile=3D\n"); + info_report("pci-assign: Can't read Option ROM %s from host", rom_= file); goto close_rom; } =20 --=20 2.52.0 From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111545; cv=none; d=zohomail.com; s=zohoarc; b=JjJhvREmAeqM8QndyjXF1RBbZ52atbw2VB1+Q9wBaTrVNKI4xADypLGWskblQJBQ+hF9j3hVD8c8wKAHhv7CgYSri0WFTHvN13eW6aD8l6NZ7jljkMVjZ7lW2Muj9D/8scQWY1AfvmIlhY9m8z0P796oJw6W2eLUFQh2RBtCgRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111545; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w67e4rO/vcswdR8q6gV9R4+pyFjhs0XSGCFwSqNmNQs=; b=P3ewwpbCs8jv0iopzM+MG/tTiM8RsZCQdjteCDKzZUYkMJufH40ficS0FodbzBKTWvPsFYv0J3bLiybdtXKhRtpW84ShbCy+uJvF9/89JUFH2rjDMlCXwkk6sltZj092u631tYGhoMmNjfAk7dXjFBJXi2z8E2W0/Z6nvV8ZrL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789111545734335.7684892376175; Fri, 11 Sep 2026 00:25:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415729.1644968 (Exim 4.92) (envelope-from ) id 1x4vdI-0000Fh-Fi; Fri, 11 Sep 2026 07:25:12 +0000 Received: by outflank-mailman (output) from mailman id 1415729.1644968; Fri, 11 Sep 2026 07:25:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdI-0000FZ-CX; Fri, 11 Sep 2026 07:25:12 +0000 Received: by outflank-mailman (input) for mailman id 1415729; Fri, 11 Sep 2026 07:25:10 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdG-0000CD-Eo for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 07:25:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4vdF-000Pny-Rq for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:25:09 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3acd1-2eae-0a2a0a5409dd-0a2a4505b21e-14 for ; Fri, 11 Sep 2026 09:25:09 +0200 Received: from [98.137.64.82] (helo=sonic305-19.consmr.mail.gq1.yahoo.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3acd3-4cb1-0a2a45050019-62894052ad2e-3 for ; Fri, 11 Sep 2026 09:25:09 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:25:07 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:25:03 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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=1789111507; bh=w67e4rO/vcswdR8q6gV9R4+pyFjhs0XSGCFwSqNmNQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=W7dUzzwP7pE0RmixTMbaj3MuPTfDk6Ud0T3qI1s6hFs22CXloL04Jd+DGnVTPIeeuIoV30VMJLI+Qw/dpuwJv5zTkdf3Va3Xm5/nORd6kfJZZiDYI/bLs7iwn1hkP/WMyH0U2LU1jqp2TI4g17E4q84SZbkKt9Ia7G6S0Z5wbSLeMi6iY09GxhqgM26iNJCp2jEf6q5h5q0n5GBBwqmILMU0cAW37j17ugnc5+4nF92Mnvao4Q2N6u5K4/z/9nz+N6CgwrDlkaRlRn3IuSh2MGuXQt2f8UQ+OjxAn/KdaIU4whau6zgexRrY85XKurav8Zqb60z4bHdD/SrGygYHWA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1789111507; bh=mP2MEXUlevjdjchDEDIedOgXWaSUBK4Ix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_4g602n2FeQaJUeyGkysyIcaJnsuDwhgeTZt_8YiR9U gmbwVWnqxLVl4cEdZz.fdlJWHEIeQ9JAhD6my0oOThs2DT5YhUDwEfBUBPQWPZuYi.m6p0YI7pvK lazgg2TNoJF5qVQztyqdhHzLxffRmr5X11WsMV6r6D47xxwZNYSnZjNyQUptNhXeni7RAD8Rp4e5 kv.3atdOFKCvIuSPFMY0BisNLLbicn9JlP9DRZCUhTq1hHaM6qEeQ_xifSSxheTIiBOjb8I9Wdef 4aLoEh0dNM_aGCpkq6CvXukTSZci2oBpB8oB1sZWeHlmd8Hua6wTG8hNh919wuAqD0Qzn1Zcvifn 0yRHWumJ5fN4iVEK3AujwAvgjqeOAatG5ir_fxAcJWb741fA0M2kqlUKWY7x8VVcpiFDFILnsMtX kGetZOB1sIRUO__dZuMUcH_by3bheC0cXU1MBPl3oJDnhOQvcSFHvWzqgYTDfFlOeb8SfzMPmaZB 31KfApoBUUcRPfqUR37f6FW2.a6ZeNZPe2I6U X-Sonic-MF: X-Sonic-ID: 6a888ae9-c4d7-4342-8360-a9f4991ce3ac 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" , Tomita Moeko Subject: [PATCH v6 5/7] xen/igd: use igd header for IGD related definitions Date: Fri, 11 Sep 2026 03:24:51 -0400 Message-ID: <20260911072453.46256-6-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 6206 X-purgate-ID: tlsNG-c201ff/1789111509-F44A42A1-CE39954F/0/0 X-purgate-type: clean X-purgate-size: 6368 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111547700158500 Content-Type: text/plain; charset="utf-8" The newly added mocro definitions will be used in a later patch that adds support for an extended video bios table (VBT) and are mostly derived from the Linux kernel vfio driver for the Intel IGD. Also rename XEN_PCI_INTEL_* -> XEN_PCI_IGD_* to make the names of the macros related to Intel IGD more consistent. No functional change intended. Signed-off-by: Chuck Zmudzinski --- Changes in v6: - v6 is the first version of the series that has this patch hw/xen/xen_pt.h | 9 --------- hw/xen/xen_pt_config_init.c | 8 ++++---- hw/xen/xen_pt_graphics.c | 16 ++++++---------- include/hw/xen/xen_igd.h | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h index 095a0f0..ef93ac7 100644 --- a/hw/xen/xen_pt.h +++ b/hw/xen/xen_pt.h @@ -87,15 +87,6 @@ typedef int (*xen_pt_conf_byte_read) =20 #define XEN_PCI_CAP_MAX 48 =20 -#define XEN_PCI_INTEL_OPREGION 0xfc - -#define XEN_PCI_IGD_DOMAIN 0 -#define XEN_PCI_IGD_BUS 0 -#define XEN_PCI_IGD_DEV 2 -#define XEN_PCI_IGD_FN 0 -#define XEN_PCI_IGD_SLOT_MASK \ - (1UL << PCI_SLOT(PCI_DEVFN(XEN_PCI_IGD_DEV, XEN_PCI_IGD_FN))) - typedef enum { XEN_PT_GRP_TYPE_HARDWIRED =3D 0, /* 0 Hardwired reg group */ XEN_PT_GRP_TYPE_EMU, /* emul reg group */ diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index bbc82a2..a708c82 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -1808,7 +1808,7 @@ static const XenPTRegGroupInfo xen_pt_emu_reg_grps[] = =3D { }, /* Intel IGD Opregion group */ { - .grp_id =3D XEN_PCI_INTEL_OPREGION, + .grp_id =3D XEN_PCI_IGD_OPREGION, .grp_type =3D XEN_PT_GRP_TYPE_EMU, .grp_size =3D 0x4, .size_init =3D xen_pt_reg_grp_size_init, @@ -2023,7 +2023,7 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Er= ror **errp) XenPTRegGroup *reg_grp_entry =3D NULL; =20 if (xen_pt_emu_reg_grps[i].grp_id !=3D 0xFF - && xen_pt_emu_reg_grps[i].grp_id !=3D XEN_PCI_INTEL_OPREGION) { + && xen_pt_emu_reg_grps[i].grp_id !=3D XEN_PCI_IGD_OPREGION) { if (xen_pt_hide_dev_cap(&s->real_device, xen_pt_emu_reg_grps[i].grp_id)) { continue; @@ -2036,7 +2036,7 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Er= ror **errp) } } =20 - if (xen_pt_emu_reg_grps[i].grp_id =3D=3D XEN_PCI_INTEL_OPREGION) { + if (xen_pt_emu_reg_grps[i].grp_id =3D=3D XEN_PCI_IGD_OPREGION) { if (!is_igd_vga_passthrough(&s->real_device) || s->real_device.vendor_id !=3D PCI_VENDOR_ID_INTEL) { continue; @@ -2046,7 +2046,7 @@ void xen_pt_config_init(XenPCIPassthroughState *s, Er= ror **errp) * If an intel device is pass through we need to trap 0xfc, * therefore the size should be 0xff. */ - reg_grp_offset =3D XEN_PCI_INTEL_OPREGION; + reg_grp_offset =3D XEN_PCI_IGD_OPREGION; } =20 reg_grp_entry =3D g_new0(XenPTRegGroup, 1); diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index c5c2d47..be71989 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -12,8 +12,6 @@ static unsigned long igd_guest_opregion; static unsigned long igd_host_opregion; =20 -#define XEN_PCI_INTEL_OPREGION_MASK 0xfff - typedef struct VGARegion { int type; /* Memory or port I/O */ uint64_t guest_base_addr; @@ -251,8 +249,6 @@ uint32_t igd_read_opregion(XenPCIPassthroughState *s) return val; } =20 -#define XEN_PCI_INTEL_OPREGION_PAGES 0x3 -#define XEN_PCI_INTEL_OPREGION_ENABLE_ACCESSED 0x1 void igd_write_opregion(XenPCIPassthroughState *s, uint32_t val) { int ret; @@ -264,15 +260,15 @@ void igd_write_opregion(XenPCIPassthroughState *s, ui= nt32_t val) } =20 /* We just work with LE. */ - xen_host_pci_get_block(&s->real_device, XEN_PCI_INTEL_OPREGION, + xen_host_pci_get_block(&s->real_device, XEN_PCI_IGD_OPREGION, (uint8_t *)&igd_host_opregion, 4); - igd_guest_opregion =3D (unsigned long)(val & ~XEN_PCI_INTEL_OPREGION_M= ASK) - | (igd_host_opregion & XEN_PCI_INTEL_OPREGION_= MASK); + igd_guest_opregion =3D (unsigned long)(val & ~XEN_PCI_IGD_OPREGION_MAS= K) + | (igd_host_opregion & XEN_PCI_IGD_OPREGION_MA= SK); =20 ret =3D xc_domain_iomem_permission(xen_xc, xen_domid, (unsigned long)(igd_host_opregion >> XC_PAGE_SHIFT), - XEN_PCI_INTEL_OPREGION_PAGES, - XEN_PCI_INTEL_OPREGION_ENABLE_ACCESSED); + XEN_PCI_IGD_OPREGION_PAGES, + XEN_PCI_IGD_OPREGION_ENABLE_ACCESSED); =20 if (ret) { XEN_PT_ERR(&s->dev, "[%d]:Can't enable to access IGD host opregion= :" @@ -285,7 +281,7 @@ void igd_write_opregion(XenPCIPassthroughState *s, uint= 32_t val) ret =3D xc_domain_memory_mapping(xen_xc, xen_domid, (unsigned long)(igd_guest_opregion >> XC_PAGE_SHIFT), (unsigned long)(igd_host_opregion >> XC_PAGE_SHIFT), - XEN_PCI_INTEL_OPREGION_PAGES, + XEN_PCI_IGD_OPREGION_PAGES, DPCI_ADD_MAPPING); =20 if (ret) { diff --git a/include/hw/xen/xen_igd.h b/include/hw/xen/xen_igd.h index da51f09..469171c 100644 --- a/include/hw/xen/xen_igd.h +++ b/include/hw/xen/xen_igd.h @@ -11,6 +11,22 @@ #ifndef XEN_IGD_H #define XEN_IGD_H =20 +#define XEN_PCI_IGD_OPREGION 0xfc +#define XEN_PCI_IGD_OPREGION_MASK 0xfff +#define XEN_PCI_IGD_OPREGION_PAGES 0x3 +#define XEN_PCI_IGD_OPREGION_ENABLE_ACCESSED 0x1 +#define XEN_PCI_IGD_OPREGION_SIGNATURE "IntelGraphicsMem" +#define XEN_PCI_IGD_VBT_SIGNATURE "$VBT" +#define XEN_PCI_IGD_OPREGION_RVDA 0x3ba +#define XEN_PCI_IGD_OPREGION_RVDS 0x3c2 +#define XEN_PCI_IGD_OPREGION_VERSION 0x16 +#define XEN_PCI_IGD_DOMAIN 0 +#define XEN_PCI_IGD_BUS 0 +#define XEN_PCI_IGD_DEV 2 +#define XEN_PCI_IGD_FN 0 +#define XEN_PCI_IGD_SLOT_MASK \ + (1UL << PCI_SLOT(PCI_DEVFN(XEN_PCI_IGD_DEV, XEN_PCI_IGD_FN))) + #include "hw/xen/xen-host-pci-device.h" =20 typedef struct XenPCIPassthroughState XenPCIPassthroughState; --=20 2.52.0 From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111539; cv=none; d=zohomail.com; s=zohoarc; b=dG3OEubZShWA3gXoj7oiCucsxn3k5y1JxucfZS5vG/ww4Jo9MjjeA0t98iWwDkXi9tQ3EanmGAi4oNITMrjQYAgD/ib+tsldEIzMvxcxHBYRsRSID9H90J8X+8+94tVWvR6qamnNzWTTUYKOF7FxRCxfL+C6xaDIUn+xzC2GEGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111539; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DeHWtm/4lazeyWTmPQN/A4L8FgKiSJ5/rJS30RCGUio=; b=XFqklB84s1PFJNAXUTVv18MOFjm/gzVQ6S+OCwluXxArSAbLqiexUx5QJaWnEvO7XrldLeWPb/2/gyjrYzOF/MHDFeqQQCdn3F66URfGr2PXC2w4+rAtlDKuUc+l6tJN3Z2mvxunk7MhEA2fGqZS756wn9+dKRkLNVRRjBuaU3A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1789111539703201.89481423126233; Fri, 11 Sep 2026 00:25:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1415732.1644979 (Exim 4.92) (envelope-from ) id 1x4vdJ-0000Op-Ab; Fri, 11 Sep 2026 07:25:13 +0000 Received: by outflank-mailman (output) from mailman id 1415732.1644979; Fri, 11 Sep 2026 07:25:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdJ-0000Nd-2y; Fri, 11 Sep 2026 07:25:13 +0000 Received: by outflank-mailman (input) for mailman id 1415732; Fri, 11 Sep 2026 07:25:11 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4vdH-0000Dh-Bl for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 07:25:11 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4vdG-004oXr-Og for xen-devel@lists.xenproject.org; Fri, 11 Sep 2026 09:25:10 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa3acc5-bab6-0a2a0a5309dd-0a2a45018eba-38 for ; Fri, 11 Sep 2026 09:25:10 +0200 Received: from [98.137.68.30] (helo=sonic308-54.consmr.mail.gq1.yahoo.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa3acd4-5984-0a2a45010019-6289441eb6a5-3 for ; Fri, 11 Sep 2026 09:25:10 +0200 Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:25:08 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:25:05 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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=1789111508; bh=DeHWtm/4lazeyWTmPQN/A4L8FgKiSJ5/rJS30RCGUio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=Jb7KTCTUxUSCZGuTZ+5vpdZaXU06xDRRrhILVWrEN0jPCXsWA8pBJa/v5/zApM2cCjoD9ovYrmCgVLcn7DLThZPgyrMTB4QvwA0vbTPcXw36KQyf9YfL27R0VMDCtzXJNx006L9c0Yqx3vmM3bNDChyGnnQ0M3+AUPtyPSn46qRdSaiIKipQYAMZjW2/eobDB16t9QEohMab0Bd8VwE1YyAVvCZJNaO/jjk8REtinLgYpzCy4hJZHeEIQpwhu0WhF4fKJMYNCV201FpW9njGNQfJK+HoZp+cgVKX9ipbzHMUcykTHQKMwtOqZaOIFUXHCiAtaz31h/hWTFHSt32H6Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1789111508; bh=XDUvK9dnrR6LWxdmuI8cqstojs0dq6l/sUU74yykL4R=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=R8/7T6s2jmdskd+WpLwBRmEIHoy7lTd7NvV6soh7068hB5LpdmUVw4UevbkxWQXrnT3RodPIY8e21iu0C9FvrfY/0to7cz9/i1HuGTptfqAd1yW/a9LSpTKGvBdhdCnIOCs7VS56NmONijlTX1BJYQ7yL4VutOuvLfcXRNnImrUvIsO8/8FUAEt4mvoONnhqO14dSBQdUxk23cgv5hpRCpwxmnDKwwjvLwkKXJ8Y6VpMn4Et1gMx2Qowy9qbPWzVIfMstHLjg76z5NCUZxZD8atK1eshCXtbj2q8XWWrwqnkNaHTXG+t0XCqlBLhx8nlTcaKVIbgu4tpz+CxIF+sow== X-YMail-OSG: Z7iXECgVM1kh.PBsb9xU6VBSCWRl0Z.FykmxECXqYgL8N3_qv60M7XLD.tfdt_1 DSOfNx2YmBFVV_0zguET9QI.6TbtBCAogZXOuma.hHLQODnROXpEXKIqJXxt52.tI9LYCd6vA5Us BXRnxf.ogSX0KjOScs9OqLPl8LLC4DwwC0_eelM1hnVd7WokECt6DpqzDSw0KGML.8eBbNfjTWhC GQbJFdC60cUCdeEzLhaYBd8ngMpN8ABWowENgs_zg4T8bhdCeC90J4jIgFeZgZT_NqmxtvMe2vrD an5lZe3xzMCG21VfJDkMxCGfpSGimAASnPIkxcu7iXtXV7xH0AMCYAhMQjJWDGRAeCZOdHhu.2d3 SskuwusqBjzdDaLkh7uq23xS52OxaUhRI3nDJ9cJbOGVtjTNCBpAUHZ9be746CX6VFEH.NeV8eVM Drg3E5ghnuexAJPP9BWitaoXtUH_HS72JsWWam4FTN5Dm3r9DOKvvc7DNEW7A7ICLXlf36vltUvk t8BsUNIIEjVZ0H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kDbB3PBdF0Tchzh88_Td5myRXvMjETUA.K.PF4iCF6mGNpJSnurRkRiJ8EwfVV8GO4N TzYGTz5Z9Oosh6F3XUqIFwHDDzWlHhxMnbncCJM7GSpeiubhXw7szvIeUUVisk0.XjAxI3A5bMq6 oBncDBtvymv19EvoyLdZyjOZCT3Szc8WJv0yPo22iiQZlqx2H0ev1BYAJkWsIZYOnLONLpQ3J99n 6.fmpen7rf1BHQV64PVRdmdV.DICd1X1nwnDyGZZ_3KuDn26fX90sy5RD5xEkjKHNwYTKv91i4h1 lShNSKKUYXl.iZ43ytbQUfhezEbDfq1nV3bhxh.33k7f8GJtr_IvviIMpP5vIAptvSZrNe2wXCKg tYuL5DmwR0HJCaU3MdmZn.H3NlIP6tDfXRYzAvWY0EAUOKBm0rO16drr_AdhgBXWPk0DBpgV6MjA NfL182rb2xzq0XoDrK_ONABB_Ku23aXuDgF6XkMyX._gbwO4Zz.SBELNrc4DXvWZWHC_3WovjBrA 8nG3sdNiJHVlhFpfZnU5z38462dxPpPIDlQLatMdfAbYsVL1c1BJk22WI1QYFKut8hcmWMYLgikn OS2wd.dG.K8tNMP5s4XzNInIIb70uF6mqTdn1JlTOHXj69k6zk_MplSJx3mikL1fxPKtBGaJk5HL hmop9D3rB2HxUTN.XRHW9iR5EhAFH7msxGnbqjw-- X-Sonic-MF: X-Sonic-ID: 1fa54d50-63c0-4570-a09f-9e5053848e1e 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" , Tomita Moeko Subject: [PATCH v6 6/7] xen/igd: implement support for extended VBT Date: Fri, 11 Sep 2026 03:24:52 -0400 Message-ID: <20260911072453.46256-7-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 25996 X-purgate-ID: tlsNG-d62444/1789111510-1FC69757-D2080B6D/0/0 X-purgate-type: clean X-purgate-size: 26534 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111541726158501 Content-Type: text/plain; charset="utf-8" The current implementation of support for Intel IGD passthrough to a Xen HVM guest relies on directly mapping the host OpRegion to the guest, and althou= gh the OpRegion is 2 pages in size, it is not always page-aligned so an extra page needs to be mapped to fully map it to the guest. This results in an ex= tra page of host memory mapped into the guest that should remain confidential to the host. This is also why XEN_PCI_IGD_OPREGION_PAGES is currently set to 3 even though the size of the OpRegion is only 2 pages. So in this new implementation avoid this confusion by redefining XEN_PCI_IGD_OPREGION_PAGES to 2, the actual size of the OpRegion. The current implementation also does not foresee the possibility that the video bios table (VBT) might not be embedded as part of the 2-page OpRegion but instead added on as an extended region beyond the 2 pages of the OpRegi= on. In such cases, the 3 pages that are mapped in the current implementation are not enough to hold both the OpRegion and the extended VBT. The current implementation of support for Intel IGD passthrough to a Xen HVM guest also relies on a position-independent OpRegion so the unmodified host OpRegion can be mapped to a different address in the guest. However, as indicated in the Link tags below referencing support for the Intel IGD in t= he Linux kernel vfio driver, since the addition of devices with an extended VBT the OpRegion is not always position-independent. That is, when the OpRegion for such a device is mapped in the guest at a different address, it will not work correctly in the guest. This position-dependent behavior arises from t= he fact that the the address of an extended VBT is stored in the OpRegion in t= he RVDA field of the OpRegion and in some cases that address is an absolute address, not an address relative to the OpRegion base address, and in other cases the extended VBT is not contiguous after the OpRegion in the host so = in such cases even a relative RVDA address would need to be adjusted for the OpRegion to be compatible with the desired memory map in the guest where the extended VBT would be contiguous with the OpRegion. To overcome these problems, this new implementation exposes an emulated OpRegion and VBT to the guest instead of directly mapping the host OpRegion= to the guest and also implements a protocol for communication between hvmloader and Qemu so both the device model and hvmloader agree on the number of pages to reserve for the OpRegion and VBT which varies depending on the size of the extended VBT instead of being the constant value of 3 as in the current implementation. In this new implemetation, Qemu reads the host OpRegion to determine if there is an extended VBT and if so, how large it is and how ma= ny pages are needed in the guest E820 map to accomodate both the OpRegion and extended VBT. Also, in this new implementation, Qemu zero-pads the extraneo= us memory in the areas before or after a non-page-aligned OpRegion or VBT to avoid exposing memory to the guest that should be confidential to the host. This implementation depends on compatible support in hvmloader and also provides for backward compatibility and fallback to the old protocol when either hvmloader or Qemu cannot fulfill the requirements of this new protoc= ol. This new protocol begins as follows: Before writing a value to the register that stores the address of the OpRegion that Intel has defined as the ASLS register and is identified in Qemu code as XEN_PCI_IGD_OPREGION, hvmloader reads from the ASLS register and Qemu, in the case when Qemu detects a read of the ASLS register before a write to the ASLS register, returns the number of pages that hvmloader needs to reserve for the OpRegion and VBT in the gu= est E820 map. With that information, hvmloader computes the address of the page base of the OpRegion in the guest and writes that value to the ASLS registe= r. Then Qemu responds to this write to the ASLS register by computing the corr= ect value for the ASLS register so that future reads of the ASLS register return that value to the guest. Qemu also responds to this write by constructing t= he OpRegion and VBT for the guest, patching the RVDA value in the OpRegion if necessary, and making the OpRegion and VBT a single continuous region accessible to the guest at the address stored in the ASLS register using Qemu's ioreq server. If for any reason Qemu is unable to access the host OpRegion and is also therefore unable to determine if there is an extended VBT and also unable to compute how many pages are needed for the OpRegion and extended VBT, Qemu falls back to the old protocol and direct maps the 3 pages from the host to the guest that are needed to fully map a non-page-aligned host OpRegion. In this case Qemu also returns 0 instead of the number of pages to reserve in = the E820 map which communicates to hvmloader that hvmloader should fall back to the old protocol and assume 3 pages for the OpRegion and expect Qemu to directly map the host OpRegion rather than expose an emulated OpRegion and = VBT using Qemu's ioreq server. Qemu can fail to access the host OpRegion because Qemu's access to the host OpRegion depends on Linux kernel support for this. Typically the Linux kern= el exposes device IO regions in the Linux sysfs filesystem, but in the case of the OpRegion and VBT, these regions are only exposed in the Linux debugfs a= nd then only when the Intel IGD is bound to the i915 driver. This means that Q= emu does not have access to the OpRegion and VBT via the debugfs when the Intel IGD is bound to the xen-pciback driver. So it is necessary that the OpRegion and VBT be placed into the host filesystem where Qemu can access them when the Intel IGD is bound to the xen-pciback driver. In this implementation, the OpRegion and VBT files are searched for in files named "intel-opregion" and "intel-vbt" in the directories configured by Qemu as firmware directori= es. These files can be automatically placed into a suitable location in the host filesystem when the Intel IGD is made assignable to a Xen guest with a suitable patch to libxl or they can be manually placed into the host filesystem by copying them from the debugfs to the "intel-opregion" and "intel-vbt" files located in an appropriate Qemu firmware directory when the Intel IGD is bound to the Linux kernel i915 driver. Assuming the Intel IGD = is at dri0 when bound to the Linux kernel i915 driver, the files in the debugfs where the OpRegion and VBT are exposed on the host can be found at /sys/kernel/debug/dri/0/i915_opregion and /sys/kernel/debug/dri/0/i915_vbt, respectively. Another case that can occur is when hvmloader lacks support for this new protocol. Qemu detects this case when hvmloader writes to the ASLS register before the guest reads the register. In this case Qemu assumes hvmloader la= cks support for allocating more than 3 pages for the OpRegion so Qemu in this c= ase falls back to the old protocol of direct mapping the 3 host pages to the gu= est that are needed to fully map a non-page-aligned host OpRegion to the guest. This new protocol also requires that after Qemu makes the OpRegion and VBT accessible to the guest via its ioreq server, hvmloader makes a copy of the OpRegion and VBT and writes the address of the OpRegion back to the ASLS register. Qemu responds to this second write of the OpRegion address to the ASLS register by unmapping the pages containing the OpRegion and VBT from t= he ioreq server. This makes it possible for hvmloader to back the pages that store the OpRegion and VBT with RAM allocated to the guest. This last part = of the protocol is required to support Windows guests because testing indicates the Windows graphics drivers are unable to access the OpRegion and VBT when the OpRegion and VBT are exposed to the guest via Qemu's ioreq server, while the Windows graphics drivers are able to access the OpRegion and VBT when t= he pages that store them are backed by RAM allocated to the guest. After the second write to the ASLS register which causes Qemu to unmap the OpRegion a= nd VBT from the ioreq server, Qemu ignores all subsequent writes to the ASLS register from the guest. In this way the Windows IGD graphics drivers work as expected. Also ensure that in xen_pt_unregister_vga_regions the call to unmap the OpRegion is only made in cases when we fall back to direct mapping of the host OpRegion. We could keep the constant 3 for the number of pages to unnap there since the number of pages to unmap will always be 3, but instead we u= se the value of opregion_vbt_pages there which also will always be 3 when we f= all back to direct mapping of the host OpRegion to the guest. Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/drivers/vfio/pci/vfio_pci_igd.c?id=3Dbab2c1990b78 Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/drivers/vfio/pci/vfio_pci_igd.c?id=3D49ba1a2976c8 Signed-off-by: Chuck Zmudzinski --- The comapnion patch to hvmloader will be posted to the xen-devel and qemu-d= evel mailing lists shortly after this patch is posted. It is v3 of the patch "tools/hvmloader: implement Intel IGD extended VBT support". Please note th= at previous versions of that patch to hvmloader are not compatible with this patch. Changes in v6: - After considering comments on v2 of the companion patch to hvmloader, t= his patch has been totally re-worked. The work of reading the OpRegion, discovering if there is an extended VBT and how many pages of memory are needed to accomodate it, and patching the OpRegion if necessary, has be= en moved from hvmloader to Qemu since v5. There are some simplifications, such as the bitmask to communicate if extended VBT and OpRegion 2+ is supported has been replaced with a simpler protocol that involves Qemu noticing if the guest reads the OpRegion register before writing to it and hvmloader noticing if Qemu returns 0 or the number of pages needed = for the OpRegion and VBT if hvmloader reads the OpRegion register before writing to it. Another simplification is that the complicated communication protocol with four extra writes to the OpRegion register has been mostly removed and replaced with ontly two writes, with the reason for the second write explained below. - All the code that involves reading the OpRegion, discovering if there is a VBT, how many pages are needed for the OpRegion + VBT, and patching t= he OpRegion if necessary has been moved from hvmloader to Qemu. - In contrast to v5 and the current implementation, the host OpRegion is never directly exposed to the guest. Instead, an emulated copy, patched= if necessary, is exposed to the guest using Qemu's ioreq server. - Because Windows IGD drivers cannot access the OpRegion and VBT when it = is exposed to the guest by the ioreq server, a second write to the OpRegion register from hvmloader is processed by Qemu to indicate to Qemu that t= he OpRegion and VBT must be unmapped from the ioreq server which allows hvmloader to configure the guest to use its own copy of the OpRegion + = VBT that is backed by guest RAM. With this configuration in place, both Windows and Linux guests are able to access the OpRegion and VBT and wo= rk as expected. Changes in v5: - fix style by adding braces to two if blocks and not initializing two static boolean variables to false - update the link to the companion patch for Xen hvmloader Changes in v4: - v4 is the first version of the series that has this patch hw/xen/xen_pt_graphics.c | 266 +++++++++++++++++++++++++++++++++++++-- include/hw/xen/xen_igd.h | 2 +- 2 files changed, 257 insertions(+), 11 deletions(-) diff --git a/hw/xen/xen_pt_graphics.c b/hw/xen/xen_pt_graphics.c index be71989..7136669 100644 --- a/hw/xen/xen_pt_graphics.c +++ b/hw/xen/xen_pt_graphics.c @@ -4,13 +4,27 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qemu/datadir.h" #include "hw/xen/xen_pt.h" #include "hw/xen/xen_igd.h" +#include "hw/xen/xen-hvm-common.h" #include "xen-host-pci-device.h" #include "system/physmem.h" =20 static unsigned long igd_guest_opregion; static unsigned long igd_host_opregion; +static uint8_t *opregion_vbt; /* pointer to OpRegion + VBT */ +/* + * If there is an extended VBT or if the OpRegion is not aligned on a page + * boundary, we will need extra pages for the OpRegion + VBT. + */ +static unsigned int extra_opregion_pages; +static unsigned long opregion_vbt_pages; /* # of pages for OpRegion + VBT = */ +static uint16_t version; /* OpRegion version */ +static uint32_t rvds; /* VBT size */ +static unsigned long rvda_host; /* VBT address in host */ +static bool opregion_is_direct_mapped; +MemoryRegion mr_opregion; =20 typedef struct VGARegion { int type; /* Memory or port I/O */ @@ -115,12 +129,11 @@ int xen_pt_unregister_vga_regions(XenHostPCIDevice *d= ev) } } =20 - if (igd_guest_opregion) { + if (opregion_is_direct_mapped && igd_guest_opregion) { ret =3D xc_domain_memory_mapping(xen_xc, xen_domid, (unsigned long)(igd_guest_opregion >> XC_PAGE_SHIFT), (unsigned long)(igd_host_opregion >> XC_PAGE_SHIFT), - 3, - DPCI_REMOVE_MAPPING); + opregion_vbt_pages, DPCI_REMOVE_MAPPING); if (ret) { return ret; } @@ -237,8 +250,158 @@ void xen_pt_setup_vga(XenPCIPassthroughState *s, XenH= ostPCIDevice *dev, =20 uint32_t igd_read_opregion(XenPCIPassthroughState *s) { + char opregion_file[64], vbt_file[64]; + FILE *fp =3D NULL; + struct stat st; + uint8_t *opregion =3D NULL, *vbt =3D NULL; + void *ptr =3D NULL; uint32_t val =3D 0; =20 + if (!igd_host_opregion) { + /* We just work with LE. */ + xen_host_pci_get_block(&s->real_device, XEN_PCI_IGD_OPREGION, + (uint8_t *)&igd_host_opregion, 4); + + g_autofree const char *fname1 =3D g_strdup("intel-opregion"); + g_autofree const char *path1 =3D qemu_find_file(QEMU_FILE_TYPE_BIO= S, + fname1); + /* + * If getting the OpRegion or VBT from the host filesystem fails, + * fallback to direct mapping of the host OpRegion to the guest. + */ + if (!path1) { + XEN_PT_WARN(&s->dev, "OpRegion host file \"%s\" not found\n", + fname1); + goto fallback; + } + snprintf(opregion_file, sizeof(opregion_file), "%s", path1); + fp =3D fopen(opregion_file, "r"); + if (fp =3D=3D NULL) { + if (errno !=3D ENOENT) { + XEN_PT_WARN(&s->dev, "Cannot open %s: %s\n", + opregion_file, strerror(errno)); + } + goto fallback; + } + if (fstat(fileno(fp), &st) =3D=3D -1) { + XEN_PT_WARN(&s->dev, "Cannot stat %s: %s\n", + opregion_file, strerror(errno)); + goto fallback; + } + if (st.st_size !=3D XEN_PCI_IGD_OPREGION_PAGES << XC_PAGE_SHIFT) { + XEN_PT_WARN(&s->dev, "Invalid OpRegion size (%u)\n", st.st_siz= e); + goto fallback; + } + opregion =3D g_new0(uint8_t, st.st_size); + ptr =3D (void *)opregion; + if (fread(ptr, 1, st.st_size, fp) !=3D st.st_size) { + XEN_PT_WARN(&s->dev, "Can't read host OpRegion %s\n", + opregion_file); + goto fallback; + } + if (memcmp(ptr, XEN_PCI_IGD_OPREGION_SIGNATURE, 16)) { + XEN_PT_WARN(&s->dev, "Invalid OpRegion signature\n"); + goto fallback; + } + fclose(fp); + + version =3D *(uint16_t *)(opregion + + XEN_PCI_IGD_OPREGION_VERSION); + XEN_PT_LOG(&s->dev, "OpRegion version: 0x%x\n", version); + if (version >=3D 0x0200) { + rvda_host =3D *(unsigned long *)(opregion + + XEN_PCI_IGD_OPREGION_RVDA); + /* It is convenient to make rvda_host absolute */ + if (version > 0x0200) { + rvda_host +=3D igd_host_opregion; + } + XEN_PT_LOG(&s->dev, "host VBT address: 0x%lx\n", rvda_host); + rvds =3D *(uint32_t *)(opregion + + XEN_PCI_IGD_OPREGION_RVDS); + XEN_PT_LOG(&s->dev, "VBT size: 0x%x\n", rvds); + } + + if (rvds && rvda_host) { + g_autofree const char *fname2 =3D g_strdup("intel-vbt"); + g_autofree const char *path2 =3D qemu_find_file(QEMU_FILE_TYPE= _BIOS, + fname2); + if (!path2) { + XEN_PT_WARN(&s->dev, "VBT host file \"%s\" not found\n", + fname2); + goto fallback; + } + snprintf(vbt_file, sizeof(vbt_file), "%s", path2); + fp =3D fopen(vbt_file, "r"); + if (fp =3D=3D NULL) { + if (errno !=3D ENOENT) { + XEN_PT_WARN(&s->dev, "Cannot open %s: %s\n", + vbt_file, strerror(errno)); + } + goto fallback; + } + if (fstat(fileno(fp), &st) =3D=3D -1) { + XEN_PT_WARN(&s->dev, "Cannot stat %s: %s\n", + vbt_file, strerror(errno)); + goto fallback; + } + if (st.st_size !=3D rvds) { + XEN_PT_WARN(&s->dev, "Invalid VBT size (%u)\n", st.st_size= ); + goto fallback; + } + vbt =3D g_new0(uint8_t, st.st_size); + ptr =3D (void *)vbt; + if (fread(ptr, 1, st.st_size, fp) !=3D st.st_size) { + XEN_PT_WARN(&s->dev, "Can't read host VBT %s\n", + vbt_file); + goto fallback; + } + if (memcmp(ptr, XEN_PCI_IGD_VBT_SIGNATURE, 4)) { + XEN_PT_WARN(&s->dev, "Invalid VBT signature\n"); + goto fallback; + } + fclose(fp); + extra_opregion_pages =3D rvds >> XC_PAGE_SHIFT; + if (rvds & XEN_PCI_IGD_OPREGION_MASK) { + extra_opregion_pages++; + } + if (((igd_host_opregion & XEN_PCI_IGD_OPREGION_MASK) + + (rvds & XEN_PCI_IGD_OPREGION_MASK)) > + (1 << XC_PAGE_SHIFT)) { + extra_opregion_pages++; + } + } else { + rvda_host =3D 0; + rvds =3D 0; + if (igd_host_opregion & XEN_PCI_IGD_OPREGION_MASK) { + extra_opregion_pages =3D 1; + } + } + + opregion_vbt_pages =3D XEN_PCI_IGD_OPREGION_PAGES + + extra_opregion_pages; + opregion_vbt =3D g_new0(uint8_t, + opregion_vbt_pages << XC_PAGE_SHIFT); + ptr =3D (void *)(opregion_vbt + + (igd_host_opregion & XEN_PCI_IGD_OPREGION_MASK)); + memcpy(ptr, (void *)opregion, + XEN_PCI_IGD_OPREGION_PAGES << XC_PAGE_SHIFT); + if (rvds) { + ptr +=3D (XEN_PCI_IGD_OPREGION_PAGES << XC_PAGE_SHIFT); + memcpy(ptr, (void *)vbt, rvds); + } + g_free(opregion); + g_free(vbt); + /* + * By returning the size of the OpRegion + VBT here instead of 0, = we + * indicate to hvmloader that we support an extended VBT and we gi= ve + * hvmloader the information it needs to place the OpRegion + VBT = in + * the E820 map. Also, in this case the guest read the OpRegion + * register before writing to it, which means the guest supports + * an extended VBT. + */ + return opregion_vbt_pages; + } + if (!igd_guest_opregion) { return val; } @@ -247,11 +410,38 @@ uint32_t igd_read_opregion(XenPCIPassthroughState *s) =20 XEN_PT_LOG(&s->dev, "Read opregion val=3D%x\n", val); return val; + +fallback: + XEN_PT_LOG(&s->dev, "Fallback to host OpRegion mapping\n"); + opregion_is_direct_mapped =3D true; + if (fp) { + fclose(fp); + } + g_free(opregion); + g_free(vbt); + return val; } =20 void igd_write_opregion(XenPCIPassthroughState *s, uint32_t val) { int ret; + static bool opregion_is_ioreq_mapped; + static unsigned long igd_guest_opregion_pgbase; + + if (opregion_is_ioreq_mapped && (val =3D=3D igd_guest_opregion)) { + /* + * To support Windows IGD drivers that don't work with the OpRegion + * and VBT when they are mapped to an ioreq server, hvmloader writ= es + * the value of igd_guest_opregion a second time to signal it is t= ime + * to unmap the OpRegion from the ioreq server. Hvmloader has made + * a copy of the OpRegion and will configure the guest to use its + * copy. In this way, the Windows IGD drivers work as expected. + */ + memory_region_del_subregion(get_system_memory(), &mr_opregion); + object_unparent(OBJECT(&mr_opregion)); + opregion_is_ioreq_mapped =3D false; + XEN_PT_LOG(&s->dev, "Successfully configured emulated OpRegion\n"); + } =20 if (igd_guest_opregion) { XEN_PT_LOG(&s->dev, "opregion register already been set, ignoring = %x\n", @@ -259,16 +449,73 @@ void igd_write_opregion(XenPCIPassthroughState *s, ui= nt32_t val) return; } =20 - /* We just work with LE. */ - xen_host_pci_get_block(&s->real_device, XEN_PCI_IGD_OPREGION, - (uint8_t *)&igd_host_opregion, 4); + if (!igd_host_opregion) { + /* We just work with LE. */ + xen_host_pci_get_block(&s->real_device, XEN_PCI_IGD_OPREGION, + (uint8_t *)&igd_host_opregion, 4); + opregion_is_direct_mapped =3D true; + } igd_guest_opregion =3D (unsigned long)(val & ~XEN_PCI_IGD_OPREGION_MAS= K) | (igd_host_opregion & XEN_PCI_IGD_OPREGION_MA= SK); + igd_guest_opregion_pgbase =3D igd_guest_opregion & + ~XEN_PCI_IGD_OPREGION_MASK; + + if (opregion_is_direct_mapped) { + XEN_PT_LOG(&s->dev, "hvmloader lacks extended VBT support, " + "continuing with legacy support only\n"); + /* + * In this case we need to direct map the OpRegion because either = we + * failed to get a copy of the OpRegion from the host filesystem or + * the guest does not support an extended VBT. In this case we also + * assume we need an extra page because the OpRegion is not always + * aligned on a page boundary. + */ + extra_opregion_pages =3D 1; + opregion_vbt_pages =3D XEN_PCI_IGD_OPREGION_PAGES + + extra_opregion_pages; + goto map; + } else { + Object *owner =3D OBJECT(&s->dev); + unsigned long rvda_guest =3D 0; /* VBT address in guest */ + + /* Compute rvda value for the guest */ + if (rvds && (version > 0x0200)) { + if (version =3D=3D 0x0200) { + rvda_guest =3D igd_guest_opregion + + (XEN_PCI_IGD_OPREGION_PAGES << XC_PAGE_SHIFT); + } else { + /* Convert to relative address */ + rvda_guest =3D XEN_PCI_IGD_OPREGION_PAGES << XC_PAGE_SHIFT; + rvda_host -=3D igd_host_opregion; + } + } + + /* Patch the OpRegion with the correct rvda value for the guest */ + if (rvds && (rvda_guest !=3D rvda_host)) { + *(unsigned long *)(opregion_vbt + (igd_guest_opregion & + XEN_PCI_IGD_OPREGION_MASK) + + XEN_PCI_IGD_OPREGION_RVDA) =3D rvda_guest; + XEN_PT_LOG(&s->dev, "Patched OpRegion with guest rvda =3D 0x%l= x\n", + rvda_guest); + } + + /* Configure ioreq server for the emulated OpRegion */ + memory_region_init_ram(&mr_opregion, owner, "xen.intel.opregion", + opregion_vbt_pages << XC_PAGE_SHIFT, + &error_fatal); + memory_region_add_subregion(get_system_memory(), + igd_guest_opregion_pgbase, &mr_opregio= n); + void *ptr =3D memory_region_get_ram_ptr(&mr_opregion); + memcpy(ptr, (void *)opregion_vbt, opregion_vbt_pages << XC_PAGE_SH= IFT); + g_free(opregion_vbt); + opregion_is_ioreq_mapped =3D true; + return; + } =20 +map: ret =3D xc_domain_iomem_permission(xen_xc, xen_domid, (unsigned long)(igd_host_opregion >> XC_PAGE_SHIFT), - XEN_PCI_IGD_OPREGION_PAGES, - XEN_PCI_IGD_OPREGION_ENABLE_ACCESSED); + opregion_vbt_pages, XEN_PCI_IGD_OPREGION_ENABLE_ACCESSED); =20 if (ret) { XEN_PT_ERR(&s->dev, "[%d]:Can't enable to access IGD host opregion= :" @@ -281,8 +528,7 @@ void igd_write_opregion(XenPCIPassthroughState *s, uint= 32_t val) ret =3D xc_domain_memory_mapping(xen_xc, xen_domid, (unsigned long)(igd_guest_opregion >> XC_PAGE_SHIFT), (unsigned long)(igd_host_opregion >> XC_PAGE_SHIFT), - XEN_PCI_IGD_OPREGION_PAGES, - DPCI_ADD_MAPPING); + opregion_vbt_pages, DPCI_ADD_MAPPING); =20 if (ret) { XEN_PT_ERR(&s->dev, "[%d]:Can't map IGD host opregion:0x%lx to" diff --git a/include/hw/xen/xen_igd.h b/include/hw/xen/xen_igd.h index 469171c..e66b3a3 100644 --- a/include/hw/xen/xen_igd.h +++ b/include/hw/xen/xen_igd.h @@ -13,7 +13,7 @@ =20 #define XEN_PCI_IGD_OPREGION 0xfc #define XEN_PCI_IGD_OPREGION_MASK 0xfff -#define XEN_PCI_IGD_OPREGION_PAGES 0x3 +#define XEN_PCI_IGD_OPREGION_PAGES 0x2 #define XEN_PCI_IGD_OPREGION_ENABLE_ACCESSED 0x1 #define XEN_PCI_IGD_OPREGION_SIGNATURE "IntelGraphicsMem" #define XEN_PCI_IGD_VBT_SIGNATURE "$VBT" --=20 2.52.0 From nobody Thu Sep 24 19:43:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=aol.com ARC-Seal: i=1; a=rsa-sha256; t=1789111561; cv=none; d=zohomail.com; s=zohoarc; b=HeQ3I79Lox92829V2d5pzFiIjNQ54dWzD2YJpkvHlNg+TA5HyXCvWj7g/BBq/WPHV5fUrqLTEOFZ487ZNHmmDLaHk8tv6KVkAcac4qCKkCliq6lX4jjgZPTnHJE8iQtmKKdhkwkHUc4q7sxugRwhBnlTF2PAus3xDh9zYtNuvpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789111561; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/3QUpHGBKJbXOgu22YsrlVzjiLJDOg/MMxR0FeGG6pI=; b=bFvBdANoVKDO0EPFSigi77p/xaIKHJKrr11fV2pmyRBZXML9WIc/jTOkZNDHihpOrDwU6W3YgGN3xq8pavVfd17u4lSzVBcioaq9Uhy6r+ki+b6zQ2lLdR+ITtnd+911CrqmKW9H5NJa3jH9G19jVPJjMWT/iq7Q/HjWB17YBdo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178911156135190.30901673242647; Fri, 11 Sep 2026 00:26:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4vdU-0008B2-V6; Fri, 11 Sep 2026 03:25:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4vdM-00088y-1e for qemu-devel@nongnu.org; Fri, 11 Sep 2026 03:25:16 -0400 Received: from sonic304-23.consmr.mail.gq1.yahoo.com ([98.137.68.204]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4vdJ-0008CM-N4 for qemu-devel@nongnu.org; Fri, 11 Sep 2026 03:25:15 -0400 Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Sep 2026 07:25:11 +0000 Received: by hermes--production-bf1-54b5569bdc-fv65m (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4451c0cd4386c4b1051306e68eb9ea1; Fri, 11 Sep 2026 07:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1789111511; bh=/3QUpHGBKJbXOgu22YsrlVzjiLJDOg/MMxR0FeGG6pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=QzLynmg1rRqy0YClCOWLrr8VWVC6sWeJSBGxWL6YF6ByqXU4gz3UFrD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p8MPNUT08HYGW.r4zWSUIzon.2xjnlCEsBkOTiGsH6D_oVLvbFiu4a9J0GX5uSb4mpid.LDLexs 9r9AOvB3F5C.7RHpGmlfXqNo4KcAlY14wsYA1Oc2gjWWM1k8fk6jt3012uulM.Wlt7iQOEsRvQvu ffEPxHGt5peIDve_Ngn4XPJ22AgUaBSFSiDvaHHcdNW_Ls_Epfx9dJP22RzGAtKTjO289hNWWfSj jXATt5Zx9VWnnPkpBzOEsuB1ThkySY4DLfofOh9pDBNMlxQCBelddd5AJwfPV1D.ogUEauarhvbz ZUr0R_QjX6EAoEaJ9o5mZJsP4j7WglWvxi7byKLJ1_APzEOC7kcamaoShdi.NaM7Y9yDxR6yv7Fi HpFQoa6YU6AjDf7UlCb81gkLLOECXL.VWXcK699HH98uMkdwhIYwHUw04OSRJcuqNS47KwPbDhVA rUcND9SS9YKR9jpzcLRjVdjHfiq8J13rd9BCq0OwoU8kwSpnpp9ZMT5y5EWmikAOq97CBZGSt9jM _FpFF5SXIPZ57U74UZ4PsPAGDaFPZmo5E6eYkscFnf6c0qZ4cOwpsypR3WYbWbQzsnnkPCawjNwc ckZC6Qhv_k3L5o9v8hW6I_mKOLcGqE94o3w9pFsH1R04OrbYhL2E4nZvTyxzvh6SOS7SWTpyR9Lb e_fd36IK.ICTB8XxPRhZI_aO3klCqffAbmvw1MtspGD7HPAURRTdIC1Ymrzig8FFZqlQeysiUex6 NAO17PvGdsPm9ZdDw_N5x33.ay63SipsSCmt7kQ4btMb83HnggaR.1yd31vjKmKOXNfAIj_yPvwf M5VPQ19qF8fqwJrOiFKAZhzj.OAlUYU86.ndcP5QYkIL2yUpbww1D2T8EunkDkBCLUe6ClOjioYa s4UnnCDsC2GNsHdAneIkjmFSNYFTxP.Z6PEx4aA-- X-Sonic-MF: X-Sonic-ID: 325b1927-76c2-4939-b9b7-27b409399d56 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" , Tomita Moeko Subject: [PATCH v6 7/7] xen/igd: use custom option ROM if provided Date: Fri, 11 Sep 2026 03:24:53 -0400 Message-ID: <20260911072453.46256-8-brchuckz@aol.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260911072453.46256-1-brchuckz@aol.com> References: <20260911072453.46256-1-brchuckz@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 9057 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=98.137.68.204; envelope-from=brchuckz@aol.com; helo=sonic304-23.consmr.mail.gq1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1789111564049158500 Content-Type: text/plain; charset="utf-8" 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 v6: - Added a link to Tomita's edk2 patches for the OvmfX64 platform for KVM/VFIO guests in this additional notes section Changes in v5: - Fix wrong whitespace in three places in a conditional block Changes in v4: - v4 is the first version of the series that has this patch 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/PosixLi= ke/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=20 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/tomitamoeko/VfioIgdPkg 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 f136f13..ab448f4 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 =3D NULL; Object *owner =3D OBJECT(dev); + g_autofree const char *fname =3D g_strdup("igd.rom"); + g_autofree const char *path =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, fn= ame); + bool sysfs =3D false; =20 /* If loading ROM from file, pci handles it */ if (dev->romfile || !dev->rom_bar) { return NULL; } =20 - 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 =3D true; + XEN_PT_LOG(dev, "Using Intel IGD romfile from host sysfs\n"); + } =20 - /* Write "1" to the ROM file to enable it */ fp =3D fopen(rom_file, "r+"); if (fp =3D=3D NULL) { if (errno !=3D ENOENT) { @@ -55,10 +66,14 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, goto close_rom; } =20 - val =3D 1; - if (fwrite(&val, 1, 1, fp) !=3D 1) { - goto close_rom; + /* Write "1" to the ROM file to enable it if using ROM from sysfs */ + if (sysfs) { + val =3D 1; + if (fwrite(&val, 1, 1, fp) !=3D 1) { + goto close_rom; + } } + fseek(fp, 0, SEEK_SET); =20 if (dev->romsize !=3D UINT_MAX) { @@ -83,11 +98,13 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, =20 *size =3D st.st_size; close_rom: - /* Write "0" to disable ROM */ - fseek(fp, 0, SEEK_SET); - val =3D 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 =3D 0; + if (!fwrite(&val, 1, 1, fp)) { + XEN_PT_WARN(dev, "%s\n", "Failed to disable pci-sysfs rom file= "); + } } fclose(fp); =20 --=20 2.52.0