From nobody Fri Apr 26 06:32:10 2024 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=1678766541; cv=none; d=zohomail.com; s=zohoarc; b=M37Pp8ZsLBfqmuV+ROKcZUNgpPXyznOlRxR2e9DrIWaaf3n/6jOABuolA2libpd+RR+LIa2jcw8KK2ZbQYQKB5AQdP0l/lFaJn6js8bAZtL7XhcP33Jl3wrp7PXfxS/c71+ltsoPsutLTF9kRyvm+K6GQnSa+1zP6zsqyBJR5kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678766541; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hfIkxSt+f+w40Cm5/M8txYvuJH0EIEq7wMJSl6CHjTc=; b=ccVYW+F9dL0urxYR/vEBlO1Xq2ZtLwwdLGwV8hDSvUJRSiDAXTBKg4OguY5Q7x5sH0djKBmsw22vIW36PTjDPnvPr9ZxfW8Kfl5FByMC4o/YgiDsVhCakITRlumAOqIrxh8oYslBF0pZkDsg6BhnABfXjVcxTuJPQhNBGqn8t7o= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678766541731849.7623954571236; Mon, 13 Mar 2023 21:02:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbvr2-0004KO-O9; Tue, 14 Mar 2023 00:01:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbvqw-0004JW-Ek for qemu-devel@nongnu.org; Tue, 14 Mar 2023 00:01:35 -0400 Received: from sonic313-21.consmr.mail.gq1.yahoo.com ([98.137.65.84]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pbvqr-00008S-OO for qemu-devel@nongnu.org; Tue, 14 Mar 2023 00:01:33 -0400 Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.gq1.yahoo.com with HTTP; Tue, 14 Mar 2023 04:01:23 +0000 Received: by hermes--production-ne1-759c9b8c64-fztnz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 76100b2c878269fd1c2471a41328eeeb; Tue, 14 Mar 2023 04:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1678766483; bh=hfIkxSt+f+w40Cm5/M8txYvuJH0EIEq7wMJSl6CHjTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=Hn2KFrOTdsWVmqwlYzlCNlDd6dqHo8PgxkHCnLsmTwWHW593iiSsON92yeIfmYVVMfA622tx9wvf7tDmz+5QgYzs+CyancqvLUGmBVKnP9lgNec7GbUdi9p5wzvFLpbVC1Fbc5dudbvZxqqqEAMm1+ONnz6m9HDd+hqCy2NKKYtxg9aFeRyJ368WyHfO2KPTh44SsNIDN4lgxwuS7UepDFW0hw4ASdAffV4Ps3TCUQsnct53crItSNwELd8A9DF+iDEPF/V0gOnQjNlYsauTJk5W5YPGmHvpNhSTgMuRMMtMeLbobCdusRQozSLK2FCpTkJRwQmUMzEoOa0b/eYqmg== X-SONIC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nIdZgwHQ_AiqYoYjR2m 9w7QOgrCpa1m.pP.KMMGpQmIHWN1rnF.qO70Bc8C6l4vqxsz5IjbaQEsT1DtnxwiMlmgq9y8NWUV 04LbHb2Z4HwWTGd.iPvgla7pCU__Vbp5pl54URt7TW4ynqPRTaLvsz_w1JpvkRNt6vSdwZZ9EVqW 54SFxeBQJMuKm.KwKdJYZHhslbrd4p6mSl5GOPUjBrh2gfgSkmaivMQ7IIz3P2OQnPbSqNsqqtfS eWPLQHfD3sJhq9wnxG5PBELMsO0HCGYIqGOmTIcbIn8OArp5aoiz93aoJpaHj03_0AZgIonW6WDJ zBWRpLw9ID2T0m40r6G.IgMn7lK.YJdmp4UMkJMR2No7ZBK6oEgAMk_NK4PyzmF9.84bHbL8jtjN D.eS9RuaGFjX9HUthTaFpqNfMU5Web6lljPpbEgH_KKOvBALw.iUqdpPOLE7Mg4t8C1tOBET6XWW smjghbpLkggqqOriVRCrDr9WMvXU8QBHH1KWMIda3rES7zrjK9brc0X1rLxQRm_FXvXN4k4otNtj 89nkIFCSrE6jcHzDoOkdC6EEIjJRC3mc8WUG1NRRhvbl_GYKlYCsSKjeHNmW5f1VhzEL4NjQj X-Sonic-MF: X-Sonic-ID: 511d7520-f088-48d5-93aa-9784919af414 From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Mark Cave-Ayland , Artyom Tarasenko , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v2 1/2] pci: avoid accessing slot_reserved_mask directly outside of pci.c Date: Tue, 14 Mar 2023 00:01:08 -0400 Message-Id: <7248ee8127e73299c53e38a635505033685787e0.1678763217.git.brchuckz@aol.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 4912 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=lists.gnu.org; Received-SPF: pass client-ip=98.137.65.84; envelope-from=brchuckz@aim.com; helo=sonic313-21.consmr.mail.gq1.yahoo.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1678766543948100008 Content-Type: text/plain; charset="utf-8" This patch provides accessor functions as replacements for direct access to slot_reserved_mask according to the comment at the top of include/hw/pci/pci_bus.h which advises that data structures for PCIBus should not be directly accessed but instead be accessed using accessor functions in pci.h. Three accessor functions can conveniently replace all direct accesses of slot_reserved_mask. With this patch, the new accessor functions are used in hw/sparc64/sun4u.c and hw/xen/xen_pt.c and pci_bus.h is removed from the included header files of the same two files. No functional change intended. Signed-off-by: Chuck Zmudzinski --- v2: This is the first version of this patch, it did not exist in v1. hw/pci/pci.c | 15 +++++++++++++++ hw/sparc64/sun4u.c | 7 +++---- hw/xen/xen_pt.c | 7 +++---- include/hw/pci/pci.h | 3 +++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index def5000e7b..8a87ccc8b0 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1116,6 +1116,21 @@ static bool pci_bus_devfn_reserved(PCIBus *bus, int = devfn) return bus->slot_reserved_mask & (1UL << PCI_SLOT(devfn)); } =20 +uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus) +{ + return bus->slot_reserved_mask; +} + +void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask) +{ + bus->slot_reserved_mask |=3D mask; +} + +void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask) +{ + bus->slot_reserved_mask &=3D ~mask; +} + /* -1 for devfn means auto assign */ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, const char *name, int devfn, diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index a25e951f9d..eae7589462 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -31,7 +31,6 @@ #include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/qdev-properties.h" #include "hw/pci-host/sabre.h" @@ -608,9 +607,9 @@ static void sun4uv_init(MemoryRegion *address_space_mem, /* Only in-built Simba APBs can exist on the root bus, slot 0 on busA = is reserved (leaving no slots free after on-board devices) however slo= ts 0-3 are free on busB */ - pci_bus->slot_reserved_mask =3D 0xfffffffc; - pci_busA->slot_reserved_mask =3D 0xfffffff1; - pci_busB->slot_reserved_mask =3D 0xfffffff0; + pci_bus_set_slot_reserved_mask(pci_bus, 0xfffffffc); + pci_bus_set_slot_reserved_mask(pci_busA, 0xfffffff1); + pci_bus_set_slot_reserved_mask(pci_busB, 0xfffffff0); =20 ebus =3D pci_new_multifunction(PCI_DEVFN(1, 0), true, TYPE_EBUS); qdev_prop_set_uint64(DEVICE(ebus), "console-serial-base", diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index 2d33d178ad..a540149639 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -57,7 +57,6 @@ #include =20 #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "xen_pt.h" @@ -951,7 +950,7 @@ void xen_igd_reserve_slot(PCIBus *pci_bus) } =20 XEN_PT_LOG(0, "Reserving PCI slot 2 for IGD\n"); - pci_bus->slot_reserved_mask |=3D XEN_PCI_IGD_SLOT_MASK; + pci_bus_set_slot_reserved_mask(pci_bus, XEN_PCI_IGD_SLOT_MASK); } =20 static void xen_igd_clear_slot(DeviceState *qdev, Error **errp) @@ -971,7 +970,7 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error= **errp) return; } =20 - if (!(pci_bus->slot_reserved_mask & XEN_PCI_IGD_SLOT_MASK)) { + if (!(pci_bus_get_slot_reserved_mask(pci_bus) & XEN_PCI_IGD_SLOT_MASK)= ) { xpdc->pci_qdev_realize(qdev, errp); return; } @@ -982,7 +981,7 @@ static void xen_igd_clear_slot(DeviceState *qdev, Error= **errp) s->real_device.dev =3D=3D XEN_PCI_IGD_DEV && s->real_device.func =3D=3D XEN_PCI_IGD_FN && s->real_device.vendor_id =3D=3D PCI_VENDOR_ID_INTEL) { - pci_bus->slot_reserved_mask &=3D ~XEN_PCI_IGD_SLOT_MASK; + pci_bus_clear_slot_reserved_mask(pci_bus, XEN_PCI_IGD_SLOT_MASK); XEN_PT_LOG(pci_dev, "Intel IGD found, using slot 2\n"); } xpdc->pci_qdev_realize(qdev, errp); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index d5a40cd058..935b4b91b4 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -287,6 +287,9 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq); void pci_bus_irqs_cleanup(PCIBus *bus); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); +uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus); +void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask); +void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask); /* 0 <=3D pin <=3D 3 0 =3D INTA, 1 =3D INTB, 2 =3D INTC, 3 =3D INTD */ static inline int pci_swizzle(int slot, int pin) { --=20 2.39.2 From nobody Fri Apr 26 06:32:10 2024 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=1678766545; cv=none; d=zohomail.com; s=zohoarc; b=AnvbCYvL7A2j41vEee1Nxu2ZuR6XeMeSWpcBm+ktXQJSo7bzZGvNvUXz7hdA7I1hNnSeQrMV9+7DzpR41cgR6xLVEo1pJd+xc5ZPg82n87314bxJrp+B+RhnerX1USp1iqVPMjy5XWT+SPeb+fH9wKUfkCAqex/DAFIMvENNfsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678766545; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yh7BMEzcRZJ+tv+RTBvmQkKgDEiGrGLXLZqIzDGAwlQ=; b=dDkbZbH1SWxdloh3fc5A4YWzFvR/uX7pgqIgvruoKPTU+GsrTjz5o4FBGRBLj9d5rHgaT6jkcEPe9T/ZS62os+cw/Ob8cgbCFOlrye0qX6IdLW0gfVR1ZvTZ80zL3UZjV0q1cjWn/f+n9fXYdpCb5PFn050XF+YzN3jQ2ZXDq/c= 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 1678766545670186.28002925056853; Mon, 13 Mar 2023 21:02:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.509443.785198 (Exim 4.92) (envelope-from ) id 1pbvqu-0003OR-6T; Tue, 14 Mar 2023 04:01:32 +0000 Received: by outflank-mailman (output) from mailman id 509443.785198; Tue, 14 Mar 2023 04:01:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pbvqu-0003Lv-0L; Tue, 14 Mar 2023 04:01:32 +0000 Received: by outflank-mailman (input) for mailman id 509443; Tue, 14 Mar 2023 04:01:30 +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 1pbvqs-0003Fb-7j for xen-devel@lists.xenproject.org; Tue, 14 Mar 2023 04:01:30 +0000 Received: from sonic315-8.consmr.mail.gq1.yahoo.com (sonic315-8.consmr.mail.gq1.yahoo.com [98.137.65.32]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e4f85328-c21c-11ed-87f5-c1b5be75604c; Tue, 14 Mar 2023 05:01:28 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.gq1.yahoo.com with HTTP; Tue, 14 Mar 2023 04:01:26 +0000 Received: by hermes--production-ne1-759c9b8c64-fztnz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 76100b2c878269fd1c2471a41328eeeb; Tue, 14 Mar 2023 04:01:20 +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" X-Inumbo-ID: e4f85328-c21c-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1678766486; bh=Yh7BMEzcRZJ+tv+RTBvmQkKgDEiGrGLXLZqIzDGAwlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=BEicIvdf4yOe9xOcm8CjCWj+mQCzTh3YK4u+fLIL8K0QUWMRAYGLjfvZ/F1KxH3KFEY+6lWNLaD8BmVYbeO6M3hz15RYLfvRUyIoKeDtq+9STwsPU4KTErzNlCXvIF/AsTptRBzD7ZtM4JgKNg4BsPnVAcOnjGKwHuB/Xlr4J0jeBf9kjbxaoeuD6lrTVMkf5+8PzRlEMJxNCD8BxvcjruUEQXSCMVC9bTixk/oKkkMYUEX6UBtD5ZwC4XtCG9+C3xDHuWZetnAFWapSpRYPPcuXjOFh+qz67hpkbz3ijQyUxP1alr0ZfsFO+nAmFMgKZwqBDDbV914iPYIwNgxtXw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1678766486; bh=1TjimQk1PnAKw1DHZs4ZFq5F31xo0tUPFSNrOyB2J0a=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=AO02/DkrBs0qhPCWCqMMJzT4PlajBIVUNh1FiSnJK0csPVvpy0t5iVk2f+WCoh0bVvnyyRAe+bpizzvwy0cjWYWX/EkbKoen86zPI7cTyyc1JYCXG/bR+Uzd0C+7CPpa0g185Xn7DmySBNquHs4YQR774OQkeEne6dD7/RLNi4T2dPyZDjlyCP5fAUr/uWPQp9NYOkcFgM5m7YVPFJ6lcfRnWcUlv4gB2+w8rrKE31+StUOTiIkfTKPg3u+QmM2WydtvtlvBOgn/UpsS6pN3MypsGZUWdKA6lNhIJ6YU8r/jRTAh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rTSCGaD3lkP6xO3zDZYeuSn hwPJJWyFL7nCyDuB6JZFWUboRbHPt1Rb1bPbtEPaXjtDAm.j_WX8cAOGK0isv92v_MfbaVgWkICL 19CVymnBOG9g_U5lgRIAZT8HgzKEFzQlqAC4dti1rlUSdbuID7w7byIXogI7qFIBVS75wsmd.VhI Vsjs- X-Sonic-MF: X-Sonic-ID: f36d0bbb-79cf-4dde-9e7b-8f81bf7803dc From: Chuck Zmudzinski To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Mark Cave-Ayland , Artyom Tarasenko , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v2 2/2] pci: allow slot_reserved_mask to be ignored with manual slot assignment Date: Tue, 14 Mar 2023 00:01:09 -0400 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Length: 5121 X-ZohoMail-DKIM: pass (identity @aol.com) X-ZM-MESSAGEID: 1678766546274100013 Content-Type: text/plain; charset="utf-8" Commit 4f67543bb8c5 ("xen/pt: reserve PCI slot 2 for Intel igd-passthru") uses slot_reserved_mask to reserve slot 2 for the Intel IGD for the xenfv machine when the guest is configured for igd-passthru. A desired extension to that commit is to allow use of the reserved slot if the administrator manually configures a device to use the reserved slot. Currently, slot_reserved_mask is enforced unconditionally. With this patch, the pci bus can be configured so the slot is only reserved if the pci device to be added to the bus is configured for automatic slot assignment. To enable the desired behavior of slot_reserved_mask machine, add a boolean member enforce_slot_reserved_mask_manual to struct PCIBus and add a function pci_bus_ignore_slot_reserved_mask_manual which can be called to change the default behavior of always enforcing slot_reserved_mask so, in that case, slot_reserved_mask is only enforced when the pci device being added is configured for automatic slot assignment. Call the new pci_bus_ignore_slot_reserved_mask_manual function after creating the pci bus for the pc/i440fx/xenfv machine type to implement the desired behavior of causing slot_reserved_mask to only apply when the pci device to be added to a pc/i440fx/xenfv machine is configured for automatic slot assignment. Link: https://lore.kernel.org/qemu-devel/20230106064838-mutt-send-email-mst= @kernel.org/ Signed-off-by: Chuck Zmudzinski --- Changelog v2: Change Subject of patch from "pci: add enforce_slot_reserved_mask_manual property" To "pci: allow slot_reserved_mask to be ignored with manual slot assignmen= t" Add pci_bus_ignore_slot_reserved_mask_manual function Call pci_bus_ignore_slot_reserved_mask_manual at appropriate place in hw/pci-host/i440fx.c hw/pci-host/i440fx.c | 1 + hw/pci/pci.c | 14 +++++++++++++- include/hw/pci/pci.h | 1 + include/hw/pci/pci_bus.h | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index 262f82c303..8e00b88926 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -257,6 +257,7 @@ PCIBus *i440fx_init(const char *pci_type, s =3D PCI_HOST_BRIDGE(dev); b =3D pci_root_bus_new(dev, NULL, pci_address_space, address_space_io, 0, TYPE_PCI_BUS); + pci_bus_ignore_slot_reserved_mask_manual(b); s->bus =3D b; object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 8a87ccc8b0..670ecc6986 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -501,6 +501,7 @@ static void pci_root_bus_internal_init(PCIBus *bus, Dev= iceState *parent, assert(PCI_FUNC(devfn_min) =3D=3D 0); bus->devfn_min =3D devfn_min; bus->slot_reserved_mask =3D 0x0; + bus->enforce_slot_reserved_mask_manual =3D true; bus->address_space_mem =3D address_space_mem; bus->address_space_io =3D address_space_io; bus->flags |=3D PCI_BUS_IS_ROOT; @@ -1116,6 +1117,17 @@ static bool pci_bus_devfn_reserved(PCIBus *bus, int = devfn) return bus->slot_reserved_mask & (1UL << PCI_SLOT(devfn)); } =20 +static bool pci_bus_devfn_reserved_manual(PCIBus *bus, int devfn) +{ + return bus->enforce_slot_reserved_mask_manual && + (bus->slot_reserved_mask & (1UL << PCI_SLOT(devfn))); +} + +void pci_bus_ignore_slot_reserved_mask_manual(PCIBus *bus) +{ + bus->enforce_slot_reserved_mask_manual =3D false; +} + uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus) { return bus->slot_reserved_mask; @@ -1164,7 +1176,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, "or reserved", name); return NULL; found: ; - } else if (pci_bus_devfn_reserved(bus, devfn)) { + } else if (pci_bus_devfn_reserved_manual(bus, devfn)) { error_setg(errp, "PCI: slot %d function %d not available for %s," " reserved", PCI_SLOT(devfn), PCI_FUNC(devfn), name); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 935b4b91b4..48d29ec234 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -287,6 +287,7 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, void pci_bus_map_irqs(PCIBus *bus, pci_map_irq_fn map_irq); void pci_bus_irqs_cleanup(PCIBus *bus); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); +void pci_bus_ignore_slot_reserved_mask_manual(PCIBus *bus); uint32_t pci_bus_get_slot_reserved_mask(PCIBus *bus); void pci_bus_set_slot_reserved_mask(PCIBus *bus, uint32_t mask); void pci_bus_clear_slot_reserved_mask(PCIBus *bus, uint32_t mask); diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 5653175957..e0f15ee9be 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -37,6 +37,7 @@ struct PCIBus { void *iommu_opaque; uint8_t devfn_min; uint32_t slot_reserved_mask; + bool enforce_slot_reserved_mask_manual; pci_set_irq_fn set_irq; pci_map_irq_fn map_irq; pci_route_irq_fn route_intx_to_irq; --=20 2.39.2