From patchwork Wed Oct 26 17:00:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 13020896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80461C38A2D for ; Wed, 26 Oct 2022 17:01:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.430700.682664 (Exim 4.92) (envelope-from ) id 1onjlp-0006Ai-61; Wed, 26 Oct 2022 17:00:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 430700.682664; Wed, 26 Oct 2022 17:00:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1onjlp-0006AY-1y; Wed, 26 Oct 2022 17:00:49 +0000 Received: by outflank-mailman (input) for mailman id 430700; Wed, 26 Oct 2022 17:00:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1onjln-0006A5-QI for xen-devel@lists.xenproject.org; Wed, 26 Oct 2022 17:00:47 +0000 Received: from sonic308-55.consmr.mail.gq1.yahoo.com (sonic308-55.consmr.mail.gq1.yahoo.com [98.137.68.31]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ba1a1f97-554f-11ed-91b5-6bf2151ebd3b; Wed, 26 Oct 2022 19:00:45 +0200 (CEST) Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Wed, 26 Oct 2022 17:00:42 +0000 Received: by hermes--production-ne1-c47ffd5f5-8c2cz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 93f63f5da119448f595de422776c389f; Wed, 26 Oct 2022 17:00:38 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ba1a1f97-554f-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1666803642; bh=eU7PpBLLODdhmYNTWitUDr6syhPI4x30puQr0AkwZn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=JNWP5RxiSEimCPsFJEl5ySrpR8ZaHnJfgcTFBWhbHjxa+DX+yv6qC507mCEFdXj4/5qw9+e+sJD3nJgbF3jvpqbggjXIU6S0u9IzPaTBCIaufbrPLAWwxF6E/MpNiwtbZDFJ9H/N4+hd+V3eRGrbKyLh45olIAZu0D1lFyhzP1zlMoAvrx4m0Wg/f4sXw0yShsnFHWki+lppr6yAe+6P2yqp+/SFiRihd9lYQubx6sEB3q5uJhSk1Vd6rLpHo35abuciG1TlYlhg1e25xb22wMH5HSa1VbUdd9dHc7rpNCLs0UZb4+70twf1G8C3ZPxmvXF5C+crj7/Qj1tnZ0pkQg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666803642; bh=FXj5u+59eDkG4z/KjVnwtjqV21VAHHrc8/npF8OKk4t=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=HUpTDXsO1/GSukqr3jTqsIL846hT4f4YfXtyBNVwLcjf/31l7VEHy+PZv+ScLGacBqJi5sHrRBCxxR2tDLGVPg3YpTco5SrKJsi1Jww8A+H2nOR/nbF9VSC4hn9ai1yjDxwnAMrqzwUw6ldJAAyx27sfjo5b70LX5aYbkN0e6VcciaoSmw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et6OvwE5qsqIK7J4 V4ttTU6aXBStkx7gX_PCMxjyuHPFrF2GFjyo7_EwJ2MNGmMhUp1jGhtNyQisZ_E8nemsXnqnKEEH sFiJ25iTG7jeGIUZ.2xOvIJX7t2AVq0VTVXutvW0F._OAmsN.05Qg.XXyEftdjP3fcPh5xzD8nO_ Zjt_chzcAXyv8MnxCWfxu3edbGnD0..pgiTrpNMAxx2twdHsVqWq6aRa_ssw5ZIDfe5FC7yqs6M7 nd1yToQ6Tef.1N1BKv4ZPuNKM1Q0WQDeLhRny.Az1xOJge5e0x2wRGilz75AruBcu6NduQsPJAtI 3jKuupKt6 X-Sonic-MF: From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org, Chuck Zmudzinski Subject: [PATCH v3 1/2] xen/pt: fix syntax error that causes FTBFS in some configurations Date: Wed, 26 Oct 2022 13:00:26 -0400 Message-Id: <1b63dcf10b2e99c6dba5f0c9b16bac3ac58d3848.1666802059.git.brchuckz@netscape.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 When Qemu is built with --enable-xen and --disable-xen-pci-passthrough and the target os is linux, the build fails with: meson.build:3477:2: ERROR: File xen_pt_stub.c does not exist. Fixes: 582ea95f5f93 ("meson: convert hw/xen") Signed-off-by: Chuck Zmudzinski --- v2: Remove From: tag at top of commit message v3: No change to this patch since v2 hw/xen/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xen/meson.build b/hw/xen/meson.build index 08dc1f6857..ae0ace3046 100644 --- a/hw/xen/meson.build +++ b/hw/xen/meson.build @@ -18,7 +18,7 @@ if have_xen_pci_passthrough 'xen_pt_msi.c', )) else - xen_specific_ss.add('xen_pt_stub.c') + xen_specific_ss.add(files('xen_pt_stub.c')) endif specific_ss.add_all(when: ['CONFIG_XEN', xen], if_true: xen_specific_ss) From patchwork Wed Oct 26 17:00:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 13020895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B69AC433FE for ; Wed, 26 Oct 2022 17:01:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.430701.682668 (Exim 4.92) (envelope-from ) id 1onjlp-0006Dh-EC; Wed, 26 Oct 2022 17:00:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 430701.682668; Wed, 26 Oct 2022 17:00:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1onjlp-0006DE-9m; Wed, 26 Oct 2022 17:00:49 +0000 Received: by outflank-mailman (input) for mailman id 430701; Wed, 26 Oct 2022 17:00:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1onjlo-0006A5-Ce for xen-devel@lists.xenproject.org; Wed, 26 Oct 2022 17:00:48 +0000 Received: from sonic314-19.consmr.mail.gq1.yahoo.com (sonic314-19.consmr.mail.gq1.yahoo.com [98.137.69.82]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bb0df635-554f-11ed-91b5-6bf2151ebd3b; Wed, 26 Oct 2022 19:00:46 +0200 (CEST) Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.gq1.yahoo.com with HTTP; Wed, 26 Oct 2022 17:00:43 +0000 Received: by hermes--production-ne1-c47ffd5f5-8c2cz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 93f63f5da119448f595de422776c389f; Wed, 26 Oct 2022 17:00:40 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bb0df635-554f-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1666803643; bh=HXJgswFBRRtT9kaDj9qpnwme4wa3QKPBT14ZHv3IuAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=h2sC5ENKC6sY9lhvU1I21u4Jhkme4x/zyVVxVAanjFIqME+TnVLzTAqaHGlriTRjCPcN+AnOc/5W4PYDqUlbxygaYm+tVaD6kre+qdf5DZyjavwrQF7pe7yITcEifXt7mm4hwusT+gSuSFWSa9l8jfhcwaVROr9DQ9ImVaX0i1ke5yOQphSDubGAoeufSwU89k4/H0Ta/C54UD1de0XWcli6gM8u7I8H2snBhrs0/L8X9Lt/PvDPLg1OR+zAyAHD7lJt9kXqdfk/vZZVw030iFFwhYvrd+2ViWleZpw1/L2q4Jh/ccaRHy5wAAZQaVdjy18lLHPt7CeiWyiN5LTYzQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1666803643; bh=hI/bVGYJ937dVcuMfGwaxi78BNd+35SdIf3yn2Pl+fy=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=HcJO0HuRj1berk1VgSley9XOCw0PmJRq1kjQw8BeJTGfuHEEcrDdv7GXdiQshQ7YzBcNDTib0XEcbSD//Vtq0tgWosdXhfJxO0BgMqZ2ByJztrvyWzPPoyx/5rTg3m0UsFW70R4zhf0/xtU1LefPA/EyBFxWOrvocNzI6yofKNDW0TGsi9vEdahePJMOhR824X3uJoVeyrWuTsNcGzIU4un1I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rATc.LhEiSV2NWkeXItazFTJ8C4StSDu_p ZX8pOqcSBoUEEhRjO3o5yWhpvCOzcqERB6pkaWm4.R6mDCtua98AnSRj91.3XjC9tmL7kq2lGeA9 RMBOFQZPkDnyv2.TjBuE2cghITNxt9X17G3e3n8pHVTTSbWFV6e58fKxQgzkZHO_dgwICSPmsq.J PIvVV45tWGZK9rjUJpbuTaWzj9WtTJOdq4q9VbQCuGeJzGRU9vZrpKM5ZoBN8kwpO2v1qZ8P53GU XvaetrS2E55Dm X-Sonic-MF: From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , xen-devel@lists.xenproject.org, Chuck Zmudzinski Subject: [PATCH v3 2/2] xen/pt: reserve PCI slot 2 for Intel igd-passthru Date: Wed, 26 Oct 2022 13:00:27 -0400 Message-Id: <69ddfbd373a61dc3ec29b405191abf5eaa9a2650.1666802059.git.brchuckz@netscape.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Intel specifies that the Intel IGD must occupy slot 2 on the PCI bus, as noted in docs/igd-assign.txt in the Qemu source code. Currently, when the xl toolstack is used to configure a Xen HVM guest with Intel IGD passthrough to the guest with the Qemu upstream device model, a Qemu emulated PCI device will occupy slot 2 and the Intel IGD will occupy a different slot. This problem often prevents the guest from booting. The only available workaround is not good: Configure Xen HVM guests to use the old and no longer maintained Qemu traditional device model available from xenbits.xen.org which does reserve slot 2 for the Intel IGD. To implement this feature in the Qemu upstream device model for Xen HVM guests, introduce the following new class, functions, types, and macros: * XEN_PT_DEVICE_CLASS declaration, based on the existing TYPE_XEN_PT_DEVICE * XEN_PT_DEVICE_GET_CLASS macro helper function for XEN_PT_DEVICE_CLASS * typedef XenPTQdevRealize function pointer * XEN_PCI_IGD_SLOT_MASK, the value of slot_reserved_mask to reserve slot 2 * xen_igd_reserve_slot and xen_igd_clear_slot functions The new xen_igd_reserve_slot function uses the existing slot_reserved_mask member of PCIBus to reserve PCI slot 2 for Xen HVM guests configured using the xl toolstack with the gfx_passthru option enabled, which sets the igd-passthru=on option to Qemu for the Xen HVM machine type. The new xen_igd_reserve_slot function also needs to be implemented in hw/xen/xen_pt_stub.c to prevent FTBFS during the link stage for the case when Qemu is configured with --enable-xen and --disable-xen-pci-passthrough, in which case it does nothing. The new xen_igd_clear_slot function overrides qdev->realize of the parent PCI device class to enable the Intel IGD to occupy slot 2 on the PCI bus since slot 2 was reserved by xen_igd_reserve_slot when the PCI bus was created in hw/i386/pc_piix.c for the case when igd-passthru=on. Signed-off-by: Chuck Zmudzinski --- Notes that might be helpful to reviewers of patched code in hw/xen: The new functions and types are based on recommendations from Qemu docs: https://qemu.readthedocs.io/en/latest/devel/qom.html Notes that might be helpful to reviewers of patched code in hw/i386: The small patch to hw/i386/pc_piix.c is protected by CONFIG_XEN so it does not affect builds that do not have CONFIG_XEN defined. xen_igd_gfx_pt_enabled() in the patched hw/i386/pc_piix.c file is an existing function that is only true when Qemu is built with xen-pci-passthrough enabled and the administrator has configured the Xen HVM guest with Qemu's igd-passthru=on option. v2: Remove From: tag at top of commit message v3: Changed the test for the Intel IGD in xen_igd_clear_slot: if (is_igd_vga_passthrough(&s->real_device) && (s->real_device.vendor_id == PCI_VENDOR_ID_INTEL)) { is changed to if (xen_igd_gfx_pt_enabled() && (s->hostaddr.slot == 2) && (s->hostaddr.function == 0)) { I hoped that I could use the test in v2, since it matches the other tests for the Intel IGD in Qemu and Xen, but those tests do not work because the necessary data structures are not set with their values yet. So instead use the test that the administrator has enabled gfx_passthru and the device address on the host is 02.0. This test does detect the Intel IGD correctly. Sorry for the extra noise. hw/i386/pc_piix.c | 3 +++ hw/xen/xen_pt.c | 25 +++++++++++++++++++++++++ hw/xen/xen_pt.h | 16 ++++++++++++++++ hw/xen/xen_pt_stub.c | 4 ++++ 4 files changed, 48 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 0b1a79c0fa..a0f04ad62e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -402,6 +402,9 @@ static void pc_xen_hvm_init(MachineState *machine) } pc_xen_hvm_init_pci(machine); + if (xen_igd_gfx_pt_enabled()) { + xen_igd_reserve_slot(pcms->bus); + } pci_create_simple(pcms->bus, -1, "xen-platform"); } #endif diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 0ec7e52183..c62f03dd9f 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -950,11 +950,35 @@ static void xen_pci_passthrough_instance_init(Object *obj) PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS; } +void xen_igd_reserve_slot(PCIBus *pci_bus) +{ + XEN_PT_LOG(0, "Reserving PCI slot 2 for IGD\n"); + pci_bus->slot_reserved_mask |= XEN_PCI_IGD_SLOT_MASK; +} + +static void xen_igd_clear_slot(DeviceState *qdev, Error **errp) +{ + PCIDevice *pci_dev = (PCIDevice *)qdev; + XenPCIPassthroughState *s = XEN_PT_DEVICE(pci_dev); + XenPTDeviceClass *xptc = XEN_PT_DEVICE_GET_CLASS(s); + PCIBus *pci_bus = pci_get_bus(pci_dev); + + if (xen_igd_gfx_pt_enabled() && (s->hostaddr.slot == 2) + && (s->hostaddr.function == 0)) { + pci_bus->slot_reserved_mask &= ~XEN_PCI_IGD_SLOT_MASK; + XEN_PT_LOG(pci_dev, "Intel IGD found, using slot 2\n"); + } + xptc->pci_qdev_realize(qdev, errp); +} + static void xen_pci_passthrough_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + XenPTDeviceClass *xptc = XEN_PT_DEVICE_CLASS(klass); + xptc->pci_qdev_realize = dc->realize; + dc->realize = xen_igd_clear_slot; k->realize = xen_pt_realize; k->exit = xen_pt_unregister_device; k->config_read = xen_pt_pci_read_config; @@ -977,6 +1001,7 @@ static const TypeInfo xen_pci_passthrough_info = { .instance_size = sizeof(XenPCIPassthroughState), .instance_finalize = xen_pci_passthrough_finalize, .class_init = xen_pci_passthrough_class_init, + .class_size = sizeof(XenPTDeviceClass), .instance_init = xen_pci_passthrough_instance_init, .interfaces = (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h index e7c4316a7d..40b31b5263 100644 --- a/hw/xen/xen_pt.h +++ b/hw/xen/xen_pt.h @@ -3,6 +3,7 @@ #include "hw/xen/xen_common.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "xen-host-pci-device.h" #include "qom/object.h" @@ -41,7 +42,20 @@ typedef struct XenPTReg XenPTReg; #define TYPE_XEN_PT_DEVICE "xen-pci-passthrough" OBJECT_DECLARE_SIMPLE_TYPE(XenPCIPassthroughState, XEN_PT_DEVICE) +#define XEN_PT_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(XenPTDeviceClass, klass, TYPE_XEN_PT_DEVICE) +#define XEN_PT_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(XenPTDeviceClass, obj, TYPE_XEN_PT_DEVICE) + +typedef void (*XenPTQdevRealize)(DeviceState *qdev, Error **errp); + +typedef struct XenPTDeviceClass { + PCIDeviceClass parent_class; + XenPTQdevRealize pci_qdev_realize; +} XenPTDeviceClass; + 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); @@ -76,6 +90,8 @@ typedef int (*xen_pt_conf_byte_read) #define XEN_PCI_INTEL_OPREGION 0xfc +#define XEN_PCI_IGD_SLOT_MASK 0x4UL /* Intel IGD slot_reserved_mask */ + typedef enum { XEN_PT_GRP_TYPE_HARDWIRED = 0, /* 0 Hardwired reg group */ XEN_PT_GRP_TYPE_EMU, /* emul reg group */ diff --git a/hw/xen/xen_pt_stub.c b/hw/xen/xen_pt_stub.c index 2d8cac8d54..5c108446a8 100644 --- a/hw/xen/xen_pt_stub.c +++ b/hw/xen/xen_pt_stub.c @@ -20,3 +20,7 @@ void xen_igd_gfx_pt_set(bool value, Error **errp) error_setg(errp, "Xen PCI passthrough support not built in"); } } + +void xen_igd_reserve_slot(PCIBus *pci_bus) +{ +}