From nobody Fri Nov 14 21:03:23 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761135650; cv=none; d=zohomail.com; s=zohoarc; b=O7F6nzCS9kdCvU6wkc4steJT1cXM8PihPW5bBRXfVnlRyK7NFjnfZ+k4I3bVosXtN73tPG+0jMved/monECZJb5JmR2Xi+Ljz0BjiSxpIPSwn5YQ3VUExfhzq6lSZjxdl6k5PV8rl/I3V8GHe2b7CtgXAC5DREqXVbrfDNzKkHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761135650; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=drGGtVaxobxu4HvmHz2FmYJQ+I8x7J88yoMWzXLYGJM=; b=El2GsCfxLfYvbIy79gFE5WBw279KwnapXFQ4UE3mZHpAtyi8mPARxdH5micIQw1sJT7lA8L/EoR9rKiEj2GUinbeNnzjgOALiGxhmVZ96+ZAfIEF1o7ld1k3qbtNCtMxgqx0Kv7oU93MB9Sqad3zdeF7FsIQWmveLe7v7a6SOFQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761135650296593.1451069295573; Wed, 22 Oct 2025 05:20:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBXoO-00014W-8t; Wed, 22 Oct 2025 08:19:28 -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 1vBXoM-00013y-AQ for qemu-devel@nongnu.org; Wed, 22 Oct 2025 08:19:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBXoK-00073w-80 for qemu-devel@nongnu.org; Wed, 22 Oct 2025 08:19:26 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-YL8Z_JnWM6eFT6gwywx-oA-1; Wed, 22 Oct 2025 08:19:20 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 303C31956070; Wed, 22 Oct 2025 12:19:19 +0000 (UTC) Received: from corto.redhat.com (unknown [10.45.224.12]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 041511800452; Wed, 22 Oct 2025 12:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761135563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=drGGtVaxobxu4HvmHz2FmYJQ+I8x7J88yoMWzXLYGJM=; b=WutfQYTZUujep1uGtUgUorZqYyQ/Hdi9enF4TV0QL65j34bKYfXnASa1R/W6LtbX9jh/cQ SEWslO+X2yJB9W+Vd5o/YxnVz/to/H/BmABdXq2iJJleEj8bvRqd0WtwPz8y2veySsg6Rg Z5kSIpobXuX1h++rv8fEaPcqH6vA8QQ= X-MC-Unique: YL8Z_JnWM6eFT6gwywx-oA-1 X-Mimecast-MFC-AGG-ID: YL8Z_JnWM6eFT6gwywx-oA_1761135559 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , John Levon , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Alex Williamson Subject: [PULL 11/12] vfio: rename field to "num_initial_regions" Date: Wed, 22 Oct 2025 14:18:45 +0200 Message-ID: <20251022121846.874152-12-clg@redhat.com> In-Reply-To: <20251022121846.874152-1-clg@redhat.com> References: <20251022121846.874152-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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 @redhat.com) X-ZM-MESSAGEID: 1761135659141158501 From: John Levon We set VFIODevice::num_regions at initialization time, and do not otherwise refresh it. As it is valid in theory for a VFIO device to later increase the number of supported regions, rename the field to "num_initial_regions" to better reflect its semantics. Signed-off-by: John Levon Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Alex Williamson Link: https://lore.kernel.org/qemu-devel/20251014151227.2298892-2-john.levo= n@nutanix.com Signed-off-by: C=C3=A9dric Le Goater --- include/hw/vfio/vfio-device.h | 2 +- hw/vfio-user/device.c | 2 +- hw/vfio/ccw.c | 4 ++-- hw/vfio/device.c | 12 ++++++------ hw/vfio/iommufd.c | 3 ++- hw/vfio/pci.c | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 7e9aed6d3cd424d718919a0b236d8acf1bc0deaf..0fe6c60ba2d65b0ef5de5ef0c75= c43cfa8e89352 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -74,7 +74,7 @@ typedef struct VFIODevice { VFIODeviceOps *ops; VFIODeviceIOOps *io_ops; unsigned int num_irqs; - unsigned int num_regions; + unsigned int num_initial_regions; unsigned int flags; VFIOMigration *migration; Error *migration_blocker; diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index 0609a7dc25428c1e7efed1e7a4e85de91aace2d4..64ef35b3209429f7158d4ea79f0= 95a5f16950d77 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -134,7 +134,7 @@ static int vfio_user_device_io_get_region_info(VFIODevi= ce *vbasedev, VFIOUserFDs fds =3D { 0, 1, fd}; int ret; =20 - if (info->index > vbasedev->num_regions) { + if (info->index > vbasedev->num_initial_regions) { return -EINVAL; } =20 diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 9560b8d851b6b25e647476c51efe845ebff10410..4d9588e7aa1c0868fc2530d7e29= 7676834d85259 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -484,9 +484,9 @@ static bool vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) * We always expect at least the I/O region to be present. We also * may have a variable number of regions governed by capabilities. */ - if (vdev->num_regions < VFIO_CCW_CONFIG_REGION_INDEX + 1) { + if (vdev->num_initial_regions < VFIO_CCW_CONFIG_REGION_INDEX + 1) { error_setg(errp, "vfio: too few regions (%u), expected at least %u= ", - vdev->num_regions, VFIO_CCW_CONFIG_REGION_INDEX + 1); + vdev->num_initial_regions, VFIO_CCW_CONFIG_REGION_INDEX= + 1); return false; } =20 diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 64f87503894791850b059b225762fd45d85ee16c..52079f4cf5bda7c1d9e6e3791a6= c340a0e3f57ba 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -257,7 +257,7 @@ int vfio_device_get_region_info_type(VFIODevice *vbased= ev, uint32_t type, { int i; =20 - for (i =3D 0; i < vbasedev->num_regions; i++) { + for (i =3D 0; i < vbasedev->num_initial_regions; i++) { struct vfio_info_cap_header *hdr; struct vfio_region_info_cap_type *cap_type; =20 @@ -466,7 +466,7 @@ void vfio_device_prepare(VFIODevice *vbasedev, VFIOCont= ainer *bcontainer, int i; =20 vbasedev->num_irqs =3D info->num_irqs; - vbasedev->num_regions =3D info->num_regions; + vbasedev->num_initial_regions =3D info->num_regions; vbasedev->flags =3D info->flags; vbasedev->reset_works =3D !!(info->flags & VFIO_DEVICE_FLAGS_RESET); =20 @@ -476,10 +476,10 @@ void vfio_device_prepare(VFIODevice *vbasedev, VFIOCo= ntainer *bcontainer, QLIST_INSERT_HEAD(&vfio_device_list, vbasedev, global_next); =20 vbasedev->reginfo =3D g_new0(struct vfio_region_info *, - vbasedev->num_regions); + vbasedev->num_initial_regions); if (vbasedev->use_region_fds) { - vbasedev->region_fds =3D g_new0(int, vbasedev->num_regions); - for (i =3D 0; i < vbasedev->num_regions; i++) { + vbasedev->region_fds =3D g_new0(int, vbasedev->num_initial_regions= ); + for (i =3D 0; i < vbasedev->num_initial_regions; i++) { vbasedev->region_fds[i] =3D -1; } } @@ -489,7 +489,7 @@ void vfio_device_unprepare(VFIODevice *vbasedev) { int i; =20 - for (i =3D 0; i < vbasedev->num_regions; i++) { + for (i =3D 0; i < vbasedev->num_initial_regions; i++) { g_free(vbasedev->reginfo[i]); if (vbasedev->region_fds !=3D NULL && vbasedev->region_fds[i] !=3D= -1) { close(vbasedev->region_fds[i]); diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index fc9cd9d22ff2d6f126d3c0964d7033eee33ed9f2..bb5775aa711a668b7927865d19c= 3a27499ef49c8 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -650,7 +650,8 @@ found_container: vfio_iommufd_cpr_register_device(vbasedev); =20 trace_iommufd_cdev_device_info(vbasedev->name, devfd, vbasedev->num_ir= qs, - vbasedev->num_regions, vbasedev->flags); + vbasedev->num_initial_regions, + vbasedev->flags); return true; =20 err_listener_register: diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 06b06afc2b43d34d3a78ab874e3735eef91f529f..8b8bc5a42186d617ccfcc2307f6= 2e19b53f46d50 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2975,9 +2975,9 @@ bool vfio_pci_populate_device(VFIOPCIDevice *vdev, Er= ror **errp) return false; } =20 - if (vbasedev->num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) { + if (vbasedev->num_initial_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) { error_setg(errp, "unexpected number of io regions %u", - vbasedev->num_regions); + vbasedev->num_initial_regions); return false; } =20 --=20 2.51.0