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 DB08EC3DA7D for ; Thu, 5 Jan 2023 21:20:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.472186.732322 (Exim 4.92) (envelope-from ) id 1pDXf4-0003FH-HE; Thu, 05 Jan 2023 21:20:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 472186.732322; Thu, 05 Jan 2023 21:20:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pDXf4-0003FA-E2; Thu, 05 Jan 2023 21:20:30 +0000 Received: by outflank-mailman (input) for mailman id 472186; Thu, 05 Jan 2023 21:20:29 +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 1pDXf2-0003F4-Ju for xen-devel@lists.xenproject.org; Thu, 05 Jan 2023 21:20:29 +0000 Received: from sonic314-20.consmr.mail.gq1.yahoo.com (sonic314-20.consmr.mail.gq1.yahoo.com [98.137.69.83]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c4b19715-8d3e-11ed-91b6-6bf2151ebd3b; Thu, 05 Jan 2023 22:20:26 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.gq1.yahoo.com with HTTP; Thu, 5 Jan 2023 21:20:23 +0000 Received: by hermes--production-bf1-5458f64d4-qthpt (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 3ae8c14202cbd65911d34094373944e4; Thu, 05 Jan 2023 21:20:18 +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: c4b19715-8d3e-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1672953623; bh=NA4PsefjDtPgPqtlyXz47iDncBWU1Smv50WH37X63KI=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From:Subject:Reply-To; b=FuoCFGtdpukvOkCciwKmcGKLHqacIweVRaRLWLwU/ULIdq6Pu+0E756V/cQbyzXvDRrdGIuyODdILXwdzsCiEj7i/mkKI74ewXvfN+xB88ZmcVAQHB/ZergsVg/MKma2vQyJCqI2/nNXF+dgLvnI88NNSEAGo4qpMryfwQCscbo/gXBgqwH3UiodD/6mVgWf0OdGvlwgF+1YIABOI2BF/cdzW2u27O6DQCN/ymMmYWlE3fSk+Aqfs0adwbQXgS4NzhmmUwBqm09rkytMwxVfhKXS0oexRIWqtdK+qdTXqRJggPetYKSkeHXzQXlWYunZ9I7LjA53inTRpKcODhtSGQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1672953623; bh=hof15gZ0OQwZiOINK1+nvXS3/ZOloYg/esR0maWeSKU=; h=X-Sonic-MF:Date:Subject:From:To:From:Subject; b=NstvfaDt1BeTqp4xp7OWIGZd03giDoK6wtR8WP1ENFFZGBuFOR+/C7nsC2IOXj5yH5HDwsRUcuNKQx/OsBW3uD45p9sIkzaSe23Dw5Cv1QZoc841snF82OlWkYWYAda8dROYKizVIAEgG0zprVAUWV9n78WUMkEQDP3PEDF7n740rtGmSIT20KGLUnWdUZ/3gjFnyay2bXu4tBD5Lp++dDFkjIeC8FLFpXcBSeRxThGj9/cEAnC8PSMqcPB60QQbj2oq6JF9fiTkF++FZ/9hLa/pX1Q5rUMhBW7clZD4W6/C4vy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h9LWovuTP4yjiYqUpkoab46lvyfQhPJEYf1Qm1R_LJaGJuBw9.pvdchb89CKiHuSp 62RgzEXWCA219_yLIBPkHGiZ8X87WNcfYFhJcdnuEjbYCWJPZvn9tRYlv_EyrUhLMUOhtJUZPUVo 6aUT0yYjOnvQWhKnM X-Sonic-MF: Message-ID: <32193041-ff39-fdc5-01b5-b6e390ed997e@aol.com> Date: Thu, 5 Jan 2023 16:20:15 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v6] xen/pt: reserve PCI slot 2 for Intel igd-passthru From: Chuck Zmudzinski To: Alex Williamson , Paul Durrant , "Michael S. Tsirkin" , Anthony Perard Cc: qemu-devel@nongnu.org, Stefano Stabellini , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , xen-devel@lists.xenproject.org References: <830263507e8f1a24a94f81909d5102c4b204e938.1672615492.git.brchuckz.ref@aol.com> <830263507e8f1a24a94f81909d5102c4b204e938.1672615492.git.brchuckz@aol.com> <20230102124605-mutt-send-email-mst@kernel.org> <20230103081456.1d676b8e.alex.williamson@redhat.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: WebService/1.1.20982 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol On 1/4/23 3:47 PM, Chuck Zmudzinski wrote: > On 1/3/23 10:14 AM, Alex Williamson wrote: > >> >> It's necessary to configure the assigned IGD at slot 2 to make it >> functional, yes, but I don't really understand this notion of >> "reserving" slot 2. If something occupies address 00:02.0 in the >> config, it's the user's or management tool's responsibility to move it >> to make this configuration functional. Why does QEMU need to play a >> part in reserving this bus address. IGD devices are not generally >> hot-pluggable either, so it doesn't seem we need to reserve an address >> in case an IGD device is added dynamically later. > > The capability to reserve a bus address for a quirky device need not > be limited to the case of hotplugged or dynamically added devices. The > igd is a quirky device, and its presence in an emulated system like > qemu requires special handling. The slot_reserved_mask member of PCIBus > is also well-suited to the case of quirky device like Intel the igd that > needs to be at slot 2. Just because it is not dynamically added later > does not change the fact that it needs special handling at its initial > configuration when the guest is being created. > >> > > Here's the problem that answers Michael's question why this patch is > specific to xen: > > ---snip--- > #ifdef CONFIG_XEN > > ... > > static void pc_xen_hvm_init(MachineState *machine) > { > PCMachineState *pcms = PC_MACHINE(machine); > > if (!xen_enabled()) { > error_report("xenfv machine requires the xen accelerator"); > exit(1); > } > > pc_xen_hvm_init_pci(machine); > pci_create_simple(pcms->bus, -1, "xen-platform"); > } > #endif > ---snip--- > > This code is from hw/i386/pc_piix.c. Note the call to > pci_create_simple to create the xen platform pci device, > which has -1 as the second argument. That -1 tells > pci_create_simple to autoconfigure the pci bdf address. > > It is *hard-coded* that way. That means no toolstack or > management tool can change it. And what is hard-coded here > is that the xen platform device will occupy slot 2, preventing > the Intel igd or any other device from occupying slot 2. > Actually, today I discovered it is possible to workaround this issue with libxl that appears to hard-code the xen platform device to slot 2. The code referenced here that effectively hard codes the xen platform device to slot 2 is only executed with the '-machine xenfv' qemu option, which is the default that libxl uses for hvm guests, but this behavior can be changed by setting xen_platform_pci = '0' in the xl guest configuration file, in which case libxl configures qemu with the '-machine pc,accel=xen' option instead, and then one can add the xen platform device at a different slot by adding, for example, device_model_args = ['-device','xen-platform,addr=03'] to the xl guest configuration file which adds the device at slot 3 instead of slot 2. This approach is an ugly workaround which has other side effects, such as by having -machine as pc,accel=xen instead of xenfv, the machine type is not exactly the same because the xenfv machine type is based on a much older version of qemu's i440fx emulation (qemu version 3.1 IIRC), so with this workaround there could be some unintended side effects, although I just tested this workaround and it does seem to work, but I have not been using this approach to the problem for very long. Also, this approach requires setting type=vif in the vif network setting of the xl guest configuration to suppress the creation of the qemu emulated network device that would grab slot 2 if it is created by the ordinary libxl network configuration settings and, for guests that do not have the xen pv network drivers installed, this also would require manually building the qemu command line using device_model_args to allow adding an emulated qemu network device at a different slot and probably also manually configuring the correct networking scripts outside of the normal xen networking scripts, because the ordinary xl guest configuration options do not have a setting for assigning an emulated qemu network device to a specific slot, and the device would otherwise grab slot 2. So,it is possible to configure the guest to have the Intel igd at slot 2 without patching either libxl or qemu, but it is a real PITA with some possible unintended side effects, and that is why I think patching qemu to reserve slot 2 is a much better solution to the problem. Kind regards, Chuck