From patchwork Mon Oct 31 21:35:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 13026370 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 C01FFFA3741 for ; Mon, 31 Oct 2022 21:36:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.433214.686110 (Exim 4.92) (envelope-from ) id 1opcS7-0006Pd-0B; Mon, 31 Oct 2022 21:36:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 433214.686110; Mon, 31 Oct 2022 21:36:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1opcS6-0006PW-TG; Mon, 31 Oct 2022 21:36:14 +0000 Received: by outflank-mailman (input) for mailman id 433214; Mon, 31 Oct 2022 21:36:13 +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 1opcS4-0006AC-Ta for xen-devel@lists.xenproject.org; Mon, 31 Oct 2022 21:36:13 +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 07bcad9e-5964-11ed-91b5-6bf2151ebd3b; Mon, 31 Oct 2022 22:36:09 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Mon, 31 Oct 2022 21:36:07 +0000 Received: by hermes--production-ne1-c47ffd5f5-2l5gs (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1d450870d12d3f727fe97841ca3633d5; Mon, 31 Oct 2022 21:36:05 +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: 07bcad9e-5964-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1667252167; bh=IGznKk12GJy9mx+cAyxhAXw1kam3mqzoP8wC6G/UoSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=VfBFhH/IiUAMeyrtK6L++FniV0n17rJw2PDlx9wTqxSzCGXqld/wx3ZCHuYv4EB3chl8DM2EfZ7lGLmWR7YsHxj8o4S9a5gyq4fqslyVgaMYhYqhbb+sbnhgaRw+CMmvZ84iwssmV3QGMnqFX6new1EdpJSDsSrIbIWgkaLi+hL3szsFILOh9fBnZ6yRIUgk4CpsPJ8Sm1s5p+/wW8oaqrZkQz2/+jcOSKSZDj3DfVuphHBDEJavXJ8qZAgAAxsJ3W3qmyajWdDYd+xF6UW4Ia6XionhUi06HMWV/2mkxIs6+6nAPf40q/1+gfEyS+efJHYupXOKCZD9LyJEBTZjkg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1667252167; bh=s1nJndFclxPJHpwkBlsE/zVpQGSKg5nGaHWBSiMCA8a=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Cp5PvtCcXALvHl5fwKJQ/Y1ZWz5Q/k1wYOZTgsPKpNpUiSLQOfPqpsK3J8DIo+aMmJWWyXqp1LoOPlg2zbMpi0rmXo5HsWDnNMJYSQWtr2tsh6VYl21FlRYEFT04Et3TEMR6NezF5q33Kg3NPbtIff+o9vR1gP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x0H3LgkHlJJDcxKI yKoMuqe3_o1EcI423JSfLJ_1rvhEcxZ9wlYZkySmcpv1.FKD2EWuaRy_a7sIT87fyvvHaVmDZ74X JqJnfuv2zIb22mkpX5RgTG8JfMMCDJqK6vGm5ywTDxBQXlZTOM6qvoggX163tXEbP1lSL2MVCUhY 3cdi_kSxAYT9xjDUDKo_zD.OokNoaE12D42kt1Pp7ohapba5HtmfTqNbfKnlhdRaZ8CMhVHaYBzK M9a6I2E0oyvpRP5lGYDDsmvax9kxBto0g6ash5ejR0s_0LdWv1TmvEb.jmrwGf3eWS_eBxDeCy1E GPGd.a6uK X-Sonic-MF: From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v4 1/2] xen/pt: fix syntax error that causes FTBFS in some configurations Date: Mon, 31 Oct 2022 17:35:52 -0400 Message-Id: <5f1342a13c09af77b1a7b0aeaba5955bcea89731.1667242033.git.brchuckz@aol.com> 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 Reviewed-by: Philippe Mathieu-Daudé --- v2: Remove From: tag at top of commit message v3: No change to this patch since v2 v4: Use brchuckz@aol.com instead of brchuckz@netscape.net for the author's email address to match the address used by the same author in commits be9c61da and c0e86b76 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 Mon Oct 31 21:35:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Zmudzinski X-Patchwork-Id: 13026372 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 B41B6FA3746 for ; Mon, 31 Oct 2022 21:36:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.433215.686121 (Exim 4.92) (envelope-from ) id 1opcSB-0006gB-9M; Mon, 31 Oct 2022 21:36:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 433215.686121; Mon, 31 Oct 2022 21:36:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1opcSB-0006g2-5G; Mon, 31 Oct 2022 21:36:19 +0000 Received: by outflank-mailman (input) for mailman id 433215; Mon, 31 Oct 2022 21:36:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1opcS8-0006bP-WF for xen-devel@lists.xenproject.org; Mon, 31 Oct 2022 21:36:17 +0000 Received: from sonic306-21.consmr.mail.gq1.yahoo.com (sonic306-21.consmr.mail.gq1.yahoo.com [98.137.68.84]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0a7917e4-5964-11ed-8fd0-01056ac49cbb; Mon, 31 Oct 2022 22:36:14 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.gq1.yahoo.com with HTTP; Mon, 31 Oct 2022 21:36:11 +0000 Received: by hermes--production-ne1-c47ffd5f5-2l5gs (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1d450870d12d3f727fe97841ca3633d5; Mon, 31 Oct 2022 21:36:06 +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: 0a7917e4-5964-11ed-8fd0-01056ac49cbb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1667252171; bh=lUp3HSP1TAIWIvem3keOMtwYZCq25W+DMpaMWizwQ7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=NoGQygL4UHhKlwiW+SVvwQKD4IhNC1iniRVPGMuosQiVwzedgpi3nSTsrapsFpjzz71xayZaZDhqP+t72BuS+XSfIDkAjsfVhb2/rrI03pMJHY7lUMIzHdGl/UHHV9ZIvf3/mCwAPLdXbk8IrNvCFb9F32vafI4odYpQY1wCM/E2Rq2kt9alo8oOe/8b4CM94BmiUtQ0aJ3wUf7WIjdknl6NBBpWV/is4SK6xAEic5A22vND6G3hCa7igkJ29e2QdNLaaPc1RHoUFtmbdtQ+0TS6MwxGpN6pqX0Y4/uTNUO7Zu1V/GWw7QWsJDfUk+oQDND0H0Ygw6ZqgqMClbZCIQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1667252171; bh=lhYpS8kXk/l9ipGQjwGSK6jo6Jo0+l9WeUuGiT4eAyV=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=HQxPjhR0+gRN0vZ5kYsnd3tQNqcorKUJjnygvO+DLLxVXBM5C5oAY8zUqLTtCsC9fKGe6emW5GKa2YVHOm39rXFTeAnJpB4uyqd7yRq2c3qKJTHSEGJ/3BoeiATuGcdpNVmVu8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4nQGD 8vZaPqJSNJ55F0E1S.8AESKwjbJ8L4jeEGnUT23AoH40cyu3pCDoLrpt4qfqdO8raOclim_H8Kbb O6hpUOONhgeDjtPq3I03zw2Pj.hIn6ZyYrLGxJPq4Kh8MZ28nlIgORhJu2Sy0y1J.dj5b.0zdk1o icjEGfT1ZENqvv7sVadH5dauVuedHTTSWB_jYkXkJghehEWKK8V.9Ri0Ir4PEpRZ8CByoq9swjB8 HYmDD_HrTVVYw6UViuKAQ.k4a4RSbUATwFns8JsjNwkiyGa4vD0noRzKylKTRB_IBfiQWILC34jz C.9yy01UHU29Xwg-- 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 Subject: [PATCH v4 2/2] xen/pt: reserve PCI slot 2 for Intel igd-passthru Date: Mon, 31 Oct 2022 17:35:53 -0400 Message-Id: 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. v4: Use brchuckz@aol.com instead of brchuckz@netscape.net for the author's email address to match the address used by the same author in commits be9c61da and c0e86b76 Change variable for XEN_PT_DEVICE_CLASS: xptc changed to xpdc 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..50a63fe12e 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 *xpdc = 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"); + } + xpdc->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 *xpdc = XEN_PT_DEVICE_CLASS(klass); + xpdc->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) +{ +}