From nobody Tue Feb 10 03:42:18 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1656930488; cv=none; d=zohomail.com; s=zohoarc; b=LFJxB6KcEB5QVyAfl4Z8pAJb4pbMk2NxI9recWkf0aKrOwwVw0qbjknJqz/lQVcZxRl6PHKWewgX0XV3cu18q9DbM7QbdjwNN9/L1edttMHpxAHxvDip27UZOWzs4OGfXeQsPaZ/WG4PNvHN/ADL5h78jxh28sBgBTI1yQI0qFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656930488; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=jDOj5wB7NWueA28G/45o222UGAg+U1GiVycZHoTVMTs=; b=d/cHCx75AM/DS5StAvQ1hSDzciU5Ao3lk1ZEZ716sk98Y0pbIuZorgO5dFznTxdknsp1RXxoo1iexzysUJtw2tkqw2iF/kHcAhD9EGUPVENvIHTrPckkAgIRAwKjt0dlXbNvo2rxN28gVutrBfOarqstmW96C+zCOjpDmhz3pzo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1656930488384291.8725301272283; Mon, 4 Jul 2022 03:28:08 -0700 (PDT) Received: from localhost ([::1]:35942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8JJH-0006M9-88 for importer@patchew.org; Mon, 04 Jul 2022 06:28:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8JGs-0004QU-KK for qemu-devel@nongnu.org; Mon, 04 Jul 2022 06:25:39 -0400 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]:38136) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8JGf-0004Ui-Lg for qemu-devel@nongnu.org; Mon, 04 Jul 2022 06:25:29 -0400 Received: from vla3-850de775f4df.qloud-c.yandex.net (vla3-850de775f4df.qloud-c.yandex.net [IPv6:2a02:6b8:c15:341d:0:640:850d:e775]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id C6F9B2E11B3; Mon, 4 Jul 2022 13:25:15 +0300 (MSK) Received: from vla5-d6d5ce7a4718.qloud-c.yandex.net (vla5-d6d5ce7a4718.qloud-c.yandex.net [2a02:6b8:c18:341e:0:640:d6d5:ce7a]) by vla3-850de775f4df.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id YLpcwSQTU2-PFJCDQ8s; Mon, 04 Jul 2022 13:25:15 +0300 Received: from rvkaganb.yandex-team.ru (unknown [2a02:6b8:b081:b689::1:26]) by vla5-d6d5ce7a4718.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id p2UjVvhT27-PFU44qct; Mon, 04 Jul 2022 13:25:15 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 2 Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1656930315; bh=jDOj5wB7NWueA28G/45o222UGAg+U1GiVycZHoTVMTs=; h=Cc:Message-Id:Date:Subject:To:From; b=hR4H6WvuHHxIyGSNa3RHElQQ2oRA6O/t68VcFccvySlQQni66sKJqYm5kEtirAqkG drSO3Rj6AKl0QyBV2UB3Z2AVIzAiGIZAA8rn3QiOWKGss46wpBhWdc+6ZQnEVe4w3t ysvcQjSCNYb3s0SWX1MeVFhZ6FcVcCxGg4OEbkUY= Authentication-Results: vla3-850de775f4df.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Roman Kagan To: qemu-devel@nongnu.org Cc: Marcel Apfelbaum , yc-core@yandex-team.ru, "Michael S. Tsirkin" Subject: [PATCH] hw/pci/pci_bridge: ensure PCIe slots have only one slot Date: Mon, 4 Jul 2022 13:25:14 +0300 Message-Id: <20220704102514.1284827-1-rvkagan@yandex-team.ru> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a02:6b8:0:1a2d::193; envelope-from=rvkagan@yandex-team.ru; helo=forwardcorp1o.mail.yandex.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1656930491345100001 Content-Type: text/plain; charset="utf-8" It's possible to create non-working configurations by attaching a device to a derivative of PCIe slot (pcie-root-port, ioh3420, etc) and specifying a slot number other that zero, e.g.: -device pcie-root-port,id=3Ds0,... \ -device virtio-blk-pci,bus=3Ds0,addr=3D4,... Make QEMU reject such configurations and only allow addr=3D0 on the secondary bus of a PCIe slot. Signed-off-by: Roman Kagan --- hw/pci/pci_bridge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index da34c8ebcd..8b38d5ad3d 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -33,6 +33,7 @@ #include "qemu/units.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" +#include "hw/pci/pcie_port.h" #include "qemu/module.h" #include "qemu/range.h" #include "qapi/error.h" @@ -386,6 +387,10 @@ void pci_bridge_initfn(PCIDevice *dev, const char *typ= ename) br->windows =3D pci_bridge_region_init(br); QLIST_INIT(&sec_bus->child); QLIST_INSERT_HEAD(&parent->child, sec_bus, sibling); + + if (PCIE_SLOT(dev)) { + sec_bus->slot_reserved_mask =3D ~1u; + } } =20 /* default qdev clean up function for PCI-to-PCI bridge */ --=20 2.36.1