From nobody Tue Nov 4 15:46:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504044541093317.07537266546774; Tue, 29 Aug 2017 15:09:01 -0700 (PDT) Received: from localhost ([::1]:47242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmogt-0001Co-08 for importer@patchew.org; Tue, 29 Aug 2017 18:08:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmodo-00080O-HG for qemu-devel@nongnu.org; Tue, 29 Aug 2017 18:05:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmodj-0001bk-Ji for qemu-devel@nongnu.org; Tue, 29 Aug 2017 18:05:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43654) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmodj-0001Zj-Dy for qemu-devel@nongnu.org; Tue, 29 Aug 2017 18:05:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E45F883C6; Tue, 29 Aug 2017 22:05:42 +0000 (UTC) Received: from gimli.home (ovpn-116-27.phx2.redhat.com [10.3.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32AF36FEF1; Tue, 29 Aug 2017 22:05:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E45F883C6 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=alex.williamson@redhat.com From: Alex Williamson To: qemu-devel@nongnu.org Date: Tue, 29 Aug 2017 16:05:39 -0600 Message-ID: <20170829220539.31136.82540.stgit@gimli.home> In-Reply-To: <20170829214929.31136.21144.stgit@gimli.home> References: <20170829214929.31136.21144.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 29 Aug 2017 22:05:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] vfio/pci: Add virtual capabilities quirk infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: a175818323@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 If the hypervisor needs to add purely virtual capabilties, give us a hook through quirks to do that. Note that we determine the maximum size for a capability based on the physical device, if we insert a virtual capability, that can change. Therefore if maximum size is smaller after added virt capabilities, use that. Signed-off-by: Alex Williamson --- hw/vfio/pci-quirks.c | 4 ++++ hw/vfio/pci.c | 8 ++++++++ hw/vfio/pci.h | 1 + 3 files changed, 13 insertions(+) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 349085ea12bc..40aaae76feb9 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1850,3 +1850,7 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev) break; } } +int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp) +{ + return 0; +} diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 916d365dfab3..bfeaaef22d00 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1833,8 +1833,16 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uin= t8_t pos, Error **errp) pdev->config[PCI_CAPABILITY_LIST] =3D 0; vdev->emulated_config_bits[PCI_CAPABILITY_LIST] =3D 0xff; vdev->emulated_config_bits[PCI_STATUS] |=3D PCI_STATUS_CAP_LIST; + + ret =3D vfio_add_virt_caps(vdev, errp); + if (ret) { + return ret; + } } =20 + /* Scale down size, esp in case virt caps were added above */ + size =3D MIN(size, vfio_std_cap_max_size(pdev, pos)); + /* Use emulated next pointer to allow dropping caps */ pci_set_byte(vdev->emulated_config_bits + pos + PCI_CAP_LIST_NEXT, 0xf= f); =20 diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index a8366bb2a74a..958cee058b3b 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -160,6 +160,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr); void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr); void vfio_bar_quirk_finalize(VFIOPCIDevice *vdev, int nr); void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev); +int vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp); =20 int vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp); =20