From nobody Sun Feb 8 09:30:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1648836530; cv=none; d=zohomail.com; s=zohoarc; b=mV37glxaYSURc0Z26WZEzJ2gbAJAHvtxnULdv2BWh3pVdO6d10ps/5BlaBNiMNehO3CnI+LFo0Kd8cmYW+1oUBMyYcleRwyCdXz6UBKVT10EggHe6Mxp8uTaIqUnSATE/0tLlGPW5+J/AxaE0TqlCWqlSV7ZEZ+2D3UPpKYF+5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648836530; h=Content-Type:Content-Transfer-Encoding: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=QQ4BMv+3OEmm8n23eF1Fg1DgWPwcNm7HW3VQnRmMFZc=; b=CUajCJZzWOfRVeYyLVBelFxWrIH4mzOKPGinmoNRBXNOU0isMRo/7hLYMv8nQy77+xYlI3or67kSPR/RJipkJLcTe3SBo5/KoOupDXu94c6Hoda1MLXXcFMfobfpkpyKLtaeIelIdFcbVBdu4uLv3dRdy0XF4FGPBc0nTTBgBvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1648836530983459.98914545515106; Fri, 1 Apr 2022 11:08:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-uUaa1bNKPNSntXxMqe8cYA-1; Fri, 01 Apr 2022 14:08:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D43FB100F81E; Fri, 1 Apr 2022 18:08:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3776414583CB; Fri, 1 Apr 2022 18:08:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E3AB81940350; Fri, 1 Apr 2022 18:08:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DA7C41947BBE for ; Fri, 1 Apr 2022 18:08:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BF26C111D7B6; Fri, 1 Apr 2022 18:08:38 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.40.193.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45A0A111D7B4 for ; Fri, 1 Apr 2022 18:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648836529; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QQ4BMv+3OEmm8n23eF1Fg1DgWPwcNm7HW3VQnRmMFZc=; b=AQcnbwU/YrB3l5t0aXAGrAKZQfsIbHxb2aoPCNnSGqLPjGEDKhnpdkaH06hh3A40JMTDwK YRmVGmOb/8jLh98N7gFLHKskjHRIu6Qjkm8LMPNglI/r/Gm7wxAqqi+D5AlXMEIb8UfiUS 2aKM96tHgB+7n9sckrI+9gEQX8JKeN4= X-MC-Unique: uUaa1bNKPNSntXxMqe8cYA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH v4 01/16] conf: Introduce VIR_PCI_CONNECT_INTEGRATED Date: Fri, 1 Apr 2022 20:08:20 +0200 Message-Id: <20220401180835.200444-2-abologna@redhat.com> In-Reply-To: <20220401180835.200444-1-abologna@redhat.com> References: <20220401180835.200444-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1648837435171100002 This new flag can be used to convince the PCI address assignment algorithm to place a device directly on the root bus. It will be used to implement support for virtio-iommu, which needs to be an integrated device in order to work correctly. Signed-off-by: Andrea Bolognani Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_addr.c | 17 +++++++++++++++++ src/conf/domain_addr.h | 26 +++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 49ca775a52..1173143635 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -303,6 +303,23 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddress= *addr, virErrorNumber errType =3D (fromConfig ? VIR_ERR_XML_ERROR : VIR_ERR_INTERNAL_ERROR= ); =20 + if (devFlags & VIR_PCI_CONNECT_INTEGRATED) { + if (addr->bus =3D=3D 0) { + /* pcie-root doesn't usually allow endpoint devices to be + * plugged directly into it, but for integrated devices + * that's exactly what we want */ + busFlags |=3D VIR_PCI_CONNECT_AUTOASSIGN; + } else { + if (reportError) { + virReportError(errType, + _("The device at PCI address %s needs to be= " + "an integrated device (bus=3D0)"), + addrStr); + } + return false; + } + } + if (fromConfig) { /* If the requested connection was manually specified in * config, allow a PCI device to connect to a PCIe slot, or diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index 814b556024..1772ea7088 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -35,24 +35,28 @@ typedef enum { VIR_PCI_CONNECT_AUTOASSIGN =3D 1 << 0, /* okay to autoassign a device = to this controller */ VIR_PCI_CONNECT_HOTPLUGGABLE =3D 1 << 1, /* is hotplug needed/supporte= d */ =20 + /* Set for devices that can only work as integrated devices (directly + * connected to pci.0 or pcie.0, with no additional buses in between) = */ + VIR_PCI_CONNECT_INTEGRATED =3D 1 << 2, + /* set for devices that can share a single slot in auto-assignment * (by assigning one device to each of the 8 functions on the slot) */ - VIR_PCI_CONNECT_AGGREGATE_SLOT =3D 1 << 2, + VIR_PCI_CONNECT_AGGREGATE_SLOT =3D 1 << 3, =20 /* kinds of devices as a bitmap so they can be combined (some PCI * controllers permit connecting multiple types of devices) */ - VIR_PCI_CONNECT_TYPE_PCI_DEVICE =3D 1 << 3, - VIR_PCI_CONNECT_TYPE_PCIE_DEVICE =3D 1 << 4, - VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT =3D 1 << 5, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT =3D 1 << 6, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT =3D 1 << 7, - VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE =3D 1 << 8, - VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS =3D 1 << 9, - VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS =3D 1 << 10, - VIR_PCI_CONNECT_TYPE_PCI_BRIDGE =3D 1 << 11, - VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE =3D 1 << 12, + VIR_PCI_CONNECT_TYPE_PCI_DEVICE =3D 1 << 4, + VIR_PCI_CONNECT_TYPE_PCIE_DEVICE =3D 1 << 5, + VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT =3D 1 << 6, + VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT =3D 1 << 7, + VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT =3D 1 << 8, + VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE =3D 1 << 9, + VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS =3D 1 << 10, + VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS =3D 1 << 11, + VIR_PCI_CONNECT_TYPE_PCI_BRIDGE =3D 1 << 12, + VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE =3D 1 << 13, } virDomainPCIConnectFlags; =20 /* a combination of all bits that describe the type of connections --=20 2.35.1