From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324110; cv=pass; d=zohomail.com; s=zohoarc; b=bq2CnOHBsErewFKuNiFIQ0OZO9yZO3ib3FJEp0HCgnHeAQjvzur6XXT7p8pBk76vFd7Me6JuYCX1hSvivObR2GSPy54bT8TRFxqO+jxlvc3JjraWyr1H97XzQUh7DQr5NRY5QLv8E/tWdmFxeb0b0QSoNrJPaFON1kCBNUVBR1I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324110; 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=ShLLJRom4lu9AovEB3oC6SSI+1VSXPqrxiewohtV3ag=; b=CoUiM2hM8Yi8EqLNdCbCRvP6ZKr4YyN4EN8S1L1gX2L9EBz2r/JLdRq8bx3kdfL0mKXQHUbFK4wQ6cu9HBSaOdR1G2fhQL6354B5eGrFXqJ/uM5U5Bsd399HZcUefIVlnZA21pv5ux135aWaucNa4qevl0cuekefiYb4kPhWp90= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324110585716.3208910956508; Thu, 15 May 2025 08:48:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFam3-0006hP-1u; Thu, 15 May 2025 11:45:31 -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 1uFalI-00062g-Tl for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:46 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFal6-0006BT-Vk for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:43 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F9OJCJ000592; Thu, 15 May 2025 08:44:27 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010002.outbound.protection.outlook.com [40.93.11.2]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcsdhs5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:26 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:22 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=ShLLJRom4lu9AovEB3oC6SSI+1VSXPqrxiewohtV3 ag=; b=F4HJQeSZcokGQNeFzeFCzE7sahGIQOdbxXCyIx33PY/7leKpd9pAHnpGp hsCruAXurF8wZfDxSB99eCdaNZZbk0O4ObuXhqt2CpNUF3yJ1dYlYfpUJF4kR8Ss FwLF7OqfMoscS5rvO4vRkbW/HDbWzLBe4ShzlNDYsM2wHWEsMOGmriAu1a7ilro8 87DosuQZd/AZGHgKV3h6U0JziSF6cWU36YhIPOCEIxAzBFMZSmFx6eQqhF9su6Pe vpIjGK/qgVBwa3SpH72OatXEVfrvJUVs5PkTUPTTVOwP1ZTyWIWgPVBRqPjCmlEs 9gOLWtKopZmeK60cNBz1bUQORe45Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uC9B9C6RWOqb9G1aUQWriF5BGCnUqwTcjU0EvRqSQzWgzd/BYnTlGyKzmiPTaO+KymkStQgW+tUkTtoazUWdVPVpE30D1UkpWxhhsxwRc8DuKdkuzfbb4O/Ofy8ANelrfztodxdzPQutMB+yikf5yV4JulTuCEpXVpmi1Ps1+HEZ+V7ZoqHP/8wU0o+k8+ydOjzkPluVCIxy5C7AaircjsrRc/k9nmV36TDa+4NXVCsjFtxGhTlTGXO0pda/ArhibooWNdhbV5Uj6/dOXK/5J9N59mlOGv7b8q3OvuoiI40ctVROyK50RntPNvglfpcq0KSMj9tBSgLpDo9n3ODL6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ShLLJRom4lu9AovEB3oC6SSI+1VSXPqrxiewohtV3ag=; b=ZI4icDX8aWFkcVAoSDxNBvazlX/Q5iamTuxLe2ptn6QlvE5XPIiwfOJHf+Bm0mKXy8b7kapyhfyvwxx1A+LEThb6Rurk/IE3mCqOEPsANi/qhMHVX7zfbqaf/ymWcFpIpiA6pylIaxODwM5VftxI0dhSBnM9QglOynh8wgAP3mstwM2N5yfvGZQ/fvc95c1jOSuOyj//ABxQGWG17tQniKffTbfciOujcl+65S9rnEv0+X7hnHLmm2SoPs6qOMche7CzV/mVAs0Vlv64mf2XkfALGGY0eTxarIHMEsjTWGN4CP/UHMqxEiYIspumNaRYEynC+mHAwMKTKlmPmatTtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ShLLJRom4lu9AovEB3oC6SSI+1VSXPqrxiewohtV3ag=; b=hIEdMmvfErqzXl/PHMBq353h2f0Rmxxx6vumjLm924nZKw5Hgcdk+qanyHaN5wXNKr4H07lrOf6og+vg0g2v1cTaJhMP+8X0COHqI8eIJVRXiI3qWkfmq8Q8AXVv87MFPmI4bbQT0uSdeGtZnC3nFgVymzFQXv6SiG0VvG1inZnYqXV6/APU3caqEe/bfbi/DnQ+oAJbwt5f4hfTBcsN4DNMI708mpPDwuqMSuUrBGjAobWHkKXRImNYnRsub+vjVweGPxTIpk451RmA7yezjXJsmlSWXNij7bXLSYRVwgIGL6X6gJ1yoqoM3mYGukgpQjkB/Q4MQHV4xk92pRLPRw== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , Steve Sistare Subject: [PATCH 01/27] vfio: return mr from vfio_get_xlat_addr Date: Thu, 15 May 2025 16:43:46 +0100 Message-ID: <20250515154413.210315-2-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: c9f3916b-ccf3-4164-d8c6-08dd93c75cbe x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nithqPKWbFp+ZXrNw2EloaKpQVSV/czQLziV4Ac1ZDCluXxiWbkj45e7YEe+?= =?us-ascii?Q?VNpVdGacDk4lPjWNW7MiYKCxVFeyrULZgVXrBmOlQUx4gp18PUeKF1OgPBHk?= =?us-ascii?Q?n2vaQYylHiSnyoCi0FrYduNbXdCINn6rmLIOcF8LWqLf43xU65QAItgZCi/L?= =?us-ascii?Q?flulKClGpFREit+bD+9Ry3NWqPJkTl+tzdcBrzeY6VdxPDhco7NtmOVss8Xm?= =?us-ascii?Q?8upKnaXt74OKiJyDcrH758CrZ3pGoC2cqJz4ml5hmfbh38eOt391FV6syi+s?= =?us-ascii?Q?axMNbI8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UvY52soU1IO04Xk?= =?us-ascii?Q?uKwDMTedebQ7YVr/7ZsIqs8AWYxnoEOzxj9WK3K5najttWoamCzJIA+EiuMA?= =?us-ascii?Q?S02ecfd5E0nyPfPZ+QZq1FYeS8/3TAM79Q1ieW/JUlw3RQUKf499rjUf5C2K?= =?us-ascii?Q?Wbyw99j5bqeEjgaardX8rqxC+s+dBLa5kGc3ouRZ2DBj5gTwykiwC+I9zILI?= =?us-ascii?Q?8VQ8LzdDQ6IuMVMUD38xHknd9pqV2JOnS9fnH/JYisETyFp4HHL9qRTZQpxQ?= =?us-ascii?Q?L+tMXO5Dj6U=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TdmVBO/seHJPg+L1JesB62n8laDaUo/AmA0/EsW94xEySkif3GrtiXaUXGd4?= =?us-ascii?Q?EDwL63ZEAUnshE4QHQD3BqJigk78EUIDknOolE3ePOzPHdlA/G9ul8AemBaA?= =?us-ascii?Q?eBjOThbJWO8gbTF5sIydRlriaYLL+ZEuYLNxPNCbP1WP0d30iyKjPshsSzaw?= =?us-ascii?Q?43cE6SocCi1Fnhx6nWCwCxneSfFPNS+pqj96CVK7UvEl7CS7aLUiqOB8tun7?= =?us-ascii?Q?/67xBZDONTjgvYB3ZDnsafgCaME7mwlbdlvPOC6PNWTsI5pht/JNL1jpEz/a?= =?us-ascii?Q?L5q8dF8u8AcM+WWcXn+ZSMVf92D4HeqYTjgnUf102BfxogSuAYVYZK+7cxVG?= =?us-ascii?Q?bJ881Ku9UMoYvLVfq/sp4PSmrfOFsMn17/28Fk08zVANNk9D/4huIcqROWRh?= =?us-ascii?Q?PBX9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fTfeXt6RBg4ejgvZ2oqBDDWA?= =?us-ascii?Q?W6K7T626HnmpPk85/0ltW3nCiZNTbGA77k/o+fX366dZOSwtHCWgf91qDQ8+?= =?us-ascii?Q?eIrktmSzNo+TntejmBEbkNQGf3IPy4NViAdknvUHuvl2yuTXK2kEGcJILgwd?= =?us-ascii?Q?VZoj98MfGVd7gyc3JbwwOtJUpHVMzwxRhs8URw7fZ2n7/sBVNVCLm3x71rls?= =?us-ascii?Q?i1shkYYSjpmkFGG2Xz6/kQUsM2cDFL2WUxaMEN/KizFOs7usR8Q+yWra9B6a?= =?us-ascii?Q?JRImwhsmvv1jSX6DGD2noRFaZLJww4uVk+D8C2LY?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9f3916b-ccf3-4164-d8c6-08dd93c75cbe X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:22.1766 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: L4RkVoXZ9WzvSHmgOurCJMDC475yLfqAVqXZrk4PVwjPbfGiCXCrdinmP5v3LXB3sKhrQh556pkpcKoi8u8sMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-GUID: 2SQYagKykVQDaIHORCsnddEgrspCOX7E X-Proofpoint-ORIG-GUID: 2SQYagKykVQDaIHORCsnddEgrspCOX7E X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX8DjKjcYaaf+L 0p/rLLsCTVeVdjgxtPGsbtU7rvlQE70ZH972pKCgXuPujYR99CYPmLyqFx7vBhBJ8eme1uXtAFN dn6if2RFG5sG9d60zKGeXx507k91wGmTPOXl5FSYEAQqcRP1oTErbqorUz66i8TczOXWFDFVRP5 fI19LChDoK5KCJR+e9DrbLXuGd1AJRLH0PVgHLrcc0VPHxXXLkVFZd90TayPGEnQ6u1fBRe+Zk1 DUezNUk3b078pZx0q1/qAJNtTpIqoiIu2W2iTaHz+xXA/4L3NsePXCK2+emPFNDsihBDSqsBD0D zaEOt65yybeX7WFoqDl3jWH3VFgJmgVz5fnab2gRaAlkpIxg+PNdynnD2RJHGoeZLcuIdk38e5G FDwsRO9xtwtq3GKl81CQeQpCzAj2OuLBP64nMBIBmhb+KrCMepjVGZIkpEQ98MpiRMq1ZCve X-Authority-Analysis: v=2.4 cv=EKMG00ZC c=1 sm=1 tr=0 ts=68260bdb cx=c_pps a=CQ+uznrK75NoT8CVPM1Etw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=LD-bTVk_YcQ43CFCkRcA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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 @nutanix.com) X-ZM-MESSAGEID: 1747324111809116600 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Modify memory_get_xlat_addr and vfio_get_xlat_addr to return the memory region that the translated address is found in. This will be needed by CPR in a subsequent patch to map blocks using IOMMU_IOAS_MAP_FILE. Also return the xlat offset, so we can simplify the interface by removing the out parameters that can be trivially derived from mr and xlat. Signed-off-by: Steve Sistare --- include/system/memory.h | 16 +++++++--------- hw/vfio/listener.c | 29 +++++++++++++++++++---------- hw/virtio/vhost-vdpa.c | 8 ++++++-- system/memory.c | 25 ++++--------------------- 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index fbbf4cf911..d74321411b 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -738,21 +738,19 @@ void ram_discard_manager_unregister_listener(RamDisca= rdManager *rdm, RamDiscardListener *rdl); =20 /** - * memory_get_xlat_addr: Extract addresses from a TLB entry + * memory_get_xlat_addr: Extract addresses from a TLB entry. + * Called with rcu_read_lock held. * * @iotlb: pointer to an #IOMMUTLBEntry - * @vaddr: virtual address - * @ram_addr: RAM address - * @read_only: indicates if writes are allowed - * @mr_has_discard_manager: indicates memory is controlled by a - * RamDiscardManager + * @mr_p: return the MemoryRegion containing the @iotlb translated addr. + * The MemoryRegion must not be accessed after rcu_read_unlock. + * @xlat_p: return the offset of the entry from the start of @mr_p * @errp: pointer to Error*, to store an error if it happens. * * Return: true on success, else false setting @errp with error. */ -bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr, - ram_addr_t *ram_addr, bool *read_only, - bool *mr_has_discard_manager, Error **errp); +bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, MemoryRegion **mr_p, + hwaddr *xlat_p, Error **errp); =20 typedef struct CoalescedMemoryRange CoalescedMemoryRange; typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index bfacb3d8d9..0da0b2e32a 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -90,16 +90,17 @@ static bool vfio_listener_skipped_section(MemoryRegionS= ection *section) section->offset_within_address_space & (1ULL << 63); } =20 -/* Called with rcu_read_lock held. */ -static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr, - ram_addr_t *ram_addr, bool *read_only, - Error **errp) +/* + * Called with rcu_read_lock held. + * The returned MemoryRegion must not be accessed after calling rcu_read_u= nlock. + */ +static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, MemoryRegion **mr_p, + hwaddr *xlat_p, Error **errp) { - bool ret, mr_has_discard_manager; + bool ret; =20 - ret =3D memory_get_xlat_addr(iotlb, vaddr, ram_addr, read_only, - &mr_has_discard_manager, errp); - if (ret && mr_has_discard_manager) { + ret =3D memory_get_xlat_addr(iotlb, mr_p, xlat_p, errp); + if (ret && memory_region_has_ram_discard_manager(*mr_p)) { /* * Malicious VMs might trigger discarding of IOMMU-mapped memory. = The * pages will remain pinned inside vfio until unmapped, resulting = in a @@ -126,6 +127,8 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOM= MUTLBEntry *iotlb) VFIOGuestIOMMU *giommu =3D container_of(n, VFIOGuestIOMMU, n); VFIOContainerBase *bcontainer =3D giommu->bcontainer; hwaddr iova =3D iotlb->iova + giommu->iommu_offset; + MemoryRegion *mr; + hwaddr xlat; void *vaddr; int ret; Error *local_err =3D NULL; @@ -150,10 +153,13 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, I= OMMUTLBEntry *iotlb) if ((iotlb->perm & IOMMU_RW) !=3D IOMMU_NONE) { bool read_only; =20 - if (!vfio_get_xlat_addr(iotlb, &vaddr, NULL, &read_only, &local_er= r)) { + if (!vfio_get_xlat_addr(iotlb, &mr, &xlat, &local_err)) { error_report_err(local_err); goto out; } + vaddr =3D memory_region_get_ram_ptr(mr) + xlat; + read_only =3D !(iotlb->perm & IOMMU_WO) || mr->readonly; + /* * vaddr is only valid until rcu_read_unlock(). But after * vfio_dma_map has set up the mapping the pages will be @@ -1010,6 +1016,8 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier= *n, IOMMUTLBEntry *iotlb) ram_addr_t translated_addr; Error *local_err =3D NULL; int ret =3D -EINVAL; + MemoryRegion *mr; + ram_addr_t xlat; =20 trace_vfio_iommu_map_dirty_notify(iova, iova + iotlb->addr_mask); =20 @@ -1021,9 +1029,10 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifie= r *n, IOMMUTLBEntry *iotlb) } =20 rcu_read_lock(); - if (!vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL, &local_er= r)) { + if (!vfio_get_xlat_addr(iotlb, &mr, &xlat, &local_err)) { goto out_unlock; } + translated_addr =3D memory_region_get_ram_addr(mr) + xlat; =20 ret =3D vfio_container_query_dirty_bitmap(bcontainer, iova, iotlb->add= r_mask + 1, translated_addr, &local_err); diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 1ab2c11fa8..f19136070e 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -209,6 +209,8 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *= n, IOMMUTLBEntry *iotlb) int ret; Int128 llend; Error *local_err =3D NULL; + MemoryRegion *mr; + hwaddr xlat; =20 if (iotlb->target_as !=3D &address_space_memory) { error_report("Wrong target AS \"%s\", only system memory is allowe= d", @@ -228,11 +230,13 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier= *n, IOMMUTLBEntry *iotlb) if ((iotlb->perm & IOMMU_RW) !=3D IOMMU_NONE) { bool read_only; =20 - if (!memory_get_xlat_addr(iotlb, &vaddr, NULL, &read_only, NULL, - &local_err)) { + if (!memory_get_xlat_addr(iotlb, &mr, &xlat, &local_err)) { error_report_err(local_err); return; } + vaddr =3D memory_region_get_ram_ptr(mr) + xlat; + read_only =3D !(iotlb->perm & IOMMU_WO) || mr->readonly; + ret =3D vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova, iotlb->addr_mask + 1, vaddr, read_only); if (ret) { diff --git a/system/memory.c b/system/memory.c index 63b983efcd..4894c0d8c1 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2174,18 +2174,14 @@ void ram_discard_manager_unregister_listener(RamDis= cardManager *rdm, } =20 /* Called with rcu_read_lock held. */ -bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr, - ram_addr_t *ram_addr, bool *read_only, - bool *mr_has_discard_manager, Error **errp) +bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, MemoryRegion **mr_p, + hwaddr *xlat_p, Error **errp) { MemoryRegion *mr; hwaddr xlat; hwaddr len =3D iotlb->addr_mask + 1; bool writable =3D iotlb->perm & IOMMU_WO; =20 - if (mr_has_discard_manager) { - *mr_has_discard_manager =3D false; - } /* * The IOMMU TLB entry we have just covers translation through * this IOMMU to its immediate target. We need to translate @@ -2203,9 +2199,6 @@ bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, void = **vaddr, .offset_within_region =3D xlat, .size =3D int128_make64(len), }; - if (mr_has_discard_manager) { - *mr_has_discard_manager =3D true; - } /* * Malicious VMs can map memory into the IOMMU, which is expected * to remain discarded. vfio will pin all pages, populating memory. @@ -2229,18 +2222,8 @@ bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, void= **vaddr, return false; } =20 - if (vaddr) { - *vaddr =3D memory_region_get_ram_ptr(mr) + xlat; - } - - if (ram_addr) { - *ram_addr =3D memory_region_get_ram_addr(mr) + xlat; - } - - if (read_only) { - *read_only =3D !writable || mr->readonly; - } - + *xlat_p =3D xlat; + *mr_p =3D mr; return true; } =20 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324209; cv=pass; d=zohomail.com; s=zohoarc; b=aTbA6TgFPOgfH83GEAFiXbArSoVD9VGwHore7dPCPv/QbBfSU5KSgRUL7zPonyPXn4URAcm6/nDCXLD4z1g1YhBb5WzjQiFaB8Wmrpf1FGOsdm/SNVkDBvcOvRzhVyYcyTKdNVIsvcCBrG+R/xFlRgCUuRTu4ysktsCaWYzIG6w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324209; 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=nIU1NX3ZAd8T0lL+E+iFcpjJ/f83h+HxXHrL9+be618=; b=dBzssJASQFc6HKRy31jjCsO+pUeeb40tJMjVCKYmae+FtbILcvpw6Ps1JPfafFuVBaW3wXr1c5tSTJjBYI7/AZgyg7V5U2vQc7+9m16eqKLyEOT98GOre4ApV8b2TJbV4B+SWTXlkfyJNETqTM6i52gvWul0J+xp97iq6NABg48= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324209952692.9002539050063; Thu, 15 May 2025 08:50:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFalm-0006KV-VC; Thu, 15 May 2025 11:45:17 -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 1uFalI-00062h-Ti for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:46 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFal6-0006BV-5Y for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:43 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F9OJCK000592; Thu, 15 May 2025 08:44:28 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010002.outbound.protection.outlook.com [40.93.11.2]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcsdhs5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:27 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:25 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=nIU1NX3ZAd8T0lL+E+iFcpjJ/f83h+HxXHrL9+be6 18=; b=nBt5OQzXjy/VD3LrBJvImMqWYxw2aWuez8F4UFJNjCISxV600Q/NIINIL Yamz1Can11KX8rQHX/gWEZxTOLxroIumbCTqlRl6zg5hDVpYMlr4H/0EWECpkMZY toSiCYTDeGlhPZc4PEaCnTnPyW4glq5NIip2Dtih54uwrjMjbLUVrG9WG+9CPTUS elNBBhxI0Xqn9a1L91SG1se8grSdc/iole87qZM0wnQQQMhwSN8mtNJ86HTx8XU5 5fIp3/SwTSEMzJFskF2ElKF4SA9rxqA3d17DKpwv7XC9fA0m0rkCeF2mBvRlQsdE Qz/GzjGnSuBSE6ew6ExKrJm9XzERA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LDWzBeGYh6m6AForyz5cSDvk8nXVx1/73rRhSxSeQCmOnj9xqwiLryN7h+sXKQ9kf/Lr2DSgr6zgkRGPHDN+8bjTrE7UGq31ZKgG+Fn+6rdxqojqytayclLXUCJFC7VzMtojxyl999/H9IoV/DLL1MLJDlq5zfMOMmYY/5d+wuJxAdQVqw2nghj/9kDd4hY5vG3Nmth2IhVXzBlpxXyt9pemhJxzXa7GIQKDNKq1y4z9T3YdtIyvlvtWniHwiLolXni3LeTZaOrkXrQwMuOqnVk0DX+lb3Ey7btF/vg+YMKTVVp80O1EQK0B3Pj3S+eejsFQ5HAOqtDAm0TlT/Syqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nIU1NX3ZAd8T0lL+E+iFcpjJ/f83h+HxXHrL9+be618=; b=ug6QU7siKpPKuo6rBCI2Xw6AxZUdj7kqVzV3JZpTpGJBLu91Mb46Vn2i90oyTqvTgEr+5jzsXl2D293uqcUNoC6xAmk7mwOXnbHJ24lQboLDOopLC85qKtk0Rd5NPdzf6LLFgI6dLkUukVZN7xo4II7giVCgaQBJnXcQRci16xZHfD+NmlXJ8CCFCw4k3WAGj4Llg/Ky6Cs+FhkofRH6Ift1a3e0Vk/odsxUeNHOliBHsiIke66EEfkjjt4zARG45VNtXBKscJqE2dH7JSDH96xdbQem4UV16Nwr9uEe30eFm0hw0vuGdQHKI/+/PFI2QvC/se5ZB7KlHQpVhs1Kag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nIU1NX3ZAd8T0lL+E+iFcpjJ/f83h+HxXHrL9+be618=; b=NCFUBjUFnxzpicsvHx62oYFBb8Q1KJFk66MAiWx6pLVcZQOJ1gJeHlrs4krL/B05TnNulAGggGJjjUgiBS5VK5cYH3WekVSgi39zZpkdpl6TuK9zx4k5RCN+byFlXXnlCfaNcJvUlq34N4i6YLeks3ESBjbkRIcoi+y0qIW9klcArQQ69hx2ZK8th4t+ynhBZK6rH+JAdqzXASUfXGccBeWqlWnoy33JR+Q403p4bxpIrT3zIReR3WZF8xz32PhUvEQVurfnNANC4mxi3EbnJ6X6OWLoqjhGPvB3oeIh0zpKx87FumM5JTGTzG7EJIMoTrt7SyqWEBvDXquaFUPq0w== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Jagannathan Raman , Elena Ufimtseva Subject: [PATCH 02/27] vfio/container: pass MemoryRegion to DMA operations Date: Thu, 15 May 2025 16:43:47 +0100 Message-ID: <20250515154413.210315-3-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 76e370fd-fcf3-4a16-1ad9-08dd93c75e65 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JEDQVBmk+iLG0dp+1a7oTauJLZtFlDlxvoTJ+pX5bG3y+udpdQdbjNJTAcv0?= =?us-ascii?Q?UUFyKTE5dYk8pAL+rXTZ6XPfRNv4VfXjQbrghnU+Q7Os1XwUs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RSwsG2fIFvo8i3Am22qTFcS7L6IIXt07E4nsl61Hgm2okwTe/3lD?= =?us-ascii?Q?okgn5SlcY3f7gEf70VEAPwn9GKCqMTlVCdIvpcTmucDqb85dKoYeGEPVRrAS?= =?us-ascii?Q?ZkaEbDxup68CJpyzLaC2GgYs+JwTdxXyYcI8hx+R0x+6BEJ1HQUsOun/ufcm?= =?us-ascii?Q?SAWeLKjklmncvJHBlmuKZjoGH7rrrvxWS5C9isznFY+ps3GjJvCtML3rARN0?= =?us-ascii?Q?SQttaf5xWELM1hBak6ePzdjfY2+gvEdxvmtTL9aWzEp26T67nHr81vXqLHLY?= =?us-ascii?Q?zxex4OK5tcKJfAnhk8D18to+PjkD2fKwaL0Hbc6NKMagCzI2CwnL+UlFcR65?= =?us-ascii?Q?hm/fmOM5BtVOyI/8tVD4D07o2vdy/pxEk4ZL7WJAKlTyHkjpop6Jx/JDJYbb?= =?us-ascii?Q?s0JL7UcaqZuyS0J1tsKA33lAjakC3jKGhtK1DhiSL2iHGE4rxD/pv/EeTayB?= =?us-ascii?Q?xKquaiXlJGo=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?G0RbVDyHPwbItg0mn9IrPqAPAI7azaI/yNx7YkLtaHXZSx5v06QhXbSIWxJF?= =?us-ascii?Q?VhwVjSY7kI6JznI9CLm5tIXep2U198jXL+QyRaEyrdkN8GMgh1PetvQf4q35?= =?us-ascii?Q?m84q9xQu4xNBNRuRghQzfsIyRwj+mqUw61f7zqgkx16D3kWMDIsDL8RrigoD?= =?us-ascii?Q?tzws9h7JdsTzSlUrLTvwfwlauM1R1/K2FPgJoJC7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nUhcKVn3f6w7kHX70iyTl6I15j+flnJqY0i7EAb8KUnYUGeEc1rrFZ?= =?us-ascii?Q?GArakmYiHJ+Lcg+1JxHX/2tCPMsbJOwnG1cYnP0GNe4i08PdyjGe+CGWU6h6?= =?us-ascii?Q?mjGO+INFcXZcrICepB7LWQeNkKESC/Y8cTBCBzQVbddm6rSK5Cr5hSL+zkDi?= =?us-ascii?Q?33/gw/iLoMd83i4R8VfyTFOzrWoOfPpd1CaABD0B92jg+k3IvlQkb0sAao5N?= =?us-ascii?Q?bwp1IP8Omr68dY+Q1+GVd/v8PwsdIZqszeCJNGRCSUlH8DpkYjXTd3CvKh+K?= =?us-ascii?Q?aetJVa0KR2SwoIJmFcrMx4sklSz2tYEelf6PDsO8dIs+F2S0qG9RmiQMmUT1?= =?us-ascii?Q?adQjwFyiFOeHDlFrAF84q2eXj/2IK6rgtEM3/9UFJ7Cskd3hrtPsGKLh39rP?= =?us-ascii?Q?QwkYPFRMJwkwXI5bpv5a9C+HtOz5sdvUTipBwMJlQgMMXS6Fq3yo9WGTW+IZ?= =?us-ascii?Q?lzeXjFSGz0gY2b7+ky1w1VGGt9ZjWfBySnNjP+u9?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76e370fd-fcf3-4a16-1ad9-08dd93c75e65 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:25.0002 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6jYNsOWb5ArX5sraHNgUsAyc/Zya3wQB8O6AUW2ff6JGMfdUoDiz8R2wgyXXgf+PYh9NRtjwdAAjDXAN4y+e5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-GUID: 6d0Xrysx_Gx06hqXG35PO_oGjC2bU5Xn X-Proofpoint-ORIG-GUID: 6d0Xrysx_Gx06hqXG35PO_oGjC2bU5Xn X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX7CInMGttl0A5 /hcqHZAO3g8v7Blhc+/epNE/DUIQZMupNe+0ZATYfiesPbXxWdOLulZfMdxSBczmJ1GrsD02jWE F2H/ek1AizX6UY+G+KHfP7EXauDATdu5qaLbizsYNKjSRxZ9+2o6J34n5oJgwBqXg/eKvk2ilXb hghraSdiJbjwwrDokUigzDRlCxiC2z/O2WA1NChwwhhI7nvLR0250muXVmR1jl24D268C/gVQhY HcX9TcJQj1EZGfo9+LYi23U16rFP/HIfMIBsqCUX22M4NrSdUXJdZed5LFuLrZ1wQtApQhu6kOc aB/lENCYdAL+gI2ZM9R2BDfrGuxkKot9WG8/tEBBTmiVp/6Ty6YPlShExxbenXGfRWut8frCoMB ECqkjqsfCoUpzKAvwfIrRn4nYP1+Iyya+4iB63lPtaZwotLZRtzyD2XuXgbJ73+XuzN4YAoQ X-Authority-Analysis: v=2.4 cv=EKMG00ZC c=1 sm=1 tr=0 ts=68260bdb cx=c_pps a=CQ+uznrK75NoT8CVPM1Etw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=P1UepQaUeP-bpQj9cxEA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324210988116600 Content-Type: text/plain; charset="utf-8" Pass through the MemoryRegion to DMA operation handlers of vfio containers. The vfio-user container will need this later, to translate the vaddr into an offset for the dma map vfio-user message. Originally-by: John Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John Levon --- include/hw/vfio/vfio-container-base.h | 4 ++-- hw/vfio/container-base.c | 4 ++-- hw/vfio/container.c | 3 ++- hw/vfio/iommufd.c | 3 ++- hw/vfio/listener.c | 6 +++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 3d392b0fd8..359b483963 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -78,7 +78,7 @@ void vfio_address_space_insert(VFIOAddressSpace *space, =20 int vfio_container_dma_map(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, - void *vaddr, bool readonly); + void *vaddr, bool readonly, MemoryRegion *mrp); int vfio_container_dma_unmap(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, IOMMUTLBEntry *iotlb, bool unmap_all); @@ -121,7 +121,7 @@ struct VFIOIOMMUClass { void (*listener_commit)(VFIOContainerBase *bcontainer); int (*dma_map)(const VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, - void *vaddr, bool readonly); + void *vaddr, bool readonly, MemoryRegion *mrp); /** * @dma_unmap * diff --git a/hw/vfio/container-base.c b/hw/vfio/container-base.c index 1c6ca94b60..a677bb6694 100644 --- a/hw/vfio/container-base.c +++ b/hw/vfio/container-base.c @@ -75,12 +75,12 @@ void vfio_address_space_insert(VFIOAddressSpace *space, =20 int vfio_container_dma_map(VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, - void *vaddr, bool readonly) + void *vaddr, bool readonly, MemoryRegion *mrp) { VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); =20 g_assert(vioc->dma_map); - return vioc->dma_map(bcontainer, iova, size, vaddr, readonly); + return vioc->dma_map(bcontainer, iova, size, vaddr, readonly, mrp); } =20 int vfio_container_dma_unmap(VFIOContainerBase *bcontainer, diff --git a/hw/vfio/container.c b/hw/vfio/container.c index a9f0dbaec4..98d6b9f90c 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -207,7 +207,8 @@ static int vfio_legacy_dma_unmap(const VFIOContainerBas= e *bcontainer, } =20 static int vfio_legacy_dma_map(const VFIOContainerBase *bcontainer, hwaddr= iova, - ram_addr_t size, void *vaddr, bool readonly) + ram_addr_t size, void *vaddr, bool readonly, + MemoryRegion *mrp) { const VFIOContainer *container =3D container_of(bcontainer, VFIOContai= ner, bcontainer); diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index af1c7ab10a..a2518c4a5d 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -34,7 +34,8 @@ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio" =20 static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr io= va, - ram_addr_t size, void *vaddr, bool readonly) + ram_addr_t size, void *vaddr, bool readonly, + MemoryRegion *mrp) { const VFIOIOMMUFDContainer *container =3D container_of(bcontainer, VFIOIOMMUFDContainer, bcontainer); diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c index 0da0b2e32a..562ce9075d 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -169,7 +169,7 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n, IOM= MUTLBEntry *iotlb) */ ret =3D vfio_container_dma_map(bcontainer, iova, iotlb->addr_mask + 1, vaddr, - read_only); + read_only, mr); if (ret) { error_report("vfio_container_dma_map(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx", %p) =3D %d (%s)", @@ -239,7 +239,7 @@ static int vfio_ram_discard_notify_populate(RamDiscardL= istener *rdl, vaddr =3D memory_region_get_ram_ptr(section->mr) + start; =20 ret =3D vfio_container_dma_map(bcontainer, iova, next - start, - vaddr, section->readonly); + vaddr, section->readonly, section->mr= ); if (ret) { /* Rollback */ vfio_ram_discard_notify_discard(rdl, section); @@ -563,7 +563,7 @@ static void vfio_listener_region_add(MemoryListener *li= stener, } =20 ret =3D vfio_container_dma_map(bcontainer, iova, int128_get64(llsize), - vaddr, section->readonly); + vaddr, section->readonly, section->mr); if (ret) { error_setg(&err, "vfio_container_dma_map(%p, 0x%"HWADDR_PRIx", " "0x%"HWADDR_PRIx", %p) =3D %d (%s)", --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324160; cv=pass; d=zohomail.com; s=zohoarc; b=fdJ0u6yv3QjTReH0YxciiBAaba19vSzULDcRz9DMVVW1/72P9Ls4Vvpp5KD2aWjwUx2FNC4liiVaHR8di3h9GRwv1OXZ+aL7n5rCEbEoBm6OREim3Lcq5CfnKZFPm1qBfJ87gLlPxtg/ePRINqBanzoZ9PCOGHLVAoi8tfAd5I0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324160; 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=c1lsMtou6XkKjYLhnCP9yJZ1pYByE0B4NV+OfajMGOg=; b=BUNJv1u1hvF+h5xYKE3h5QGGmashujXRkB72PHyDH8oLoYpoGIGZBXF4ji+5TzullkU/eyBZxSwOb7qr+bbAY1YGvRDbgLPRGmkzNvSbhtCHIA7wmHLZ2KRF08IJ4hcQYtomHLODsf4Z1Yji4WQiCnr3Qrb374vbKgkec0UJcBI= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324160138131.35079459868825; Thu, 15 May 2025 08:49:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanU-0001j7-CT; Thu, 15 May 2025 11:47:00 -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 1uFalI-00062f-TP for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:46 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFal6-0006BZ-46 for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:43 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F9OJCL000592; Thu, 15 May 2025 08:44:28 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010002.outbound.protection.outlook.com [40.93.11.2]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcsdhs5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:28 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:27 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=c1lsMtou6XkKjYLhnCP9yJZ1pYByE0B4NV+OfajMG Og=; b=UBbhAQ7kTLiB3JjVjYmntYFWB1JYD6B3xLNdXZbBhUpppdc3/Y2rierEh B9WLAePiZW/TXlc/dVE/z6GphJLpAaD/WVNEKbLVVkeH6TVly5nbe9BI4GRYfxr9 wGXxkGzI52y5niZW4fqGuI0EIzDtdxb6hAzmrQ7wOblOyC3qE5XXKRkCeQrXGp33 N0q9XFn+xrTFegRTlCF35nSp/nFYHEI8Gjr7I22ewbu7tpqIXchv6cBECTDwsG/a BVqOPMBxM9ZL+lo9nD+C/2tktalo66Z1FQBIubguLIK915XF/6OzLZZOfMj0YKYR pfNLmE2Oz5MwnJon2mXUz7/vCQnVQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kQf/ZAer388EoNHllgBNClMnzJpx7zi+WdDLE/HQPt7+WaZP/8f2Q7C9adQHilKRI6wvMUCYRNxBkQvM2Y98cC6E/6Fne2r/gn6iDGpzh6eiww/VqQ51OXZ5hy3fD3cyxuoMWBppZHTkzAplQ1njJrE/cfE9yokS44mfcubmErLNp9dpTeisxN+ORZ9KZ7CiY/jNaFYo+A9MHqJVhEGVJ+keO7N2BueWLHcN/hs0krgXzmDvUn8ieKHXw2vgS0rd3NXpN+kUZXBzWrnAow1ZOzfPM0pRrf7tW1sRkEcpdOMl+cLF91HLiQ3I5lcJHLIkG67AmgqBkQ5nP8tC7DP/EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c1lsMtou6XkKjYLhnCP9yJZ1pYByE0B4NV+OfajMGOg=; b=yLz/ZesJiAtCELC2ZihrzntvJ65HH6oD53cuVYDiI0evmyF+7u+A2TYbDuPcActSQxtq2voK8RGN65GrOW2XZNPeHMSAenas2A7IKr/mU+908S4faUVpvxoMY5THSQXQx6qWmgEScdUFBhfKhym6US3aXrLy4Fb+chmX2/DahPw1NQBaWynmw8p5SYGEn+C8SO8Dj1SoDVJeoxPkdge3Dxcquhmd38D2oVloEg20k/TfKLl2fEOG9yeMs2pVLVtKDVkC+LmflUqWqrmiNcoBCN2ZFr562PvNt9Tl9eLHLF3nzzGPxicv8O0fqy7GB5Sn67J6vIYfTy8DQg75Y4+BVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c1lsMtou6XkKjYLhnCP9yJZ1pYByE0B4NV+OfajMGOg=; b=Aza9g/4PLQfVuXombQzSj1egfxu0oK8gNxtmH6uQR2V7qf4T+Et27jHVnJfOjlat0wZ7v5piXiPx+HVGculmZYs/0cU5cGs9dlUfA5wY3IIF2h/SnF1ea4UyyS54Wwz0B+Y1ul4ho2GGvIoLJlTv52fxqm2yTc2vZFrmB21bZp55Wy+seC04ceHlP6zMJeurt4ebWTx1yf+Ucve3BpT5A04iS1WrGSWczBGh7lhgau9DjbrjM5Z9hqZvWVnjHDQmDcOfUVurjzFen6Hjah9J7PGVPQv5zP72FCBjVbOQDvlkQpHYy3bOzi9I5evTOnOALKeug2KzWECiS3zIQ13zOg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 03/27] vfio: move more cleanup into vfio_pci_put_device() Date: Thu, 15 May 2025 16:43:48 +0100 Message-ID: <20250515154413.210315-4-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 87eeb2b1-ee1b-4f2b-ca13-08dd93c75fb4 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XxTO3NClNUt7FKfSLjVVOesYrOh7eB1AHMZuhYyGDyW1nRoDnx/ilkIX8Cq2?= =?us-ascii?Q?kqIthp6IEQZGj2oFSf6Imy6a45OT+O5ez8AcsUsU7L66hitESnvAxRbImIPb?= =?us-ascii?Q?XenlxXY7J7oxw5KC94IImLB6i/j1mWip31sjJlhWgjw/44o3L7JtoDfUA4NT?= =?us-ascii?Q?5NpNrSV0+5zRXZFuHhiMB/PUuSAXPn40TRlSQOTSl/GQndjibI0fbn3OMbYG?= =?us-ascii?Q?SivNsxCl0SozGD4MkK1h40wzTAPJPQgV2sSqhZGJG7Pa/uFJlDmNPg2f5+96?= =?us-ascii?Q?7OClu//dhxjbzC52zWe6zBryhiKWJvG0TAMkjWekH00IukMjd1oMYw0jUYlt?= =?us-ascii?Q?nuCBz4dDY47i3e9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=?us-ascii?Q?oolLRbN5d1fet1Z6iuvKlIgHNracRUwGuIB0QVZJK3cj+rrUfKRLNL/uute2?= =?us-ascii?Q?kCXSA52C8f+DG3f+oaVOgW/prowI6K8q3/FZZmYtLo0QuMw2OYByIBUZ5OVU?= =?us-ascii?Q?oaUfXLje0C71TIQa0ojNN64GJDtj30sPQ+JCg3Uk58llIqpEb3Vmph3n2oVZ?= =?us-ascii?Q?lQY8NJE7Shk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?5W/6hCe6qO6Bj74z9AfQa9rBwWkWZj0zrmp8ErvNOsMdd1AT6zvWSRPeFe8S?= =?us-ascii?Q?cLvMDmyIDBvDJXjR3w9RpQMs2gb1nq1EN5uf5quTmXGSmxp/WcPH0rFd6ZEG?= =?us-ascii?Q?XptGhE6ayaZ/cnzwgi1T2EDJmg/fbt+L0k17nHfytikxuJCU2Kie6tXNzpMF?= =?us-ascii?Q?0wYK5rrsLxph6w0AzGhbmwhdJgH+sWovIt7MBSaArjd5pUVo4lI2I0GTPv9T?= =?us-ascii?Q?K/1Gb3y4ZjAKErS612cmppi+rtWBOkpyawfXcfhI7NWDOMjGZ+kW9fWALI2p?= =?us-ascii?Q?uY3rUd911PvaykGb+Z8sK170EStaRLAvAJE6DBpS8mWb9JMSt9dcMbXX/YTM?= =?us-ascii?Q?dZf4M7knahYmgyuNfw5lSYsO34uAT2hyuibOYbP+oMwHgURV2elYeq/Ue0zb?= =?us-ascii?Q?XPwYpgvPzJolKDi0QdQss096jpNjID5HFazn2Q7Eiaxp3rIo+l+QG3S/1Va2?= =?us-ascii?Q?7Y6kkQ57FV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p6zyLqHAKk+RBrTke?= =?us-ascii?Q?4auuI65tohOfkoJU4Nr+zXJ8HyVAvoO/0se3+om1zEEPSuSnq0zQnyezl6xE?= =?us-ascii?Q?vvU8JWic7il8AQqzgY90cVCxnZcxTEXzO5cffpBTRA+JOooXUgF6Mmma/F3G?= =?us-ascii?Q?/MZA564xYx4tZQQyrVRSqr9fGjuNnw19p1fv3lf9IzQttqPZi246SXHnjkVM?= =?us-ascii?Q?LIokCKin0OdIm5UxJaD5Thgaoi/oWdTi4UC6++Q9?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87eeb2b1-ee1b-4f2b-ca13-08dd93c75fb4 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:27.1408 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jVgHmOJOJcJw8Wy4d1Y/zykuMKmb64+z8POYtJS8ED3Jgqjv0FKheVfnL7Xapfh58dW67diYunA1CJTJI+WTUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-GUID: homVQ4_LdYZKjoo1jI59e8cz3XbgfmHA X-Proofpoint-ORIG-GUID: homVQ4_LdYZKjoo1jI59e8cz3XbgfmHA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX7VlqS2MyPUU5 y9R8nBg8TzG4oyo5GdADoRjXB0nJJ163qIUNiJHd3HrqLUd3yTXfpbKQQAa6GpDjekQCa5kxxyt Q9+5ohPXHAWBRJbQXf7hXSHuFdGaeakI8QQvbl6IAmcff22bPKVvUUJbSIQ7CGDUkVNgYSaYpjA l4/u6D7ewcUFpycDhPv3dqQoGkh0eJr6hjaNd+W27x2uuHCEZLKnN54EVWzWGyS/nyZoOp6zHtj FRfucccdRG6/d3XD/KPEjTISzI2nRhHwst7kO3yk2jNElG0CQ1z30kYgEuacKBnKqcTEfTJfIpp 8MOAobl/WWGcmHbwTk8dUYhAhb5t+Tv61gh0KTB+wqeLSY338Og1gzzxrhJFnBhhZ92z2YrEH7P XpaVwAW8hmyhqqCjV+X62OCbrMoiDHATIm4qSHrkZAl4CyZZwrT3kXmDfPPXFTWP4nbxx6CG X-Authority-Analysis: v=2.4 cv=EKMG00ZC c=1 sm=1 tr=0 ts=68260bdc cx=c_pps a=CQ+uznrK75NoT8CVPM1Etw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=_mo5Ov_VicZQ5TNRUswA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324162402116600 Content-Type: text/plain; charset="utf-8" All of the cleanup can be done in the same place, and vfio-user will want to do the same. Signed-off-by: John Levon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index a1bfdfe375..d96b55f80c 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2854,6 +2854,18 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev= , Error **errp) =20 static void vfio_pci_put_device(VFIOPCIDevice *vdev) { + vfio_display_finalize(vdev); + vfio_bars_finalize(vdev); + g_free(vdev->emulated_config_bits); + g_free(vdev->rom); + /* + * XXX Leaking igd_opregion is not an oversight, we can't remove the + * fw_cfg entry therefore leaking this allocation seems like the safest + * option. + * + * g_free(vdev->igd_opregion); + */ + vfio_device_detach(&vdev->vbasedev); =20 g_free(vdev->vbasedev.name); @@ -3302,17 +3314,6 @@ static void vfio_instance_finalize(Object *obj) { VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(obj); =20 - vfio_display_finalize(vdev); - vfio_bars_finalize(vdev); - g_free(vdev->emulated_config_bits); - g_free(vdev->rom); - /* - * XXX Leaking igd_opregion is not an oversight, we can't remove the - * fw_cfg entry therefore leaking this allocation seems like the safest - * option. - * - * g_free(vdev->igd_opregion); - */ vfio_pci_put_device(vdev); } =20 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324081; cv=pass; d=zohomail.com; s=zohoarc; b=aDNC3fJQyJUfNkTZXcDE0ItKt1cnbHdRbRcS9eEeYbCmEOIvsEPp89f6ja/a08oKcK3LU+Bdmxn8kn7Tta5ORuJuXDawqFmCOUb1cf0erEBCuQ60upOO/1G1pO/LxHKgwnVhzxe67VLsmLU3uUoo+Zb6TV1fk5Ns6K0PKksT/uU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324081; 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=sJWhCq6bCtaHFBNDEcT5XhZrDmbqdEHKdCDmnsLfeGU=; b=F3n/phK006RflCZ386cfc2WDLsq9mt7sRuOOhyi4EsZM+b+vok8gTo4vZOjaMFkVasz/BiD3jTBOmU3ws4Srt/rywY5AopRqWaqx3Nch08/0QlFpj/61VGhTb38WpjRvlTfOTPFqIVJES3mEh6bVZ3YqGHw3viIO1Ex9sYmadmE= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324081787760.074716718245; Thu, 15 May 2025 08:48:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFam4-0006yF-BM; Thu, 15 May 2025 11:45:32 -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 1uFalI-00062c-SG for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:46 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFal7-0006Bh-HX for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:43 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F9pAtJ006566; Thu, 15 May 2025 08:44:31 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010004.outbound.protection.outlook.com [40.93.11.4]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcwwdxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:31 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:29 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=sJWhCq6bCtaHFBNDEcT5XhZrDmbqdEHKdCDmnsLfe GU=; b=cQwfHwTH1OsX4wbz0W/JFBhup35IaPR6evzCN1wOiwxD7wkK3iWypD2PP 0ycrX7x2QsGdedMJBEVMK0lXLfdT3CJbUQ3EC7sSEAQxHSgiBULcu95OR4DEtM3F ke6av2OT0AfrUNISFjKHoRWZUUGQ/mZyyOviGIPFND8qMuxh3WSGd/rB+IsZdrGS 9rHSXB2C2PyvP33KT8CV/bi2QVp/0Z4583nORhoD+LPl8rkrcJs9UFpT7EI0BIsd EHEepXd0t3fQ13qoP8SFxeIYTaudiYciyYL9L0pK95f3QZgbLO/lgVmPtOtFBBI+ SXLbF3hC8zgOchtARHNxwdBLJhUpg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hkYFeVBxq3jAmcW1sgI9IyTwDEPw3uE1rGx1rcOJsf/R+YVLR26bDI1fFkWzw74M60dtgKWnxpPms999RqVc4H74f6AMtZrq1QwbfofGsuxIAfLGXk0ziVfzANaoMgpXCpuzx+SRQ+5jPZ8im0t/oJ8oCpf7BcH/naqbRMck3cSuq+c7CLsucVzEmc8yp4IkHY7gNys5G2zhMCMa2enra7Tdumxy+OG7sa6cUfHaV2Haf9+NJbX9/c81jG3QrNfP6ji5GK02IHW8BgGcQ0Bc/SyRq2n9aMIFwpTy59wWvX5KVI5ipUB+xrvZgMEOS8ZOYnfzSB5XHpsdGit0ESip2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sJWhCq6bCtaHFBNDEcT5XhZrDmbqdEHKdCDmnsLfeGU=; b=mqQ0Y6r2kVPHLcqS/Gxyge5Tjdpb0eTIa2d62D98eSrrU2Am+MX8rsjdiKbOz8m/l3c2ZMDxfV8S+7ahFp9E282v43V5tSjExGz9OUF52Sr9d4uCogsyou3qtjrmzqdVNudIlNjLw97iRWEahE1cJQjmjTwjgaFwcgED+4akOageIlY7YtHahkpeRfa92/Lbz7yRKLM1bcMaOPXRjyQyg8nifVbi3xFrW+pYpzhlWnve+AS4OK6Zws/fVrdnF5VNdI1XwwMkn2HQoo+CX0JCqe5m+L+yc4hE8Q3LhhAAFlp5WY/Rb4EoR+Amz5yPynw425j0fAMu3dpkizfDpuFRRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sJWhCq6bCtaHFBNDEcT5XhZrDmbqdEHKdCDmnsLfeGU=; b=IBF3Xr45kaewsfEieJ6tZOHRFBahOIMLPwJFzPULKnd9MGBrA5voN497OqP04E1Ry/tSzZxGC087CNEvB+NUP3U+RTOjPI3V9494+yXJmykVdQVciUSq5gNI07PGC4jARQAL6n3y2bwEBUMI0Y44pH1zFgg9wIhEE1xtFPLLjJZAMn24Sk2SBIJBMsB0hXkL9S91r02N5y74J3nBgPZDaEHXQa0oh56jfkmjhMGNKWahOOUWSvm/cTmSzHL/ebxlvV/wfexgkChCaIyr33ahr0HrbRfGZkpFegTRiroMEVdu4rjgVbS29t8pptlusiMqv+eY/Njc/pZFX5h1F8R8NA== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 04/27] vfio: move config space read into vfio_pci_config_setup() Date: Thu, 15 May 2025 16:43:49 +0100 Message-ID: <20250515154413.210315-5-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 436bd3e0-88a0-4d21-262d-08dd93c760fc x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3U/zY2Pk578RzKIm08kzvRdHuPYIc7AkSnhmqSeho3i1DFHS7e/FGFHafynH?= =?us-ascii?Q?SxanEBTmuPh57f3y01dkAgXnTKPr20fiHNFW54ancaDds1YxMuV+e4t7D4S8?= =?us-ascii?Q?GzYsfODRngWqpz/6CJmSVmKhZ8NBzywmJHM/TbuUJx4rfyB9C6uB2RqYsmtP?= =?us-ascii?Q?LkCy9/TNyyO7WfORwPrUpV++vSqDLYmDuvB35kQ9h/k3d/IY6c0nth4HxGnU?= =?us-ascii?Q?Mw/0TzHUNRmGKeO6iu96WKxHKyGULSuBQV1zIaNn2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TllL4RLeh1fT/0KJSW934A7cHe776Newt6a5SGtib?= =?us-ascii?Q?YMSTktPhTe5RcUliujQQiKGZ6eCXgiidyebhTwzwRxktbHKSUWcuqVNQNwXq?= =?us-ascii?Q?t7d/rJqUacY9naaMeUdOrww3EPc8nDj+dBAszH5wPM8blegw/tr2qpqlg+z6?= =?us-ascii?Q?ukV58WJ8uljcpXJOiEJ6f34XqEk8zk3yI3uD2SjPqFWtEcX+oMvNTY/7oyHU?= =?us-ascii?Q?FK977WqT96O848BdwSATE0qoiJ1cHaEOnuGucgMf0fshHeHFV1K5yYa3K8zd?= =?us-ascii?Q?862bFMhxQwE=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ORf8hDkPVmPszVmkFlQqliLF0wvOJ4c75TN1u2Cropnz1VOX6KkGeA799WQj?= =?us-ascii?Q?KBtAB39QPTMpK69eHwACYfepfwWpaemVr8ts9zr8AiT3eFtVTn2Fxqr72Tbx?= =?us-ascii?Q?gp97ORmClzd+jZGWB2G5zGh9tylUt3D0Qyc4+r7k6gW5JYZwIIbLZ7U1QU2X?= =?us-ascii?Q?0TSa6Vy5pE16SSySXhZfRCBzfzpEnGFbpSjxX4NPZ5vwjRtU2OzQ/5DyhOoL?= =?us-ascii?Q?a7CuopIxGnfqvNXfZLmeXwwu9U+gxSygjloMJZ6yOehwLH+KFBP9DuiXZSsg?= =?us-ascii?Q?1LiX6tN9EzpsLnQfac/2xSMdiboZJHHNpEKSjM3YS7pqYixk3Bho7Uahhy+E?= =?us-ascii?Q?dYHubgairo1SaPjopwvxucZ7AVVQqDHkhq/bzzI5kICckSul1dxiNL6G5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Yz1SmQcS29U95Pg7Ty7s?= =?us-ascii?Q?IZo5Y+iWXVmypPIWG5BwZiVE91N05FzIWetFfgtV+jszhXDemdB58kdw522s?= =?us-ascii?Q?qhSSOsZS4XdO+NGEEmwINg1INGbwFXPblIAQ4+Ab65bnSPwE0E4tEFYEqt8V?= =?us-ascii?Q?5Ppgq2DOvr3deOboLY2oTMn751AQM0TSyev7yK4TWzFbxB5dyUXSH5ID4bXU?= =?us-ascii?Q?zMb+Uh//EdA1s8CT4C/d3IpgLvSOHCseKrs+Fsd0A+QhJodyan3yMlgZ8MCk?= =?us-ascii?Q?wF9T4XvlB0RgR9lqNpKEfAZGGtm5MhPu7VLX3MES?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 436bd3e0-88a0-4d21-262d-08dd93c760fc X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:29.2763 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C7PobCagSNb12AvtucazT4FrwQJ6HhrL5leV7L6MbQqw0sy0r9j/p6nV3kFp7u5BCZCsHw85sy4LeWwN74CuAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-GUID: 2NeEDT3-LYHU6R7LjDrWpooa38L4YQLf X-Authority-Analysis: v=2.4 cv=fNg53Yae c=1 sm=1 tr=0 ts=68260bdf cx=c_pps a=uYdjBAypVXkA+ZVpDPXefQ==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=FCJwmHiiXP3F3EZgyVoA:9 X-Proofpoint-ORIG-GUID: 2NeEDT3-LYHU6R7LjDrWpooa38L4YQLf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXwORxSX/0f59e qy5hy0X+/ZwW/EWQZ3r2+98b+3ucpHypciNdaRpXgB8buFFoVE4TUD2aqt829/Vf5ARBEZ5fMlA MyuCHn7HNJkpgcCBzcol0LzlG+cW0aINtQCHiY472SWAF8/oUnKLP1xkT6TTZcPpjKypZ/W5Aoo crcLr4ETmSigdP7MojUmqSKVkRZkdkS8EZoj8H6ZDwH0KRzVmgtINYgty+k1swA9n7Ybp5/xIcl Mmgu2P+ZSmiyIQ7aJc2lh8nl/GBXxWbQZQb6L/XofebgTls/g/ZFVIzlEJU3Ik0Srf1vN84x8Wt YHc5JFflM84VtT/fIQfCHuxl0VZ9MWVpmwxEMh7r1wWbNiBJkNqhvrXVW0qMWkTPn8Baq2mXSGo zmnpyfeKjO4YSuTS5p4CS5KcSRCvbN5qmD7yWu+CRcANywa3rl6dlwaW/73Et2VwgUj4LNjj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324083380116600 Content-Type: text/plain; charset="utf-8" Small cleanup that reduces duplicate code for vfio-user. Signed-off-by: John Levon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index d96b55f80c..7912c17dd2 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3017,6 +3017,19 @@ static bool vfio_pci_config_setup(VFIOPCIDevice *vde= v, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; VFIODevice *vbasedev =3D &vdev->vbasedev; + uint32_t config_space_size; + int ret; + + config_space_size =3D MIN(pci_config_size(&vdev->pdev), vdev->config_s= ize); + + /* Get a copy of config space */ + ret =3D vfio_pci_config_space_read(vdev, 0, config_space_size, + vdev->pdev.config); + if (ret < (int)config_space_size) { + ret =3D ret < 0 ? -ret : EFAULT; + error_setg_errno(errp, ret, "failed to read device config space"); + return false; + } =20 /* vfio emulates a lot for us, but some bits need extra love */ vdev->emulated_config_bits =3D g_malloc0(vdev->config_size); @@ -3143,10 +3156,9 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) ERRP_GUARD(); VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(pdev); VFIODevice *vbasedev =3D &vdev->vbasedev; - int i, ret; + int i; char uuid[UUID_STR_LEN]; g_autofree char *name =3D NULL; - uint32_t config_space_size; =20 if (vbasedev->fd < 0 && !vbasedev->sysfsdev) { if (!(~vdev->host.domain || ~vdev->host.bus || @@ -3201,17 +3213,6 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) goto error; } =20 - config_space_size =3D MIN(pci_config_size(&vdev->pdev), vdev->config_s= ize); - - /* Get a copy of config space */ - ret =3D vfio_pci_config_space_read(vdev, 0, config_space_size, - vdev->pdev.config); - if (ret < (int)config_space_size) { - ret =3D ret < 0 ? -ret : EFAULT; - error_setg_errno(errp, ret, "failed to read device config space"); - goto error; - } - if (!vfio_pci_config_setup(vdev, errp)) { goto error; } --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324106; cv=pass; d=zohomail.com; s=zohoarc; b=E7ZEEwbeukes1i0ej9yOjogi2+GRHnIKa7NTfJoBt3+U8EtZPN74EsDzLe//xaATAAGBXGqrmHWhls8XUBoe32xs+d5xSkLmWyTONCIg5/Ou4nUYF6q/81afxy5yrLRiHJlBsscbnE0I0FgRc79k+2IoEKWKEoOJeLT2CBst5WY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324106; 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=npqxWyJMo2rtaXRZ0jYvnVrrUmWBxwfW5iGHoqj/izI=; b=SAmz2VZgHycNzy7aOXZlGj1GOI+DduTgylBWMhrwRGkb7c0NppYYqeiMVhI1uNfjFeEqgABk9v1PGIp0OReRy/nfPJXRqDmPPHkSP29snmcr1H+AeAWUeav/PrteJAb2BiVvKzuWC2iWAxE75aSeqcfQzlmwTm05N9u+0o45pT0= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324106710391.64188264390884; Thu, 15 May 2025 08:48:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFam4-0006vp-BG; Thu, 15 May 2025 11:45:32 -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 1uFalR-0006BS-83 for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:57 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalI-0006CR-NF for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:52 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F8GHeZ021276; Thu, 15 May 2025 08:44:41 -0700 Received: from sj2pr03cu002.outbound.protection.outlook.com (mail-westusazlp17013076.outbound.protection.outlook.com [40.93.1.76]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbctngvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:40 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:31 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=npqxWyJMo2rtaXRZ0jYvnVrrUmWBxwfW5iGHoqj/i zI=; b=uVtuOCnVrmktGyo3jLQKq5dcM68t/0oqOsTdtB9X+OI265rxJR34nBMnI 5tZkel/6Shovckp4OpCKMC2HVLjT00YtLkZFnhejGVWUPXIpimHMAPWS55rqHBTO F+akpKtyisn8BGhJP+qgAxPk6boQNP7/FBfBm9jBLoU/kUDcXfEbi+A7LRNo+gxo S7ulu6wsBKGvPhWRNCIRPqVNFh6Gh3etbjQtAqYk9D8eIwSufns9BXaz+ZN7Bevz +tq5AFewDTkjgwRDiTYBN0KpIz/VWEeX0PKIyWfmSnT3OnfOCwCB00xRZAwTijDW KF7r5Pk2j5os/Kd49KHZQCjUo5wHw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M3/yBF24Flm3g2e3k02Z2pTqgGycAhtgr2YylPmoFwbr5n8FqTrqCIuNpWUtfiFpj1fHRoBrULtRPtwQxjDskx/0eVcw6aBwI2UdES+noslPB15VAgKkYfpxI5pb615Zs9DXrA8wn1xZs0AmoteHyU2gOjccPC3fe6fXK+wmlNCADGLM9NexR66DBo7J6KereZzlAU1JQr8Fu1ZI5qbw1XcD4u/H0/Z6NboYDKuc7i5RlR+eUO8JNqAtF5nQYUVJlNIOJ3ivMFpxKA3CxzeJ0/aDpS70p0owY+PU7JigD4wv2HbLTObjc90Cl6eo7njVk+LoFAppirHF7Ms8xGQlfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=npqxWyJMo2rtaXRZ0jYvnVrrUmWBxwfW5iGHoqj/izI=; b=lyf3Ec4Z9w3+3DxyqYjLzwRxb6o9EUpbsZKXXqnuFjC10xoxV2RP1rCW7txR+M60lxvVChXNuN1PYDXppL0nVqPBvyOID9BP9SJ2zKAIeRSlgKtHhXCf1gs+HwHaAomODcetZwk2KeEWkYheueeqTeLuZ4n4Blmzl55ywZ0kt8322ZjuFu6p0KLFYhImam+zk7WOC19ttWOdK9xl3MW+UmG6yZS2EBKiv8vl3DuEcTOG3Vh7hn91nxgihbQ6Hm06rIH5JdhAZbbCybBo3Z5buTZJKlDVmV16X6QpvPcjtfr0W5MWry92LMO2UKvd4ihmXlPXCbuFkHpGIqlyRIfyJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=npqxWyJMo2rtaXRZ0jYvnVrrUmWBxwfW5iGHoqj/izI=; b=GudyUDWzndc5Wg9KOr399TjLRSnM/x9wuajasKhronYv7nJEdfx5Nu+uAjq3fIshJ083hPINhyuSBYZec33PI4OQsalVNeij9c79KlD0uIqDH5h1oBpf2lPFQXUeR0d4jgVo3iQ+n3/o98q2yzXh1i2U7aM+O7ZDBtwHUtLXxJCd3HlChdq7+u7DO8jNUFJKe+71GHK3Z1ZL/hG9K9AqYg+Zjb8w8woVWiOdcfNH4E/5cg7M2KA4pKQ8V1RIiBGt5RFYwg/mgWfi2VkgdluxaoXjlQ9wHktz9hlmcD1V6ugxO8etSjpWrMpkhU6oB+LGeRs/ZPkmLoQ/dLrOf3tXHg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 05/27] vfio: refactor out IRQ signalling setup Date: Thu, 15 May 2025 16:43:50 +0100 Message-ID: <20250515154413.210315-6-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ea78c17-fd5c-4af0-ab51-08dd93c76248 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rb20YSNB7KYQnXVfIUYoFabYiEeEjLkYu0orHpUVFwFohi2xGu/nDv/jCB7Y?= =?us-ascii?Q?3pOelBgzCvksOkhERnaicJPUi+UDZhrwxZ1rXGUALWytuN2XyflMdjl7Vdjv?= =?us-ascii?Q?eExdxj4e6JDHvp8vFe/38Mn5EtqvL7+CmrDEiaJhs7FOnyXbfLdf67f6nYwc?= =?us-ascii?Q?ERgRoAb6DVWKSyUnqvB2RfRaJ16WdNuKGlTb8EmMjxUjtpdqDcuyMC3IImvW?= =?us-ascii?Q?Ue+XXuTOgqRqpCPCBc6GPqco6x8zLI8kv1opybl/YKR4n56igqSAESq8W64k?= =?us-ascii?Q?vDQff++IDmUQ2Xyypfbml8WmvgMclurDnRrxyJUzOoTEs4FBVPnVLPAy0lN8?= =?us-ascii?Q?RnrpouJCEu7aTy58HXo7qR9HFrHaXxJ6oEIVR/vrSO9oauOlJtQahwEYtY0u?= =?us-ascii?Q?uVR0vEOtzA8LbFjhfIZfHdW/3CR6oH0PjIoMvITH947cwe5jka9tmQeMhZsZ?= =?us-ascii?Q?kHWg1mL4BKbM6/+nPG3mXZL6OHkXdsre7cIS3LkYxplwoIWcyRHH/NgOtNEv?= =?us-ascii?Q?FbNLcWMoUDZiTFM8RQ5vHlG+SNRJ6EL9qMCjjyzNX0mCBUTYuBQjk6l+lcT/?= =?us-ascii?Q?MKKnHGolMqyIZi2Yf/sFZT41BhJpCaETVKsShIATrFhNcnvEg4eG8Lu84z1e?= =?us-ascii?Q?nNijmwPAECMPSjG6bO+GG9+ukJ/ymxdfxmpxTvcbV/aHslNVo5lTVqS1g0bQ?= =?us-ascii?Q?ouo/L7G++wgaKOcWfQ97VB0NllONo9IOCX943FCVOu5mCSlsEQ847IjRyJ9l?= =?us-ascii?Q?3tTtiVMVak5JvcLaHCxXSKfyrPckf6g93uagMPFo0bPG9a7N/d/2Q2dojil6?= =?us-ascii?Q?3jwMGkTFLd9LyrR806+243D8FUPDgaHHAqA+6N1TWbK2dKclyvD1EEjlVXit?= =?us-ascii?Q?2F/BLFOQTl12K2uZvulpaWH1hnXRrMHnPjmHaFKaPbBhufpgGEwxMe9aYr5a?= =?us-ascii?Q?9sdSS85QVIuwZfzCRWxTz45/XvxsddviSm7Ypclk43SzdE0et6dXUDlSgnfB?= =?us-ascii?Q?qTdBgVltUcPCJ1Z8ZfNc+k+06V9B9WvsCukl5Vi0P6J+T6YF5H6/G+ZhsRWP?= =?us-ascii?Q?H64igZS7iQLbeMWLhanRIEMogIhHXyBPYoLrg2kOotB/dAS7bCp4YcjJwbp+?= =?us-ascii?Q?bnlO9aKaEB8czrtorKpRmV+6co355dPAXD8FyLMBUUyoML5zU6K/mw5IZcZh?= =?us-ascii?Q?/i0qk/KM6TQ3D39zo+gUexNpyPk6Amlx0L+alWewl13h5da6wC1Y0zU1NAOO?= =?us-ascii?Q?00jF7tdgqLYMk8KGaL+C5n5XGNBmpNr9YmmWydGP27AQXdQ4prhiL/pjTCVp?= =?us-ascii?Q?EeP08q09xMNlNkDxALV0OeAXFVvGtCpuNRfV+wvyohhtLCQFW7rwVOL7hVbS?= =?us-ascii?Q?Wdt8PltVJO4EY/Uca+wSYlJxoWIqMMkHpmeAy/xX+T5+2CogxA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cTxxvlHj0vCKR+ou/b0wIeEVMizO2r7XB9vDGaHJuve5dRryTLhDTYVtAc97?= =?us-ascii?Q?j1MTLoS1oL++9qSLZ3c5eBkAblY7HGByP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?= =?us-ascii?Q?hISFIpsDuxUfmmB0/v1Tn1SjPATC4Dd7PGMwTkIOPEpz3Uk54qnGt32KqDOU?= =?us-ascii?Q?/van27b0XSDGC24NN/er2oyzZEZi9pBMTpxviugTL/PbbyrhfRiE0h1s7D31?= =?us-ascii?Q?8RA1tlDdoUI+ZJDs70Gslle3TT6CSHVgUFUI6sskczDQYu9qEHX7FKW/dlIG?= =?us-ascii?Q?lHcCytFYmfOrrjTfH7oOpPXQKEQM9NFm7vxUORDABgq3dnAOU1WAh9JHqc8j?= =?us-ascii?Q?yk7UMWGNNs3bGitPv8A9PZC96ccCNYMv7HVFXUIBk14h6obOwgujath3IGZR?= =?us-ascii?Q?i1slu21hKm312IT8K2/AIA3YyzZhWX8TSeWKiWBLOpziejQEw70MRFnQfsBb?= =?us-ascii?Q?ifhD+egRe0nTqdFfTmKHSLfdzm5depRE5cXvHuwOi+JK7KHB1f6jY9dmmKoM?= =?us-ascii?Q?urwMESwuY0OJb+wNyHMdFsyAZn/bNXPrjvMG6c9G2YH1QGV4iXk7NZxCAzCC?= =?us-ascii?Q?PQvNYQPmTz4BY8b0HkZwK3EJyJuyo/lMlx8zSNH0xzP3tFaJC+O+QMOrjISA?= =?us-ascii?Q?nZWPbOXTtAm0N4aGQWJQ5Pv5DCpLEsrv2YWRZ31Xj3ErztF4wvB+qpkNeLA4?= =?us-ascii?Q?ZWvyvrLQxulne7zfjt1ijEmmQBn98Xk+sAVxf3a6?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea78c17-fd5c-4af0-ab51-08dd93c76248 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:31.5015 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zRQj2yL39D3PCjoe6VGW2zYz3+8kox+5fRCFYJET3NWmvzHQsUE995ywEvnwnZ3Qkz5AXf/8bV89cDMStXlrhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=euLfzppX c=1 sm=1 tr=0 ts=68260be8 cx=c_pps a=OVSnam+0waiSP26xbJD4Ig==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=Cuy1blySaGDMMkobshQA:9 X-Proofpoint-ORIG-GUID: 9w-vwXJb0tWOUuRCoMPIITCdLtBr9f-5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX7QWNY2y6869q Oh3BMO+ZBCRUNdsKQtv0eB0qB7twmRr5JpCizpSzVKuIn/jNUoFX7TtqqNqFw0KmeIt9oKiZ1dn BUTFkXn4yuIY5zPypIgdL4uIt3/ifag8sgVRJ8j/RYld/ftVxjrLC4mvV2HEYap30aeOncDXZgY DV+Vk62aOr31YVZTtA2KKSkUAT5GERzZtDg4XBHHDSevG5n7goak4Qb5/+W5z+IXttyjfoM09j2 pMVat+2k68nQAwfJ9Nsak7BhviKGVjU5h8po7PDFLy/isBjCGXMkeNQAlZQ0gN0t85Z3OLtcPsJ yDh9N3XZL0ysp2vufcJkqoaK+fo+LGQQILsBhCeWAxLwaIbXyX88nbaaCs3wlJA7qb329xuR0yM 1uSDEKXYYOCjHjOXSdc8bjoR6OQO1LPK+ltLQ9FpsZsvXdzTiVccu+EI4kAPpEJJ03PdbWYR X-Proofpoint-GUID: 9w-vwXJb0tWOUuRCoMPIITCdLtBr9f-5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324107997116600 Content-Type: text/plain; charset="utf-8" This makes for a slightly more readable vfio_msix_vector_do_use() implementation, and we will rely on this shortly. Signed-off-by: John Levon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 7912c17dd2..9dd0bd4068 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -511,6 +511,25 @@ static void vfio_update_kvm_msi_virq(VFIOMSIVector *ve= ctor, MSIMessage msg, kvm_irqchip_commit_routes(kvm_state); } =20 +static void set_irq_signalling(VFIODevice *vbasedev, VFIOMSIVector *vector, + unsigned int nr) +{ + Error *err =3D NULL; + int32_t fd; + + if (vector->virq >=3D 0) { + fd =3D event_notifier_get_fd(&vector->kvm_interrupt); + } else { + fd =3D event_notifier_get_fd(&vector->interrupt); + } + + if (!vfio_device_irq_set_signaling(vbasedev, VFIO_PCI_MSIX_IRQ_INDEX, = nr, + VFIO_IRQ_SET_ACTION_TRIGGER, + fd, &err)) { + error_reportf_err(err, VFIO_MSG_PREFIX, vbasedev->name); + } +} + static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr, MSIMessage *msg, IOHandler *handler) { @@ -583,21 +602,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, un= signed int nr, strerror(-ret)); } } else { - Error *err =3D NULL; - int32_t fd; - - if (vector->virq >=3D 0) { - fd =3D event_notifier_get_fd(&vector->kvm_interrupt); - } else { - fd =3D event_notifier_get_fd(&vector->interrupt); - } - - if (!vfio_device_irq_set_signaling(&vdev->vbasedev, - VFIO_PCI_MSIX_IRQ_INDEX, nr, - VFIO_IRQ_SET_ACTION_TRIGGER, fd, - &err)) { - error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.nam= e); - } + set_irq_signalling(&vdev->vbasedev, vector, nr); } } =20 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324204; cv=pass; d=zohomail.com; s=zohoarc; b=h2khAqFajHSsP4fynXEL6Ghg0+kT4B8d9h7WhkU9U0GL+p+0wwbLYLGR0V4oio5igi8zZBu6IhD6adwFJ/7v3GMG4zC4iGa1fDVkwbnkALTq9/Q2wRZMgphQqxpjYxIUZYVw3oISnUYM6dmaRhIPRataCvf3mJxq1OVrd4BOnn8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324204; 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=6efGDQ5E+PyV2LofmeWE2ZwHjNBUgMcIRbU2OZQdqSY=; b=HU5/au3esyPzx/tjMDtwu+SG2OHQGBh6YRFZ9VFrHREklIjP3X7gboTlyQdhwbK3Nygt3NO5yCS1ZZcjUGkhcUgmtlCPKAzH+sVfiIHgK05QGnAOK0e886vlyVh52HE3MeF3HapVfawqcwyQeokkd7l+mDL/TKrj1pphd4J1A50= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324204331356.29541837643035; Thu, 15 May 2025 08:50:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFamA-0007aZ-I6; Thu, 15 May 2025 11:45:38 -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 1uFalP-0006BM-Ve for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:56 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalK-0006CT-GO for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:51 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F8GHea021276; Thu, 15 May 2025 08:44:41 -0700 Received: from sj2pr03cu002.outbound.protection.outlook.com (mail-westusazlp17013076.outbound.protection.outlook.com [40.93.1.76]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbctngvk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:41 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:34 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=6efGDQ5E+PyV2LofmeWE2ZwHjNBUgMcIRbU2OZQdq SY=; b=K9g/teqGuOpZgBm7KX/JsWs7DTVXcwD94/4f2uuDUM3VxbpyshC4w/5GP yReZERcU+V3gjB4XabDpU++IOmyrCQfCMjwHagdYmC1PtD/rnVLsuSV8gxxH8wCQ 42k+ikfoyzuTEGKAnCnLiXXAW1eflLlCrpBLsTGr10u58M6KibS887A/Q45DF+F6 wc248NpFdRbTYqWWSVl5PqjExPgDPliCraDxRLwCSEDv86idHUC80B6wmO/K+wzn okoCxAdHdzBq9WSPMy3fSwWkWTmDE2rXcL6DPww3ZKw6KfBnmuc6QYOm/Uc2/esg wz63Ryh8ZhP34hIbV3FKowyKJ0NCQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hkv7fT4QuJVsvA1YjbhBRf8BV2uE/iT+av/WAAj4xEjAhNCOSpzXfuL7I6gQm5AsSbbixtdfvs6mhjoZP482DaYrPIwDQmUQG53UGWyu/khlzgl72WXlN0e8Cye5BVjvbnHCAB7LQX97PuQLs095/xRlSysY97Q9ndLUw4pKxDxhpcfNa6kRvdDTJPe9OhZ5Vqq2h6LMTOoWTdU5qe0X3uZEq5aUVmNegUnDnqicq6GVfGQJfMuyulXk2AV24w1YwbEv1hzkL0h6irbJXwsyntCkU7mRbk9YX6axZAAjmS5twsgDPJJjdTK8aUm8t9AOLcVaweqMEGbgFSQAYmWnfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6efGDQ5E+PyV2LofmeWE2ZwHjNBUgMcIRbU2OZQdqSY=; b=yT7F8Cs2sMrsjFPbuW+BVumYunC0dfJ8WSrdcH+hbYaoctfO/OnMA6ukyfKZ/JBhSV+YdgGq7sU1c8uJ4mtev9DNmqUl3KYiT3woUZYbxH2lap1OK+fdzlAAVWkbd/XfGHEyo5+VNR/ExnpsE3cZYPOZZ9i7BmhFwj3on73ktH6uaobRI5vFoO6mKVWrhjXP3ZeJnHPf0nvXTAYZuvr/PESWr9z0TPhUUEqwaVPdIXmfJRZRBTKCvTN3LdgcWrjel7j0ADAQOKnJmAKxZPnLF+qk/6kRJf+Isv3W0CmsNn0xU9aAMRDjRkGumF5lypuwWlDopbAprUr5qNa8N/KZFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6efGDQ5E+PyV2LofmeWE2ZwHjNBUgMcIRbU2OZQdqSY=; b=wf7iaVMrDD+cMwt//WWL5fORHfRtVpVK2378Juv/AG4yb5NlUlZod+RnwYTHV+Mg5BLJfBT8+wDtZXdhrYbkcCnqktMMdmM6/dcMh0QXyN53Kr32hxOHIklf+BBvStIWD47yk7MSjZ081nNlEBY0Jxk5hBjUFPzUrZaN6lKbZ9dswHxqCx+FR0KB1PqeKykmw9uug1v/e/Zu4SGiAzkVqTMJRZVkw7DL88szW4oILZxlr8ADbQiL57Tx2MePIty4frq0AvgbDCNQQku5cjo20F1JW8jnE9Qw5itURACACL1N+hJv6us172rmW34/d625dHKzzP4YwnDbEjr8QGvMBw== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 06/27] vfio: enable per-IRQ MSI-X masking Date: Thu, 15 May 2025 16:43:51 +0100 Message-ID: <20250515154413.210315-7-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 757d183d-e433-491a-38c6-08dd93c763d2 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gPQv+Q/e5G6baCvrUlMOaHgTh4m38wJJPukPfnj46h+HSc1Ccv8MGyvh8btN?= =?us-ascii?Q?E4N2HWZ0S9S/rJcbQKYHaDBh76j7gmJWUrepKpdjdRV1lviyto5NDzCGmA/I?= =?us-ascii?Q?Sq3WkXMD80tKyeB41BeU1n7m6g6pNY6TF/jgbKMNDWkBgN16kPD/yFUp7btY?= =?us-ascii?Q?oFyRjXMZMDi3WeKtYuTcPirmdtvRV0ZSZkb+oN5tNBbMqXf2ZXtMqnJ6up0A?= =?us-ascii?Q?U/tK/Wj7lNoKJLPd9eTjExlxveba7damHUOgVhjVYOHY20XBTLUHWP4FDQCJ?= =?us-ascii?Q?GhhwEEruWhgWPzPQu5WW/INokLZnPdNjZ5KMj4xcjMI9c59E1msZUKdpry+L?= =?us-ascii?Q?XAnmZX7MroK4dnsl6vl/wy2nSYMhwP83zCLiBPKbhtVNTob+zIUHKIl0fhXf?= =?us-ascii?Q?h/ojUEm7DE0dyEMu6bUW9vDE5ocdX8nlhQp9dtmQUacdAsOYM9ogEKk0mAXB?= =?us-ascii?Q?/kUqjMw4fQZEjmJ24ovno3Wy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8PjPztnI6lBm/RM8GeXSuHhxnAKXMOaShU/9bZJ0mOL6bpBq0FoBT3MC/?= =?us-ascii?Q?dxu8o+q7N9M=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ffCW6gdlGWNTTqaVwvQ1us6aa4BkqmeBg+QZJyIJsdu0HP5/ncaD6RbHnIKB?= =?us-ascii?Q?8q6VmIYRU3Z5bw/C6HHdWRxfGORpMHdcWgbVZJ6S75FbDpwmlm/eBWS8rIT8?= =?us-ascii?Q?O5WCKfBbAVsGXlhwciUeOXJQ3DytU5eF1qiuLAD8BSkdr7tNou6RXenSPHKl?= =?us-ascii?Q?Mqr61P7xiDZ9HVpFoqdSp21OEp0eMVq0AqXizH00p0rHCN3EXC8ZL1yL5esN?= =?us-ascii?Q?xN9DasFCMY7efLlmhanzXJn+Z6FYgG8U37swLEgVFxeGeRjEDPyOiw91YsAi?= =?us-ascii?Q?RqC2KfRgMenFuC48Zy9duP8etIdV/xD16RQ44RjkonvDhRWBgKC2iYlj1DRQ?= =?us-ascii?Q?BsO3yq86rthCdgquoKWd9HmAUaOti90i/WoLJLyvpdeY6Ot4lW7GbVzoaQgF?= =?us-ascii?Q?fe+ApKtvqaNYLtKBxqOdcJHoiOjdukjgv8cbQgrBB0dMZRs5A9WMQjzSmXaz?= =?us-ascii?Q?Y//gWYZermeao8DIfhH48faDEeRfDRccQ1QS3VUbWzpDymuR1CMHMt6BawuL?= =?us-ascii?Q?IWCeyj3rfCfWfxPjdHT2lI+6DgMf1ipBPPI3mWYj1z4S7Ju3086nHcIQdmma?= =?us-ascii?Q?NPsbUBwawpL/tj23+i6emuni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1Pj/?= =?us-ascii?Q?6RVT5h69TOuZhshPWPXlnuOCpBbG+fJkn1kqvM8UEdwehVyqCXjlKAdFUds/?= =?us-ascii?Q?FvfSgBvQRg5aW8tDkF/UDx9sP0EuhuI8Nb3PPivc?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 757d183d-e433-491a-38c6-08dd93c763d2 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:34.4058 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SyD932tonpt+tBtxqEha2DqK4OCpch6ArDzyP/4kL0xTVW8XSy9qwIvtDeRutNgQBYWZcW6V1BKteUcttBBWcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=euLfzppX c=1 sm=1 tr=0 ts=68260be9 cx=c_pps a=OVSnam+0waiSP26xbJD4Ig==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=_brLm_9mC3lTafiPIV8A:9 X-Proofpoint-ORIG-GUID: 7HofQFzB9WVQYOzzkk9cE8eBShydGHQP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX7ash+sGs7mV/ B06PNt5ItiE9ncIpTWbJS3tQwRC9u6iXgCpPBgtDoPrQ0sj2Xheqpk3oq1viOebznqABt/+HZeH kuX2BhrW51OPIKTC0paZBVLA0agtZaaYCA0DzVW50GUCEaHEJ2bQLY2V63IcRCFyqUCqYv//7mV 07BP5JR3UhXxKEsgZnAOR8Gskk7Ihc7pDO7yKNFCZGf1tYnxURM4uCZlw2tEcvh7VtMhgV9Z6uN rKbmk7cf5k7uen6c8CclR1og8dSONCoy7xv/8irt/XWje+OY2ga+f6cdsQ929y1NUU5eFRK4j2h eFIMakhPqchpGFOcOA2X8zv43awpMABsvKna3lOWIOuoTl8X/XKL7OU5yLix6CGX1neqtkFOlKF IrncL5aRNX5T4eFLTu86BDhcgw26KcUhT4I4UB0BNK7+pEG6GtNOxSMkGvkA9ge37DheYmJo X-Proofpoint-GUID: 7HofQFzB9WVQYOzzkk9cE8eBShydGHQP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324206907116600 Content-Type: text/plain; charset="utf-8" If VFIO_IRQ_INFO_MASKABLE is set for VFIO_PCI_MSIX_IRQ_INDEX, record this in ->can_mask_msix, and use it to individually mask MSI-X interrupts as needed. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio/pci.h | 1 + include/hw/vfio/vfio-device.h | 2 ++ hw/vfio/device.c | 26 +++++++++++++++++++ hw/vfio/pci.c | 47 ++++++++++++++++++++++++++++++----- 4 files changed, 70 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 5ce0fb916f..7a03d24805 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -191,6 +191,7 @@ struct VFIOPCIDevice { bool defer_kvm_irq_routing; bool clear_parent_atomics_on_exit; bool skip_vsc_check; + bool can_mask_msix; VFIODisplay *dpy; Notifier irqchip_change_notifier; }; diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 8bcb3c19f6..923f9cd116 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -133,7 +133,9 @@ struct VFIODeviceOps { (ret < 0 ? strerror(-ret) : "short write") =20 void vfio_device_irq_disable(VFIODevice *vbasedev, int index); +void vfio_device_irq_unmask_single(VFIODevice *vbasedev, int index, int ir= q); void vfio_device_irq_unmask(VFIODevice *vbasedev, int index); +void vfio_device_irq_mask_single(VFIODevice *vbasedev, int index, int irq); void vfio_device_irq_mask(VFIODevice *vbasedev, int index); bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int su= bindex, int action, int fd, Error **errp); diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 9fba2c7272..d0068086ae 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -85,6 +85,19 @@ void vfio_device_irq_disable(VFIODevice *vbasedev, int i= ndex) vbasedev->io_ops->set_irqs(vbasedev, &irq_set); } =20 +void vfio_device_irq_unmask_single(VFIODevice *vbasedev, int index, int ir= q) +{ + struct vfio_irq_set irq_set =3D { + .argsz =3D sizeof(irq_set), + .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_UNMASK, + .index =3D index, + .start =3D irq, + .count =3D 1, + }; + + vbasedev->io_ops->set_irqs(vbasedev, &irq_set); +} + void vfio_device_irq_unmask(VFIODevice *vbasedev, int index) { struct vfio_irq_set irq_set =3D { @@ -98,6 +111,19 @@ void vfio_device_irq_unmask(VFIODevice *vbasedev, int i= ndex) vbasedev->io_ops->set_irqs(vbasedev, &irq_set); } =20 +void vfio_device_irq_mask_single(VFIODevice *vbasedev, int index, int irq) +{ + struct vfio_irq_set irq_set =3D { + .argsz =3D sizeof(irq_set), + .flags =3D VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_ACTION_MASK, + .index =3D index, + .start =3D irq, + .count =3D 1, + }; + + vbasedev->io_ops->set_irqs(vbasedev, &irq_set); +} + void vfio_device_irq_mask(VFIODevice *vbasedev, int index) { struct vfio_irq_set irq_set =3D { diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 9dd0bd4068..3f5b296523 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -535,6 +535,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, { VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(pdev); VFIOMSIVector *vector; + bool new_vec =3D false; int ret; bool resizing =3D !!(vdev->nr_vectors < nr + 1); =20 @@ -549,6 +550,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, error_report("vfio: Error: event_notifier_init failed"); } vector->use =3D true; + new_vec =3D true; msix_vector_use(pdev, nr); } =20 @@ -575,6 +577,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, kvm_irqchip_commit_route_changes(&vfio_route_change); vfio_connect_kvm_msi_virq(vector); } + new_vec =3D true; } } =20 @@ -584,6 +587,9 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, * in use, so we shutdown and incrementally increase them as needed. * nr_vectors represents the total number of vectors allocated. * + * Otherwise, unmask the vector if the vector is already setup (and we= can + * do so) or send the fd if not. + * * When dynamic allocation is supported, let the host only allocate * and enable a vector when it is in use in guest. nr_vectors represen= ts * the upper bound of vectors being enabled (but not all of the ranges @@ -594,13 +600,20 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, u= nsigned int nr, } =20 if (!vdev->defer_kvm_irq_routing) { - if (vdev->msix->noresize && resizing) { - vfio_device_irq_disable(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_IND= EX); - ret =3D vfio_enable_vectors(vdev, true); - if (ret) { - error_report("vfio: failed to enable vectors, %s", - strerror(-ret)); + if (resizing) { + if (vdev->msix->noresize) { + vfio_device_irq_disable(&vdev->vbasedev, + VFIO_PCI_MSIX_IRQ_INDEX); + ret =3D vfio_enable_vectors(vdev, true); + if (ret) { + error_report("vfio: failed to enable vectors, %d", ret= ); + } + } else { + set_irq_signalling(&vdev->vbasedev, vector, nr); } + } else if (vdev->can_mask_msix && !new_vec) { + vfio_device_irq_unmask_single(&vdev->vbasedev, + VFIO_PCI_MSIX_IRQ_INDEX, nr); } else { set_irq_signalling(&vdev->vbasedev, vector, nr); } @@ -630,6 +643,13 @@ static void vfio_msix_vector_release(PCIDevice *pdev, = unsigned int nr) =20 trace_vfio_msix_vector_release(vdev->vbasedev.name, nr); =20 + /* just mask vector if peer supports it */ + if (vdev->can_mask_msix) { + vfio_device_irq_mask_single(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_IND= EX, + nr); + return; + } + /* * There are still old guests that mask and unmask vectors on every * interrupt. If we're using QEMU bypass with a KVM irqfd, leave all = of @@ -702,6 +722,13 @@ static void vfio_msix_enable(VFIOPCIDevice *vdev) error_report("vfio: failed to enable vectors, %s", strerror(-ret)); } + } else if (vdev->can_mask_msix) { + /* + * If we can use single irq masking, send an invalid fd on vector 0 + * to enable MSI-X without any vectors enabled. + */ + vfio_device_irq_set_signaling(&vdev->vbasedev, VFIO_PCI_MSIX_IRQ_I= NDEX, + 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, = NULL); } else { /* * Some communication channels between VF & PF or PF & fw rely on = the @@ -2842,6 +2869,14 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev= , Error **errp) } } =20 + ret =3D vfio_device_get_irq_info(vbasedev, VFIO_PCI_MSIX_IRQ_INDEX, + &irq_info); + if (ret =3D=3D 0 && (irq_info.flags & VFIO_IRQ_INFO_MASKABLE)) { + vdev->can_mask_msix =3D true; + } else { + vdev->can_mask_msix =3D false; + } + ret =3D vfio_device_get_irq_info(vbasedev, VFIO_PCI_ERR_IRQ_INDEX, &ir= q_info); if (ret) { /* This can fail for an old kernel or legacy PCI dev */ --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324152; cv=pass; d=zohomail.com; s=zohoarc; b=YLpbJuXdiQA+vmS2J7F1a30+Pp+4/E48671FY+g5gqXTaibaIFLU69jolDTz17gXT9/tc327jebdSf49LGGediOd2dHPPJt3l91Mts2LSJwV6+qkeTGTX9AjB07xcZHBld/uqcfGiyemR+VzUJewKUIy6EJQDOkXxyxoXYVf+rw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324152; 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=z2VXFeduDIUIMUtFpLP9ErTdTd4WNkw5pDScHzJjSmw=; b=dKkjPoTcOOtfux+yxzdbxjm8ngdJVJJdHxcK3dou5mg/aL1k6+BsQs1mSGieabQEjLthfPaexL4eDXZoYBTaJo8MLLswyaMs+m8PM5njhxW5t49zx+OVEtssDgtfCdg43HezTpdAopSVHR5R1u5p941e+5hjiACU585wXMSV3xY= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324152110835.2370476735762; Thu, 15 May 2025 08:49:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFam8-0007Kf-6v; Thu, 15 May 2025 11:45:36 -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 1uFalP-0006BL-RR for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:56 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalK-0006CV-EP for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:50 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F8GHeb021276; Thu, 15 May 2025 08:44:42 -0700 Received: from sj2pr03cu002.outbound.protection.outlook.com (mail-westusazlp17013076.outbound.protection.outlook.com [40.93.1.76]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbctngvk-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:41 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:36 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=z2VXFeduDIUIMUtFpLP9ErTdTd4WNkw5pDScHzJjS mw=; b=yCxPhqWB60V2CXv9rSRU7H9qddR8pcjSsdhs2+DB7t/HsuiayqKtTonuv Kr+70wixXXECmBnqnhS7ub61T5WN88CYo0meSVHDYLWFV4XQcgfEY3kxdniVbyCy BVkcqcqn0D+wz783Ae5+dffxB2HmGn4PV0U8Q00EP48HQl1j74GN4DPq6OIg3fVH EXURpBgf627gqd/JqVfvAiEsEdH/VYhu1Rj/sq4e6La+ELzDSDCNRN1pFLpnq0LB 9pqcrRvnB1wmqpkOHCR6uLjeUwqpV2GV87IHS6QiaLQvzMQnXBVN3X0J2S6NFs0W vUei6FsjFVxFfZeQRsRyi1Dz5zUGQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RMCjx9Ap8Pkic9ZnW4jg4hvkq5LwQGhVRsxG0bBkjmTf9ylfZwPaAb8eFDYgDfTqOTM5ipvnNJ28dP9cSN0qKls+HSmG9uY7eWvNszSeAUxTo3yuIUmL8JbRhNBRSUGHw8UGuf/YQYMQira9U8vj2ARV32qqVR3YzRHycF/TAhCSZSVuEWWkLTP2d8QsYm+ESQmhq1vsauEhq0VfGdw76ABUq7wqirYykTNw6aDQ8ytuhV6ZAMhZBDoXPaoRWTwW8qY9yLzo3H+kA8xPAzqSk40GVz3FpFnlMqvSY3Rt5xpUJsSYwCWKm2uD4yPixk58Fjz3QgtBSkaTCeRtx6ru4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z2VXFeduDIUIMUtFpLP9ErTdTd4WNkw5pDScHzJjSmw=; b=lTRbzVoFGVMLExFxwGMJHlCKYki/6emJ1eYiOsp+8sSN9IoDYhlScN5vL66ILYySKVgSCGE3SsOrJuB1Y0vD9b3b4Aalq3jAgapaTbe04G8je5YmjoCLBsgn2xeNZr6kOrk4G98B3kC7U3qgS/hJLR9D4hE15MrJzijvmeI48IGwb4VLXV66lPJdXUcDI9ZwL4aTzdaFE604c8jZ16+bJMloIsKo0C5WFhtvoqqsy6nrlSPEYfJPOc8cQgxm5SzzaYXZzwQaRf4OeQHps4/+NmJS4s4ezE3nyBShkCsYCatT3HUupt1DSUyjgRdOsp/Q/tAWjYzS41BfqN2JSbvjRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z2VXFeduDIUIMUtFpLP9ErTdTd4WNkw5pDScHzJjSmw=; b=PB22JzMgpL8NqsI2ylwMkvMiRpaa9xA/LrHJX+e1cteHi72n3TUO7WMswNEa5ri3JjwrU5V1a7NBH4KLK4CKz5sQbkqU865jpgIDFu+invy9LTeB+SPgeffy6KbzcFSEWUwJ7DyEcUrQiijd5oNDVWXhyKYFGxwP+Y7+sBiR/gQeLBgNppj69qTlzWzSiiamR/1/n+QrUdey7qXD6R0urSrGIOZm1/F0j4F4M9xf7goELY87nBCZm5WcTUHXONKyK1fXmxHm3q39noKLPX4hfoWbpNVIDlNQgADJEv+laQOWeGV2x77oKvf38+Qgi72KNNDPwTfUAG3mqC6Q7SG7MA== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 07/27] vfio: add per-region fd support Date: Thu, 15 May 2025 16:43:52 +0100 Message-ID: <20250515154413.210315-8-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d65b1f3-43a8-4c4c-8386-08dd93c7654d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?f5V50R+zmQCHd1JcpQ6yXGrohG+ArFY4Uwd/YLZprt1NdIaLGDwIqWCyP4Ko?= =?us-ascii?Q?Lz2siHKMoWkAw831P6L0oFtdC5HOamgHREEFTlL8kT71pK6d+afDJsv6kBLN?= =?us-ascii?Q?IwWxTZ/xeltXf0cb8duUsPzWEsRRV96GaUMQP3z4pz/EAxtu6q7b4GUYWrrg?= =?us-ascii?Q?GvO7iLMFe9MZdMRBRzPcCxv4Yt9it2p6pYjmWgRzUfnneLBXXGO5lLRGCYNe?= =?us-ascii?Q?HGTXqaMVQDb4dXLAIPcbBDnHt0svPFGNFDK6jNCsXIlySDo9uxMtX/KCpDYE?= =?us-ascii?Q?+wVL0YNGG/4K438oreRHRir9d9JXmEgkkdwcugyWVTmeZz6mCZIvacKKgcyE?= =?us-ascii?Q?OcBqGUwpwxuOvqFt6qD3KyohGVpY/hp6uiI9Rr2LHl/0Ndv+qxfOK2hzE1wX?= =?us-ascii?Q?1DjcwKD6HYiHbSOM8k/2zfNZi117M5NfiRgBuvhWKuf41ebEkd3JSULdn6j7?= =?us-ascii?Q?CitLXAg4T0BJEg+B9y3Eyo4luqgZgNRYRhIYA4PzdXofqZqKbUyFUERDfe66?= =?us-ascii?Q?Yol+XvLesx1wdoRxMl4n3NCVxERofLia0FWfiehIEao80i53rHt5+H97cWCd?= =?us-ascii?Q?k6e7et5eHJxeXEfMrxylPN+nN1XbX6JEFVZ8c8yIkZX6/ckDozFxbfI6GXKR?= =?us-ascii?Q?p85R+uec1eQRxi61tQKKM8vfmUlmalybSUVAmsXh2q3HV7gbVber4RKK+whb?= =?us-ascii?Q?6K0kb4ootTwo2bW8+sELE68sKybdsaTNfEIqV2fMwJV04CmkKPRMKumfBetf?= =?us-ascii?Q?/BW2brqGru986L0Vdr//UU2wlBFYC4WQDvHNvJJ3kKKPlH0vrF24LxaLW5ld?= =?us-ascii?Q?Hokqyorz+UAmw2qdUGppjno8ozOMIUiv3Iv8XjJdhbV2/iXdqO/L8OGtr39l?= =?us-ascii?Q?KBLn9YsL2BCtPwnOwMRzenrFNQHLm2Ab3eL3eJI2WQ1C1/gNITlBJWk4/TY7?= =?us-ascii?Q?uzylIBfHUB9cJivEN7vxbDLbQb8rtz+mq/ER0zXFoRJtAafRHhJhVh4gfaS+?= =?us-ascii?Q?Vbj4RgcwOtUEtbJ8A4JLnM+BBVYO9iGdUaZ2mGkOB40BLKMIXh3meOJynzGy?= =?us-ascii?Q?pGTsC3HiIOWJjWujTYytwHwWu6dKWhsYfVSiDe4wxCy7NCBQBJLmTznxfMG4?= =?us-ascii?Q?ghxUEGuZh3WTi3mkVZsdsqoLQTXU86AiLeq8d/so0x4whV+d5L1yJu4KQ+H4?= =?us-ascii?Q?W+PqCOivgiEIxpv2vWAN5zZIs88m4hj5T5yl2e/wLIuHCMXBnTRYZoYcvjTX?= =?us-ascii?Q?P0JsFkz7OP7uRbfWcPuBZI6ohE59g+E5VhJOIAmjStBjOmeZ9WpsE46j+gJN?= =?us-ascii?Q?ShPU4GZp1o+op3ywieI7MCwWOFEeSSngHjLTJkC6O1AGPeCbB5HAYioUi6N/?= =?us-ascii?Q?aZLbxPpvXic1xGJiUW6GGH0MWHVLGWJWHrjV0RTQmmL8yvhxL2ejAaGUWY8s?= =?us-ascii?Q?t9gz/v90yWE=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cCLFP+pRLbrdy+DjfWa34MMQjZ8OwkPC2EXJgIzyr9iVKHQXg+Ek4ggtI64t?= =?us-ascii?Q?jBVWiu6MAYDi368J5GNi32zFpEpfO0oT61LNWJ5AuH2LIQnWElylEjGPcYKl?= =?us-ascii?Q?Vyi845i+HoFIXRJ/fZU/1fYilPDCOrLxUfkxqjBK0397ql9AYGimOMgq9IIl?= =?us-ascii?Q?xQekFHNCGo5n9+Vcqfg36Rw92tvCwk3fm2r9eHM58pu8UBYnFylRe+F1zIkT?= =?us-ascii?Q?hx9q7A6sp8EaBc6cLN62NvdgMQdBJyoCkhRSDDnXju9dMc7T8nihAsthpk05?= =?us-ascii?Q?J7kPsL63nsyLmk6joMMlYQoexuTEUN91/eIQF2zWgjozCpHm1DlxkvTJkKy5?= =?us-ascii?Q?TXKPLiXuAECUdJ3KUJCFIAELmQhJXzQXrSD7VNHG06fytuwS1K5/5tvHCim9?= =?us-ascii?Q?40U6rFvjHwj+t+omj2Pe9AJ2JxEzcuEuo58Bmt+bV3Y11pJ+nNOURDptv++1?= =?us-ascii?Q?bzsbQM2PZEM4Mm5lO0wS7oSirravxXejIBedlh70DiyvstTGKrTKccSSa6w0?= =?us-ascii?Q?0ZI64P8zOUPzIHgcmbfpQ335DXtscM1fjyz6a6i9MtRshWs+EMI6sgf8tkf9?= =?us-ascii?Q?2pKWvYQLhsnMWaRAXiVQUtbvQFindbi1FRwO8BX5ITnLwzvyi9ZRpt7+TfMh?= =?us-ascii?Q?GAZI84ZKeaA3bOrDq5H8X6A5L/NzW29VFCZAG+cktHtAl1e7tTMr1puyk9IM?= =?us-ascii?Q?9Xl53GLoHt1Xr8Fv4bHlb83ihB4kpFNqsivBeIGR7qEGMaxcbZ1YzGaO5aFv?= =?us-ascii?Q?xnU4nV769lpBxhn5uHwU7IxEI/Q0o0Q0+egS+xFudpsZGk1rfSgDgEekqrwh?= =?us-ascii?Q?Dazdbjcjlsx9pqcOZ/PE4Bhs9RGriz4xq2geBXkdGTptOgRdMEZLzp3t1lJa?= =?us-ascii?Q?VRLt4w1RvxmHcHueQqAm+rJ8xBX0X9xqaS4ya+aYHTIPJ3aIMNirQT7IHSAx?= =?us-ascii?Q?/vss+N7AAECFcOFdkrECsESP8OgQjvUUxD/fwIkxI4GXwb4g7fAi9UNOLP63?= =?us-ascii?Q?ERftM6NK0facNcEfR4e7p4hAuZ0UaNV7ibLqLgCRNEUa858+YEDoWhjeD/Qu?= =?us-ascii?Q?2lviB7H9kWfypbAvHOqeHHI3ABo1m8wBrQ5LI2KZ+a8Co26saSpEhVlYrqJX?= =?us-ascii?Q?oULPpXYepz23oV6+EGF5sDt4kyVMcRJyohA0QU5yftWTviFNTeu8OrYzFFpz?= =?us-ascii?Q?V7dp9V16t88xItH6X6O0NsqDQdTtKeKpdrzedlNtAw3uzZg3wRGC8Gip+HQe?= =?us-ascii?Q?hW+qYEgaaHQjLqmq3AIszrM1X7Z/HqxJb5fyCBlj+uvTjcpyGYi6gQW1ZXs9?= =?us-ascii?Q?b9w3rIfjxgWrV4BWdk8ki5fRzuYzyAPJUQSrS06QAfuWIKsMZ1c0bAMNGS0t?= =?us-ascii?Q?fOAjDV5LYBTinf4kLQ6qcEv07X1SeJPD6pRYs+SV3LkYwe3zQSt6FScvc8El?= =?us-ascii?Q?Xu4ANr2UbUcKNqp/YWvJyA+IRcg8asGsSpzNbcvmu/GMrJTH7dayjOfd9KKX?= =?us-ascii?Q?TsUmqisRQK7QZ/ySaW7NsH6tD9HIyBtJMN2clrKD503usGJGmovp1meJDZqn?= =?us-ascii?Q?WpX6SOSU8yDt1+/0kYmu4c4Pkv9cPISvC6xHqS5Q?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d65b1f3-43a8-4c4c-8386-08dd93c7654d X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:36.5064 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W+fXWH/CUSx3lOsblH5qn+D/9U0tDrnwfC2LIINeD4ONOgNIOTcYfT+xsKpHdMNV9o+X7iVu+jJ9AaEA4c/Agw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=euLfzppX c=1 sm=1 tr=0 ts=68260be9 cx=c_pps a=OVSnam+0waiSP26xbJD4Ig==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=5dvBy8a1CCwUYuo3VioA:9 X-Proofpoint-ORIG-GUID: nPdZ18jnQGtCZ3isxXi4OItWv7yOGgES X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX2bjVrAA3Fmub cLlbvtMcXZezsSwH0YXExXL4P32lhOunYql9LhYLFpuTE3iVwZNKIGdYucmxj+9CohzdxBKYJbM o77+m0tBG1vYUtKZSTjBmHvzYMiLUDzGFF+QO1TPyLfcSJPeoBLatm1H5rDwrh0i0WLKfcq5dDE c4suvWGaTvFW+GwZYM9l65PgYBjplqYwknzdRuKQaRUb5pEDoZ0gjD7GXtThzDUc8+Vqx/+hOyf qG0mGZ6ns/CJ9+liXycpHJ6dgMJD07IazuYjBlujZGNj6yNQLwoRhs4TlDz4UqOubEU6yAfbsFx MpssfsuGP/kSpus56lRG7XSvmzfzOfq8ECLeq6+9WhWHkixwmN6BeiiDoSPBwKjrBsRmcfw8iGR I8nWhR8rh1yvlcHwYDPiIfVFIlrBl70wz1kE8xUHB2p09sIUg/Xg27IS4g9JEzm+mPvSVrVE X-Proofpoint-GUID: nPdZ18jnQGtCZ3isxXi4OItWv7yOGgES X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324154317116600 Content-Type: text/plain; charset="utf-8" For vfio-user, each region has its own fd rather than sharing vbasedev's. Add the necessary plumbing to support this. For vfio backends with a shared fd, initialize region->fd to the shared one. Signed-off-by: John Levon --- include/hw/vfio/vfio-device.h | 7 +++++-- include/hw/vfio/vfio-region.h | 1 + hw/vfio/device.c | 28 ++++++++++++++++++++++++++-- hw/vfio/region.c | 7 ++++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 923f9cd116..5cb817fd6a 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -66,6 +66,7 @@ typedef struct VFIODevice { OnOffAuto enable_migration; OnOffAuto migration_multifd_transfer; bool migration_events; + bool use_region_fds; VFIODeviceOps *ops; VFIODeviceIOOps *io_ops; unsigned int num_irqs; @@ -84,6 +85,7 @@ typedef struct VFIODevice { VFIOIOASHwpt *hwpt; QLIST_ENTRY(VFIODevice) hwpt_next; struct vfio_region_info **reginfo; + int *region_fds; } VFIODevice; =20 struct VFIODeviceOps { @@ -172,10 +174,11 @@ struct VFIODeviceIOOps { /** * @get_region_info * - * Fill in @info with information on the region given by @info->index. + * Fill in @info (and optionally @fd) with information on the region g= iven + * by @info->index. */ int (*get_region_info)(VFIODevice *vdev, - struct vfio_region_info *info); + struct vfio_region_info *info, int *fd); =20 /** * @get_irq_info diff --git a/include/hw/vfio/vfio-region.h b/include/hw/vfio/vfio-region.h index cbffb26962..80e83b23fd 100644 --- a/include/hw/vfio/vfio-region.h +++ b/include/hw/vfio/vfio-region.h @@ -29,6 +29,7 @@ typedef struct VFIORegion { uint32_t nr_mmaps; VFIOMmap *mmaps; uint8_t nr; /* cache the region number for debug */ + int fd; /* fd to mmap() region */ } VFIORegion; =20 =20 diff --git a/hw/vfio/device.c b/hw/vfio/device.c index d0068086ae..41db403992 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -226,6 +226,7 @@ int vfio_device_get_region_info(VFIODevice *vbasedev, i= nt index, struct vfio_region_info **info) { size_t argsz =3D sizeof(struct vfio_region_info); + int fd =3D -1; int ret; =20 /* check cache */ @@ -240,7 +241,7 @@ int vfio_device_get_region_info(VFIODevice *vbasedev, i= nt index, retry: (*info)->argsz =3D argsz; =20 - ret =3D vbasedev->io_ops->get_region_info(vbasedev, *info); + ret =3D vbasedev->io_ops->get_region_info(vbasedev, *info, &fd); if (ret !=3D 0) { g_free(*info); *info =3D NULL; @@ -251,11 +252,19 @@ retry: argsz =3D (*info)->argsz; *info =3D g_realloc(*info, argsz); =20 + if (fd !=3D -1) { + close(fd); + fd =3D -1; + } + goto retry; } =20 /* fill cache */ vbasedev->reginfo[index] =3D *info; + if (vbasedev->region_fds !=3D NULL) { + vbasedev->region_fds[index] =3D fd; + } =20 return 0; } @@ -360,6 +369,7 @@ void vfio_device_init(VFIODevice *vbasedev, int type, V= FIODeviceOps *ops, vbasedev->io_ops =3D &vfio_device_io_ops_ioctl; vbasedev->dev =3D dev; vbasedev->fd =3D -1; + vbasedev->use_region_fds =3D false; =20 vbasedev->ram_block_discard_allowed =3D ram_discard; } @@ -470,6 +480,9 @@ void vfio_device_prepare(VFIODevice *vbasedev, VFIOCont= ainerBase *bcontainer, =20 vbasedev->reginfo =3D g_new0(struct vfio_region_info *, vbasedev->num_regions); + if (vbasedev->use_region_fds) { + vbasedev->region_fds =3D g_new0(int, vbasedev->num_regions); + } } =20 void vfio_device_unprepare(VFIODevice *vbasedev) @@ -478,9 +491,17 @@ void vfio_device_unprepare(VFIODevice *vbasedev) =20 for (i =3D 0; i < vbasedev->num_regions; i++) { g_free(vbasedev->reginfo[i]); + if (vbasedev->region_fds !=3D NULL && vbasedev->region_fds[i] !=3D= -1) { + close(vbasedev->region_fds[i]); + } + } g_free(vbasedev->reginfo); vbasedev->reginfo =3D NULL; + if (vbasedev->region_fds !=3D NULL) { + g_free(vbasedev->region_fds); + vbasedev->region_fds =3D NULL; + } =20 QLIST_REMOVE(vbasedev, container_next); QLIST_REMOVE(vbasedev, global_next); @@ -502,10 +523,13 @@ static int vfio_device_io_device_feature(VFIODevice *= vbasedev, } =20 static int vfio_device_io_get_region_info(VFIODevice *vbasedev, - struct vfio_region_info *info) + struct vfio_region_info *info, + int *fd) { int ret; =20 + *fd =3D -1; + ret =3D ioctl(vbasedev->fd, VFIO_DEVICE_GET_REGION_INFO, info); =20 return ret < 0 ? -errno : ret; diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 34752c3f65..3c93da91d8 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -200,6 +200,11 @@ int vfio_region_setup(Object *obj, VFIODevice *vbasede= v, VFIORegion *region, region->size =3D info->size; region->fd_offset =3D info->offset; region->nr =3D index; + if (vbasedev->region_fds !=3D NULL) { + region->fd =3D vbasedev->region_fds[index]; + } else { + region->fd =3D vbasedev->fd; + } =20 if (region->size) { region->mem =3D g_new0(MemoryRegion, 1); @@ -278,7 +283,7 @@ int vfio_region_mmap(VFIORegion *region) =20 region->mmaps[i].mmap =3D mmap(map_align, region->mmaps[i].size, p= rot, MAP_SHARED | MAP_FIXED, - region->vbasedev->fd, + region->fd, region->fd_offset + region->mmaps[i].offset); if (region->mmaps[i].mmap =3D=3D MAP_FAILED) { --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324324; cv=pass; d=zohomail.com; s=zohoarc; b=MwHsFaJHlXRjObffVHBu6qpmQZqwwg3BHDpip6PvBs07Fg7/1pI6Kj2cpz3K+RpwHJbMQmDNTXOcN4ztTXohTKVJ5X0fjNSr79hI63PiH5hWAde8kMPWpIZaaIUpYi69Jv00aF/r8GcrQt1S1+3iFMS3dVkYqCGDbAXxF1jCuFY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324324; 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=OS8ZnygR5pimSkeXzbjaJPNutuK4XK95fbT4iYYxKbc=; b=CMnJCIMlOM19E+nU3LQkO7766eaJMt2bHUzOTn6w82uWtrUywhQB84KlAxtOCQkOPqHJH3lKy60CLoUbAerm0qR5N6sPydrWGu0I+7NZzh1ZZfDgnptwJ9QLsuojg/ptgSQE8Fd2u2JBKPCWB11dFkLygUcn9j83I61tNL6/L88= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324324169100.94097818252953; Thu, 15 May 2025 08:52:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFamE-0007uS-8O; Thu, 15 May 2025 11:45:42 -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 1uFalR-0006BU-Nf for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:57 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalK-0006Cy-KF for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:53 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F8GHec021276; Thu, 15 May 2025 08:44:43 -0700 Received: from sj2pr03cu002.outbound.protection.outlook.com (mail-westusazlp17013076.outbound.protection.outlook.com [40.93.1.76]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbctngvk-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:42 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:38 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=OS8ZnygR5pimSkeXzbjaJPNutuK4XK95fbT4iYYxK bc=; b=2zygQpkyk2P0nfcdMx6oJO7Lcrfr4JyvtHUOfinPFL4w15YmvxMscFO1H 9mqJ5UETx7PQMspX0Gj92kHMYR0ke5pAq9DJZ6rrk6/VbMiDimvHHtA/sssh4jzu S8OzAcE9+hxKjwaEPR5SkM/d6Y6ZBxmZtMB10m9NDfhcGHYOhjzicj9kcftDhHcQ JZx//O/Mf5XziZ4WEa7hs8KrHJB6qfCJCh9PnEKrwwOxnepJcjZacxOPh+BZS7Xx 3E1l4PCm0EZr+6APi1TOiQ3P/WAUVRarL94V/vbh7l2Gplgsk9I/7r6q/WFOdawS YEEW+LLsFiwBIECf8+g5yf2Fm0rkA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nsvtgN52dbUk9O8BlyRYomtn99r04u5vpNycEPNIiWWTMyllRj2DYmoFYRhLz2C+F3PHAuJZrzelQZyVCimwXw9wIWORo/BuOZ1KPAa+H4cBgeiNzg7mx9nB5gmIoFlz4HOJORQV8YAKYyJjmJM0Va7Ep7G/gmj8V+wGHlofGgHRuAbSVYhMjqplowrqIYYNor2ok2RUQx321IbKbQkGJaGwJVgLyXKstdu4ujjMm35kuUYNqusbR9V5Z7gZkxNvp8RcHvVNYQ96J7YjCUDApWYupJMgQf5Vf6pl/bOXiyspFgaL7JZR7zT1iYpeTz7iv1snbXI2u9dTxlTz2eKM6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OS8ZnygR5pimSkeXzbjaJPNutuK4XK95fbT4iYYxKbc=; b=OsnVKGO1gNYvk08UZgCujjDNZnj41gHh9cl7e3TFtYlBwc9JfWrjTLHEm267HmdzV60qCb1Wvtqt15O10o6LibnxGkAjpOWZpuFTePEv0br/5lb1lvfZ8b7453YHYtCQ17EejRLG/yU2Cn77Guy+xMkBLAxg57bMyRPgudjg6wV7R3PcGVBEqPEUwIDan6uE/TGsXoARyu2YHsdtkJq573QEPTM0AWF78NVVs5TGVdVCjrIMVWdkW/kflK/HDBCrtG3jcLxojH6Vza8NC/4adcWJVPUY6UIGuUPC3rhPBb2PQY+FZUuXyrT5zyGsTxMJN/LG1VSywmd5oIYf0zKt6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OS8ZnygR5pimSkeXzbjaJPNutuK4XK95fbT4iYYxKbc=; b=smZtF62NlaZ7J8XneEmi9dzN8F9LNWhXbRS51kbAhPz4h9wmP0xqD1zyF4TgBga5QNcPiGqtUoGriqlm6prd/Lr5uDzXqXlClFuLQ4av9lVrN6nfLVHNvxLTb9vFOoag+M1VPig1Gvifu4DCGbEN+AsxgmPv1NdcEYRwvqwrTlfcKPELu7YrURF8bFQ2OFd8jIVd6C6yE9VihXCmJ1vBxS2cexvrSvdF3hTOu0xqfYKBW4Vij3H45cu0mhGeUqemP7jRl947nBH2EaHaFPpaIGZjjl1SeHJHpOzVJ3i8kAgiPxjHEG0CXqxjNMqUq1VMB4wxfJxUFbKLyHRNBx7P4A== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 08/27] vfio: mark posted writes in region write callbacks Date: Thu, 15 May 2025 16:43:53 +0100 Message-ID: <20250515154413.210315-9-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: c2992ca3-1b13-4dba-7789-08dd93c76692 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZLRMDBKI8bW2ij0Yo25LmacaCR1MhzCR+Lb0GySWMUZNqQ0oJc789FZSA76C?= =?us-ascii?Q?kDbTXtQ3fEKyxqVLnmn9vxJlcgZKm1dAP4R2QIvMBtHVXAnEQLgXAqc1AGPY?= =?us-ascii?Q?tOwWd6tFn4UcBLJgrIGhJvZfWs1QMIEQxrkvf/mZ+NNLz0wB7XKyJDcjBPm8?= =?us-ascii?Q?hPNRmdWe3+2AN8l8TjHQFjyeLqYNRd+mUxwy4ajHwtRFk9tp8jIBNHVQ2E1T?= =?us-ascii?Q?Y8ZhbLDlHEdNpPMLffCwbuoXab3cB9FVJFBuwNL1nKFFJfM1WmHNdHWtBQYx?= =?us-ascii?Q?d3DZQPPPsbJTDnC/Dn8Vu94yshz3Kwn2JDtC0/UCR0F78HDInJ8mKUZGEc5L?= =?us-ascii?Q?57GcC+hu3BR8rQ+2Fi/Z8q81/y4gSR0z5sTIwpsCwjETUEMRu1WrZruHgFwW?= =?us-ascii?Q?PkltEpGM8AePxMuQ9OwDZfEZ9sgGRR79cRvokUkrYZhsNWyDJDldo7j6w8O6?= =?us-ascii?Q?NBGya/M92qU5MlphN72ue6SWx4mSmSbMqDQAPHebJEBvBEw+F8gpYvlyOTtk?= =?us-ascii?Q?lH6Cwfh7ToUzArtLV/OF7rIgMSE5jzr4UIuttei3FusYYGhQKHujb6VtdHjz?= =?us-ascii?Q?ENF8YZcHEBU6QeIB0KM0Lo/Gx7BFgVpg7QmNdTwMf9xEwykf4WGPi/bTQ1BR?= =?us-ascii?Q?qw8O5q0TnroQ4819/DVfCIEiBpnPfMRonYriEkP+7asM+OXV6g653yG4DBIa?= =?us-ascii?Q?riYaam6kwjKAbYHWChTocZLu8R8B5Zt8YZCd/Jz1VpuorDhgfuf7Kd4gt6fk?= =?us-ascii?Q?tgTogw02IID5UYQYpcisjcIYvBa2jxgRFq/2f2WVtpyhYJ9o6DH7oi6F/oIU?= =?us-ascii?Q?yaw+CwI0HvJWg1UqRNNz7VJI7xgCutz9na6zv4ZrD5aERMWb2dv6M4WKmiAr?= =?us-ascii?Q?JnJyrG8NdY0I4Jso9M0DPi2nHYEsYR+T8iznWgMtH6to3K35LagvhuBnS3OK?= =?us-ascii?Q?ZBPOWjDhlHq4lzXa7gt68bnm/Vo87NQBctRM5FGlGmbJdzJ51a3CJ4BqPLjQ?= =?us-ascii?Q?1jXnLG7ooY0FmsYCOa8JUfv8P8HqU1P1wQakhd30ujBgec5QOn/ojRJ4jhFD?= =?us-ascii?Q?/PrZHvTxy5QYDuPPEdG5CKiWEDZntUvGfs6v//nHh0EVIAQt/DnrRDO8G0Af?= =?us-ascii?Q?VS5VfVsMl95jWUhDTWIIEYJKKhrCURcM2PozIXQqk6o2jCQJD+gcRUH9XK5q?= =?us-ascii?Q?STtFRh+vdx+RfcMs6xQDUK1INA69TRwZ4EZZIuUXDEFFD96/jbuCYmFJRV33?= =?us-ascii?Q?RP4ZFP/KCUYbtJJpUsLdvyYN5hu8UYADim7OEfAQuTh0FvkHNiORvh7EzsMw?= =?us-ascii?Q?xnfuzfleEe7xTXrowC8YTcsC+fW8xC2Z1J0IpRWklLULS8IpxOFxdMYQRjJA?= =?us-ascii?Q?HC3OzcxkWU/nzm1LfZNDH2LaXjfASr0UWvmaZ09yTBFCQgM8+QE8Ajcu6hX9?= =?us-ascii?Q?YylxjE1tR9M=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tp3989fXdFIkSpC8xXOHv9jq9CXDE0xZwq2iN+t/jRhLddh4KKnwFJfCz+/s?= =?us-ascii?Q?K/52Qrrv3jmFkFQkzK7ewAtCuu1Q7v3s+SoME320OJZFHr5xhKnVvRwP+5/7?= =?us-ascii?Q?gKHbUlYuF4sYyrNtZi/Tshjne/q82sZBNsuttOQWwqo+Xf6HSsDlJMRzRjI7?= =?us-ascii?Q?xd3+LiqBavVEZYPXSflot12RVb+V//UHCkMKLQHU4VTJTCHOuqDFadQ8f/bb?= =?us-ascii?Q?lgAoTJTk86h0meSD21soCxxjMnGbkjvdGvBbuIxaanavSGqp0D7fc8R9YgRw?= =?us-ascii?Q?0KN34KBGy3nbAFFna6PraxNtuoiKxGeK5cjNdZKq5mpBTZ4Y61HShs4HZYqz?= =?us-ascii?Q?LyBFFTj6q9DDJi1/Y611D3rcumJwv1+fwcwxdnJJiw94a2KUyssCkWng2UMH?= =?us-ascii?Q?5ZRrd4At+lqndOa0DFCjDAX6Rf5tHifQEaTAWyP3u3/pkq69IO2gFgUsXxRr?= =?us-ascii?Q?kcVQxzZva6e2ltljMPqxyqxw+qW4xbL0EIk7jYhHCXvu2oAjDqybmxlAxHoa?= =?us-ascii?Q?bbx3rt1fkGhZp5P/eumqZRZmpMiETN1852tF1K6kaDjTpB3AtXnfev7k0rt7?= =?us-ascii?Q?AcVgt5ptV/p4k4REdDp8b0yuEe0+SD9TdspGN8C+3Tek6FEZhvveAQy4frTE?= =?us-ascii?Q?ApGXYHj13F4iGgkjQbYle/y7cVvpNmvYhUOpyV7RdTDnabsXR0WewAcr+BjN?= =?us-ascii?Q?wFiHQMHnxdQQJVJQD0ILwseh+nDH8ikbc7Kwhq+PaTgaEkEPKn8D9o+y78HS?= =?us-ascii?Q?FL7sRZwpv2A9XKMj2D1vemNMTd6O2bwgZVt0P06/viNedfzIWxJelzwlvTeY?= =?us-ascii?Q?O/wXKLBLHToqqUcfBoAr2XYf6carev4ecSH5S4PJ1GfHXLX3cMuqDx+jSty8?= =?us-ascii?Q?ti1CRlQ4lGd85kr5p7EmRw6zdPNYNpIHUYc4DALrJ+RuFRRsKRoHqxpBhAdQ?= =?us-ascii?Q?y6BgZkSd7pGdc3Y+KSXCyz3EkNg6mSVrzBMPZVi+RyMSSRC+IMFceqVzXXYU?= =?us-ascii?Q?97sv4LBMasPKQB1AUDtvY1/WXIaN8mJxW46dYahhR+2SyRfFMVNZpzzJ7E7d?= =?us-ascii?Q?SAj8XtdQqQvGvrgx8QO5zBA9O7VxX3f5aQekFNFbSYB25W2RO4ivfQ090bcV?= =?us-ascii?Q?ZAZCXhNDBMJ1D1A0Qnw41vprumEIUu7wuLibaXrRbw+T8Yh8TDYtHY0bJyzd?= =?us-ascii?Q?4l9xSAySX3yWy2nse9inqvEkKSgnai1sCxsr8OkQXZJo4doO6FaUhGXJHK5l?= =?us-ascii?Q?3G4a8uK+VDLQOLp5PVqhGsPA7J/HV/RbbfsZ2uM9iQDgmGcNPUuYvt2+7unY?= =?us-ascii?Q?tVTJOdsw3jjqsRpY5Lf744UOYh35lCPGfNq54cOLQf4B0UpdSSn5AlD4khrG?= =?us-ascii?Q?yjR8G+zxGIeirCEUuRIPgmifrt2VgERbkoUiL+CeWPJGkirYnPcoDL/KnnbI?= =?us-ascii?Q?UNHH+USQF4zOi1tlqBLnSuizz8A+DQI0IHIHBepG9MTPDCihGSzG2qxD2j/J?= =?us-ascii?Q?tZ/PVJhGfl/91m3PcfwjPTyatqwAL9KfJ3gA46ts6QtO9ZOtkxLzFKEhoWBJ?= =?us-ascii?Q?X+wuz4bltit/razCbFVheH513tZ89hdzQ3RQl1f1?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2992ca3-1b13-4dba-7789-08dd93c76692 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:38.6673 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UylL+ZxVy5DXyR0TLHeLPGobdHtVTTZwASmKHVn26qIfPhZO2LZjrNAqLjXMLV3J97H/kkWa1iMgKfR1d50+Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=euLfzppX c=1 sm=1 tr=0 ts=68260bea cx=c_pps a=OVSnam+0waiSP26xbJD4Ig==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=AhJUW1JONd81xBax9acA:9 X-Proofpoint-ORIG-GUID: PGkq8FSZ5k8r-_KStmJ1ei6ERBxb8phh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX6QJCGLGIV6NS Ns8TuybgwKJFmaIj4mKE8Xr4meiAuyZMyf8IgKUHp0ZNkKEX54ejAgdoWGOKkiRPwjJKlxmOUrd rCSUNGLUIayr0E0UsljUv8L9qAHODBQeXd0TddREUfj8Od7lg676iiNW+D2izS605WHdSkro82x UuDox/KKWa2iDPCitax6VdSMGy2IBbmUmUM6r4xnTOWTFEjPH+NxTp5kGXC+2XlPJBCVXqt2nFH uRysrsZ8EWDNrowDOdl/J9HfACH41dsigWhAIRm4v8S0F+86qWNzbGFR3WuC7mHwJ9uPpdZX1/x LklqMXYqkLzrgnOWro/enmtflxpPmcKq5yuuv9DJQsoGR3Hd/TuPyZmin5BRvos4mMQp+xU8yuh bTne3X22pNFSp6x2BaJs8XHq1WaOJLxApVK6xS6qVg0pqK2tdCnBMZZz5wR3eirO+YNW4Hx1 X-Proofpoint-GUID: PGkq8FSZ5k8r-_KStmJ1ei6ERBxb8phh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324326023116600 Content-Type: text/plain; charset="utf-8" For vfio-user, the region write implementation needs to know if the write is posted; add the necessary plumbing to support this. Signed-off-by: John Levon --- include/hw/vfio/vfio-device.h | 4 ++-- include/hw/vfio/vfio-region.h | 1 + hw/vfio/device.c | 3 ++- hw/vfio/pci.c | 5 ++++- hw/vfio/region.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index 5cb817fd6a..a23ef4ea13 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -207,10 +207,10 @@ struct VFIODeviceIOOps { * @region_write * * Write @size bytes to the region @nr at offset @off from the buffer - * @data. + * @data; if @post, the write is posted. */ int (*region_write)(VFIODevice *vdev, uint8_t nr, off_t off, uint32_t = size, - void *data); + void *data, bool post); }; =20 void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontain= er, diff --git a/include/hw/vfio/vfio-region.h b/include/hw/vfio/vfio-region.h index 80e83b23fd..f1ae5125ba 100644 --- a/include/hw/vfio/vfio-region.h +++ b/include/hw/vfio/vfio-region.h @@ -30,6 +30,7 @@ typedef struct VFIORegion { VFIOMmap *mmaps; uint8_t nr; /* cache the region number for debug */ int fd; /* fd to mmap() region */ + bool post_wr; /* writes can be posted */ } VFIORegion; =20 =20 diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 41db403992..cb1a212b8f 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -572,7 +572,8 @@ static int vfio_device_io_region_read(VFIODevice *vbase= dev, uint8_t index, } =20 static int vfio_device_io_region_write(VFIODevice *vbasedev, uint8_t index, - off_t off, uint32_t size, void *dat= a) + off_t off, uint32_t size, void *dat= a, + bool post) { struct vfio_region_info *info; int ret; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 3f5b296523..84daac5f2b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1016,7 +1016,7 @@ static int vfio_pci_config_space_write(VFIOPCIDevice = *vdev, off_t offset, { return vdev->vbasedev.io_ops->region_write(&vdev->vbasedev, VFIO_PCI_CONFIG_REGION_INDE= X, - offset, size, data); + offset, size, data, false); } =20 static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size) @@ -1820,6 +1820,9 @@ static void vfio_bar_prepare(VFIOPCIDevice *vdev, int= nr) bar->type =3D pci_bar & (bar->ioport ? ~PCI_BASE_ADDRESS_IO_MASK : ~PCI_BASE_ADDRESS_MEM_MASK); bar->size =3D bar->region.size; + + /* IO regions are sync, memory can be async */ + bar->region.post_wr =3D (bar->ioport =3D=3D 0); } =20 static void vfio_bars_prepare(VFIOPCIDevice *vdev) diff --git a/hw/vfio/region.c b/hw/vfio/region.c index 3c93da91d8..936502b37a 100644 --- a/hw/vfio/region.c +++ b/hw/vfio/region.c @@ -66,7 +66,7 @@ void vfio_region_write(void *opaque, hwaddr addr, } =20 ret =3D vbasedev->io_ops->region_write(vbasedev, region->nr, - addr, size, &buf); + addr, size, &buf, region->post_wr= ); if (ret !=3D size) { error_report("%s(%s:region%d+0x%"HWADDR_PRIx", 0x%"PRIx64 ",%d) failed: %s", @@ -200,6 +200,7 @@ int vfio_region_setup(Object *obj, VFIODevice *vbasedev= , VFIORegion *region, region->size =3D info->size; region->fd_offset =3D info->offset; region->nr =3D index; + region->post_wr =3D false; if (vbasedev->region_fds !=3D NULL) { region->fd =3D vbasedev->region_fds[index]; } else { --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324160; cv=pass; d=zohomail.com; s=zohoarc; b=G0DwW/HFHORCI/4wAF0JsDSgA+0T57yLBtaTkoVrANxBMdlKbaVIBK6XyCT19/M8zURP8q5Y8XUevjbROhurYiVWyi32KYRDiILy+863nOkqyeGxomZzlouz3prpTzfUfIUyamrGw8WjRZ4AzaUhFOhJhmy+cFDSY7+xinqpNqQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324160; 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=jgGxX7AAuov5EEMp/7WosYFWwTQx342BqvxK24VXywc=; b=RfYQTKKQ2G5+ifAkZZWEsK0zakJKkH4yT9u7lioqfDGwoRYnO8wtjYCrTHYyXNR5NLMLe5knFKspPHxmCrgCTcZkt0D1f5humTTF8nnMQx7R/WP8tTEVp7DD/wSSmZ9c+OsVoStbpbFmo3Mz+bK5RHorOekJqsxTPsBreF6WESg= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324160444726.834684000533; Thu, 15 May 2025 08:49:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFan3-0000JG-NY; Thu, 15 May 2025 11:46:34 -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 1uFalX-0006Ij-Dd for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:01 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalL-0006Cz-DJ for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:58 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F8GHed021276; Thu, 15 May 2025 08:44:44 -0700 Received: from sj2pr03cu002.outbound.protection.outlook.com (mail-westusazlp17013076.outbound.protection.outlook.com [40.93.1.76]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbctngvk-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:43 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:41 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=jgGxX7AAuov5EEMp/7WosYFWwTQx342BqvxK24VXy wc=; b=WMOHWMSH3hc9HbVisEOIm2mXTXWFKvM/XjJkC8iDDik5Bx8e4SVEOqoIz k/p2iDgPU62d1APRXpAU9iaBr1Cu6YvXIk6Jb5/d4L+wgzDOoMlfld0IJFKcNeuD ByPFSQR/IycHtcJedBhoXfRhA30V5ejvgQm/mvt0qSJAtYMY03tI3wI9n68mw1av 4JIan3GAFuKu3N9oGyS7SK5FA+XkVSbQ7V98VikzCcNWVjfSuvoA+11nVr+BDBLD gx1M6ReSAjuuRTmU8xCDrpDvnCDTUsOc7CI3yrB5yKXx3FCj3wQD+a4oWWk8kemy zYzqvPuzY9oXzTjpIPhxmfhcpwicg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f+USeL/4kZFoU4XaSG4e87NWG+cUyoWYH57VPm7h34zQNCzgL773Dtv8CgiSMnnI/sNVAoZBSM42mo3w04ma0q7HmqGwU/L0GvuC/L6R3U2ot1aBMwyxhYa4T8QJouEbnxYDdpRHmKuwTccoHrejCQIaSyFRUC7ocAlnsNP/ReoN2Af66WwGJLJGSQz+Hs2RIrqn6S8PXaxkomZMa8Fw2466FATK797UHyqKCgihD98k8OzyhvzjPasmeMLcN/tliiPuI3loVniLdWmT+v2tUiVkfM9hVfoVfZrKxqPzxxPBquAKtcs1BSZmn07cCLsF3ZB1p3p2Hr3wvw0kQ+in9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jgGxX7AAuov5EEMp/7WosYFWwTQx342BqvxK24VXywc=; b=Zkkw1XMvhWNnnOqWkxr3p5XmlX6e3nFP1yGP09Ye0o5XiACzslZA3EjZq04CjwBHjLiJEA99ZRqsFAW1kovWJwLa3QoeU7tkD9ZjETzg7/BU0zJoM+XSVUVF2FsietoFkOtqanlBeviYN9YqucA3pm36FueO9wuZO6C7sJyZMABCEwl2M2RBmdO/Up2duwsBIBThE1TEEyQ9lFqAf+ZBagqwxs1oZ9pYbLkyFdQjx9XW+7zPNPPgBgQKYFh9tUtYebOQllsvCkAcEJOHLmzUaTivYukTcFyQLda6dIkp8iMDDk9OlrWPxBwavLQT6bm5iK54oxGC5YfoLLHGai5LQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jgGxX7AAuov5EEMp/7WosYFWwTQx342BqvxK24VXywc=; b=I9HTd4h4IeyOqIWtOfdnfJ2xYJBwqpKeRiRPt1xX4M6uGPeWOc510N0IvB54ApX92fH2m3f7MJoB937iItNRHQ7BUd+7TT0kG4bR3SyrhljxI0dO80sTuV6oYyEhoT90ZLodsgxPcSKVl5+dqnoDkBsxve1dN7cTYHjzbLwSDvQpLDPb3Y2WcaB4JstTwfoAlUm+H3rrTVSjJTEycRuQyb2mcBZ5c9TxqOqET434RVHcXE2Y9CBsy6eentHw0TKJ1qAi7C+2D1KsDqTkX8rEz5JHkvFjQ9RNVPpdjR1XbWQf0wPSyIPnrpwnXZ/BGGDVhaYVyUZ+bi9I30Ybsu0bmw== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 09/27] vfio-user: introduce vfio-user protocol specification Date: Thu, 15 May 2025 16:43:54 +0100 Message-ID: <20250515154413.210315-10-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f4586c3-9ecc-4ef9-1380-08dd93c767dd x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KD0tEZa5QttWNShAIVVkB0Iq7bhbSAyA2bHGrRScxuaD4/44QzVWU+lvXoIK?= =?us-ascii?Q?k7Ze64ADo1uvtGtGGnuKiZQDWCoAFWnTZXVEbD2k01jEPlxveLYfqjJhKUgW?= =?us-ascii?Q?C+CxRkSIyqb2l30ASDqUZHOAc3uJFYVKdsjZo3/fA6cwNWIMtD5XDCSfQMr8?= =?us-ascii?Q?NThhhzVqKmUENvTB1K0etp/jYMwXQdpOlHmQTDeAodmdlncX5lbvAECmf8TS?= =?us-ascii?Q?ZOQm5/PD51Rc94t4fC9VAXB09km7sCrrKvdLvt9HgefKTayCrG1Ui/Yk/r5h?= =?us-ascii?Q?qLoZ06YAds+iorPJR9SVBEtpitgWO1w0WEHBYOtXVfRrVju4eDi+4EvId0fk?= =?us-ascii?Q?Cfv/TxKiCjWfP4KuKvmjbA+6qq62otNQyE+f2uHeCQNZo1k6qUFQsREdGule?= =?us-ascii?Q?A8LZm4sCseX+ox9ZRWL9j5PZCpcbmPQAqLPzo88KIALvTdXHEKTzH9VR8LPN?= =?us-ascii?Q?1pshh67Wnp2/Vd1QyEBWrAhwc7qbRaOMhfuZQ/PJ2fag/enr2Fsgze3Zv9ES?= =?us-ascii?Q?ZiJY5eReg8MpGMY++JHco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Q?kCoxpw5Iwtk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6hoI1ywBKKqb86IPd2eo3Q0VuynreODagh37pspL6j1JrbykndbcHXF2FmCp?= =?us-ascii?Q?iKOWeMdCrQUEj8N1+WoNSPTypoREfYzCIjTqGrwAUm5+vZhkdjt3Ofz91XXm?= =?us-ascii?Q?IjczDPqa2OHcmOEz8rXLL9bkN3xhGPgSKmU//BS9vRnk8U/ASiirC9UPxlW0?= =?us-ascii?Q?Zqf/SUyxTRDl796H7QkSnEYHzjcVaoTPf1amZHBRTnEu+6VMYmOj1JveawdZ?= =?us-ascii?Q?VHzvIWB6uX28l/8sfTfxKsY7qDuI44NfUIUsFy6E4U9RoUqmcPmqK6yNcvpQ?= =?us-ascii?Q?h4COuZQsZtnFG0Zh58MlLR8AY7oCoXGhYRfIoEvip6dQ7/lynAJAbyP1HYqq?= =?us-ascii?Q?ao441+1FENUsKb9PpgNIF0T3BHqMo+DFH0lWQC+dgOHq8rP/zODjUxOnqqw+?= =?us-ascii?Q?UOHbzYfuJRVrsqCDk8d0zEoG9jaGAUCNwqTjV+tGg04BlRRwXWSoKc0QYD59?= =?us-ascii?Q?O/71WWxt05RL3S+nTT3F8PfzCyl4pc3IaaLEm3Gnk5pT06zRoRsyDRDNSEFu?= =?us-ascii?Q?n+sc2DEdWBVETAFd0QZafgIp4Ta21KjSvWTqrBCRZRxDzbkZ5qZUHnpdtTHH?= =?us-ascii?Q?AKG9x6lvUN2YTlRKKeMIobT8dpkaUpz1GD072QcS0rXIa/SM0FyZzrC/dB3y?= =?us-ascii?Q?C6yQJx0qvFtXCdIZblSE94JxrHRIumKTRc9slfaKO0yCQUEJsC7TRBdSM9HL?= =?us-ascii?Q?pglMm6ycYq8Uty4VIKp/LWKGWu3+ruReEBXeaxrSX+6vLjy9w3BOveUb5q8b?= =?us-ascii?Q?9z7zM2wDtE93xEftc37prXnf5e1B6vO7nhUFHFqNzAWJDWwk6H+t2Mxkh2or?= =?us-ascii?Q?r5N5wc53S1oGjbCkAEC2BRJc4gHlxncvjpy/93gl/62p6/0Tu8/6UbzEQlEU?= =?us-ascii?Q?PfjiQI2SivXjCL2ofUpryyRUkQkKkMKjyF92ACrjkicFrb8xbz97KztmUQOm?= =?us-ascii?Q?kna6HyvEDcmweSAeXQsg0F6kbw0TSugGdMLtTj7/9qfRrHWpAYVb2KvKhdg4?= =?us-ascii?Q?8DB+Isakli2+4HLY7C/cGMupLxm1xKRzU7EjEZB5ehwLHzWY8T02qyoBqVBd?= =?us-ascii?Q?7MlHIDNaGHZ7uZmk7P2ZQ2RcnD5NOBZsEZIXucPWowIb84zUoHImTddII+rc?= =?us-ascii?Q?FZa1KJRFkRHesEqLYpPwcrXbY5gUetuLu8XE6nUxbV6utCE1qublBGN8mrHQ?= =?us-ascii?Q?sqGaBpsi9zDGsbY1bLIsIZ1p9ziYT99C3ZludlFVZ7nPIwVRX6foK/aBJy+4?= =?us-ascii?Q?yb9jHbsjKKJOYf9Tl5zso/Co84CFXm9UVSGJueKvvV5ffPYdcK2Zzrs5AfAr?= =?us-ascii?Q?IXZvi4zg8EoE1bWYhdDeBZ53OR6I59Fq9kENlvx/shuwBwfl/AQPF8kuG6rR?= =?us-ascii?Q?th17yNpZgud+nl2hecXykIpD97/2hleAZCysNxX8ulhDwPbgGknfZviDDcpQ?= =?us-ascii?Q?l1bSly80VBp81BZnzgka7P0WuvVm42utFTdnboCFAgFjv48dO/exHZJCIm6x?= =?us-ascii?Q?Pm2eL12h3XAynfFNkKm1di3pHnh5yVEJ3huDcGX1winczitiG0pi44dKtjQp?= =?us-ascii?Q?JWYq7N5afkfiHOR3CW5K0GAJow5T9mU5qicLjoPq?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f4586c3-9ecc-4ef9-1380-08dd93c767dd X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:41.0175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vParT3bUbb78NwdU/JzTrhN7mMtzV8YFxnXQRAR2HVHx/ExxE0t/fTh8CD35sDuyY/ts0cLOYMJs6NNM/gBTvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=euLfzppX c=1 sm=1 tr=0 ts=68260beb cx=c_pps a=OVSnam+0waiSP26xbJD4Ig==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=VwQbUJbxAAAA:8 a=pGLkceISAAAA:8 a=64Cc0HZtAAAA:8 a=20KFwNOVAAAA:8 a=z4glEzOvAAAA:8 a=h9SPtozqHe0Wh_k42joA:9 a=x5O-bmgOEKQMiMGR:21 a=N0yriQgkpQ4A:10 a=HplO-upLQ7EA:10 a=92dS5hN0c3Q7EetK7xW5:22 X-Proofpoint-ORIG-GUID: v90CvXoqQLWTwBKOxvyqKFuDn3yngIGF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXy+4dOMnGe0LM SQPcoOT8NC6tIBqeR8SIU36wS8dlfod6E5vLVxdnG+xvpjpR8jxKK/bHtyshYtW6g1j/2l07KHo egpNy8z18Ldyzq8pAghJVUIo7TstFtSvg3YiZonDV6Hb77jHVLnyrk7bKbXS6Zg72LR2B4t2XY5 g4dUzf5RZFCAlQqP5Q+vskVOjUOp9kVSKacEjRYDSyTBGBiu/GmqpmhJZVnuKpD96UkOKhIpTL6 gt9cd3R0A1bvEs6vNeYTx2DpUUlYXPNNptF+BggEe3/XLMvAlcnkM5oA9YtQz36Cge2rg6WUbbB aE4DIsO9RP38lEeDcy4FSFz5/o3A2Y41mCf3S24MMkkCD2Pz7vNzWBt9Mb43Jd1jWFtW4jJlKBK w5MTngvosToXbgVgw4BNhEyFBQDZvQhzpi7vZSCGOAMeHAxUygIQYeP2zvd3PLyqy2+WB2zN X-Proofpoint-GUID: v90CvXoqQLWTwBKOxvyqKFuDn3yngIGF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01, WEIRD_QUOTING=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 @nutanix.com) X-ZM-MESSAGEID: 1747324162636116600 Content-Type: text/plain; charset="utf-8" From: Thanos Makatos This patch introduces the vfio-user protocol specification (formerly known as VFIO-over-socket), which is designed to allow devices to be emulated outside QEMU, in a separate process. vfio-user reuses the existing VFIO defines, structs and concepts. It has been earlier discussed as an RFC in: "RFC: use VFIO over a UNIX domain socket to implement device offloading" Signed-off-by: Thanos Makatos Signed-off-by: John Levon --- MAINTAINERS | 8 +- docs/devel/index-internals.rst | 1 + docs/devel/vfio-user.rst | 1522 ++++++++++++++++++++++++++++++++ 3 files changed, 1530 insertions(+), 1 deletion(-) create mode 100644 docs/devel/vfio-user.rst diff --git a/MAINTAINERS b/MAINTAINERS index 6dacd6d004..71a7819448 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4218,13 +4218,19 @@ F: hw/remote/proxy-memory-listener.c F: include/hw/remote/proxy-memory-listener.h F: hw/remote/iohub.c F: include/hw/remote/iohub.h -F: subprojects/libvfio-user F: hw/remote/vfio-user-obj.c F: include/hw/remote/vfio-user-obj.h F: hw/remote/iommu.c F: include/hw/remote/iommu.h F: tests/functional/test_multiprocess.py =20 +VFIO-USER: +M: John Levon +M: Thanos Makatos +S: Supported +F: docs/devel/vfio-user.rst +F: subprojects/libvfio-user + EBPF: M: Jason Wang R: Andrew Melnychenko diff --git a/docs/devel/index-internals.rst b/docs/devel/index-internals.rst index 7a0678cbdd..1b04311f06 100644 --- a/docs/devel/index-internals.rst +++ b/docs/devel/index-internals.rst @@ -22,6 +22,7 @@ Details about QEMU's various subsystems including how to = add features to them. tracing uefi-vars vfio-iommufd + vfio-user writing-monitor-commands virtio-backends crypto diff --git a/docs/devel/vfio-user.rst b/docs/devel/vfio-user.rst new file mode 100644 index 0000000000..0d96477a68 --- /dev/null +++ b/docs/devel/vfio-user.rst @@ -0,0 +1,1522 @@ +.. include:: +******************************** +vfio-user Protocol Specification +******************************** + +-------------- +Version_ 0.9.1 +-------------- + +.. contents:: Table of Contents + +Introduction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +vfio-user is a protocol that allows a device to be emulated in a separate +process outside of a Virtual Machine Monitor (VMM). vfio-user devices cons= ist +of a generic VFIO device type, living inside the VMM, which we call the cl= ient, +and the core device implementation, living outside the VMM, which we call = the +server. + +The vfio-user specification is partly based on the +`Linux VFIO ioctl interface `_. + +VFIO is a mature and stable API, backed by an extensively used framework. = The +existing VFIO client implementation in QEMU (``qemu/hw/vfio/``) can be lar= gely +re-used, though there is nothing in this specification that requires that +particular implementation. None of the VFIO kernel modules are required for +supporting the protocol, on either the client or server side. Some source +definitions in VFIO are re-used for vfio-user. + +The main idea is to allow a virtual device to function in a separate proce= ss in +the same host over a UNIX domain socket. A UNIX domain socket (``AF_UNIX``= ) is +chosen because file descriptors can be trivially sent over it, which in tu= rn +allows: + +* Sharing of client memory for DMA with the server. +* Sharing of server memory with the client for fast MMIO. +* Efficient sharing of eventfd's for triggering interrupts. + +Other socket types could be used which allow the server to run in a separa= te +guest in the same host (``AF_VSOCK``) or remotely (``AF_INET``). Theoretic= ally +the underlying transport does not necessarily have to be a socket, however= we do +not examine such alternatives. In this protocol version we focus on using = a UNIX +domain socket and introduce basic support for the other two types of socke= ts +without considering performance implications. + +While passing of file descriptors is desirable for performance reasons, su= pport +is not necessary for either the client or the server in order to implement= the +protocol. There is always an in-band, message-passing fall back mechanism. + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D + +VFIO is a framework that allows a physical device to be securely passed th= rough +to a user space process; the device-specific kernel driver does not drive = the +device at all. Typically, the user space process is a VMM and the device = is +passed through to it in order to achieve high performance. VFIO provides a= n API +and the required functionality in the kernel. QEMU has adopted VFIO to all= ow a +guest to directly access physical devices, instead of emulating them in +software. + +vfio-user reuses the core VFIO concepts defined in its API, but implements= them +as messages to be sent over a socket. It does not change the kernel-based = VFIO +in any way, in fact none of the VFIO kernel modules need to be loaded to u= se +vfio-user. It is also possible for the client to concurrently use the curr= ent +kernel-based VFIO for one device, and vfio-user for another device. + +VFIO Device Model +----------------- + +A device under VFIO presents a standard interface to the user process. Man= y of +the VFIO operations in the existing interface use the ``ioctl()`` system c= all, and +references to the existing interface are called the ``ioctl()`` implementa= tion in +this document. + +The following sections describe the set of messages that implement the vfi= o-user +interface over a socket. In many cases, the messages are analogous to data +structures used in the ``ioctl()`` implementation. Messages derived from t= he +``ioctl()`` will have a name derived from the ``ioctl()`` command name. E= .g., the +``VFIO_DEVICE_GET_INFO`` ``ioctl()`` command becomes a +``VFIO_USER_DEVICE_GET_INFO`` message. The purpose of this reuse is to sh= are as +much code as feasible with the ``ioctl()`` implementation``. + +Connection Initiation +^^^^^^^^^^^^^^^^^^^^^ + +After the client connects to the server, the initial client message is +``VFIO_USER_VERSION`` to propose a protocol version and set of capabilitie= s to +apply to the session. The server replies with a compatible version and set= of +capabilities it supports, or closes the connection if it cannot support the +advertised version. + +Device Information +^^^^^^^^^^^^^^^^^^ + +The client uses a ``VFIO_USER_DEVICE_GET_INFO`` message to query the serve= r for +information about the device. This information includes: + +* The device type and whether it supports reset (``VFIO_DEVICE_FLAGS_``), +* the number of device regions, and +* the device presents to the client the number of interrupt types the devi= ce + supports. + +Region Information +^^^^^^^^^^^^^^^^^^ + +The client uses ``VFIO_USER_DEVICE_GET_REGION_INFO`` messages to query the +server for information about the device's regions. This information descri= bes: + +* Read and write permissions, whether it can be memory mapped, and whether= it + supports additional capabilities (``VFIO_REGION_INFO_CAP_``). +* Region index, size, and offset. + +When a device region can be mapped by the client, the server provides a fi= le +descriptor which the client can ``mmap()``. The server is responsible for +polling for client updates to memory mapped regions. + +Region Capabilities +""""""""""""""""""" + +Some regions have additional capabilities that cannot be described adequat= ely +by the region info data structure. These capabilities are returned in the +region info reply in a list similar to PCI capabilities in a PCI device's +configuration space. + +Sparse Regions +"""""""""""""" +A region can be memory-mappable in whole or in part. When only a subset of= a +region can be mapped by the client, a ``VFIO_REGION_INFO_CAP_SPARSE_MMAP`` +capability is included in the region info reply. This capability describes +which portions can be mapped by the client. + +.. Note:: + For example, in a virtual NVMe controller, sparse regions can be used so + that accesses to the NVMe registers (found in the beginning of BAR0) are + trapped (an infrequent event), while allowing direct access to the door= bells + (an extremely frequent event as every I/O submission requires a write to + BAR0), found in the next page after the NVMe registers in BAR0. + +Device-Specific Regions +""""""""""""""""""""""" + +A device can define regions additional to the standard ones (e.g. PCI inde= xes +0-8). This is achieved by including a ``VFIO_REGION_INFO_CAP_TYPE`` capabi= lity +in the region info reply of a device-specific region. Such regions are ref= lected +in ``struct vfio_user_device_info.num_regions``. Thus, for PCI devices this +value can be equal to, or higher than, ``VFIO_PCI_NUM_REGIONS``. + +Region I/O via file descriptors +------------------------------- + +For unmapped regions, region I/O from the client is done via +``VFIO_USER_REGION_READ/WRITE``. As an optimization, ioeventfds or ioregi= onfds +may be configured for sub-regions of some regions. A client may request +information on these sub-regions via ``VFIO_USER_DEVICE_GET_REGION_IO_FDS`= `; by +configuring the returned file descriptors as ioeventfds or ioregionfds, the +server can be directly notified of I/O (for example, by KVM) without takin= g a +trip through the client. + +Interrupts +^^^^^^^^^^ + +The client uses ``VFIO_USER_DEVICE_GET_IRQ_INFO`` messages to query the se= rver +for the device's interrupt types. The interrupt types are specific to the = bus +the device is attached to, and the client is expected to know the capabili= ties +of each interrupt type. The server can signal an interrupt by directly inj= ecting +interrupts into the guest via an event file descriptor. The client configu= res +how the server signals an interrupt with ``VFIO_USER_SET_IRQS`` messages. + +Device Read and Write +^^^^^^^^^^^^^^^^^^^^^ + +When the guest executes load or store operations to an unmapped device reg= ion, +the client forwards these operations to the server with +``VFIO_USER_REGION_READ`` or ``VFIO_USER_REGION_WRITE`` messages. The serv= er +will reply with data from the device on read operations or an acknowledgem= ent on +write operations. See `Read and Write Operations`_. + +Client memory access +-------------------- + +The client uses ``VFIO_USER_DMA_MAP`` and ``VFIO_USER_DMA_UNMAP`` messages= to +inform the server of the valid DMA ranges that the server can access on be= half +of a device (typically, VM guest memory). DMA memory may be accessed by the +server via ``VFIO_USER_DMA_READ`` and ``VFIO_USER_DMA_WRITE`` messages ove= r the +socket. In this case, the "DMA" part of the naming is a misnomer. + +Actual direct memory access of client memory from the server is possible i= f the +client provides file descriptors the server can ``mmap()``. Note that ``mm= ap()`` +privileges cannot be revoked by the client, therefore file descriptors sho= uld +only be exported in environments where the client trusts the server not to +corrupt guest memory. + +See `Read and Write Operations`_. + +Client/server interactions +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +Socket +------ + +A server can serve: + +1) one or more clients, and/or +2) one or more virtual devices, belonging to one or more clients. + +The current protocol specification requires a dedicated socket per +client/server connection. It is a server-side implementation detail whethe= r a +single server handles multiple virtual devices from the same or multiple +clients. The location of the socket is implementation-specific. Multiplexi= ng +clients, devices, and servers over the same socket is not supported in this +version of the protocol. + +Authentication +-------------- + +For ``AF_UNIX``, we rely on OS mandatory access controls on the socket fil= es, +therefore it is up to the management layer to set up the socket as require= d. +Socket types that span guests or hosts will require a proper authentication +mechanism. Defining that mechanism is deferred to a future version of the +protocol. + +Command Concurrency +------------------- + +A client may pipeline multiple commands without waiting for previous comma= nd +replies. The server will process commands in the order they are received.= A +consequence of this is if a client issues a command with the *No_reply* bi= t, +then subsequently issues a command without *No_reply*, the older command w= ill +have been processed before the reply to the younger command is sent by the +server. The client must be aware of the device's capability to process +concurrent commands if pipelining is used. For example, pipelining allows +multiple client threads to concurrently access device regions; the client = must +ensure these accesses obey device semantics. + +An example is a frame buffer device, where the device may allow concurrent +access to different areas of video memory, but may have indeterminate beha= vior +if concurrent accesses are performed to command or status registers. + +Note that unrelated messages sent from the server to the client can appear= in +between a client to server request/reply and vice versa. + +Implementers should be prepared for certain commands to exhibit potentially +unbounded latencies. For example, ``VFIO_USER_DEVICE_RESET`` may take an +arbitrarily long time to complete; clients should take care not to block +unnecessarily. + +Socket Disconnection Behavior +----------------------------- +The server and the client can disconnect from each other, either intention= ally +or unexpectedly. Both the client and the server need to know how to handle= such +events. + +Server Disconnection +^^^^^^^^^^^^^^^^^^^^ +A server disconnecting from the client may indicate that: + +1) A virtual device has been restarted, either intentionally (e.g. because= of a + device update) or unintentionally (e.g. because of a crash). +2) A virtual device has been shut down with no intention to be restarted. + +It is impossible for the client to know whether or not a failure is +intermittent or innocuous and should be retried, therefore the client shou= ld +reset the VFIO device when it detects the socket has been disconnected. +Error recovery will be driven by the guest's device error handling +behavior. + +Client Disconnection +^^^^^^^^^^^^^^^^^^^^ +The client disconnecting from the server primarily means that the client +has exited. Currently, this means that the guest is shut down so the devic= e is +no longer needed therefore the server can automatically exit. However, the= re +can be cases where a client disconnection should not result in a server ex= it: + +1) A single server serving multiple clients. +2) A multi-process QEMU upgrading itself step by step, which is not yet + implemented. + +Therefore in order for the protocol to be forward compatible, the server s= hould +respond to a client disconnection as follows: + + - all client memory regions are unmapped and cleaned up (including closin= g any + passed file descriptors) + - all IRQ file descriptors passed from the old client are closed + - the device state should otherwise be retained + +The expectation is that when a client reconnects, it will re-establish IRQ= and +client memory mappings. + +If anything happens to the client (such as qemu really did exit), the cont= rol +stack will know about it and can clean up resources accordingly. + +Security Considerations +----------------------- + +Speaking generally, vfio-user clients should not trust servers, and vice v= ersa. +Standard tools and mechanisms should be used on both sides to validate inp= ut and +prevent against denial of service scenarios, buffer overflow, etc. + +Request Retry and Response Timeout +---------------------------------- +A failed command is a command that has been successfully sent and has been +responded to with an error code. Failure to send the command in the first = place +(e.g. because the socket is disconnected) is a different type of error exa= mined +earlier in the disconnect section. + +.. Note:: + QEMU's VFIO retries certain operations if they fail. While this makes s= ense + for real HW, we don't know for sure whether it makes sense for virtual + devices. + +Defining a retry and timeout scheme is deferred to a future version of the +protocol. + +Message sizes +------------- + +Some requests have an ``argsz`` field. In a request, it defines the maximum +expected reply payload size, which should be at least the size of the fixed +reply payload headers defined here. The *request* payload size is defined = by the +usual ``msg_size`` field in the header, not the ``argsz`` field. + +In a reply, the server sets ``argsz`` field to the size needed for a full +payload size. This may be less than the requested maximum size. This may be +larger than the requested maximum size: in that case, the full payload is = not +included in the reply, but the ``argsz`` field in the reply indicates the = needed +size, allowing a client to allocate a larger buffer for holding the reply = before +trying again. + +In addition, during negotiation (see `Version`_), the client and server m= ay +each specify a ``max_data_xfer_size`` value; this defines the maximum data= that +may be read or written via one of the ``VFIO_USER_DMA/REGION_READ/WRITE`` +messages; see `Read and Write Operations`_. + +Protocol Specification +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +To distinguish from the base VFIO symbols, all vfio-user symbols are prefi= xed +with ``vfio_user`` or ``VFIO_USER``. In this revision, all data is in the +endianness of the host system, although this may be relaxed in future +revisions in cases where the client and server run on different hosts +with different endianness. + +Unless otherwise specified, all sizes should be presumed to be in bytes. + +.. _Commands: + +Commands +-------- +The following table lists the VFIO message command IDs, and whether the +message command is sent from the client or the server. + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Name Command Request Direction +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +``VFIO_USER_VERSION`` 1 client -> server +``VFIO_USER_DMA_MAP`` 2 client -> server +``VFIO_USER_DMA_UNMAP`` 3 client -> server +``VFIO_USER_DEVICE_GET_INFO`` 4 client -> server +``VFIO_USER_DEVICE_GET_REGION_INFO`` 5 client -> server +``VFIO_USER_DEVICE_GET_REGION_IO_FDS`` 6 client -> server +``VFIO_USER_DEVICE_GET_IRQ_INFO`` 7 client -> server +``VFIO_USER_DEVICE_SET_IRQS`` 8 client -> server +``VFIO_USER_REGION_READ`` 9 client -> server +``VFIO_USER_REGION_WRITE`` 10 client -> server +``VFIO_USER_DMA_READ`` 11 server -> client +``VFIO_USER_DMA_WRITE`` 12 server -> client +``VFIO_USER_DEVICE_RESET`` 13 client -> server +``VFIO_USER_REGION_WRITE_MULTI`` 15 client -> server +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Header +------ + +All messages, both command messages and reply messages, are preceded by a +16-byte header that contains basic information about the message. The head= er is +followed by message-specific data described in the sections below. + ++----------------+--------+-------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| Message ID | 0 | 2 | ++----------------+--------+-------------+ +| Command | 2 | 2 | ++----------------+--------+-------------+ +| Message size | 4 | 4 | ++----------------+--------+-------------+ +| Flags | 8 | 4 | ++----------------+--------+-------------+ +| | +-----+------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0-3 | Type | | +| | +-----+------------+ | +| | | 4 | No_reply | | +| | +-----+------------+ | +| | | 5 | Error | | +| | +-----+------------+ | ++----------------+--------+-------------+ +| Error | 12 | 4 | ++----------------+--------+-------------+ +| | 16 | variable | ++----------------+--------+-------------+ + +* *Message ID* identifies the message, and is echoed in the command's reply + message. Message IDs belong entirely to the sender, can be re-used (even + concurrently) and the receiver must not make any assumptions about their + uniqueness. +* *Command* specifies the command to be executed, listed in Commands_. It = is + also set in the reply header. +* *Message size* contains the size of the entire message, including the he= ader. +* *Flags* contains attributes of the message: + + * The *Type* bits indicate the message type. + + * *Command* (value 0x0) indicates a command message. + * *Reply* (value 0x1) indicates a reply message acknowledging a previ= ous + command with the same message ID. + * *No_reply* in a command message indicates that no reply is needed for = this + command. This is commonly used when multiple commands are sent, and o= nly + the last needs acknowledgement. + * *Error* in a reply message indicates the command being acknowledged had + an error. In this case, the *Error* field will be valid. + +* *Error* in a reply message is an optional UNIX errno value. It may be ze= ro + even if the Error bit is set in Flags. It is reserved in a command messa= ge. + +Each command message in Commands_ must be replied to with a reply message, +unless the message sets the *No_Reply* bit. The reply consists of the hea= der +with the *Reply* bit set, plus any additional data. + +If an error occurs, the reply message must only include the reply header. + +As the header is standard in both requests and replies, it is not included= in +the command-specific specifications below; each message definition should = be +appended to the standard header, and the offsets are given from the end of= the +standard header. + +``VFIO_USER_VERSION`` +--------------------- + +.. _Version: + +This is the initial message sent by the client after the socket connection= is +established; the same format is used for the server's reply. + +Upon establishing a connection, the client must send a ``VFIO_USER_VERSION= `` +message proposing a protocol version and a set of capabilities. The server +compares these with the versions and capabilities it supports and sends a +``VFIO_USER_VERSION`` reply according to the following rules. + +* The major version in the reply must be the same as proposed. If the clie= nt + does not support the proposed major, it closes the connection. +* The minor version in the reply must be equal to or less than the minor + version proposed. +* The capability list must be a subset of those proposed. If the server + requires a capability the client did not include, it closes the connecti= on. + +The protocol major version will only change when incompatible protocol cha= nges +are made, such as changing the message format. The minor version may change +when compatible changes are made, such as adding new messages or capabilit= ies, +Both the client and server must support all minor versions less than the +maximum minor version it supports. E.g., an implementation that supports +version 1.3 must also support 1.0 through 1.2. + +When making a change to this specification, the protocol version number mu= st +be included in the form "added in version X.Y" + +Request +^^^^^^^ + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D +Name Offset Size +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D +version major 0 2 +version minor 2 2 +version data 4 variable (including terminating NUL). Optional. +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D + +The version data is an optional UTF-8 encoded JSON byte array with the fol= lowing +format: + ++--------------+--------+-----------------------------------+ +| Name | Type | Description | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| capabilities | object | Contains common capabilities that | +| | | the sender supports. Optional. | ++--------------+--------+-----------------------------------+ + +Capabilities: + ++--------------------+---------+------------------------------------------= ------+ +| Name | Type | Description = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| max_msg_fds | number | Maximum number of file descriptors that c= an be | +| | | received by the sender in one message. = | +| | | Optional. If not specified then the recei= ver | +| | | must assume a value of ``1``. = | ++--------------------+---------+------------------------------------------= ------+ +| max_data_xfer_size | number | Maximum ``count`` for data transfer messa= ges; | +| | | see `Read and Write Operations`_. Optiona= l, | +| | | with a default value of 1048576 bytes. = | ++--------------------+---------+------------------------------------------= ------+ +| pgsizes | number | Page sizes supported in DMA map operation= s | +| | | or'ed together. Optional, with a default = value | +| | | of supporting only 4k pages. = | ++--------------------+---------+------------------------------------------= ------+ +| max_dma_maps | number | Maximum number DMA map windows that can b= e | +| | | valid simultaneously. Optional, with a = | +| | | value of 65535 (64k-1). = | ++--------------------+---------+------------------------------------------= ------+ +| migration | object | Migration capability parameters. If missi= ng | +| | | then migration is not supported by the se= nder. | ++--------------------+---------+------------------------------------------= ------+ +| write_multiple | boolean | ``VFIO_USER_REGION_WRITE_MULTI`` messages= | +| | | are supported if the value is ``true``. = | ++--------------------+---------+------------------------------------------= ------+ + +The migration capability contains the following name/value pairs: + ++-----------------+--------+----------------------------------------------= ----+ +| Name | Type | Description = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D+ +| pgsize | number | Page size of dirty pages bitmap. The smallest= | +| | | between the client and the server is used. = | ++-----------------+--------+----------------------------------------------= ----+ +| max_bitmap_size | number | Maximum bitmap size in ``VFIO_USER_DIRTY_PAGE= S`` | +| | | and ``VFIO_DMA_UNMAP`` messages. Optional, = | +| | | with a default value of 256MB. = | ++-----------------+--------+----------------------------------------------= ----+ + +Reply +^^^^^ + +The same message format is used in the server's reply with the semantics +described above. + +``VFIO_USER_DMA_MAP`` +--------------------- + +This command message is sent by the client to the server to inform it of t= he +memory regions the server can access. It must be sent before the server can +perform any DMA to the client. It is normally sent directly after the vers= ion +handshake is completed, but may also occur when memory is added to the cli= ent, +or if the client uses a vIOMMU. + +Request +^^^^^^^ + +The request payload for this message is a structure of the following forma= t: + ++-------------+--------+-------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------------+--------+-------------+ +| flags | 4 | 4 | ++-------------+--------+-------------+ +| | +-----+------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | readable | | +| | +-----+------------+ | +| | | 1 | writeable | | +| | +-----+------------+ | ++-------------+--------+-------------+ +| offset | 8 | 8 | ++-------------+--------+-------------+ +| address | 16 | 8 | ++-------------+--------+-------------+ +| size | 24 | 8 | ++-------------+--------+-------------+ + +* *argsz* is the size of the above structure. Note there is no reply paylo= ad, + so this field differs from other message types. +* *flags* contains the following region attributes: + + * *readable* indicates that the region can be read from. + + * *writeable* indicates that the region can be written to. + +* *offset* is the file offset of the region with respect to the associated= file + descriptor, or zero if the region is not mappable +* *address* is the base DMA address of the region. +* *size* is the size of the region. + +This structure is 32 bytes in size, so the message size is 16 + 32 bytes. + +If the DMA region being added can be directly mapped by the server, a file +descriptor must be sent as part of the message meta-data. The region can be +mapped via the mmap() system call. On ``AF_UNIX`` sockets, the file descri= ptor +must be passed as ``SCM_RIGHTS`` type ancillary data. Otherwise, if the D= MA +region cannot be directly mapped by the server, no file descriptor must be= sent +as part of the message meta-data and the DMA region can be accessed by the +server using ``VFIO_USER_DMA_READ`` and ``VFIO_USER_DMA_WRITE`` messages, +explained in `Read and Write Operations`_. A command to map over an existi= ng +region must be failed by the server with ``EEXIST`` set in error field in = the +reply. + +Reply +^^^^^ + +There is no payload in the reply message. + +``VFIO_USER_DMA_UNMAP`` +----------------------- + +This command message is sent by the client to the server to inform it that= a +DMA region, previously made available via a ``VFIO_USER_DMA_MAP`` command +message, is no longer available for DMA. It typically occurs when memory is +subtracted from the client or if the client uses a vIOMMU. The DMA region = is +described by the following structure: + +Request +^^^^^^^ + +The request payload for this message is a structure of the following forma= t: + ++--------------+--------+------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++--------------+--------+------------------------+ +| flags | 4 | 4 | ++--------------+--------+------------------------+ +| address | 8 | 8 | ++--------------+--------+------------------------+ +| size | 16 | 8 | ++--------------+--------+------------------------+ + +* *argsz* is the maximum size of the reply payload. +* *flags* is unused in this version. +* *address* is the base DMA address of the DMA region. +* *size* is the size of the DMA region. + +The address and size of the DMA region being unmapped must match exactly a +previous mapping. + +Reply +^^^^^ + +Upon receiving a ``VFIO_USER_DMA_UNMAP`` command, if the file descriptor is +mapped then the server must release all references to that DMA region befo= re +replying, which potentially includes in-flight DMA transactions. + +The server responds with the original DMA entry in the request. + + +``VFIO_USER_DEVICE_GET_INFO`` +----------------------------- + +This command message is sent by the client to the server to query for basic +information about the device. + +Request +^^^^^^^ + ++-------------+--------+--------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------------+--------+--------------------------+ +| flags | 4 | 4 | ++-------------+--------+--------------------------+ +| | +-----+-------------------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | VFIO_DEVICE_FLAGS_RESET | | +| | +-----+-------------------------+ | +| | | 1 | VFIO_DEVICE_FLAGS_PCI | | +| | +-----+-------------------------+ | ++-------------+--------+--------------------------+ +| num_regions | 8 | 4 | ++-------------+--------+--------------------------+ +| num_irqs | 12 | 4 | ++-------------+--------+--------------------------+ + +* *argsz* is the maximum size of the reply payload +* all other fields must be zero. + +Reply +^^^^^ + ++-------------+--------+--------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------------+--------+--------------------------+ +| flags | 4 | 4 | ++-------------+--------+--------------------------+ +| | +-----+-------------------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | VFIO_DEVICE_FLAGS_RESET | | +| | +-----+-------------------------+ | +| | | 1 | VFIO_DEVICE_FLAGS_PCI | | +| | +-----+-------------------------+ | ++-------------+--------+--------------------------+ +| num_regions | 8 | 4 | ++-------------+--------+--------------------------+ +| num_irqs | 12 | 4 | ++-------------+--------+--------------------------+ + +* *argsz* is the size required for the full reply payload (16 bytes today) +* *flags* contains the following device attributes. + + * ``VFIO_DEVICE_FLAGS_RESET`` indicates that the device supports the + ``VFIO_USER_DEVICE_RESET`` message. + * ``VFIO_DEVICE_FLAGS_PCI`` indicates that the device is a PCI device. + +* *num_regions* is the number of memory regions that the device exposes. +* *num_irqs* is the number of distinct interrupt types that the device sup= ports. + +This version of the protocol only supports PCI devices. Additional devices= may +be supported in future versions. + +``VFIO_USER_DEVICE_GET_REGION_INFO`` +------------------------------------ + +This command message is sent by the client to the server to query for +information about device regions. The VFIO region info structure is define= d in +```` (``struct vfio_region_info``). + +Request +^^^^^^^ + ++------------+--------+------------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D+ +| argsz | 0 | 4 | ++------------+--------+------------------------------+ +| flags | 4 | 4 | ++------------+--------+------------------------------+ +| index | 8 | 4 | ++------------+--------+------------------------------+ +| cap_offset | 12 | 4 | ++------------+--------+------------------------------+ +| size | 16 | 8 | ++------------+--------+------------------------------+ +| offset | 24 | 8 | ++------------+--------+------------------------------+ + +* *argsz* the maximum size of the reply payload +* *index* is the index of memory region being queried, it is the only field + that is required to be set in the command message. +* all other fields must be zero. + +Reply +^^^^^ + ++------------+--------+------------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D+ +| argsz | 0 | 4 | ++------------+--------+------------------------------+ +| flags | 4 | 4 | ++------------+--------+------------------------------+ +| | +-----+-----------------------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | VFIO_REGION_INFO_FLAG_READ | | +| | +-----+-----------------------------+ | +| | | 1 | VFIO_REGION_INFO_FLAG_WRITE | | +| | +-----+-----------------------------+ | +| | | 2 | VFIO_REGION_INFO_FLAG_MMAP | | +| | +-----+-----------------------------+ | +| | | 3 | VFIO_REGION_INFO_FLAG_CAPS | | +| | +-----+-----------------------------+ | ++------------+--------+------------------------------+ ++------------+--------+------------------------------+ +| index | 8 | 4 | ++------------+--------+------------------------------+ +| cap_offset | 12 | 4 | ++------------+--------+------------------------------+ +| size | 16 | 8 | ++------------+--------+------------------------------+ +| offset | 24 | 8 | ++------------+--------+------------------------------+ + +* *argsz* is the size required for the full reply payload (region info str= ucture + plus the size of any region capabilities) +* *flags* are attributes of the region: + + * ``VFIO_REGION_INFO_FLAG_READ`` allows client read access to the region. + * ``VFIO_REGION_INFO_FLAG_WRITE`` allows client write access to the regi= on. + * ``VFIO_REGION_INFO_FLAG_MMAP`` specifies the client can mmap() the reg= ion. + When this flag is set, the reply will include a file descriptor in its + meta-data. On ``AF_UNIX`` sockets, the file descriptors will be passed= as + ``SCM_RIGHTS`` type ancillary data. + * ``VFIO_REGION_INFO_FLAG_CAPS`` indicates additional capabilities found= in the + reply. + +* *index* is the index of memory region being queried, it is the only field + that is required to be set in the command message. +* *cap_offset* describes where additional region capabilities can be found. + cap_offset is relative to the beginning of the VFIO region info structur= e. + The data structure it points is a VFIO cap header defined in + ````. +* *size* is the size of the region. +* *offset* is the offset that should be given to the mmap() system call for + regions with the MMAP attribute. It is also used as the base offset when + mapping a VFIO sparse mmap area, described below. + +VFIO region capabilities +"""""""""""""""""""""""" + +The VFIO region information can also include a capabilities list. This lis= t is +similar to a PCI capability list - each entry has a common header that +identifies a capability and where the next capability in the list can be f= ound. +The VFIO capability header format is defined in ```` (``stru= ct +vfio_info_cap_header``). + +VFIO cap header format +"""""""""""""""""""""" + ++---------+--------+------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D+ +| id | 0 | 2 | ++---------+--------+------+ +| version | 2 | 2 | ++---------+--------+------+ +| next | 4 | 4 | ++---------+--------+------+ + +* *id* is the capability identity. +* *version* is a capability-specific version number. +* *next* specifies the offset of the next capability in the capability lis= t. It + is relative to the beginning of the VFIO region info structure. + +VFIO sparse mmap cap header +""""""""""""""""""""""""""" + ++------------------+----------------------------------+ +| Name | Value | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| id | VFIO_REGION_INFO_CAP_SPARSE_MMAP | ++------------------+----------------------------------+ +| version | 0x1 | ++------------------+----------------------------------+ +| next | | ++------------------+----------------------------------+ +| sparse mmap info | VFIO region info sparse mmap | ++------------------+----------------------------------+ + +This capability is defined when only a subrange of the region supports +direct access by the client via mmap(). The VFIO sparse mmap area is defin= ed in +```` (``struct vfio_region_sparse_mmap_area`` and ``struct +vfio_region_info_cap_sparse_mmap``). + +VFIO region info cap sparse mmap +"""""""""""""""""""""""""""""""" + ++----------+--------+------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D= =3D+ +| nr_areas | 0 | 4 | ++----------+--------+------+ +| reserved | 4 | 4 | ++----------+--------+------+ +| offset | 8 | 8 | ++----------+--------+------+ +| size | 16 | 8 | ++----------+--------+------+ +| ... | | | ++----------+--------+------+ + +* *nr_areas* is the number of sparse mmap areas in the region. +* *offset* and size describe a single area that can be mapped by the clien= t. + There will be *nr_areas* pairs of offset and size. The offset will be ad= ded to + the base offset given in the ``VFIO_USER_DEVICE_GET_REGION_INFO`` to for= m the + offset argument of the subsequent mmap() call. + +The VFIO sparse mmap area is defined in ```` (``struct +vfio_region_info_cap_sparse_mmap``). + + +``VFIO_USER_DEVICE_GET_REGION_IO_FDS`` +-------------------------------------- + +Clients can access regions via ``VFIO_USER_REGION_READ/WRITE`` or, if prov= ided, by +``mmap()`` of a file descriptor provided by the server. + +``VFIO_USER_DEVICE_GET_REGION_IO_FDS`` provides an alternative access mech= anism via +file descriptors. This is an optional feature intended for performance +improvements where an underlying sub-system (such as KVM) supports communi= cation +across such file descriptors to the vfio-user server, without needing to +round-trip through the client. + +The server returns an array of sub-regions for the requested region. Each +sub-region describes a span (offset and size) of a region, along with the +requested file descriptor notification mechanism to use. Each sub-region = in the +response message may choose to use a different method, as defined below. = The +two mechanisms supported in this specification are ioeventfds and ioregion= fds. + +The server in addition returns a file descriptor in the ancillary data; cl= ients +are expected to configure each sub-region's file descriptor with the reque= sted +notification method. For example, a client could configure KVM with the +requested ioeventfd via a ``KVM_IOEVENTFD`` ``ioctl()``. + +Request +^^^^^^^ + ++-------------+--------+------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D= =3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------------+--------+------+ +| flags | 4 | 4 | ++-------------+--------+------+ +| index | 8 | 4 | ++-------------+--------+------+ +| count | 12 | 4 | ++-------------+--------+------+ + +* *argsz* the maximum size of the reply payload +* *index* is the index of memory region being queried +* all other fields must be zero + +The client must set ``flags`` to zero and specify the region being queried= in +the ``index``. + +Reply +^^^^^ + ++-------------+--------+------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D= =3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------------+--------+------+ +| flags | 4 | 4 | ++-------------+--------+------+ +| index | 8 | 4 | ++-------------+--------+------+ +| count | 12 | 4 | ++-------------+--------+------+ +| sub-regions | 16 | ... | ++-------------+--------+------+ + +* *argsz* is the size of the region IO FD info structure plus the + total size of the sub-region array. Thus, each array entry "i" is at off= set + i * ((argsz - 32) / count). Note that currently this is 40 bytes for bot= h IO + FD types, but this is not to be relied on. As elsewhere, this indicates = the + full reply payload size needed. +* *flags* must be zero +* *index* is the index of memory region being queried +* *count* is the number of sub-regions in the array +* *sub-regions* is the array of Sub-Region IO FD info structures + +The reply message will additionally include at least one file descriptor i= n the +ancillary data. Note that more than one sub-region may share the same file +descriptor. + +Note that it is the client's responsibility to verify the requested values= (for +example, that the requested offset does not exceed the region's bounds). + +Each sub-region given in the response has one of two possible structures, +depending whether *type* is ``VFIO_USER_IO_FD_TYPE_IOEVENTFD`` or +``VFIO_USER_IO_FD_TYPE_IOREGIONFD``: + +Sub-Region IO FD info format (ioeventfd) +"""""""""""""""""""""""""""""""""""""""" + ++-----------+--------+------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D+ +| offset | 0 | 8 | ++-----------+--------+------+ +| size | 8 | 8 | ++-----------+--------+------+ +| fd_index | 16 | 4 | ++-----------+--------+------+ +| type | 20 | 4 | ++-----------+--------+------+ +| flags | 24 | 4 | ++-----------+--------+------+ +| padding | 28 | 4 | ++-----------+--------+------+ +| datamatch | 32 | 8 | ++-----------+--------+------+ + +* *offset* is the offset of the start of the sub-region within the region + requested ("physical address offset" for the region) +* *size* is the length of the sub-region. This may be zero if the access s= ize is + not relevant, which may allow for optimizations +* *fd_index* is the index in the ancillary data of the FD to use for ioeve= ntfd + notification; it may be shared. +* *type* is ``VFIO_USER_IO_FD_TYPE_IOEVENTFD`` +* *flags* is any of: + + * ``KVM_IOEVENTFD_FLAG_DATAMATCH`` + * ``KVM_IOEVENTFD_FLAG_PIO`` + * ``KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY`` (FIXME: makes sense?) + +* *datamatch* is the datamatch value if needed + +See https://www.kernel.org/doc/Documentation/virtual/kvm/api.txt, *4.59 +KVM_IOEVENTFD* for further context on the ioeventfd-specific fields. + +Sub-Region IO FD info format (ioregionfd) +""""""""""""""""""""""""""""""""""""""""" + ++-----------+--------+------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D+ +| offset | 0 | 8 | ++-----------+--------+------+ +| size | 8 | 8 | ++-----------+--------+------+ +| fd_index | 16 | 4 | ++-----------+--------+------+ +| type | 20 | 4 | ++-----------+--------+------+ +| flags | 24 | 4 | ++-----------+--------+------+ +| padding | 28 | 4 | ++-----------+--------+------+ +| user_data | 32 | 8 | ++-----------+--------+------+ + +* *offset* is the offset of the start of the sub-region within the region + requested ("physical address offset" for the region) +* *size* is the length of the sub-region. This may be zero if the access s= ize is + not relevant, which may allow for optimizations; ``KVM_IOREGION_POSTED_W= RITES`` + must be set in *flags* in this case +* *fd_index* is the index in the ancillary data of the FD to use for ioreg= ionfd + messages; it may be shared +* *type* is ``VFIO_USER_IO_FD_TYPE_IOREGIONFD`` +* *flags* is any of: + + * ``KVM_IOREGION_PIO`` + * ``KVM_IOREGION_POSTED_WRITES`` + +* *user_data* is an opaque value passed back to the server via a message o= n the + file descriptor + +For further information on the ioregionfd-specific fields, see: +https://lore.kernel.org/kvm/cover.1613828726.git.eafanasova@gmail.com/ + +(FIXME: update with final API docs.) + +``VFIO_USER_DEVICE_GET_IRQ_INFO`` +--------------------------------- + +This command message is sent by the client to the server to query for +information about device interrupt types. The VFIO IRQ info structure is +defined in ```` (``struct vfio_irq_info``). + +Request +^^^^^^^ + ++-------+--------+---------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------+--------+---------------------------+ +| flags | 4 | 4 | ++-------+--------+---------------------------+ +| | +-----+--------------------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | VFIO_IRQ_INFO_EVENTFD | | +| | +-----+--------------------------+ | +| | | 1 | VFIO_IRQ_INFO_MASKABLE | | +| | +-----+--------------------------+ | +| | | 2 | VFIO_IRQ_INFO_AUTOMASKED | | +| | +-----+--------------------------+ | +| | | 3 | VFIO_IRQ_INFO_NORESIZE | | +| | +-----+--------------------------+ | ++-------+--------+---------------------------+ +| index | 8 | 4 | ++-------+--------+---------------------------+ +| count | 12 | 4 | ++-------+--------+---------------------------+ + +* *argsz* is the maximum size of the reply payload (16 bytes today) +* index is the index of IRQ type being queried (e.g. ``VFIO_PCI_MSIX_IRQ_I= NDEX``) +* all other fields must be zero + +Reply +^^^^^ + ++-------+--------+---------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------+--------+---------------------------+ +| flags | 4 | 4 | ++-------+--------+---------------------------+ +| | +-----+--------------------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | VFIO_IRQ_INFO_EVENTFD | | +| | +-----+--------------------------+ | +| | | 1 | VFIO_IRQ_INFO_MASKABLE | | +| | +-----+--------------------------+ | +| | | 2 | VFIO_IRQ_INFO_AUTOMASKED | | +| | +-----+--------------------------+ | +| | | 3 | VFIO_IRQ_INFO_NORESIZE | | +| | +-----+--------------------------+ | ++-------+--------+---------------------------+ +| index | 8 | 4 | ++-------+--------+---------------------------+ +| count | 12 | 4 | ++-------+--------+---------------------------+ + +* *argsz* is the size required for the full reply payload (16 bytes today) +* *flags* defines IRQ attributes: + + * ``VFIO_IRQ_INFO_EVENTFD`` indicates the IRQ type can support server ev= entfd + signalling. + * ``VFIO_IRQ_INFO_MASKABLE`` indicates that the IRQ type supports the ``= MASK`` + and ``UNMASK`` actions in a ``VFIO_USER_DEVICE_SET_IRQS`` message. + * ``VFIO_IRQ_INFO_AUTOMASKED`` indicates the IRQ type masks itself after= being + triggered, and the client must send an ``UNMASK`` action to receive new + interrupts. + * ``VFIO_IRQ_INFO_NORESIZE`` indicates ``VFIO_USER_SET_IRQS`` operations= setup + interrupts as a set, and new sub-indexes cannot be enabled without dis= abling + the entire type. +* index is the index of IRQ type being queried +* count describes the number of interrupts of the queried type. + +``VFIO_USER_DEVICE_SET_IRQS`` +----------------------------- + +This command message is sent by the client to the server to set actions for +device interrupt types. The VFIO IRQ set structure is defined in +```` (``struct vfio_irq_set``). + +Request +^^^^^^^ + ++-------+--------+------------------------------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| argsz | 0 | 4 | ++-------+--------+------------------------------+ +| flags | 4 | 4 | ++-------+--------+------------------------------+ +| | +-----+-----------------------------+ | +| | | Bit | Definition | | +| | +=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ | +| | | 0 | VFIO_IRQ_SET_DATA_NONE | | +| | +-----+-----------------------------+ | +| | | 1 | VFIO_IRQ_SET_DATA_BOOL | | +| | +-----+-----------------------------+ | +| | | 2 | VFIO_IRQ_SET_DATA_EVENTFD | | +| | +-----+-----------------------------+ | +| | | 3 | VFIO_IRQ_SET_ACTION_MASK | | +| | +-----+-----------------------------+ | +| | | 4 | VFIO_IRQ_SET_ACTION_UNMASK | | +| | +-----+-----------------------------+ | +| | | 5 | VFIO_IRQ_SET_ACTION_TRIGGER | | +| | +-----+-----------------------------+ | ++-------+--------+------------------------------+ +| index | 8 | 4 | ++-------+--------+------------------------------+ +| start | 12 | 4 | ++-------+--------+------------------------------+ +| count | 16 | 4 | ++-------+--------+------------------------------+ +| data | 20 | variable | ++-------+--------+------------------------------+ + +* *argsz* is the size of the VFIO IRQ set request payload, including any *= data* + field. Note there is no reply payload, so this field differs from other + message types. +* *flags* defines the action performed on the interrupt range. The ``DATA`` + flags describe the data field sent in the message; the ``ACTION`` flags + describe the action to be performed. The flags are mutually exclusive for + both sets. + + * ``VFIO_IRQ_SET_DATA_NONE`` indicates there is no data field in the com= mand. + The action is performed unconditionally. + * ``VFIO_IRQ_SET_DATA_BOOL`` indicates the data field is an array of boo= lean + bytes. The action is performed if the corresponding boolean is true. + * ``VFIO_IRQ_SET_DATA_EVENTFD`` indicates an array of event file descrip= tors + was sent in the message meta-data. These descriptors will be signalled= when + the action defined by the action flags occurs. In ``AF_UNIX`` sockets,= the + descriptors are sent as ``SCM_RIGHTS`` type ancillary data. + If no file descriptors are provided, this de-assigns the specified + previously configured interrupts. + * ``VFIO_IRQ_SET_ACTION_MASK`` indicates a masking event. It can be used= with + ``VFIO_IRQ_SET_DATA_BOOL`` or ``VFIO_IRQ_SET_DATA_NONE`` to mask an in= terrupt, + or with ``VFIO_IRQ_SET_DATA_EVENTFD`` to generate an event when the gu= est masks + the interrupt. + * ``VFIO_IRQ_SET_ACTION_UNMASK`` indicates an unmasking event. It can be= used + with ``VFIO_IRQ_SET_DATA_BOOL`` or ``VFIO_IRQ_SET_DATA_NONE`` to unmas= k an + interrupt, or with ``VFIO_IRQ_SET_DATA_EVENTFD`` to generate an event = when the + guest unmasks the interrupt. + * ``VFIO_IRQ_SET_ACTION_TRIGGER`` indicates a triggering event. It can b= e used + with ``VFIO_IRQ_SET_DATA_BOOL`` or ``VFIO_IRQ_SET_DATA_NONE`` to trigg= er an + interrupt, or with ``VFIO_IRQ_SET_DATA_EVENTFD`` to generate an event = when the + server triggers the interrupt. + +* *index* is the index of IRQ type being setup. +* *start* is the start of the sub-index being set. +* *count* describes the number of sub-indexes being set. As a special case= , a + count (and start) of 0, with data flags of ``VFIO_IRQ_SET_DATA_NONE`` di= sables + all interrupts of the index. +* *data* is an optional field included when the + ``VFIO_IRQ_SET_DATA_BOOL`` flag is present. It contains an array of bool= eans + that specify whether the action is to be performed on the corresponding + index. It's used when the action is only performed on a subset of the ra= nge + specified. + +Not all interrupt types support every combination of data and action flags. +The client must know the capabilities of the device and IRQ index before it +sends a ``VFIO_USER_DEVICE_SET_IRQ`` message. + +In typical operation, a specific IRQ may operate as follows: + +1. The client sends a ``VFIO_USER_DEVICE_SET_IRQ`` message with + ``flags=3D(VFIO_IRQ_SET_DATA_EVENTFD|VFIO_IRQ_SET_ACTION_TRIGGER)`` alo= ng + with an eventfd. This associates the IRQ with a particular eventfd on t= he + server side. + +#. The client may send a ``VFIO_USER_DEVICE_SET_IRQ`` message with + ``flags=3D(VFIO_IRQ_SET_DATA_EVENTFD|VFIO_IRQ_SET_ACTION_MASK/UNMASK)``= along + with another eventfd. This associates the given eventfd with the + mask/unmask state on the server side. + +#. The server may trigger the IRQ by writing 1 to the eventfd. + +#. The server may mask/unmask an IRQ which will write 1 to the correspondi= ng + mask/unmask eventfd, if there is one. + +5. A client may trigger a device IRQ itself, by sending a + ``VFIO_USER_DEVICE_SET_IRQ`` message with + ``flags=3D(VFIO_IRQ_SET_DATA_NONE/BOOL|VFIO_IRQ_SET_ACTION_TRIGGER)``. + +6. A client may mask or unmask the IRQ, by sending a + ``VFIO_USER_DEVICE_SET_IRQ`` message with + ``flags=3D(VFIO_IRQ_SET_DATA_NONE/BOOL|VFIO_IRQ_SET_ACTION_MASK/UNMASK)= ``. + +Reply +^^^^^ + +There is no payload in the reply. + +.. _Read and Write Operations: + +Note that all of these operations must be supported by the client and/or s= erver, +even if the corresponding memory or device region has been shared as mappa= ble. + +The ``count`` field must not exceed the value of ``max_data_xfer_size`` of= the +peer, for both reads and writes. + +``VFIO_USER_REGION_READ`` +------------------------- + +If a device region is not mappable, it's not directly accessible by the cl= ient +via ``mmap()`` of the underlying file descriptor. In this case, a client c= an +read from a device region with this message. + +Request +^^^^^^^ + ++--------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| offset | 0 | 8 | ++--------+--------+----------+ +| region | 8 | 4 | ++--------+--------+----------+ +| count | 12 | 4 | ++--------+--------+----------+ + +* *offset* into the region being accessed. +* *region* is the index of the region being accessed. +* *count* is the size of the data to be transferred. + +Reply +^^^^^ + ++--------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| offset | 0 | 8 | ++--------+--------+----------+ +| region | 8 | 4 | ++--------+--------+----------+ +| count | 12 | 4 | ++--------+--------+----------+ +| data | 16 | variable | ++--------+--------+----------+ + +* *offset* into the region accessed. +* *region* is the index of the region accessed. +* *count* is the size of the data transferred. +* *data* is the data that was read from the device region. + +``VFIO_USER_REGION_WRITE`` +-------------------------- + +If a device region is not mappable, it's not directly accessible by the cl= ient +via mmap() of the underlying fd. In this case, a client can write to a dev= ice +region with this message. + +Request +^^^^^^^ + ++--------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| offset | 0 | 8 | ++--------+--------+----------+ +| region | 8 | 4 | ++--------+--------+----------+ +| count | 12 | 4 | ++--------+--------+----------+ +| data | 16 | variable | ++--------+--------+----------+ + +* *offset* into the region being accessed. +* *region* is the index of the region being accessed. +* *count* is the size of the data to be transferred. +* *data* is the data to write + +Reply +^^^^^ + ++--------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| offset | 0 | 8 | ++--------+--------+----------+ +| region | 8 | 4 | ++--------+--------+----------+ +| count | 12 | 4 | ++--------+--------+----------+ + +* *offset* into the region accessed. +* *region* is the index of the region accessed. +* *count* is the size of the data transferred. + +``VFIO_USER_DMA_READ`` +----------------------- + +If the client has not shared mappable memory, the server can use this mess= age to +read from guest memory. + +Request +^^^^^^^ + ++---------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| address | 0 | 8 | ++---------+--------+----------+ +| count | 8 | 8 | ++---------+--------+----------+ + +* *address* is the client DMA memory address being accessed. This address = must have + been previously exported to the server with a ``VFIO_USER_DMA_MAP`` mess= age. +* *count* is the size of the data to be transferred. + +Reply +^^^^^ + ++---------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| address | 0 | 8 | ++---------+--------+----------+ +| count | 8 | 8 | ++---------+--------+----------+ +| data | 16 | variable | ++---------+--------+----------+ + +* *address* is the client DMA memory address being accessed. +* *count* is the size of the data transferred. +* *data* is the data read. + +``VFIO_USER_DMA_WRITE`` +----------------------- + +If the client has not shared mappable memory, the server can use this mess= age to +write to guest memory. + +Request +^^^^^^^ + ++---------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| address | 0 | 8 | ++---------+--------+----------+ +| count | 8 | 8 | ++---------+--------+----------+ +| data | 16 | variable | ++---------+--------+----------+ + +* *address* is the client DMA memory address being accessed. This address = must have + been previously exported to the server with a ``VFIO_USER_DMA_MAP`` mess= age. +* *count* is the size of the data to be transferred. +* *data* is the data to write + +Reply +^^^^^ + ++---------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| address | 0 | 8 | ++---------+--------+----------+ +| count | 8 | 4 | ++---------+--------+----------+ + +* *address* is the client DMA memory address being accessed. +* *count* is the size of the data transferred. + +``VFIO_USER_DEVICE_RESET`` +-------------------------- + +This command message is sent from the client to the server to reset the de= vice. +Neither the request or reply have a payload. + +``VFIO_USER_REGION_WRITE_MULTI`` +-------------------------------- + +This message can be used to coalesce multiple device write operations +into a single messgage. It is only used as an optimization when the +outgoing message queue is relatively full. + +Request +^^^^^^^ + ++---------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| wr_cnt | 0 | 8 | ++---------+--------+----------+ +| wrs | 8 | variable | ++---------+--------+----------+ + +* *wr_cnt* is the number of device writes coalesced in the message +* *wrs* is an array of device writes defined below + +Single Device Write Format +"""""""""""""""""""""""""" + ++--------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| offset | 0 | 8 | ++--------+--------+----------+ +| region | 8 | 4 | ++--------+--------+----------+ +| count | 12 | 4 | ++--------+--------+----------+ +| data | 16 | 8 | ++--------+--------+----------+ + +* *offset* into the region being accessed. +* *region* is the index of the region being accessed. +* *count* is the size of the data to be transferred. This format can + only describe writes of 8 bytes or less. +* *data* is the data to write. + +Reply +^^^^^ + ++---------+--------+----------+ +| Name | Offset | Size | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D+ +| wr_cnt | 0 | 8 | ++---------+--------+----------+ + +* *wr_cnt* is the number of device writes completed. + + +Appendices +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Unused VFIO ``ioctl()`` commands +-------------------------------- + +The following VFIO commands do not have an equivalent vfio-user command: + +* ``VFIO_GET_API_VERSION`` +* ``VFIO_CHECK_EXTENSION`` +* ``VFIO_SET_IOMMU`` +* ``VFIO_GROUP_GET_STATUS`` +* ``VFIO_GROUP_SET_CONTAINER`` +* ``VFIO_GROUP_UNSET_CONTAINER`` +* ``VFIO_GROUP_GET_DEVICE_FD`` +* ``VFIO_IOMMU_GET_INFO`` + +However, once support for live migration for VFIO devices is finalized some +of the above commands may have to be handled by the client in their +corresponding vfio-user form. This will be addressed in a future protocol +version. + +VFIO groups and containers +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The current VFIO implementation includes group and container idioms that +describe how a device relates to the host IOMMU. In the vfio-user +implementation, the IOMMU is implemented in SW by the client, and is not +visible to the server. The simplest idea would be that the client put each +device into its own group and container. + +Backend Program Conventions +--------------------------- + +vfio-user backend program conventions are based on the vhost-user ones. + +* The backend program must not daemonize itself. +* No assumptions must be made as to what access the backend program has on= the + system. +* File descriptors 0, 1 and 2 must exist, must have regular + stdin/stdout/stderr semantics, and can be redirected. +* The backend program must honor the SIGTERM signal. +* The backend program must accept the following commands line options: + + * ``--socket-path=3DPATH``: path to UNIX domain socket, + * ``--fd=3DFDNUM``: file descriptor for UNIX domain socket, incompatible= with + ``--socket-path`` +* The backend program must be accompanied with a JSON file stored under + ``/usr/share/vfio-user``. + +TODO add schema similar to docs/interop/vhost-user.json. --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324211; cv=pass; d=zohomail.com; s=zohoarc; b=J9QLC64HEUsNYPRK/ZLoxVn+kpqGXQ1MQzlN7x09VnCWEMNKC0vPc8bPnf+qVcFOXiVL3DsHdtu9zJXw1IfozLwMLWO3kH9CAQHG2ycde3/DI1rttPW5Iz2DUmjcyBkufBJzlWvoIlj0tDOGGBaoUzVPClznPC7OnWZ5KCRyDCM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324211; 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=bt368S//TFpiN6sebSh8SFSdPdLJh8K8ut+DZyEUSZE=; b=YB2s+qgccnsnEwAdbU32Psz6JE9hYJ90nEzFvH29fR6J/eTWlro8cxvLJn/N9MzOfSTFctSFgH0TwYYY22FvNhlvSTbOdun1BSwfyLH4LF8JT52puorvPszLIfRUUyxKNHXaiGERSqvnGz7GwJ4PBWdjXGHNNsqC73XYAEwQx54= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324211782479.7735275375878; Thu, 15 May 2025 08:50:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFamO-0008BM-4U; Thu, 15 May 2025 11:45:59 -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 1uFalX-0006H4-Bv for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:00 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalT-0006Dl-0X for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:58 -0400 Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7ma9r006289; Thu, 15 May 2025 08:44:52 -0700 Received: from sj2pr03cu002.outbound.protection.outlook.com (mail-westusazlp17013079.outbound.protection.outlook.com [40.93.1.79]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mxh0k19x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:51 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:43 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=bt368S//TFpiN6sebSh8SFSdPdLJh8K8ut+DZyEUS ZE=; b=rU9oBryzwZ2MuWNWqudiWhmizsuGJc5VvvBOM6qrto3Z0xWBvx1cDs0y2 klQBCBGt83VOSiNcdiRaOpnx5NpsXUgd6Vtpi8JgTUO5ZHhd7DbaExt+pEoClvFw kdjsfQqCbdJC2K9xnqhCVNiGISYfWozaWV04nmnXjUnL2nBr7uTiHVJ62w0FwVFp UYnCd/NtAhVgbJ5RVW75pzDaN8HjEtagkYwxBsPu/0y6lEh87TULAVFrv1yBidwL T0KSKeVUeSbWBEcC9hKCa+lMR60tqxZQfzTOZlTbWDIddLwZwOgQXyWvtNBk33WR JfygtnBd6sfp5lZoQGIdpFo0tRzHA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FH+Z6pmW1/p36uR9OVw8z5cOH386MTnZhQwXK/0xr8it8pidlmEi0FAdLdf23cvKaHeqg4l29xVURHunHNHRllBEawmPUoT/h1sRYCtGdNmm+Eoia72j+Zt1+y/BR+wre3S+FmWyNd4KZVb8Yl16U/VapJ2RdsOyNnQjZbfqF6r90w/wx97KqqZUFEOUJQEisDYwoNpw6+WP+jKy7dghKkZFqk8T9eMrrUpFLBpVIGL/+rjeE0kt5xfDeNnTYI0kXWrrvNl9hb5ZBcFa2s+6UT+1Nru8gr/uiXw5KMRLDby5Rq1DMRZBMmO8+8GU9U87bg1FX1pbvW6+T8V++/JiYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bt368S//TFpiN6sebSh8SFSdPdLJh8K8ut+DZyEUSZE=; b=V9S1jfmW5ds2FIF2zEUGvZNNnxN04CCwQGQzXictLPRtEsz47alukfi/CGtbK28DtfdsTlZJ0ErneE98a7iYydNC0+Jcctx6xXWyLHImsQknSJvoVykATX801A351RtE7oh+SUq4raWfOLT8epKxaGdEwM/n7X9dM/Ov+l4axEgzK4o4OsEoNSw/j1prfAXduO4Yd5WyUwF0JiTrFBgqQpjqMouujTlkfS5qCuA6x6aX0HkIuJAZmOC9xTrT+loOtpMwNQjt1xuKOKncGJw+n839/xCh2LYoi5WEag5lEX3mE3xMMD+pUTy6a3vJYwm05rE+wW2Zkl6HYSIg19peqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bt368S//TFpiN6sebSh8SFSdPdLJh8K8ut+DZyEUSZE=; b=qkaIFMm3CObovIHrTK93yK1J6W2rzMFZqVEaURue+fUmJ6CJXyMfO8shcVBFMIyc/BpetfieSzDOMccl5Q0u5eXGWA971/zfj84qJGy8uqm20k4Q7HBJ0PAB61Ho8TOk4E5+0EEW/xpb0lFXrra5YSINN9auX9FwgufHAU2i2HWZol5aWJRFXfI7enSQRLbRNn1QzwHelfN3KDxEIifzaHdHAsfuqfQsg6w3aZy0jqXIMT5ch/j5yDHtjz0qI++vEoyBuuRAqb21RSWko5jAUkibUJWu/jJOx25sDu3FILi5t7+EYVQW84o8AYmbBYxhBg5grIGf3GdaZXkKo+cOYg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 10/27] vfio-user: add vfio-user class and container Date: Thu, 15 May 2025 16:43:55 +0100 Message-ID: <20250515154413.210315-11-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: a2d0254e-9bba-46ef-1dfd-08dd93c76978 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YVNrenFtSnROd0tXL2pjRGJheW1mZ0VtekpTTGdFRXcwRG1XNXpqQUxVMkw2?= =?utf-8?B?Y2VTV0ZrK0JHdkdHM3hJMFdib2dLZkIrQS9OKzlyaFhLdmlhbTZiZFBWUkl3?= =?utf-8?B?ZUYwWEN0NlRMbEdrQmtNUk5odTBvbHdCejkwTDFsRk1TRDZyTkRsUGNlY0FE?= =?utf-8?B?aFIyNWtzeFowbVRHdkVGK2FO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IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MHpoZnlaWU5YUkRTcWQrOExzSVdZQTN3ZnU3RTlQdjdiSFloTGFNVHdScktB?= =?utf-8?B?dzJTUjFzMjBpb0grNUtvMVBEQWhsdG9BblVmc2VrWjdCRnc5c0Vxb1Bwc1lM?= =?utf-8?B?NkFnanFwZkI5ODhza0U3bGVFLzJqV0VDVXdJMEZqYWZKcHY3S0hhcFM2NEls?= =?utf-8?B?QUhzYVl5SU5rMEE1dEdrcTlaVUJNNy9QMmtFTStOWUo0RXdtdlN0UHlLWlBs?= =?utf-8?B?YkZxTUNRaHhUakUxaFJhQStEckU4SXo4YkVuNEh2ZVpTYktyQ1VaNUdTeHRY?= =?utf-8?B?NTBBenhYWUZOZm01RStTUnYrdnBnekFyUHBPNDVhbWw1aTU1aHd4eGN6Ulph?= =?utf-8?B?Z3cxVjNETm4zVGpkdTQ3WEVtWHoxT2U1OW9EMmorVW1aZmorbERjbkJuMFRm?= =?utf-8?B?aUVuMm5HQ1RHQlM4VlBvUTZmV0ZCYmVzQkZGeW5kQUR0R3QzVmJHemR3RVhO?= =?utf-8?B?T2kxY2F1dm5hZllDbVZ2cE85Z3hwTVRWOEJFZk1BaEI0dU9QRmN4MkpZeTYw?= =?utf-8?B?Q1YvUGtOdGJEblhkdFdRTHdPOUZEa2V6UkV2N2NWTFNrSmswekFVNUE3Rk5l?= =?utf-8?B?NnFjY0dKSkc3L3p6bG9FQVN4Wkl2TkU5U2F0UVdQamZZZVE5QVNTSG5MUjRa?= =?utf-8?B?TG9pOVVxekV3bHppY0MxRHFvbm1lazlBTEhWaGZ0WTNMalpySi9ZbVhBaFZX?= =?utf-8?B?SHgrcWpoclNDNzRlb251Z0RFVER4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oyY1lrbzJHRVZvNCtRZ3JDZzBQMEZLb0p6elJ0eTB0YTlXSjJX?= =?utf-8?B?Vmo0NmZnRVRETUJhZEhCMTV4UXBLOTFISnZNSUhmd1pkdEhHUDA5eGYzUDBB?= =?utf-8?B?MmlOWXVBL1Q1dTFreFoxdkFHek5uVHNoL3V0RVl4cktMcU5MMEI5MG5MWVEy?= =?utf-8?B?L2lHYWgrY0xBbHRlY1JwNzdsTGVqMXBWZ2piYXBPdHRhQi93bnY3YzIvNzdr?= =?utf-8?B?Q29FeE9OZmYzSHJaTThLUzRQR2N2WVlQeDgwM1JudWpTN3dQK3lqa3FrNmZ6?= =?utf-8?B?REg1Wk9qT0FxRXFIWEpPaCtYUmdBdDZLb3UyRDE1REg4NnNlcldNU2xUWnYy?= =?utf-8?B?dlJIdzBTTXRNZlArYjRGWGNoU0NtNS9iazVjR2VlcEErei80bHJjZVlHNlZv?= =?utf-8?B?RU1rR01uZ3AyTzFNVG9aN25nWEQ3TCtBQ3FEWEs4eE9tak1paGNqa0dkZmg1?= =?utf-8?Q?L/GlYzzdPOcouVKKritYd0EX7?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2d0254e-9bba-46ef-1dfd-08dd93c76978 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:43.6030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D9gFaQ3N69vWbk9WZ76dFUxOgoMP607AvI+t96YNuFlDdB07EHy9l8dKwMxK1CrxBDQbqIJtTfGHNRdHTVmBQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-GUID: 2uj7OV1uuqq7eeILh-QogCdZPPaWtTM9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX1r6g5N3rAFV0 F1z7R5E7bfOcW8V0od/i57eqd/PyhGJbi+3iz1LwwLkZfAAOODO+lYAnLBzE5hBF1wmSLnIbDdT khPlrf4GT0IQgzt9XhHhqLwf5iS3fM9jFAHbOxj5TZA5lWMTIuj5b7sJyB1Zj2J8o7HMPYUk5GQ W+PAFumXJkEzihd8U+zWlBAQbR85+KrRyONA6Rvl1kblMA2d1RmeouhDx95tA/WavtLHUgvwcr2 yEuFSTPwSq5xwHSLWCgz+FyCfr4ep+RC7A1qaDxwj17m1BUdDrxcBarIwEuZWrjSaGTuOslg29t qpvqg51oVz6F1ZDEoOodsC+cUpDBnyldU4r7ED1xQ8THM+Gznkp4zzFhrCLjIW1OT2ICAZxe8sQ tNOHi59/GaYhsybsa+kUTvnXvYqxV8bIY/Zxgvf0UAw5GVhebh2p4+nkXTNPYJHjHQb1Ih5F X-Authority-Analysis: v=2.4 cv=cNrgskeN c=1 sm=1 tr=0 ts=68260bf3 cx=c_pps a=OYTBATO8h6EMnG+Ds1NGug==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=BurPQXY8rhTUgOTzSGEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: 2uj7OV1uuqq7eeILh-QogCdZPPaWtTM9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324213192116600 Introduce basic plumbing for vfio-user behind a new --enable-vfio-user-client option. We introduce VFIOUserContainer in hw/vfio-user/container.c, which is a container type for the "IOMMU" type "vfio-iommu-user", and share some common container code from hw/vfio/container.c. Add hw/vfio-user/pci.c for instantiating VFIOUserPCIDevice objects, sharing some common code from hw/vfio/pci.c. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- MAINTAINERS | 2 + hw/vfio-user/container.h | 25 +++ hw/vfio/pci.h | 6 + include/hw/vfio/vfio-container-base.h | 1 + hw/vfio-user/container.c | 212 ++++++++++++++++++++++++++ hw/vfio-user/pci.c | 146 ++++++++++++++++++ hw/vfio/pci.c | 10 +- hw/meson.build | 1 + hw/vfio-user/meson.build | 9 ++ meson_options.txt | 2 + scripts/meson-buildoptions.sh | 4 + 11 files changed, 413 insertions(+), 5 deletions(-) create mode 100644 hw/vfio-user/container.h create mode 100644 hw/vfio-user/container.c create mode 100644 hw/vfio-user/pci.c create mode 100644 hw/vfio-user/meson.build diff --git a/MAINTAINERS b/MAINTAINERS index 71a7819448..c3d224e54c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4229,6 +4229,8 @@ M: John Levon M: Thanos Makatos S: Supported F: docs/devel/vfio-user.rst +F: hw/vfio-user/* +F: include/hw/vfio-user/* F: subprojects/libvfio-user =20 EBPF: diff --git a/hw/vfio-user/container.h b/hw/vfio-user/container.h new file mode 100644 index 0000000000..3cd3303e68 --- /dev/null +++ b/hw/vfio-user/container.h @@ -0,0 +1,25 @@ +/* + * vfio-user specific definitions. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_VFIO_USER_CONTAINER_H +#define HW_VFIO_USER_CONTAINER_H + +#include +#include + +#include "hw/vfio/vfio-container-base.h" + +/* MMU container sub-class for vfio-user. */ +typedef struct VFIOUserContainer { + VFIOContainerBase bcontainer; +} VFIOUserContainer; + +OBJECT_DECLARE_SIMPLE_TYPE(VFIOUserContainer, VFIO_IOMMU_USER); + +#endif /* HW_VFIO_USER_CONTAINER_H */ diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 7a03d24805..c5fc4aa500 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -215,6 +215,12 @@ uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_= t addr, int len); void vfio_pci_write_config(PCIDevice *pdev, uint32_t addr, uint32_t val, int len); =20 +void vfio_intx_eoi(VFIODevice *vbasedev); +Object *vfio_pci_get_object(VFIODevice *vbasedev); +int vfio_pci_save_config(VFIODevice *vbasedev, QEMUFile *f, Error **errp); +int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f); +void vfio_pci_put_device(VFIOPCIDevice *vdev); + uint64_t vfio_vga_read(void *opaque, hwaddr addr, unsigned size); void vfio_vga_write(void *opaque, hwaddr addr, uint64_t data, unsigned siz= e); =20 diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 359b483963..0d3f6a70be 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -109,6 +109,7 @@ vfio_container_get_page_size_mask(const VFIOContainerBa= se *bcontainer) #define TYPE_VFIO_IOMMU_LEGACY TYPE_VFIO_IOMMU "-legacy" #define TYPE_VFIO_IOMMU_SPAPR TYPE_VFIO_IOMMU "-spapr" #define TYPE_VFIO_IOMMU_IOMMUFD TYPE_VFIO_IOMMU "-iommufd" +#define TYPE_VFIO_IOMMU_USER TYPE_VFIO_IOMMU "-user" =20 OBJECT_DECLARE_TYPE(VFIOContainerBase, VFIOIOMMUClass, VFIO_IOMMU) =20 diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c new file mode 100644 index 0000000000..2892845b4f --- /dev/null +++ b/hw/vfio-user/container.c @@ -0,0 +1,212 @@ +/* + * Container for vfio-user IOMMU type: rather than communicating with the = kernel + * vfio driver, we communicate over a socket to a server using the vfio-us= er + * protocol. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include "qemu/osdep.h" + +#include "hw/vfio-user/container.h" +#include "hw/vfio/vfio-cpr.h" +#include "hw/vfio/vfio-device.h" +#include "hw/vfio/vfio-listener.h" +#include "qapi/error.h" +#include "trace.h" + +static int vfio_user_dma_unmap(const VFIOContainerBase *bcontainer, + hwaddr iova, ram_addr_t size, + IOMMUTLBEntry *iotlb, bool unmap_all) +{ + return -ENOTSUP; +} + +static int vfio_user_dma_map(const VFIOContainerBase *bcontainer, hwaddr i= ova, + ram_addr_t size, void *vaddr, bool readonly, + MemoryRegion *mrp) +{ + return -ENOTSUP; +} + +static int +vfio_user_set_dirty_page_tracking(const VFIOContainerBase *bcontainer, + bool start, Error **errp) +{ + error_setg_errno(errp, ENOTSUP, "Not supported"); + return -ENOTSUP; +} + +static int vfio_user_query_dirty_bitmap(const VFIOContainerBase *bcontaine= r, + VFIOBitmap *vbmap, hwaddr iova, + hwaddr size, Error **errp) +{ + error_setg_errno(errp, ENOTSUP, "Not supported"); + return -ENOTSUP; +} + +static bool vfio_user_setup(VFIOContainerBase *bcontainer, Error **errp) +{ + error_setg_errno(errp, ENOTSUP, "Not supported"); + return -ENOTSUP; +} + +static VFIOUserContainer *vfio_user_create_container(Error **errp) +{ + VFIOUserContainer *container; + + container =3D VFIO_IOMMU_USER(object_new(TYPE_VFIO_IOMMU_USER)); + return container; +} + +/* + * Try to mirror vfio_container_connect() as much as possible. + */ +static VFIOUserContainer * +vfio_user_container_connect(AddressSpace *as, Error **errp) +{ + VFIOContainerBase *bcontainer; + VFIOUserContainer *container; + VFIOAddressSpace *space; + VFIOIOMMUClass *vioc; + + space =3D vfio_address_space_get(as); + + container =3D vfio_user_create_container(errp); + if (!container) { + goto put_space_exit; + } + + bcontainer =3D &container->bcontainer; + + if (!vfio_cpr_register_container(bcontainer, errp)) { + goto free_container_exit; + } + + vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + assert(vioc->setup); + + if (!vioc->setup(bcontainer, errp)) { + goto unregister_container_exit; + } + + vfio_address_space_insert(space, bcontainer); + + if (!vfio_listener_register(bcontainer, errp)) { + goto listener_release_exit; + } + + bcontainer->initialized =3D true; + + return container; + +listener_release_exit: + vfio_listener_unregister(bcontainer); + if (vioc->release) { + vioc->release(bcontainer); + } + +unregister_container_exit: + vfio_cpr_unregister_container(bcontainer); + +free_container_exit: + object_unref(container); + +put_space_exit: + vfio_address_space_put(space); + + return NULL; +} + +static void vfio_user_container_disconnect(VFIOUserContainer *container) +{ + VFIOContainerBase *bcontainer =3D &container->bcontainer; + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + + vfio_listener_unregister(bcontainer); + if (vioc->release) { + vioc->release(bcontainer); + } + + VFIOAddressSpace *space =3D bcontainer->space; + + vfio_cpr_unregister_container(bcontainer); + object_unref(container); + + vfio_address_space_put(space); +} + +static bool vfio_user_device_get(VFIOUserContainer *container, + VFIODevice *vbasedev, Error **errp) +{ + struct vfio_device_info info =3D { 0 }; + + vbasedev->fd =3D -1; + + vfio_device_prepare(vbasedev, &container->bcontainer, &info); + + return true; +} + +/* + * vfio_user_device_attach: attach a device to a new container. + */ +static bool vfio_user_device_attach(const char *name, VFIODevice *vbasedev, + AddressSpace *as, Error **errp) +{ + VFIOUserContainer *container; + + container =3D vfio_user_container_connect(as, errp); + if (container =3D=3D NULL) { + error_prepend(errp, "failed to connect proxy"); + return false; + } + + return vfio_user_device_get(container, vbasedev, errp); +} + +static void vfio_user_device_detach(VFIODevice *vbasedev) +{ + VFIOUserContainer *container =3D container_of(vbasedev->bcontainer, + VFIOUserContainer, bcontai= ner); + + vfio_device_unprepare(vbasedev); + + vfio_user_container_disconnect(container); +} + +static int vfio_user_pci_hot_reset(VFIODevice *vbasedev, bool single) +{ + /* ->needs_reset is always false for vfio-user. */ + return 0; +} + +static void vfio_iommu_user_class_init(ObjectClass *klass, const void *dat= a) +{ + VFIOIOMMUClass *vioc =3D VFIO_IOMMU_CLASS(klass); + + vioc->setup =3D vfio_user_setup; + vioc->dma_map =3D vfio_user_dma_map; + vioc->dma_unmap =3D vfio_user_dma_unmap; + vioc->attach_device =3D vfio_user_device_attach; + vioc->detach_device =3D vfio_user_device_detach; + vioc->set_dirty_page_tracking =3D vfio_user_set_dirty_page_tracking; + vioc->query_dirty_bitmap =3D vfio_user_query_dirty_bitmap; + vioc->pci_hot_reset =3D vfio_user_pci_hot_reset; +}; + +static const TypeInfo types[] =3D { + { + .name =3D TYPE_VFIO_IOMMU_USER, + .parent =3D TYPE_VFIO_IOMMU, + .instance_size =3D sizeof(VFIOUserContainer), + .class_init =3D vfio_iommu_user_class_init, + }, +}; + +DEFINE_TYPES(types) diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c new file mode 100644 index 0000000000..0525becb33 --- /dev/null +++ b/hw/vfio-user/pci.c @@ -0,0 +1,146 @@ +/* + * vfio PCI device over a UNIX socket. + * + * Copyright =C2=A9 2018, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include "qemu/osdep.h" + +#include "hw/qdev-properties.h" +#include "hw/vfio/pci.h" + +#define TYPE_VFIO_USER_PCI "vfio-user-pci" +OBJECT_DECLARE_SIMPLE_TYPE(VFIOUserPCIDevice, VFIO_USER_PCI) + +struct VFIOUserPCIDevice { + VFIOPCIDevice device; + char *sock_name; +}; + +/* + * Emulated devices don't use host hot reset + */ +static void vfio_user_compute_needs_reset(VFIODevice *vbasedev) +{ + vbasedev->needs_reset =3D false; +} + +static VFIODeviceOps vfio_user_pci_ops =3D { + .vfio_compute_needs_reset =3D vfio_user_compute_needs_reset, + .vfio_eoi =3D vfio_intx_eoi, + .vfio_get_object =3D vfio_pci_get_object, + .vfio_save_config =3D vfio_pci_save_config, + .vfio_load_config =3D vfio_pci_load_config, +}; + +static void vfio_user_pci_realize(PCIDevice *pdev, Error **errp) +{ + ERRP_GUARD(); + VFIOUserPCIDevice *udev =3D VFIO_USER_PCI(pdev); + VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(pdev); + VFIODevice *vbasedev =3D &vdev->vbasedev; + AddressSpace *as; + + /* + * TODO: make option parser understand SocketAddress + * and use that instead of having scalar options + * for each socket type. + */ + if (!udev->sock_name) { + error_setg(errp, "No socket specified"); + error_append_hint(errp, "Use -device vfio-user-pci,socket=3D= \n"); + return; + } + + vbasedev->name =3D g_strdup_printf("VFIO user <%s>", udev->sock_name); + + /* + * vfio-user devices are effectively mdevs (don't use a host iommu). + */ + vbasedev->mdev =3D true; + + as =3D pci_device_iommu_address_space(pdev); + if (!vfio_device_attach_by_iommu_type(TYPE_VFIO_IOMMU_USER, + vbasedev->name, vbasedev, + as, errp)) { + error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name); + return; + } +} + +static void vfio_user_instance_init(Object *obj) +{ + PCIDevice *pci_dev =3D PCI_DEVICE(obj); + VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(obj); + VFIODevice *vbasedev =3D &vdev->vbasedev; + + device_add_bootindex_property(obj, &vdev->bootindex, + "bootindex", NULL, + &pci_dev->qdev); + vdev->host.domain =3D ~0U; + vdev->host.bus =3D ~0U; + vdev->host.slot =3D ~0U; + vdev->host.function =3D ~0U; + + vfio_device_init(vbasedev, VFIO_DEVICE_TYPE_PCI, &vfio_user_pci_ops, + DEVICE(vdev), false); + + vdev->nv_gpudirect_clique =3D 0xFF; + + /* + * QEMU_PCI_CAP_EXPRESS initialization does not depend on QEMU command + * line, therefore, no need to wait to realize like other devices. + */ + pci_dev->cap_present |=3D QEMU_PCI_CAP_EXPRESS; +} + +static void vfio_user_instance_finalize(Object *obj) +{ + VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(obj); + + vfio_pci_put_device(vdev); +} + +static const Property vfio_user_pci_dev_properties[] =3D { + DEFINE_PROP_UINT32("x-pci-vendor-id", VFIOPCIDevice, + vendor_id, PCI_ANY_ID), + DEFINE_PROP_UINT32("x-pci-device-id", VFIOPCIDevice, + device_id, PCI_ANY_ID), + DEFINE_PROP_UINT32("x-pci-sub-vendor-id", VFIOPCIDevice, + sub_vendor_id, PCI_ANY_ID), + DEFINE_PROP_UINT32("x-pci-sub-device-id", VFIOPCIDevice, + sub_device_id, PCI_ANY_ID), + DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name), +}; + +static void vfio_user_pci_dev_class_init(ObjectClass *klass, const void *d= ata) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *pdc =3D PCI_DEVICE_CLASS(klass); + + device_class_set_props(dc, vfio_user_pci_dev_properties); + dc->desc =3D "VFIO over socket PCI device assignment"; + pdc->realize =3D vfio_user_pci_realize; +} + +static const TypeInfo vfio_user_pci_dev_info =3D { + .name =3D TYPE_VFIO_USER_PCI, + .parent =3D TYPE_VFIO_PCI_BASE, + .instance_size =3D sizeof(VFIOUserPCIDevice), + .class_init =3D vfio_user_pci_dev_class_init, + .instance_init =3D vfio_user_instance_init, + .instance_finalize =3D vfio_user_instance_finalize, +}; + +static void register_vfio_user_dev_type(void) +{ + type_register_static(&vfio_user_pci_dev_info); +} + + type_init(register_vfio_user_dev_type) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 84daac5f2b..ef4095b3ad 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -103,7 +103,7 @@ static void vfio_intx_interrupt(void *opaque) } } =20 -static void vfio_intx_eoi(VFIODevice *vbasedev) +void vfio_intx_eoi(VFIODevice *vbasedev) { VFIOPCIDevice *vdev =3D container_of(vbasedev, VFIOPCIDevice, vbasedev= ); =20 @@ -2629,7 +2629,7 @@ static void vfio_pci_compute_needs_reset(VFIODevice *= vbasedev) } } =20 -static Object *vfio_pci_get_object(VFIODevice *vbasedev) +Object *vfio_pci_get_object(VFIODevice *vbasedev) { VFIOPCIDevice *vdev =3D container_of(vbasedev, VFIOPCIDevice, vbasedev= ); =20 @@ -2685,7 +2685,7 @@ static const VMStateDescription vmstate_vfio_pci_conf= ig =3D { } }; =20 -static int vfio_pci_save_config(VFIODevice *vbasedev, QEMUFile *f, Error *= *errp) +int vfio_pci_save_config(VFIODevice *vbasedev, QEMUFile *f, Error **errp) { VFIOPCIDevice *vdev =3D container_of(vbasedev, VFIOPCIDevice, vbasedev= ); =20 @@ -2693,7 +2693,7 @@ static int vfio_pci_save_config(VFIODevice *vbasedev,= QEMUFile *f, Error **errp) errp); } =20 -static int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f) +int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f) { VFIOPCIDevice *vdev =3D container_of(vbasedev, VFIOPCIDevice, vbasedev= ); PCIDevice *pdev =3D &vdev->pdev; @@ -2895,7 +2895,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) return true; } =20 -static void vfio_pci_put_device(VFIOPCIDevice *vdev) +void vfio_pci_put_device(VFIOPCIDevice *vdev) { vfio_display_finalize(vdev); vfio_bars_finalize(vdev); diff --git a/hw/meson.build b/hw/meson.build index b91f761fe0..791ce21ab4 100644 --- a/hw/meson.build +++ b/hw/meson.build @@ -39,6 +39,7 @@ subdir('uefi') subdir('ufs') subdir('usb') subdir('vfio') +subdir('vfio-user') subdir('virtio') subdir('vmapple') subdir('watchdog') diff --git a/hw/vfio-user/meson.build b/hw/vfio-user/meson.build new file mode 100644 index 0000000000..f1fee70c85 --- /dev/null +++ b/hw/vfio-user/meson.build @@ -0,0 +1,9 @@ +vfio_user_ss =3D ss.source_set() +vfio_user_ss.add(files( + 'container.c', + 'pci.c', +)) + +if get_option('vfio_user_client').enabled() + specific_ss.add_all(vfio_user_ss) +endif diff --git a/meson_options.txt b/meson_options.txt index a442be2995..97d3db44cd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -109,6 +109,8 @@ option('multiprocess', type: 'feature', value: 'auto', description: 'Out of process device emulation support') option('relocatable', type : 'boolean', value : true, description: 'toggle relocatable install') +option('vfio_user_client', type: 'feature', value: 'disabled', + description: 'vfio-user client support') option('vfio_user_server', type: 'feature', value: 'disabled', description: 'vfio-user server support') option('dbus_display', type: 'feature', value: 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index f09ef9604f..2c5673769a 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -201,6 +201,8 @@ meson_options_help() { printf "%s\n" ' vdi vdi image format support' printf "%s\n" ' vduse-blk-export' printf "%s\n" ' VDUSE block export support' + printf "%s\n" ' vfio-user-client' + printf "%s\n" ' vfio-user client support' printf "%s\n" ' vfio-user-server' printf "%s\n" ' vfio-user server support' printf "%s\n" ' vhdx vhdx image format support' @@ -529,6 +531,8 @@ _meson_option_parse() { --disable-vdi) printf "%s" -Dvdi=3Ddisabled ;; --enable-vduse-blk-export) printf "%s" -Dvduse_blk_export=3Denabled ;; --disable-vduse-blk-export) printf "%s" -Dvduse_blk_export=3Ddisabled = ;; + --enable-vfio-user-client) printf "%s" -Dvfio_user_client=3Denabled ;; + --disable-vfio-user-client) printf "%s" -Dvfio_user_client=3Ddisabled = ;; --enable-vfio-user-server) printf "%s" -Dvfio_user_server=3Denabled ;; --disable-vfio-user-server) printf "%s" -Dvfio_user_server=3Ddisabled = ;; --enable-vhdx) printf "%s" -Dvhdx=3Denabled ;; --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324087; cv=pass; d=zohomail.com; s=zohoarc; b=K4KVJhOZdEFcF+KQ//uiRsThSltqlBoyOhcY8kxz4qfdJP/6g8neKuuqAPaJFkVNdQ29tJ4w5Fsi88XmBb3etzPWp0/T0AC/VaMf5xsmnfKSWgwcZ3w5ghwaSOZzWfb2YjGQwWV5hwUDP+0PknWk01CsTorZoZ3jNHKsH0ltmT4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324087; 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=OmLi7Q79wS1SZfhbKLbxV0E3r3axuBtWF/BaQ0objAs=; b=BJHewsw7QlAWfQRnrF0b5TkHQzVzSMAvF7fsjVDxTmuqBuOejnDM5d6NFvnluu15z5mqAy/swpLChVEKaBwy4eLYS14SYanVL8iNpjUl7tMwn6k5gVJGA9IM2orCFzDEgr7Uq9vy5malYzbGnA1uL7J/SfFKDOwtX+8TJwauneg= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 174732408756036.58347914990941; Thu, 15 May 2025 08:48:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanT-0001eG-NM; Thu, 15 May 2025 11:46:59 -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 1uFam9-0007VL-Av for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:37 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalz-0006Rd-Ff for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:36 -0400 Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7nlpt026476; Thu, 15 May 2025 08:45:15 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010007.outbound.protection.outlook.com [40.93.11.7]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mjmtvrfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:14 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:44:46 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=OmLi7Q79wS1SZfhbKLbxV0E3r3axuBtWF/BaQ0obj As=; b=NFdkQHet1gGGveZmFMigh+ovqyVJ8BWlbiII/ryq32kpXDWp/1a56ebBw jtWQzAaXpsFQZE8p6RmfgoXzuwSdUIAICThenRBe7JRlyGIg6D32tLi8cnDWDKh+ piSlPXHok6ljtXP2j/klSkds1Fm0rs1n3JhjyyNsNLnjsE2LxBescrJuSU9AU/66 JtlLRQovVp8rVzxUmdCKTMAFGtzFMMxv+VR2W03/kNa+XjPigTukC8R84+2LNszK mpFRPmocg4QzKPJLjKlFxAoUnATNmUqxJun26casvxbhHb947Xqq9C1Yg1REubDZ yCiLrbpk+mbOXJUf7cz/gF5w8WR8Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HRw8jpWBrUCeuFxD/BOCSJ00hZwtMqnnHrFnFX96kVSkKatafd2NybnJORXo4rXfUC2dI4LUJnKE+7VdOC70SqLIp7kRNjMWW16bINa58B3BnDplyP3oLYLRCHGvslIhs6ChD3V+xBSFtefbtuCykpwTpU5Vhud965wXeSaioRUoOSdZmt3wPUY3otr6WTe3TPiRL5a8NsCbGhB0+efYEqZo0Etx73/bW4hy4FvhCnAax07IaA/DPoQ4sIw/GuZkCekQrcxXHc/9HBoXRJC4YWjBtv2XZhuKdLdLECvg6S5Pw1ojfW1GTHY/1k4fm+NoH9eHzNGY4MW2+lFta3gSvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OmLi7Q79wS1SZfhbKLbxV0E3r3axuBtWF/BaQ0objAs=; b=VrcqJ76WaDhKN//zSqjRD4pWR7XhKHiLY57uGWuMgUU4byNzHvPzmzrWxS+G29NfqhVoJAh17l1KxEOKhcbQRbL7wMnod4TX+eE7XtDG0XFu4xbvTYCnEDQvahTFh2CdeLvJuPgQcb4jr89lAI+2FygURHWV3STBXVp7RHaGcShMcnG2HyLJ8PEO2dLhmyfgKTJZVDV5iRsQZWtKKa/1aD1D+svmtz6//v+rCfLN/St9wJ73OuN240aJdeOVFanpgUK7y3MuL3i+i4x0MNa8/IvxZxHhA8jf1y17Rrya6lL74wuT4IsCF2ODQWOhky1IPY18iKh1ECZUUVVL2RWb+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OmLi7Q79wS1SZfhbKLbxV0E3r3axuBtWF/BaQ0objAs=; b=Ol51c9q0/Eu0iDnHH2XTifcWeOF46aXSmjmsUZP6DvnzhMGTch+yOkbC/RtlbkYaEa2WEks8bRZKzdoKZVluoYQtOqo4zSuGT1NF7gF2g/DOArQHES4keeP3hxEjKMSHEjAXT9u9+eTTExJH7C5tS0h1kfjOTbYkDg4zCBuZ1stwdEUr0YEl/QUgGeVEOWx30o8SG6H61FrbEOhpuKSKDOkOdI6aX8g+JeCm4A6pR/IiCdgKd+bXaLFyxptLP2tPYMW6m6T6H2s8lhMUEcyGEhzUmL7/hnje+izGV7+mKaB1F3hmAo9xuxUWk/439WpzRdjPqEcory0F1XK5ro2kJg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 11/27] vfio-user: connect vfio proxy to remote server Date: Thu, 15 May 2025 16:43:56 +0100 Message-ID: <20250515154413.210315-12-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: c364b451-9db3-4ede-8517-08dd93c76b0c x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RTRsZ3J0SXpWdWRxaVVyenQ4UjNGNTF5R0NHckJtWU15MkxiZGFxVnBNQmZH?= =?utf-8?B?bnM4c1V3WUlSK0VZUHlQaUpkekVHMGZkbnc4alBMWXQxQ1MyREV0cHAvTXJ5?= =?utf-8?B?VFYrNkFOTTJkUm9wN3htSS9OSFREM0kwd3Q0WTJOcy9HSmxiRnltUWRadjBs?= =?utf-8?B?M0RqWU5QaTMra3F0Tzk5NkxXWkdNK1pWd3hPc0Z3ck1BWXBucnlCWFM5aTBx?= =?utf-8?B?VmR2QTdKM3BvK0ZZeEtmMXVKRS9zVjU5bWR1cE5Md0oyeVIyM2Z3cmNpdGtQ?= =?utf-8?B?WVNoYTJwYzdISkVUU2VJMTE4UDgybFlBVjc1RjliK1habkZzVkg3dXowcFM4?= =?utf-8?B?dE1WMWh2L0o1OHhkbUFCcDJYTWU4ZEYycG95MWV5by9kVTlaVzFVbDFZOUNV?= =?utf-8?B?Q0dmOUl3NGlybXpSc3p2Z2NINElFY1NnclVZR0UrZmRBZU9lMGk4NUVkemxQ?= =?utf-8?B?dk1qOXc2b2tLaTk5aEwvY0g4WEIwNXlXOFZmNmZSeVlCUUlUTWR5czZlOVVX?= =?utf-8?B?bnI2M1VuS0x6bVdxZGhvZm5ENk1DTXNhcEl5NnlhWi9qQjZqTWdudS9PTk95?= =?utf-8?B?a1JEL0ZMK3ZaTmxXdGpZc1ZFUmtYcDJrbHE0dGo1bXh4RVBpNERLWDlRZ25o?= =?utf-8?B?RUswVUx3Q0xoOXV6RDNXWWpKZGU0V0M2M2FzSGI2dVhMQS96VU1ySzROMnpz?= =?utf-8?B?QjhweFhMUGt5YVV4QXd5MEJwUHhOVDhmT2NjRnE5VjVKUStGVU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Q0eTB6SkJueHpSNFF6cjViSU8zRFB0SUhZ?= =?utf-8?B?V0ZQQWQyWU9mSUt2ZVYwbmhaTGcxeG1XbkdjZXpmb2Q0RHpVb2ZkQVp6Y05j?= =?utf-8?B?anJmcEFpU2FLU01FTjNia0oyRU5vMi83MkxXd1F3TEx4Uk9RUDByVXB5R1J6?= =?utf-8?B?eWhRbEdFbXhnVU1zazYzbVd3Nm16K0o0SHJSOUV6U0JkK09PaFlrOWt2TUpi?= =?utf-8?B?MDdSQmk2a2lEUUtHQVJVdVFmWllkcURwd0l3UUpSUEN1aXE4ZHk4ekkwaHRy?= =?utf-8?Q?Md1cfIQAZbw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TmpCazZxa2FYZld3K01aUEQ3dEh4WmxPanFXNGZNK0daT2NPNHZnTmo2N1l6?= =?utf-8?B?cExnUzhyRDBtcVJMdGNkTUt5Nzh5aFEyWmh2RThPMjY0Q3pidkhEaWNSaWhr?= =?utf-8?B?a0EvbTIrRlZUWkFzNTdTSFl4Z21PNjd4aGJPTTlGaHY1SndwNGQzMjVpWUF6?= =?utf-8?B?MG5OdGhkQXlsK1M1YnlTQlZJSWYvKzd4T2F0RGhyajdwNHJWek9hWDRVbkds?= =?utf-8?B?VlBwMlFGNFlTcUwrOXRuU0RFK0Q1c1JDM2haMVY5UGtkNkxYdW8zS1FEQ3Jh?= =?utf-8?B?bTk0MVJMeUZWaTNLTXE5aGIzU2R5anpxTFdNWldmYVBmVm9PS2FOUnRFWEdU?= =?utf-8?B?SG1BYUdWcVRUVmdJTEYvVEFJTU5nQ3QyS2Q2WkQ0RnZ2M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-Network-Message-Id: c364b451-9db3-4ede-8517-08dd93c76b0c X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:46.1710 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cxLnGEfXoDeokMdqiNlI/aOQ1flzxWgQovErCdxbFLhYLQrCJQs71GDUmQWGB9v6/CFanDyoCi9ktgV+o7s+4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=TauWtQQh c=1 sm=1 tr=0 ts=68260c0b cx=c_pps a=kylQlKNaLH8A8Uw3zR316Q==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=vhHEnE-nI2wpHcbFAcgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: xKk5kh8_U5xbTubRh9sdd0FiMhnXAmwh X-Proofpoint-GUID: xKk5kh8_U5xbTubRh9sdd0FiMhnXAmwh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX/VKoUMEf8oyh 3REYnDMSwL9AoxuR/OQj0n/62f5GYa74rUZZKJaJSmor9WOb/nOoMYlS9MMTD6+LHvEiXMZYglq 4M7hq4hGr36u8bcyZ0HVToBlccjFTa4oQbbQ88Naly7KyRYf7+IpimuArCiB/RHfHcJvsrTF4ge MvP2ZltM6GhXvYU3K6n37WiPH+Jwhs0YlP9aPVnYkhsCyT+meQPxdOK9AELUHudHSbY1IRKa4O8 BDs7oAzqwoYccH9DIY4a6B6uUYl3deTPZsdISxO9x2ngbm/xrNyB6EFzY4wMAvNk4ro8iw4ZQ6b P+m4ALDPPIBi6J0YQXphKLZrQ3Munxjeh5Hvu1hN6D0e9JjKRb6Z7/UmUgGYoDoJXaj6vNS+prq TdbJK5bHodi10T70g1rnJi8EDbwor76Bjeo2CLHWIBKC7ynFGSCk+vfK7kCxOEVRJAwseo1I X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324089658116600 Introduce the vfio-user "proxy": this is the client code responsible for sending and receiving vfio-user messages across the control socket. The new files hw/vfio-user/proxy.[ch] contain some basic plumbing for managing the proxy; initialize the proxy during realization of the VFIOUserPCIDevice instance. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/proxy.h | 82 +++++++++++++++++ include/hw/vfio/vfio-device.h | 2 + hw/vfio-user/pci.c | 17 ++++ hw/vfio-user/proxy.c | 165 ++++++++++++++++++++++++++++++++++ hw/vfio-user/meson.build | 1 + 5 files changed, 267 insertions(+) create mode 100644 hw/vfio-user/proxy.h create mode 100644 hw/vfio-user/proxy.c diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h new file mode 100644 index 0000000000..60fe3e0b6d --- /dev/null +++ b/hw/vfio-user/proxy.h @@ -0,0 +1,82 @@ +#ifndef VFIO_USER_PROXY_H +#define VFIO_USER_PROXY_H + +/* + * vfio protocol over a UNIX socket. + * + * Copyright =C2=A9 2018, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "io/channel.h" +#include "io/channel-socket.h" + +typedef struct { + int send_fds; + int recv_fds; + int *fds; +} VFIOUserFDs; + +enum msg_type { + VFIO_MSG_NONE, + VFIO_MSG_ASYNC, + VFIO_MSG_WAIT, + VFIO_MSG_NOWAIT, + VFIO_MSG_REQ, +}; + +typedef struct VFIOUserMsg { + QTAILQ_ENTRY(VFIOUserMsg) next; + VFIOUserFDs *fds; + uint32_t rsize; + uint32_t id; + QemuCond cv; + bool complete; + enum msg_type type; +} VFIOUserMsg; + + +enum proxy_state { + VFIO_PROXY_CONNECTED =3D 1, + VFIO_PROXY_ERROR =3D 2, + VFIO_PROXY_CLOSING =3D 3, + VFIO_PROXY_CLOSED =3D 4, +}; + +typedef QTAILQ_HEAD(VFIOUserMsgQ, VFIOUserMsg) VFIOUserMsgQ; + +typedef struct VFIOUserProxy { + QLIST_ENTRY(VFIOUserProxy) next; + char *sockname; + struct QIOChannel *ioc; + void (*request)(void *opaque, VFIOUserMsg *msg); + void *req_arg; + int flags; + QemuCond close_cv; + AioContext *ctx; + QEMUBH *req_bh; + + /* + * above only changed when BQL is held + * below are protected by per-proxy lock + */ + QemuMutex lock; + VFIOUserMsgQ free; + VFIOUserMsgQ pending; + VFIOUserMsgQ incoming; + VFIOUserMsgQ outgoing; + VFIOUserMsg *last_nowait; + enum proxy_state state; +} VFIOUserProxy; + +/* VFIOProxy flags */ +#define VFIO_PROXY_CLIENT 0x1 + +VFIOUserProxy *vfio_user_connect_dev(SocketAddress *addr, Error **errp); +void vfio_user_disconnect(VFIOUserProxy *proxy); + +#endif /* VFIO_USER_PROXY_H */ diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h index a23ef4ea13..09f1a21bf8 100644 --- a/include/hw/vfio/vfio-device.h +++ b/include/hw/vfio/vfio-device.h @@ -46,6 +46,7 @@ typedef struct VFIOMigration VFIOMigration; =20 typedef struct IOMMUFDBackend IOMMUFDBackend; typedef struct VFIOIOASHwpt VFIOIOASHwpt; +typedef struct VFIOUserProxy VFIOUserProxy; =20 typedef struct VFIODevice { QLIST_ENTRY(VFIODevice) next; @@ -86,6 +87,7 @@ typedef struct VFIODevice { QLIST_ENTRY(VFIODevice) hwpt_next; struct vfio_region_info **reginfo; int *region_fds; + VFIOUserProxy *proxy; } VFIODevice; =20 struct VFIODeviceOps { diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 0525becb33..593104d15e 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -14,6 +14,7 @@ =20 #include "hw/qdev-properties.h" #include "hw/vfio/pci.h" +#include "hw/vfio-user/proxy.h" =20 #define TYPE_VFIO_USER_PCI "vfio-user-pci" OBJECT_DECLARE_SIMPLE_TYPE(VFIOUserPCIDevice, VFIO_USER_PCI) @@ -46,6 +47,8 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error = **errp) VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(pdev); VFIODevice *vbasedev =3D &vdev->vbasedev; AddressSpace *as; + SocketAddress addr; + VFIOUserProxy *proxy; =20 /* * TODO: make option parser understand SocketAddress @@ -58,6 +61,15 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error= **errp) return; } =20 + memset(&addr, 0, sizeof(addr)); + addr.type =3D SOCKET_ADDRESS_TYPE_UNIX; + addr.u.q_unix.path =3D udev->sock_name; + proxy =3D vfio_user_connect_dev(&addr, errp); + if (!proxy) { + return; + } + vbasedev->proxy =3D proxy; + vbasedev->name =3D g_strdup_printf("VFIO user <%s>", udev->sock_name); =20 /* @@ -103,8 +115,13 @@ static void vfio_user_instance_init(Object *obj) static void vfio_user_instance_finalize(Object *obj) { VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(obj); + VFIODevice *vbasedev =3D &vdev->vbasedev; =20 vfio_pci_put_device(vdev); + + if (vbasedev->proxy !=3D NULL) { + vfio_user_disconnect(vbasedev->proxy); + } } =20 static const Property vfio_user_pci_dev_properties[] =3D { diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c new file mode 100644 index 0000000000..ac481553ba --- /dev/null +++ b/hw/vfio-user/proxy.c @@ -0,0 +1,165 @@ +/* + * vfio protocol over a UNIX socket. + * + * Copyright =C2=A9 2018, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include + +#include "hw/vfio/vfio-device.h" +#include "hw/vfio-user/proxy.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/lockable.h" +#include "system/iothread.h" + +static IOThread *vfio_user_iothread; + +static void vfio_user_shutdown(VFIOUserProxy *proxy); + + +/* + * Functions called by main, CPU, or iothread threads + */ + +static void vfio_user_shutdown(VFIOUserProxy *proxy) +{ + qio_channel_shutdown(proxy->ioc, QIO_CHANNEL_SHUTDOWN_READ, NULL); + qio_channel_set_aio_fd_handler(proxy->ioc, proxy->ctx, NULL, + proxy->ctx, NULL, NULL); +} + +/* + * Functions only called by iothread + */ + +static void vfio_user_cb(void *opaque) +{ + VFIOUserProxy *proxy =3D opaque; + + QEMU_LOCK_GUARD(&proxy->lock); + + proxy->state =3D VFIO_PROXY_CLOSED; + qemu_cond_signal(&proxy->close_cv); +} + + +/* + * Functions called by main or CPU threads + */ + +static QLIST_HEAD(, VFIOUserProxy) vfio_user_sockets =3D + QLIST_HEAD_INITIALIZER(vfio_user_sockets); + +VFIOUserProxy *vfio_user_connect_dev(SocketAddress *addr, Error **errp) +{ + VFIOUserProxy *proxy; + QIOChannelSocket *sioc; + QIOChannel *ioc; + char *sockname; + + if (addr->type !=3D SOCKET_ADDRESS_TYPE_UNIX) { + error_setg(errp, "vfio_user_connect - bad address family"); + return NULL; + } + sockname =3D addr->u.q_unix.path; + + sioc =3D qio_channel_socket_new(); + ioc =3D QIO_CHANNEL(sioc); + if (qio_channel_socket_connect_sync(sioc, addr, errp)) { + object_unref(OBJECT(ioc)); + return NULL; + } + qio_channel_set_blocking(ioc, false, NULL); + + proxy =3D g_malloc0(sizeof(VFIOUserProxy)); + proxy->sockname =3D g_strdup_printf("unix:%s", sockname); + proxy->ioc =3D ioc; + proxy->flags =3D VFIO_PROXY_CLIENT; + proxy->state =3D VFIO_PROXY_CONNECTED; + + qemu_mutex_init(&proxy->lock); + qemu_cond_init(&proxy->close_cv); + + if (vfio_user_iothread =3D=3D NULL) { + vfio_user_iothread =3D iothread_create("VFIO user", errp); + } + + proxy->ctx =3D iothread_get_aio_context(vfio_user_iothread); + + QTAILQ_INIT(&proxy->outgoing); + QTAILQ_INIT(&proxy->incoming); + QTAILQ_INIT(&proxy->free); + QTAILQ_INIT(&proxy->pending); + QLIST_INSERT_HEAD(&vfio_user_sockets, proxy, next); + + return proxy; +} + +void vfio_user_disconnect(VFIOUserProxy *proxy) +{ + VFIOUserMsg *r1, *r2; + + qemu_mutex_lock(&proxy->lock); + + /* our side is quitting */ + if (proxy->state =3D=3D VFIO_PROXY_CONNECTED) { + vfio_user_shutdown(proxy); + if (!QTAILQ_EMPTY(&proxy->pending)) { + error_printf("vfio_user_disconnect: outstanding requests\n"); + } + } + object_unref(OBJECT(proxy->ioc)); + proxy->ioc =3D NULL; + + proxy->state =3D VFIO_PROXY_CLOSING; + QTAILQ_FOREACH_SAFE(r1, &proxy->outgoing, next, r2) { + qemu_cond_destroy(&r1->cv); + QTAILQ_REMOVE(&proxy->outgoing, r1, next); + g_free(r1); + } + QTAILQ_FOREACH_SAFE(r1, &proxy->incoming, next, r2) { + qemu_cond_destroy(&r1->cv); + QTAILQ_REMOVE(&proxy->incoming, r1, next); + g_free(r1); + } + QTAILQ_FOREACH_SAFE(r1, &proxy->pending, next, r2) { + qemu_cond_destroy(&r1->cv); + QTAILQ_REMOVE(&proxy->pending, r1, next); + g_free(r1); + } + QTAILQ_FOREACH_SAFE(r1, &proxy->free, next, r2) { + qemu_cond_destroy(&r1->cv); + QTAILQ_REMOVE(&proxy->free, r1, next); + g_free(r1); + } + + /* + * Make sure the iothread isn't blocking anywhere + * with a ref to this proxy by waiting for a BH + * handler to run after the proxy fd handlers were + * deleted above. + */ + aio_bh_schedule_oneshot(proxy->ctx, vfio_user_cb, proxy); + qemu_cond_wait(&proxy->close_cv, &proxy->lock); + + /* we now hold the only ref to proxy */ + qemu_mutex_unlock(&proxy->lock); + qemu_cond_destroy(&proxy->close_cv); + qemu_mutex_destroy(&proxy->lock); + + QLIST_REMOVE(proxy, next); + if (QLIST_EMPTY(&vfio_user_sockets)) { + iothread_destroy(vfio_user_iothread); + vfio_user_iothread =3D NULL; + } + + g_free(proxy->sockname); + g_free(proxy); +} diff --git a/hw/vfio-user/meson.build b/hw/vfio-user/meson.build index f1fee70c85..695b341547 100644 --- a/hw/vfio-user/meson.build +++ b/hw/vfio-user/meson.build @@ -2,6 +2,7 @@ vfio_user_ss =3D ss.source_set() vfio_user_ss.add(files( 'container.c', 'pci.c', + 'proxy.c', )) =20 if get_option('vfio_user_client').enabled() --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324443; cv=pass; d=zohomail.com; s=zohoarc; b=b7ptNYGsgvA8GB9aZKQ5rlXRdU69OTud/p2qRCXHOH1BRm6IlphTMimGkzh12Z0jUDmafMNqH0cL85dY0/Igxq3rOqjRaCln5LvCDoxZe9abAG+P/IiVLwN414dq/TrzP33572VJSfmMYs5ci5/ou77Jnwjq4Yw2Icg7d2Ct0c8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324443; 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=JsL49K9a6ej+cz0VI0i4HZ8MV1hh+/ssVQkPAgqReuo=; b=bFo+4Gw4pAXjoSnf7bz37pnrjHrgvRh6xXxF+LiCMC9A8HqKoXR19tV/NqJHXEsaMoD0ymse4PsNqKrlWbMs1U6XAGmDwbTQCtGNAhgFPFWQOUCyz57EaZzBmJF0f0VTwQDB1aAzGGvWQsro4cBvpeBkQnF8wBfFgvBtXOQEa7c= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324443574686.583267714577; Thu, 15 May 2025 08:54:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFamB-0007cv-5F; Thu, 15 May 2025 11:45:39 -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 1uFalX-0006Il-Ow for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:01 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalU-0006Dh-Jl for qemu-devel@nongnu.org; Thu, 15 May 2025 11:44:59 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7p8s2009723; Thu, 15 May 2025 08:44:52 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010005.outbound.protection.outlook.com [40.93.1.5]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcwwdy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:51 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:44:49 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=JsL49K9a6ej+cz0VI0i4HZ8MV1hh+/ssVQkPAgqRe uo=; b=YyPloKPscUMJMk4vX9k9wqiyf2no5DMrZTKvWNXpYoLBTShS3HuHEqQGY VjCYS2zWiZoE96MPOsXQX5pCIRlab5ok7Vfo4WzOjjEGLk3p4+SRrVOKqJw0LkqP RznwoMrlppg5Djzpg4XvILWZ/OTYlb2+WZGYbuBdekuIUxvlmMVuerYlTDVHEfTe 5G01kuxzK966EYJeZBixDH3vtg1ZoCofz8ZUS4onaOYinVRnKgvRzcDpnoWQ4G/a hLzRV+ej6tzgyueMyqCdJN+KVHFKtXaaIMVCktZOD/OVotJ5GgPcyyoIV4qFSf8g u1LSWbb3inKa5c9vyHAMCByizqiOA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BwBiq8JutPM64RAkNXeeSD6PgZ9zLbhNnNLR5ngJCHynk2PdJ4W80eN6YxLU9Q8LCB9xWK3PPwiI2Lu03ofG9DCoJSL0H1E2oGylveiYP6mk+JK8kpwfHaOVPEHtHmow8RA7y080KRmRZNV37SeKOlIe5VS7Cc3zrmCMI0XTo7TeXsNMCOybtbv7MqBJq9eE+DF9iM48VEkXKqcu5NXDiy4GBYlhUlRmlI0CA5LzaLUwM5O8w4d5nShm5lHKCYgxU0O5dM5ib4W2mB+8RC5mGksl1V4iBgyknylqSH4OS7B+GF2w7se+4VwpkCLY+b1bKoIHfhd721JzBIkX3TDCcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JsL49K9a6ej+cz0VI0i4HZ8MV1hh+/ssVQkPAgqReuo=; b=HGM9c9TyZtTh+QuCZzBHH/YYbguNV58Q1GNV0lS/T9m0pvW9kr/7i5G1tcZ/CCO+xbInZI6a8daMZbRy1qQdEQ/lk6cRLbdkcLNLnb57U9u8B8hLa8YvMQ52qv/gKrJlOZvsWvm3WgUXhqjyL+0mrjZms2O2360vYjHvn0Rv8HCiGQSRR7495fpgRvGJqhxe6lpkus8ePV/5i9K4dSgIlpdw8KUIUbmrxNuK1ldRk/Rg9Y1bS9bdyD/Vu0nWMdLR67YHMYY6n+WVIuipdBz/kmz6V/XuC1SxlzTj4RGRoPBhcFo4wb0TtqXUNw7LGC7gcnZsCmJmaPLbDloqNAmc+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JsL49K9a6ej+cz0VI0i4HZ8MV1hh+/ssVQkPAgqReuo=; b=dJUBXpZCsF+Hk7D0WzPUk4yhGRuvLVc0N9e03auyxuKWDPLp3rLgoNwVuDx7HUsX9Hij5/TDl5FjtgWqNQ3/Q7FZAWkojY21Rpz2BdTT2OTihJXyDBvARjhD2t/GbDRwNsdOTsTn9Z10QsxcQVM6s8ZD5UFhvey1IKcc5NzgSCqyGZpnIpg/4lrJxOHdBmSjgcktfxFXkC5i7nPRjdLKUlUH51KGIjSgDiSJ2zQ4qUTKSQYPd0xiqtNFc1NduQr44SPPZYeo7P7Y/WD/mkp4Sn4GRaFi1215zE2ePmrl8NhYEpeqS5y0lnZoMsPtWfXT0hsal1fAn0pbRVPP71SVjA== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 12/27] vfio-user: implement message receive infrastructure Date: Thu, 15 May 2025 16:43:57 +0100 Message-ID: <20250515154413.210315-13-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 58d86423-a5a5-4230-9313-08dd93c76c87 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?eDRHRzBMcGErOVFOWndzNGNlVnBIZ1Z4VmRJbEs0VDRCSTFCT2FnZlBhSkpw?= =?utf-8?B?M3dpSTgwUnhh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Zk1q?= =?utf-8?B?NjRpaTlhM2o4RmpqTEtxeDFOc29hbHdDRnVTSS9BaFJXY3c9PQ==?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RXUvelhSWElDNVBCb0pYSTh5Vmo0L0hIQkNaMTdiVGRhaG91ZG5FdWlpeFFa?= =?utf-8?B?Q0lRZnlScUpqYTEvbnkwNUhjZTZ1RC9FTmxrWldremIwek9HZUtKQnNzcTdQ?= =?utf-8?B?Y0NZdjRpcjN4em5EbEZ4WU9lMEVneWZpQStDTzN4bTRMYlVYdndyLzArWDMz?= =?utf-8?B?M1BCa2t1akx3MVdDSHR2MXRBOVpMMC9IVk5zUFhUNVJ3SHp6clZYODFxNzk1?= =?utf-8?B?NHMzQkFlUFBUWHB0VFFGUzYvbU94V28xajREMGpoNkpNd2JCczBEWElKbGp4?= =?utf-8?B?WFo4UEpwaDJYaXV6a2dnM0lHTGpYMDcxaGRTMXJIb1JNTzQ0TmF3dGxycEFp?= =?utf-8?B?S3UvMnY4dFRiVTJId3N4UmhOMW9ONVBxZURWVTJmaDBGeStRUmQvc1V5R2to?= =?utf-8?B?dDdqeVovTDBDakg1dFI5ckpVeEU0Y2libkVtV0RISHA0UGVFUGJjU2pldUU1?= =?utf-8?B?OVBsdHlDRU5KL3BMNTcvQkk1aDAzeVl0RktIWDkyRFdPRFBzRUlRRWhOaWtl?= =?utf-8?B?aksvNEdZSWVXODhIbmVuMkJGRSs5SkFEb0lBUkxxbnhIaWgxMTNvd3Y5clFR?= =?utf-8?B?UTQzclZhVk9UVzVSVFhVVnhTQWwvTUtCWWN5dmNZNlRobDY1RUxyeURYNmFq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VJQR1NJMldQYWpHMm5ZUDlr?= =?utf-8?B?ckdVR3cvc3Y3NFZKbmxiVW5GbS8wWXdTZWF2T1FnTFNEZGNjZnBzRmFBRTJv?= =?utf-8?B?R3A1eW54REF4eGsweUtvMnpYdnQyMUZHaXBEcHdwSE1jMU9YcmpRaGJnbUUx?= =?utf-8?B?UG5ZRTBaaG9Vc2pacWtFaDFCRUxvdFlSZThrODhUaENzN1hyOXdMZG9XY0U4?= =?utf-8?B?U282bU1ZWExSRjFFR05mcEl6ZGxoY0plQ1ZiTWNQQkdkQkw5cUVnRHE2b2cz?= =?utf-8?B?Vld3T3N2bHFJcjRzdHFwQUxBTEs2Y25YdmR6eTNTRXhhTVVQZDV6MWFNbG16?= =?utf-8?B?VDljZXJVcExtQ3NnRmpyTno2aWhsZVFCelJVU1JzUVUzcGhJK24zVWVxdFZS?= =?utf-8?B?ZEp3cjN2VzlxR2ExMWdxTWhBc0hwMW01WlRuV3NRS1dEbUFNbjVjdE1YRTg1?= =?utf-8?B?dkw1U0NvRVJWcnFoZVBZKzZMMUJ0b1Q0TzhObTZLM2FjTmJldkZ5VXRqUzBQ?= =?utf-8?B?N2VLS2pNaDMyZ25KZ2ZUQUlOaTcrTjFRa3A1UjVxOGhxNlEvTGhydyt6R1Nn?= =?utf-8?Q?9EdOFn0ytOEfdImoGqln8KtRF?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58d86423-a5a5-4230-9313-08dd93c76c87 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:48.8091 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: atjFNd0OeqIZCk6sFX6IzrAmCa7trx0Cc18S8GJFDPOaRwUd1OBkjn76Cd1d0DH+ZmL0I3tHk9sS39JBXGv5aQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-GUID: JrcDKCaMwBYGlHATCJnY0rjLPys8LuJ7 X-Authority-Analysis: v=2.4 cv=fNg53Yae c=1 sm=1 tr=0 ts=68260bf3 cx=c_pps a=94i1PXq8WVRBNmfdvHlv4w==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=vXCtUE0a-urccVGwgxAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: JrcDKCaMwBYGlHATCJnY0rjLPys8LuJ7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXzYgV8fH2yzUm fwhk8TmxHGvlmTMUpUgwX7Nvd82tWNV2f2yIxP2TZnwJITT6NliZnqVpcT7HFzmPVSzLuNs2O58 UQzNBJwhrquDGPqgXoxOwvW3Bd56At4us01NWivLOC/dYii7bXpbI2dTYF6gVmWbuVYnCvVhl1u bEpJHOXbNf0pNXP3Odr/jEQBkjnIVVxMntYvonLes8yGjQhuBMfYx9DVNHOvxj/s+fShV7sH0CX rtXj/4SHzU7FJUX8GreKWiM7n6dAb0V3pPdmHIUo5gohB7Gc2c+hNdghJj1FqXivCZO32u3oA7w sASmRmzxYftTHbQ+HVkP9bB7sgnpKtNTv32QCnW/jlSMyfzYypj9jCTvqfy3QJXXMPoEek9ysWM 5hq49XuHUQgdcQimNyEofJigisIH/A+kGA9kQ2nGB+32eAC7sLI9o0Ntl5ccRFxlwAWyScDV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324446219116600 Add the basic implementation for receiving vfio-user messages from the control socket. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- meson.build | 1 + hw/vfio-user/protocol.h | 56 ++++++ hw/vfio-user/proxy.h | 11 + hw/vfio-user/trace.h | 1 + hw/vfio-user/pci.c | 11 + hw/vfio-user/proxy.c | 409 ++++++++++++++++++++++++++++++++++++++ hw/vfio-user/trace-events | 6 + 7 files changed, 495 insertions(+) create mode 100644 hw/vfio-user/protocol.h create mode 100644 hw/vfio-user/trace.h create mode 100644 hw/vfio-user/trace-events diff --git a/meson.build b/meson.build index 7f91500bb7..1873f92313 100644 --- a/meson.build +++ b/meson.build @@ -3642,6 +3642,7 @@ if have_system 'hw/ufs', 'hw/usb', 'hw/vfio', + 'hw/vfio-user', 'hw/virtio', 'hw/vmapple', 'hw/watchdog', diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h new file mode 100644 index 0000000000..6300c681e7 --- /dev/null +++ b/hw/vfio-user/protocol.h @@ -0,0 +1,56 @@ +#ifndef VFIO_USER_PROTOCOL_H +#define VFIO_USER_PROTOCOL_H + +/* + * vfio protocol over a UNIX socket. + * + * Copyright =C2=A9 2018, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Each message has a standard header that describes the command + * being sent, which is almost always a VFIO ioctl(). + * + * The header may be followed by command-specific data, such as the + * region and offset info for read and write commands. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +typedef struct { + uint16_t id; + uint16_t command; + uint32_t size; + uint32_t flags; + uint32_t error_reply; +} VFIOUserHdr; + +/* VFIOUserHdr commands */ +enum vfio_user_command { + VFIO_USER_VERSION =3D 1, + VFIO_USER_DMA_MAP =3D 2, + VFIO_USER_DMA_UNMAP =3D 3, + VFIO_USER_DEVICE_GET_INFO =3D 4, + VFIO_USER_DEVICE_GET_REGION_INFO =3D 5, + VFIO_USER_DEVICE_GET_REGION_IO_FDS =3D 6, + VFIO_USER_DEVICE_GET_IRQ_INFO =3D 7, + VFIO_USER_DEVICE_SET_IRQS =3D 8, + VFIO_USER_REGION_READ =3D 9, + VFIO_USER_REGION_WRITE =3D 10, + VFIO_USER_DMA_READ =3D 11, + VFIO_USER_DMA_WRITE =3D 12, + VFIO_USER_DEVICE_RESET =3D 13, + VFIO_USER_DIRTY_PAGES =3D 14, + VFIO_USER_MAX, +}; + +/* VFIOUserHdr flags */ +#define VFIO_USER_REQUEST 0x0 +#define VFIO_USER_REPLY 0x1 +#define VFIO_USER_TYPE 0xF + +#define VFIO_USER_NO_REPLY 0x10 +#define VFIO_USER_ERROR 0x20 + +#endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 60fe3e0b6d..0105479d02 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -15,6 +15,9 @@ #include "io/channel.h" #include "io/channel-socket.h" =20 +#include "qemu/sockets.h" +#include "hw/vfio-user/protocol.h" + typedef struct { int send_fds; int recv_fds; @@ -31,6 +34,7 @@ enum msg_type { =20 typedef struct VFIOUserMsg { QTAILQ_ENTRY(VFIOUserMsg) next; + VFIOUserHdr *hdr; VFIOUserFDs *fds; uint32_t rsize; uint32_t id; @@ -70,13 +74,20 @@ typedef struct VFIOUserProxy { VFIOUserMsgQ incoming; VFIOUserMsgQ outgoing; VFIOUserMsg *last_nowait; + VFIOUserMsg *part_recv; + size_t recv_left; enum proxy_state state; } VFIOUserProxy; =20 /* VFIOProxy flags */ #define VFIO_PROXY_CLIENT 0x1 =20 +typedef struct VFIODevice VFIODevice; + VFIOUserProxy *vfio_user_connect_dev(SocketAddress *addr, Error **errp); void vfio_user_disconnect(VFIOUserProxy *proxy); +void vfio_user_set_handler(VFIODevice *vbasedev, + void (*handler)(void *opaque, VFIOUserMsg *msg), + void *reqarg); =20 #endif /* VFIO_USER_PROXY_H */ diff --git a/hw/vfio-user/trace.h b/hw/vfio-user/trace.h new file mode 100644 index 0000000000..574b59aa89 --- /dev/null +++ b/hw/vfio-user/trace.h @@ -0,0 +1 @@ +#include "trace/trace-hw_vfio_user.h" diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 593104d15e..53fbc218f3 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -24,6 +24,16 @@ struct VFIOUserPCIDevice { char *sock_name; }; =20 +/* + * Incoming request message callback. + * + * Runs off main loop, so BQL held. + */ +static void vfio_user_pci_process_req(void *opaque, VFIOUserMsg *msg) +{ + +} + /* * Emulated devices don't use host hot reset */ @@ -69,6 +79,7 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error = **errp) return; } vbasedev->proxy =3D proxy; + vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev); =20 vbasedev->name =3D g_strdup_printf("VFIO user <%s>", udev->sock_name); =20 diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index ac481553ba..4a654d7597 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -14,15 +14,32 @@ =20 #include "hw/vfio/vfio-device.h" #include "hw/vfio-user/proxy.h" +#include "hw/vfio-user/trace.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/lockable.h" +#include "qemu/main-loop.h" #include "system/iothread.h" =20 static IOThread *vfio_user_iothread; =20 static void vfio_user_shutdown(VFIOUserProxy *proxy); +static VFIOUserMsg *vfio_user_getmsg(VFIOUserProxy *proxy, VFIOUserHdr *hd= r, + VFIOUserFDs *fds); +static VFIOUserFDs *vfio_user_getfds(int numfds); +static void vfio_user_recycle(VFIOUserProxy *proxy, VFIOUserMsg *msg); =20 +static void vfio_user_recv(void *opaque); +static int vfio_user_recv_one(VFIOUserProxy *proxy); +static void vfio_user_cb(void *opaque); + +static void vfio_user_request(void *opaque); + +static inline void vfio_user_set_error(VFIOUserHdr *hdr, uint32_t err) +{ + hdr->flags |=3D VFIO_USER_ERROR; + hdr->error_reply =3D err; +} =20 /* * Functions called by main, CPU, or iothread threads @@ -35,10 +52,340 @@ static void vfio_user_shutdown(VFIOUserProxy *proxy) proxy->ctx, NULL, NULL); } =20 +static VFIOUserMsg *vfio_user_getmsg(VFIOUserProxy *proxy, VFIOUserHdr *hd= r, + VFIOUserFDs *fds) +{ + VFIOUserMsg *msg; + + msg =3D QTAILQ_FIRST(&proxy->free); + if (msg !=3D NULL) { + QTAILQ_REMOVE(&proxy->free, msg, next); + } else { + msg =3D g_malloc0(sizeof(*msg)); + qemu_cond_init(&msg->cv); + } + + msg->hdr =3D hdr; + msg->fds =3D fds; + return msg; +} + +/* + * Recycle a message list entry to the free list. + */ +static void vfio_user_recycle(VFIOUserProxy *proxy, VFIOUserMsg *msg) +{ + if (msg->type =3D=3D VFIO_MSG_NONE) { + error_printf("vfio_user_recycle - freeing free msg\n"); + return; + } + + /* free msg buffer if no one is waiting to consume the reply */ + if (msg->type =3D=3D VFIO_MSG_NOWAIT || msg->type =3D=3D VFIO_MSG_ASYN= C) { + g_free(msg->hdr); + if (msg->fds !=3D NULL) { + g_free(msg->fds); + } + } + + msg->type =3D VFIO_MSG_NONE; + msg->hdr =3D NULL; + msg->fds =3D NULL; + msg->complete =3D false; + QTAILQ_INSERT_HEAD(&proxy->free, msg, next); +} + +static VFIOUserFDs *vfio_user_getfds(int numfds) +{ + VFIOUserFDs *fds =3D g_malloc0(sizeof(*fds) + (numfds * sizeof(int))); + + fds->fds =3D (int *)((char *)fds + sizeof(*fds)); + + return fds; +} + /* * Functions only called by iothread */ =20 +/* + * Process a received message. + */ +static void vfio_user_process(VFIOUserProxy *proxy, VFIOUserMsg *msg, + bool isreply) +{ + + /* + * Replies signal a waiter, if none just check for errors + * and free the message buffer. + * + * Requests get queued for the BH. + */ + if (isreply) { + msg->complete =3D true; + if (msg->type =3D=3D VFIO_MSG_WAIT) { + qemu_cond_signal(&msg->cv); + } else { + if (msg->hdr->flags & VFIO_USER_ERROR) { + error_printf("vfio_user_process: error reply on async "); + error_printf("request command %x error %s\n", + msg->hdr->command, + strerror(msg->hdr->error_reply)); + } + /* youngest nowait msg has been ack'd */ + if (proxy->last_nowait =3D=3D msg) { + proxy->last_nowait =3D NULL; + } + vfio_user_recycle(proxy, msg); + } + } else { + QTAILQ_INSERT_TAIL(&proxy->incoming, msg, next); + qemu_bh_schedule(proxy->req_bh); + } +} + +/* + * Complete a partial message read + */ +static int vfio_user_complete(VFIOUserProxy *proxy, Error **errp) +{ + VFIOUserMsg *msg =3D proxy->part_recv; + size_t msgleft =3D proxy->recv_left; + bool isreply; + char *data; + int ret; + + data =3D (char *)msg->hdr + (msg->hdr->size - msgleft); + while (msgleft > 0) { + ret =3D qio_channel_read(proxy->ioc, data, msgleft, errp); + + /* error or would block */ + if (ret <=3D 0) { + /* try for rest on next iternation */ + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + proxy->recv_left =3D msgleft; + } + return ret; + } + trace_vfio_user_recv_read(msg->hdr->id, ret); + + msgleft -=3D ret; + data +=3D ret; + } + + /* + * Read complete message, process it. + */ + proxy->part_recv =3D NULL; + proxy->recv_left =3D 0; + isreply =3D (msg->hdr->flags & VFIO_USER_TYPE) =3D=3D VFIO_USER_REPLY; + vfio_user_process(proxy, msg, isreply); + + /* return positive value */ + return 1; +} + +static void vfio_user_recv(void *opaque) +{ + VFIOUserProxy *proxy =3D opaque; + + QEMU_LOCK_GUARD(&proxy->lock); + + if (proxy->state =3D=3D VFIO_PROXY_CONNECTED) { + while (vfio_user_recv_one(proxy) =3D=3D 0) { + ; + } + } +} + +/* + * Receive and process one incoming message. + * + * For replies, find matching outgoing request and wake any waiters. + * For requests, queue in incoming list and run request BH. + */ +static int vfio_user_recv_one(VFIOUserProxy *proxy) +{ + VFIOUserMsg *msg =3D NULL; + g_autofree int *fdp =3D NULL; + VFIOUserFDs *reqfds; + VFIOUserHdr hdr; + struct iovec iov =3D { + .iov_base =3D &hdr, + .iov_len =3D sizeof(hdr), + }; + bool isreply =3D false; + int i, ret; + size_t msgleft, numfds =3D 0; + char *data =3D NULL; + char *buf =3D NULL; + Error *local_err =3D NULL; + + /* + * Complete any partial reads + */ + if (proxy->part_recv !=3D NULL) { + ret =3D vfio_user_complete(proxy, &local_err); + + /* still not complete, try later */ + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + return ret; + } + + if (ret <=3D 0) { + goto fatal; + } + /* else fall into reading another msg */ + } + + /* + * Read header + */ + ret =3D qio_channel_readv_full(proxy->ioc, &iov, 1, &fdp, &numfds, 0, + &local_err); + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + return ret; + } + + /* read error or other side closed connection */ + if (ret <=3D 0) { + goto fatal; + } + + if (ret < sizeof(hdr)) { + error_setg(&local_err, "short read of header"); + goto fatal; + } + + /* + * Validate header + */ + if (hdr.size < sizeof(VFIOUserHdr)) { + error_setg(&local_err, "bad header size"); + goto fatal; + } + switch (hdr.flags & VFIO_USER_TYPE) { + case VFIO_USER_REQUEST: + isreply =3D false; + break; + case VFIO_USER_REPLY: + isreply =3D true; + break; + default: + error_setg(&local_err, "unknown message type"); + goto fatal; + } + trace_vfio_user_recv_hdr(proxy->sockname, hdr.id, hdr.command, hdr.siz= e, + hdr.flags); + + /* + * For replies, find the matching pending request. + * For requests, reap incoming FDs. + */ + if (isreply) { + QTAILQ_FOREACH(msg, &proxy->pending, next) { + if (hdr.id =3D=3D msg->id) { + break; + } + } + if (msg =3D=3D NULL) { + error_setg(&local_err, "unexpected reply"); + goto err; + } + QTAILQ_REMOVE(&proxy->pending, msg, next); + + /* + * Process any received FDs + */ + if (numfds !=3D 0) { + if (msg->fds =3D=3D NULL || msg->fds->recv_fds < numfds) { + error_setg(&local_err, "unexpected FDs"); + goto err; + } + msg->fds->recv_fds =3D numfds; + memcpy(msg->fds->fds, fdp, numfds * sizeof(int)); + } + } else { + if (numfds !=3D 0) { + reqfds =3D vfio_user_getfds(numfds); + memcpy(reqfds->fds, fdp, numfds * sizeof(int)); + } else { + reqfds =3D NULL; + } + } + + /* + * Put the whole message into a single buffer. + */ + if (isreply) { + if (hdr.size > msg->rsize) { + error_setg(&local_err, "reply larger than recv buffer"); + goto err; + } + *msg->hdr =3D hdr; + data =3D (char *)msg->hdr + sizeof(hdr); + } else { + buf =3D g_malloc0(hdr.size); + memcpy(buf, &hdr, sizeof(hdr)); + data =3D buf + sizeof(hdr); + msg =3D vfio_user_getmsg(proxy, (VFIOUserHdr *)buf, reqfds); + msg->type =3D VFIO_MSG_REQ; + } + + /* + * Read rest of message. + */ + msgleft =3D hdr.size - sizeof(hdr); + while (msgleft > 0) { + ret =3D qio_channel_read(proxy->ioc, data, msgleft, &local_err); + + /* prepare to complete read on next iternation */ + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + proxy->part_recv =3D msg; + proxy->recv_left =3D msgleft; + return ret; + } + + if (ret <=3D 0) { + goto fatal; + } + trace_vfio_user_recv_read(hdr.id, ret); + + msgleft -=3D ret; + data +=3D ret; + } + + vfio_user_process(proxy, msg, isreply); + return 0; + + /* + * fatal means the other side closed or we don't trust the stream + * err means this message is corrupt + */ +fatal: + vfio_user_shutdown(proxy); + proxy->state =3D VFIO_PROXY_ERROR; + + /* set error if server side closed */ + if (ret =3D=3D 0) { + error_setg(&local_err, "server closed socket"); + } + +err: + for (i =3D 0; i < numfds; i++) { + close(fdp[i]); + } + if (isreply && msg !=3D NULL) { + /* force an error to keep sending thread from hanging */ + vfio_user_set_error(msg->hdr, EINVAL); + msg->complete =3D true; + qemu_cond_signal(&msg->cv); + } + error_prepend(&local_err, "vfio_user_recv_one: "); + error_report_err(local_err); + return -1; +} + static void vfio_user_cb(void *opaque) { VFIOUserProxy *proxy =3D opaque; @@ -54,6 +401,53 @@ static void vfio_user_cb(void *opaque) * Functions called by main or CPU threads */ =20 +/* + * Process incoming requests. + * + * The bus-specific callback has the form: + * request(opaque, msg) + * where 'opaque' was specified in vfio_user_set_handler + * and 'msg' is the inbound message. + * + * The callback is responsible for disposing of the message buffer, + * usually by re-using it when calling vfio_send_reply or vfio_send_error, + * both of which free their message buffer when the reply is sent. + * + * If the callback uses a new buffer, it needs to free the old one. + */ +static void vfio_user_request(void *opaque) +{ + VFIOUserProxy *proxy =3D opaque; + VFIOUserMsgQ new, free; + VFIOUserMsg *msg, *m1; + + /* reap all incoming */ + QTAILQ_INIT(&new); + WITH_QEMU_LOCK_GUARD(&proxy->lock) { + QTAILQ_FOREACH_SAFE(msg, &proxy->incoming, next, m1) { + QTAILQ_REMOVE(&proxy->incoming, msg, next); + QTAILQ_INSERT_TAIL(&new, msg, next); + } + } + + /* process list */ + QTAILQ_INIT(&free); + QTAILQ_FOREACH_SAFE(msg, &new, next, m1) { + QTAILQ_REMOVE(&new, msg, next); + trace_vfio_user_recv_request(msg->hdr->command); + proxy->request(proxy->req_arg, msg); + QTAILQ_INSERT_HEAD(&free, msg, next); + } + + /* free list */ + WITH_QEMU_LOCK_GUARD(&proxy->lock) { + QTAILQ_FOREACH_SAFE(msg, &free, next, m1) { + vfio_user_recycle(proxy, msg); + } + } +} + + static QLIST_HEAD(, VFIOUserProxy) vfio_user_sockets =3D QLIST_HEAD_INITIALIZER(vfio_user_sockets); =20 @@ -92,6 +486,7 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *addr= , Error **errp) } =20 proxy->ctx =3D iothread_get_aio_context(vfio_user_iothread); + proxy->req_bh =3D qemu_bh_new(vfio_user_request, proxy); =20 QTAILQ_INIT(&proxy->outgoing); QTAILQ_INIT(&proxy->incoming); @@ -102,6 +497,18 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *ad= dr, Error **errp) return proxy; } =20 +void vfio_user_set_handler(VFIODevice *vbasedev, + void (*handler)(void *opaque, VFIOUserMsg *msg), + void *req_arg) +{ + VFIOUserProxy *proxy =3D vbasedev->proxy; + + proxy->request =3D handler; + proxy->req_arg =3D req_arg; + qio_channel_set_aio_fd_handler(proxy->ioc, proxy->ctx, + vfio_user_recv, NULL, NULL, proxy); +} + void vfio_user_disconnect(VFIOUserProxy *proxy) { VFIOUserMsg *r1, *r2; @@ -117,6 +524,8 @@ void vfio_user_disconnect(VFIOUserProxy *proxy) } object_unref(OBJECT(proxy->ioc)); proxy->ioc =3D NULL; + qemu_bh_delete(proxy->req_bh); + proxy->req_bh =3D NULL; =20 proxy->state =3D VFIO_PROXY_CLOSING; QTAILQ_FOREACH_SAFE(r1, &proxy->outgoing, next, r2) { diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events new file mode 100644 index 0000000000..89d6c11c4c --- /dev/null +++ b/hw/vfio-user/trace-events @@ -0,0 +1,6 @@ +# See docs/devel/tracing.rst for syntax documentation. + +# common.c +vfio_user_recv_hdr(const char *name, uint16_t id, uint16_t cmd, uint32_t s= ize, uint32_t flags) " (%s) id 0x%x cmd 0x%x size 0x%x flags 0x%x" +vfio_user_recv_read(uint16_t id, int read) " id 0x%x read 0x%x" +vfio_user_recv_request(uint16_t cmd) " command 0x%x" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324169; cv=pass; d=zohomail.com; s=zohoarc; b=TDhOl8utq2vwN+PVzTZX50sxLT4uFZ3AKSJqIGmJazdUKPoH1LlNo4yIyiXFDcRIeQHinA+Mi83rbNIHDspEreaLA2K9YNnp2gc+D7N3Y2A1OL3VRoko5IF8blivEIQM/WRIsODTwUCiKo1lEHQZ7neAH/+av7lW7k2T4FVywko= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324169; 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=SvrRLBoBv0l7V9QrW/Mozo4syme+X9WO96yGjCo48nM=; b=OhTj1mOMZPA7u/UMZsoQp1TfvRWKG1R6lFdBtbK7emQxUjV0EWfjNY+yjl3xQLSPKm44NW807siuqKLDHG8ujj5CMeMGOYYFLp1vKC06UUN3ZnBueIgnyaucMWKHIsniIyzimjjSZb1lHm1+4kmHi+Qk6c63cLS5VGjiGwCWlz8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324168921335.6817683239424; Thu, 15 May 2025 08:49:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFam8-0007MX-LZ; Thu, 15 May 2025 11:45:36 -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 1uFalZ-0006Ke-Jb for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:04 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalU-0006E7-SB for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:01 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FBPdHZ007971; Thu, 15 May 2025 08:44:55 -0700 Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012010.outbound.protection.outlook.com [40.93.14.10]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbd0we20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:54 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:44:51 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=SvrRLBoBv0l7V9QrW/Mozo4syme+X9WO96yGjCo48 nM=; b=Re3icmJdAksTTBBwvNPxnWkuYdJwM0SZ57G2bm1pQ6GYV0xgHpsVSx4zb 36XQAv59iFRQEfiOwxU8xTDqBZXemqlyi/qgFRNOQoytmus8Hg694rxO+XNpnC9M rl1HrK1bcLOc3KduMqGk9+F9JI754pJhU1t64HWyF44U0iXw3Qa/YA9JpVTSaUZ2 0tSQTrPoimZcWNLNLU9kOx4Tsfyu53WJSazPupG9/LcqT2pjd7IjMDAsLoG2sLv3 gxucCLcW0ZIgZN+kL91keJAPEx0MqAXGjyF0k66Byf9/JqhdLITPnfRNCPqsNW8v qN4zpPYq76aTrSqDNUYprIAJJvvew== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=unt7qa6OmggvDvA//VN08Z6Bu7IScGDAlq0yA8r1+X0imEJOtN2SNGYaTefzVLuI0+WTWc+T3xyCv8atGuHS4Ia1qsL4E1vKVmWhBfY+Zbk0kYFcALjqs5tjWFa7jT28aHq8CILZoJ/DeR2EdCoN1xyobErSOvM91Ve92avbXVrgVW4pITXuZPWAFQ5MIzYExhZCIntmGgwivglPvoEQt2b3giPTHFo4NtJX/kaCdW1tAZJgkilaJZIf29lWOWLmdy4/+/hCyCIPIhpirNF12G4YUoWboMnzLSYHPmyOsrNN0fRpWt/p68R4e+j6Qg1kR0peesa3x1fCWHOaac3DaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SvrRLBoBv0l7V9QrW/Mozo4syme+X9WO96yGjCo48nM=; b=JVEX6Y31Z+frkTC9R78fjYMmZFK9TM3HoHuzhvW2Ii0lonEgFAeipCwlP1qO5+TPVdm1HHEuYhJYdDCdt+N/lCWsOPnSZ/pM0JGAdkghhpM+s5CY2SlAhvY1RXrxG9G672hy8goluXgAtYSnmmCCY9u0CaH4thGnD/y1tmBlcTuxIBKJ0+FyYfK5fpJtY9dwyOhL7vsQeBjI/Oykv8PtQuYyA5ZDoH2vF5eVob9YjSu9xUKY7nzHCionK+7W59SV8zXsMH4OSqpFIuwkmXtfRhvYCg+x0OVClKNrqMa7c2Um6vPn3RW+sfwoBJja0oKNr4/cNlqOSL2WaY1J0PysZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SvrRLBoBv0l7V9QrW/Mozo4syme+X9WO96yGjCo48nM=; b=yHVuh21ARnorqXxD7BZAnKchwTJUh0la4gyCmvOj9elktY40S6TZy13VjvDKsLEwRmUJnWhMu37ABwpSEDEPwDilKwKwE+x0fbMp0bJMzNqK33B3fdgwP0Tnvbaxp1X6sSUSJsQ5LfEkuIqott7G8n60ygnwbLdfaFJYP+EHeDcx8NKX5fklwKwUah3uNE6kh2AriEOMKYuH8xyon2Q7TW2ARtuAl1LHaBA3T/o3CTNo5LasdYpnqCm1V5mP2znVAEVL8NpIt62w2WGVczTuBYZ8Tn0N5IzStGE5tJ8sTMKL+H9RvVFjjlUN/JzEKi4lGydLK3fovBYQ6M0a9cexUg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Jagannathan Raman , Elena Ufimtseva Subject: [PATCH 13/27] vfio-user: implement message send infrastructure Date: Thu, 15 May 2025 16:43:58 +0100 Message-ID: <20250515154413.210315-14-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: f7a65b94-7f87-413e-7f84-08dd93c76e27 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ZXIN2Ezh7z0QoCrU1JIxRDZUtvvjMw+AT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NPmG6kLvkoy4rPG9pltuKJFkw4jwD9MsoE/zpL9oZNFO1a6?= =?us-ascii?Q?zw0/oLZIkLYUBsYU3dHp9lHDbcpr9SpuPUO0DlcXGveL7xVBLBq7A1DOdn4X?= =?us-ascii?Q?pYOk72ZcGbORu++X1lgn30UN7xteXeMCpivYUrCmlJeD+xQug1egth2miUPV?= =?us-ascii?Q?0FjJpgggw/vyOBkwmwXuiLhrZoX9xk7HsSDvJWeQiF/9X12Qda0YNB0hxy2B?= =?us-ascii?Q?DCRz7VwByB5ZdovHxUKdwLUzRheaCfmmqYS3cfWqcQL6+GIdZgiO0Cz0rC2b?= =?us-ascii?Q?P60T4IbpBbL9UffxTqSYZYVL3UcY6HFfzafpMyfQLPb09XHWDJiO76EbbUtA?= =?us-ascii?Q?U+3ABHtuzzcpm+SAYalHqpGrZyrE35dNUjv9fcwD5sBe9ntjqzMCeFfaALWV?= =?us-ascii?Q?tMXhoj6SDv5JR+g12H0UHzSoJlqwU+8e0z7G8naYM/CZHsNglIWG3crK/RKU?= =?us-ascii?Q?/L5iVTb5olM8qYDVzsWoD0WYKM7Sv7q4IR9ovw4gjXmbAu5TXVP3Uce3HZAM?= =?us-ascii?Q?Df8H7aq2uAE=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?RXIrhKTcAmdHFujo5G2KmoUgjl89+ET0yybd2Cc8WhNLXuy686IEI8ebZ03f?= =?us-ascii?Q?N6GJOpc4GBOSMZbqLR9CObacIZyVqTaJxLRE8mYYaearYGhQ+aqb4EEO+jGQ?= =?us-ascii?Q?F1wgDd6OerJ7nvSxH97RkHG541TpVJkZYUbo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?Ak4WTXfzofWtFqKdKQLHEI76r9SCw46U5Hbf+N8KpHW+ktouikGsKxLX4C+r?= =?us-ascii?Q?NfdlpqDEY3DQKhp23Riq0q7WxAiw7AS8sfujcx3JuamfTRGlrtWI/kImCWP7?= =?us-ascii?Q?4pq+hUggV5ZdkGuomGZkfWCe/+dLBu2sfWphv1E0tkdHh80WykVElolKYZ/z?= =?us-ascii?Q?9paRweNsBX7TmBEo06vDCF8vBUTj8TXzgWAsBDAlSij/W6GGa49ROXGB4kBC?= =?us-ascii?Q?zxbRuM8FvutIjsX3AYj08iN33xmkgwgmAvpvXYqffO0GB73aX2RaDkrar4on?= =?us-ascii?Q?6Eh3ehCBHoOx/VRLCmilr73S52OvOStRP8y1FpJX+IK7CblRMnmJN8iv16yK?= =?us-ascii?Q?aHEBWLzyWlv7TqY0BF4w0LOIFOXl8lbGjI5+4Xlr2qZIkeC6cJv18QyQKVPF?= =?us-ascii?Q?mcufj6qVKuzxzYr7FXof1rU2vjVK89ASbVbiC0I/1tkVbqV/wVV1WsTLC0+6?= =?us-ascii?Q?FX8B6W8rkzPxyLyGFKxaKuckBplmiRCYcQPo3zfA2C6f6EXXoJHxP4CN2h5a?= =?us-ascii?Q?6/bvP2TC0Qw7Ekj+D5TZvD4IqQsIvSQIWSANuPxL?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7a65b94-7f87-413e-7f84-08dd93c76e27 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:51.4654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S0oXhECPhQiqSYxwL4wHsx6nc2Jhif7q/klD4bQnoIlzpYq52/tNzhQyv9G7u3bRx63aF+XBmfWyswIRpKhz8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-ORIG-GUID: TIOaWvPc9Gvg68N4_AEq23gMuBk9Fx2b X-Proofpoint-GUID: TIOaWvPc9Gvg68N4_AEq23gMuBk9Fx2b X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX56GEmQYUiR0e af2GShivaOhiqTCSaQ2L3GpN49bbMA/8AEbFbZ5j38oIGvwDApVxG/VUnNbjUzcITVvMuPR7nYJ EKGdz5LtK8hkDvgsQgBnGR066xZU1AX93n7CFP0Lj9XBHpjP/j9JElmns+BpuqPvObTIvhB3r/F xr58GQPGiWI34+NO5sWcAZqmqABUZUZJfJtlaKJI62O0B3Cbub3v+0JEDIC6uAhplt3cN+Go42R /+7Ijrmmj+MdjfafLPnpMUoQkjGqZcQ4/Bz242jPfjyw9JlUS4KKC/wGxGVOGLKJ26sPU1lISzB y2bQtu5hRi+8DDTC2Pwof/ExAl8vxIVyZfjUiP8wuGCZBsurDEY/8Me9gsuOFrxiT5y0ReFa1jl tXTMYhD8cZF4TlNadcNlN8mWZkUReSsToEFTiHfTbgif90igfx2077sdyKhmE3G6quFq7Zov X-Authority-Analysis: v=2.4 cv=KKlaDEFo c=1 sm=1 tr=0 ts=68260bf6 cx=c_pps a=5L1ZokDb34JZJib1CqSWiA==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=UnscCpd6-9sbi9RN3AUA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324170838116600 Content-Type: text/plain; charset="utf-8" Add plumbing for sending vfio-user messages on the control socket. Add initial version negotation on connection. Originally-by: John Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John Levon --- hw/vfio-user/protocol.h | 62 +++++ hw/vfio-user/proxy.h | 9 + hw/vfio-user/pci.c | 18 +- hw/vfio-user/proxy.c | 494 ++++++++++++++++++++++++++++++++++++++ hw/vfio-user/trace-events | 2 + 5 files changed, 583 insertions(+), 2 deletions(-) diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 6300c681e7..74ea2a94e6 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -53,4 +53,66 @@ enum vfio_user_command { #define VFIO_USER_NO_REPLY 0x10 #define VFIO_USER_ERROR 0x20 =20 + +/* + * VFIO_USER_VERSION + */ +typedef struct { + VFIOUserHdr hdr; + uint16_t major; + uint16_t minor; + char capabilities[]; +} VFIOUserVersion; + +#define VFIO_USER_MAJOR_VER 0 +#define VFIO_USER_MINOR_VER 0 + +#define VFIO_USER_CAP "capabilities" + +/* "capabilities" members */ +#define VFIO_USER_CAP_MAX_FDS "max_msg_fds" +#define VFIO_USER_CAP_MAX_XFER "max_data_xfer_size" +#define VFIO_USER_CAP_PGSIZES "pgsizes" +#define VFIO_USER_CAP_MAP_MAX "max_dma_maps" +#define VFIO_USER_CAP_MIGR "migration" + +/* "migration" members */ +#define VFIO_USER_CAP_PGSIZE "pgsize" +#define VFIO_USER_CAP_MAX_BITMAP "max_bitmap_size" + +/* + * Max FDs mainly comes into play when a device supports multiple interrup= ts + * where each ones uses an eventfd to inject it into the guest. + * It is clamped by the the number of FDs the qio channel supports in a + * single message. + */ +#define VFIO_USER_DEF_MAX_FDS 8 +#define VFIO_USER_MAX_MAX_FDS 16 + +/* + * Max transfer limits the amount of data in region and DMA messages. + * Region R/W will be very small (limited by how much a single instruction + * can process) so just use a reasonable limit here. + */ +#define VFIO_USER_DEF_MAX_XFER (1024 * 1024) +#define VFIO_USER_MAX_MAX_XFER (64 * 1024 * 1024) + +/* + * Default pagesizes supported is 4k. + */ +#define VFIO_USER_DEF_PGSIZE 4096 + +/* + * Default max number of DMA mappings is stolen from the + * linux kernel "dma_entry_limit" + */ +#define VFIO_USER_DEF_MAP_MAX 65535 + +/* + * Default max bitmap size is also take from the linux kernel, + * where usage of signed ints limits the VA range to 2^31 bytes. + * Dividing that by the number of bits per byte yields 256MB + */ +#define VFIO_USER_DEF_MAX_BITMAP (256 * 1024 * 1024) + #endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 0105479d02..33e8a4d83b 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -40,6 +40,7 @@ typedef struct VFIOUserMsg { uint32_t id; QemuCond cv; bool complete; + bool pending; enum msg_type type; } VFIOUserMsg; =20 @@ -59,6 +60,12 @@ typedef struct VFIOUserProxy { struct QIOChannel *ioc; void (*request)(void *opaque, VFIOUserMsg *msg); void *req_arg; + uint64_t max_xfer_size; + uint64_t max_send_fds; + uint64_t max_dma; + uint64_t dma_pgsizes; + uint64_t max_bitmap; + uint64_t migr_pgsize; int flags; QemuCond close_cv; AioContext *ctx; @@ -81,6 +88,7 @@ typedef struct VFIOUserProxy { =20 /* VFIOProxy flags */ #define VFIO_PROXY_CLIENT 0x1 +#define VFIO_PROXY_FORCE_QUEUED 0x4 =20 typedef struct VFIODevice VFIODevice; =20 @@ -89,5 +97,6 @@ void vfio_user_disconnect(VFIOUserProxy *proxy); void vfio_user_set_handler(VFIODevice *vbasedev, void (*handler)(void *opaque, VFIOUserMsg *msg), void *reqarg); +bool vfio_user_validate_version(VFIOUserProxy *proxy, Error **errp); =20 #endif /* VFIO_USER_PROXY_H */ diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 53fbc218f3..ee343023f3 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -22,6 +22,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VFIOUserPCIDevice, VFIO_USER_P= CI) struct VFIOUserPCIDevice { VFIOPCIDevice device; char *sock_name; + bool send_queued; /* all sends are queued */ }; =20 /* @@ -81,6 +82,14 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Error= **errp) vbasedev->proxy =3D proxy; vfio_user_set_handler(vbasedev, vfio_user_pci_process_req, vdev); =20 + if (udev->send_queued) { + proxy->flags |=3D VFIO_PROXY_FORCE_QUEUED; + } + + if (!vfio_user_validate_version(proxy, errp)) { + goto error; + } + vbasedev->name =3D g_strdup_printf("VFIO user <%s>", udev->sock_name); =20 /* @@ -92,9 +101,13 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Erro= r **errp) if (!vfio_device_attach_by_iommu_type(TYPE_VFIO_IOMMU_USER, vbasedev->name, vbasedev, as, errp)) { - error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name); - return; + goto error; } + + return; + +error: + error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } =20 static void vfio_user_instance_init(Object *obj) @@ -145,6 +158,7 @@ static const Property vfio_user_pci_dev_properties[] = =3D { DEFINE_PROP_UINT32("x-pci-sub-device-id", VFIOPCIDevice, sub_device_id, PCI_ANY_ID), DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name), + DEFINE_PROP_BOOL("x-send-queued", VFIOUserPCIDevice, send_queued, fals= e), }; =20 static void vfio_user_pci_dev_class_init(ObjectClass *klass, const void *d= ata) diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 4a654d7597..0bc12da865 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -16,14 +16,19 @@ #include "hw/vfio-user/proxy.h" #include "hw/vfio-user/trace.h" #include "qapi/error.h" +#include "qobject/qdict.h" +#include "qobject/qjson.h" +#include "qobject/qnum.h" #include "qemu/error-report.h" #include "qemu/lockable.h" #include "qemu/main-loop.h" #include "system/iothread.h" =20 +static int wait_time =3D 5000; /* wait up to 5 sec for busy servers */ static IOThread *vfio_user_iothread; =20 static void vfio_user_shutdown(VFIOUserProxy *proxy); +static int vfio_user_send_qio(VFIOUserProxy *proxy, VFIOUserMsg *msg); static VFIOUserMsg *vfio_user_getmsg(VFIOUserProxy *proxy, VFIOUserHdr *hd= r, VFIOUserFDs *fds); static VFIOUserFDs *vfio_user_getfds(int numfds); @@ -31,9 +36,16 @@ static void vfio_user_recycle(VFIOUserProxy *proxy, VFIO= UserMsg *msg); =20 static void vfio_user_recv(void *opaque); static int vfio_user_recv_one(VFIOUserProxy *proxy); +static void vfio_user_send(void *opaque); +static int vfio_user_send_one(VFIOUserProxy *proxy); static void vfio_user_cb(void *opaque); =20 static void vfio_user_request(void *opaque); +static int vfio_user_send_queued(VFIOUserProxy *proxy, VFIOUserMsg *msg); +static void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds, int rsize); +static void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, + uint32_t size, uint32_t flags); =20 static inline void vfio_user_set_error(VFIOUserHdr *hdr, uint32_t err) { @@ -52,6 +64,35 @@ static void vfio_user_shutdown(VFIOUserProxy *proxy) proxy->ctx, NULL, NULL); } =20 +static int vfio_user_send_qio(VFIOUserProxy *proxy, VFIOUserMsg *msg) +{ + VFIOUserFDs *fds =3D msg->fds; + struct iovec iov =3D { + .iov_base =3D msg->hdr, + .iov_len =3D msg->hdr->size, + }; + size_t numfds =3D 0; + int ret, *fdp =3D NULL; + Error *local_err =3D NULL; + + if (fds !=3D NULL && fds->send_fds !=3D 0) { + numfds =3D fds->send_fds; + fdp =3D fds->fds; + } + + ret =3D qio_channel_writev_full(proxy->ioc, &iov, 1, fdp, numfds, 0, + &local_err); + + if (ret =3D=3D -1) { + vfio_user_set_error(msg->hdr, EIO); + vfio_user_shutdown(proxy); + error_report_err(local_err); + } + trace_vfio_user_send_write(msg->hdr->id, ret); + + return ret; +} + static VFIOUserMsg *vfio_user_getmsg(VFIOUserProxy *proxy, VFIOUserHdr *hd= r, VFIOUserFDs *fds) { @@ -92,6 +133,7 @@ static void vfio_user_recycle(VFIOUserProxy *proxy, VFIO= UserMsg *msg) msg->hdr =3D NULL; msg->fds =3D NULL; msg->complete =3D false; + msg->pending =3D false; QTAILQ_INSERT_HEAD(&proxy->free, msg, next); } =20 @@ -386,6 +428,54 @@ err: return -1; } =20 +/* + * Send messages from outgoing queue when the socket buffer has space. + * If we deplete 'outgoing', remove ourselves from the poll list. + */ +static void vfio_user_send(void *opaque) +{ + VFIOUserProxy *proxy =3D opaque; + + QEMU_LOCK_GUARD(&proxy->lock); + + if (proxy->state =3D=3D VFIO_PROXY_CONNECTED) { + while (!QTAILQ_EMPTY(&proxy->outgoing)) { + if (vfio_user_send_one(proxy) < 0) { + return; + } + } + qio_channel_set_aio_fd_handler(proxy->ioc, proxy->ctx, + vfio_user_recv, NULL, NULL, proxy); + } +} + +/* + * Send a single message. + * + * Sent async messages are freed, others are moved to pending queue. + */ +static int vfio_user_send_one(VFIOUserProxy *proxy) +{ + VFIOUserMsg *msg; + int ret; + + msg =3D QTAILQ_FIRST(&proxy->outgoing); + ret =3D vfio_user_send_qio(proxy, msg); + if (ret < 0) { + return ret; + } + + QTAILQ_REMOVE(&proxy->outgoing, msg, next); + if (msg->type =3D=3D VFIO_MSG_ASYNC) { + vfio_user_recycle(proxy, msg); + } else { + QTAILQ_INSERT_TAIL(&proxy->pending, msg, next); + msg->pending =3D true; + } + + return 0; +} + static void vfio_user_cb(void *opaque) { VFIOUserProxy *proxy =3D opaque; @@ -447,6 +537,119 @@ static void vfio_user_request(void *opaque) } } =20 +/* + * Messages are queued onto the proxy's outgoing list. + * + * It handles 3 types of messages: + * + * async messages - replies and posted writes + * + * There will be no reply from the server, so message + * buffers are freed after they're sent. + * + * nowait messages - map/unmap during address space transactions + * + * These are also sent async, but a reply is expected so that + * vfio_wait_reqs() can wait for the youngest nowait request. + * They transition from the outgoing list to the pending list + * when sent, and are freed when the reply is received. + * + * wait messages - all other requests + * + * The reply to these messages is waited for by their caller. + * They also transition from outgoing to pending when sent, but + * the message buffer is returned to the caller with the reply + * contents. The caller is responsible for freeing these messages. + * + * As an optimization, if the outgoing list and the socket send + * buffer are empty, the message is sent inline instead of being + * added to the outgoing list. The rest of the transitions are + * unchanged. + * + * returns 0 if the message was sent or queued + * returns -1 on send error + */ +static int vfio_user_send_queued(VFIOUserProxy *proxy, VFIOUserMsg *msg) +{ + int ret; + + /* + * Unsent outgoing msgs - add to tail + */ + if (!QTAILQ_EMPTY(&proxy->outgoing)) { + QTAILQ_INSERT_TAIL(&proxy->outgoing, msg, next); + return 0; + } + + /* + * Try inline - if blocked, queue it and kick send poller + */ + if (proxy->flags & VFIO_PROXY_FORCE_QUEUED) { + ret =3D QIO_CHANNEL_ERR_BLOCK; + } else { + ret =3D vfio_user_send_qio(proxy, msg); + } + if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + QTAILQ_INSERT_HEAD(&proxy->outgoing, msg, next); + qio_channel_set_aio_fd_handler(proxy->ioc, proxy->ctx, + vfio_user_recv, proxy->ctx, + vfio_user_send, proxy); + return 0; + } + if (ret =3D=3D -1) { + return ret; + } + + /* + * Sent - free async, add others to pending + */ + if (msg->type =3D=3D VFIO_MSG_ASYNC) { + vfio_user_recycle(proxy, msg); + } else { + QTAILQ_INSERT_TAIL(&proxy->pending, msg, next); + msg->pending =3D true; + } + + return 0; +} + +static void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds, int rsize) +{ + VFIOUserMsg *msg; + int ret; + + if (hdr->flags & VFIO_USER_NO_REPLY) { + error_printf("vfio_user_send_wait on async message\n"); + vfio_user_set_error(hdr, EINVAL); + return; + } + + qemu_mutex_lock(&proxy->lock); + + msg =3D vfio_user_getmsg(proxy, hdr, fds); + msg->id =3D hdr->id; + msg->rsize =3D rsize ? rsize : hdr->size; + msg->type =3D VFIO_MSG_WAIT; + + ret =3D vfio_user_send_queued(proxy, msg); + + if (ret =3D=3D 0) { + while (!msg->complete) { + if (!qemu_cond_timedwait(&msg->cv, &proxy->lock, wait_time)) { + VFIOUserMsgQ *list; + + list =3D msg->pending ? &proxy->pending : &proxy->outgoing; + QTAILQ_REMOVE(list, msg, next); + vfio_user_set_error(hdr, ETIMEDOUT); + break; + } + } + } + vfio_user_recycle(proxy, msg); + + qemu_mutex_unlock(&proxy->lock); +} =20 static QLIST_HEAD(, VFIOUserProxy) vfio_user_sockets =3D QLIST_HEAD_INITIALIZER(vfio_user_sockets); @@ -475,6 +678,15 @@ VFIOUserProxy *vfio_user_connect_dev(SocketAddress *ad= dr, Error **errp) proxy =3D g_malloc0(sizeof(VFIOUserProxy)); proxy->sockname =3D g_strdup_printf("unix:%s", sockname); proxy->ioc =3D ioc; + + /* init defaults */ + proxy->max_xfer_size =3D VFIO_USER_DEF_MAX_XFER; + proxy->max_send_fds =3D VFIO_USER_DEF_MAX_FDS; + proxy->max_dma =3D VFIO_USER_DEF_MAP_MAX; + proxy->dma_pgsizes =3D VFIO_USER_DEF_PGSIZE; + proxy->max_bitmap =3D VFIO_USER_DEF_MAX_BITMAP; + proxy->migr_pgsize =3D VFIO_USER_DEF_PGSIZE; + proxy->flags =3D VFIO_PROXY_CLIENT; proxy->state =3D VFIO_PROXY_CONNECTED; =20 @@ -572,3 +784,285 @@ void vfio_user_disconnect(VFIOUserProxy *proxy) g_free(proxy->sockname); g_free(proxy); } + +static void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, + uint32_t size, uint32_t flags) +{ + static uint16_t next_id; + + hdr->id =3D qatomic_fetch_inc(&next_id); + hdr->command =3D cmd; + hdr->size =3D size; + hdr->flags =3D (flags & ~VFIO_USER_TYPE) | VFIO_USER_REQUEST; + hdr->error_reply =3D 0; +} + +struct cap_entry { + const char *name; + bool (*check)(VFIOUserProxy *proxy, QObject *qobj, Error **errp); +}; + +static bool caps_parse(VFIOUserProxy *proxy, QDict *qdict, + struct cap_entry caps[], Error **errp) +{ + QObject *qobj; + struct cap_entry *p; + + for (p =3D caps; p->name !=3D NULL; p++) { + qobj =3D qdict_get(qdict, p->name); + if (qobj !=3D NULL) { + if (!p->check(proxy, qobj, errp)) { + return false; + } + qdict_del(qdict, p->name); + } + } + + /* warning, for now */ + if (qdict_size(qdict) !=3D 0) { + warn_report("spurious capabilities"); + } + return true; +} + +static bool check_migr_pgsize(VFIOUserProxy *proxy, QObject *qobj, Error *= *errp) +{ + QNum *qn =3D qobject_to(QNum, qobj); + uint64_t pgsize; + + if (qn =3D=3D NULL || !qnum_get_try_uint(qn, &pgsize)) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_PGSIZE); + return false; + } + + /* must be larger than default */ + if (pgsize & (VFIO_USER_DEF_PGSIZE - 1)) { + error_setg(errp, "pgsize 0x%"PRIx64" too small", pgsize); + return false; + } + + proxy->migr_pgsize =3D pgsize; + return true; +} + +static bool check_bitmap(VFIOUserProxy *proxy, QObject *qobj, Error **errp) +{ + QNum *qn =3D qobject_to(QNum, qobj); + uint64_t bitmap_size; + + if (qn =3D=3D NULL || !qnum_get_try_uint(qn, &bitmap_size)) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_MAX_BITMAP); + return false; + } + + /* can only lower it */ + if (bitmap_size > VFIO_USER_DEF_MAX_BITMAP) { + error_setg(errp, "%s too large", VFIO_USER_CAP_MAX_BITMAP); + return false; + } + + proxy->max_bitmap =3D bitmap_size; + return true; +} + +static struct cap_entry caps_migr[] =3D { + { VFIO_USER_CAP_PGSIZE, check_migr_pgsize }, + { VFIO_USER_CAP_MAX_BITMAP, check_bitmap }, + { NULL } +}; + +static bool check_max_fds(VFIOUserProxy *proxy, QObject *qobj, Error **err= p) +{ + QNum *qn =3D qobject_to(QNum, qobj); + uint64_t max_send_fds; + + if (qn =3D=3D NULL || !qnum_get_try_uint(qn, &max_send_fds) || + max_send_fds > VFIO_USER_MAX_MAX_FDS) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_MAX_FDS); + return false; + } + proxy->max_send_fds =3D max_send_fds; + return true; +} + +static bool check_max_xfer(VFIOUserProxy *proxy, QObject *qobj, Error **er= rp) +{ + QNum *qn =3D qobject_to(QNum, qobj); + uint64_t max_xfer_size; + + if (qn =3D=3D NULL || !qnum_get_try_uint(qn, &max_xfer_size) || + max_xfer_size > VFIO_USER_MAX_MAX_XFER) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_MAX_XFER); + return false; + } + proxy->max_xfer_size =3D max_xfer_size; + return true; +} + +static bool check_pgsizes(VFIOUserProxy *proxy, QObject *qobj, Error **err= p) +{ + QNum *qn =3D qobject_to(QNum, qobj); + uint64_t pgsizes; + + if (qn =3D=3D NULL || !qnum_get_try_uint(qn, &pgsizes)) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_PGSIZES); + return false; + } + + /* must be larger than default */ + if (pgsizes & (VFIO_USER_DEF_PGSIZE - 1)) { + error_setg(errp, "pgsize 0x%"PRIx64" too small", pgsizes); + return false; + } + + proxy->dma_pgsizes =3D pgsizes; + return true; +} + +static bool check_max_dma(VFIOUserProxy *proxy, QObject *qobj, Error **err= p) +{ + QNum *qn =3D qobject_to(QNum, qobj); + uint64_t max_dma; + + if (qn =3D=3D NULL || !qnum_get_try_uint(qn, &max_dma)) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_MAP_MAX); + return false; + } + + /* can only lower it */ + if (max_dma > VFIO_USER_DEF_MAP_MAX) { + error_setg(errp, "%s too large", VFIO_USER_CAP_MAP_MAX); + return false; + } + + proxy->max_dma =3D max_dma; + return true; +} + +static bool check_migr(VFIOUserProxy *proxy, QObject *qobj, Error **errp) +{ + QDict *qdict =3D qobject_to(QDict, qobj); + + if (qdict =3D=3D NULL) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_MAX_FDS); + return true; + } + return caps_parse(proxy, qdict, caps_migr, errp); +} + +static struct cap_entry caps_cap[] =3D { + { VFIO_USER_CAP_MAX_FDS, check_max_fds }, + { VFIO_USER_CAP_MAX_XFER, check_max_xfer }, + { VFIO_USER_CAP_PGSIZES, check_pgsizes }, + { VFIO_USER_CAP_MAP_MAX, check_max_dma }, + { VFIO_USER_CAP_MIGR, check_migr }, + { NULL } +}; + +static bool check_cap(VFIOUserProxy *proxy, QObject *qobj, Error **errp) +{ + QDict *qdict =3D qobject_to(QDict, qobj); + + if (qdict =3D=3D NULL) { + error_setg(errp, "malformed %s", VFIO_USER_CAP); + return false; + } + return caps_parse(proxy, qdict, caps_cap, errp); +} + +static struct cap_entry ver_0_0[] =3D { + { VFIO_USER_CAP, check_cap }, + { NULL } +}; + +static bool caps_check(VFIOUserProxy *proxy, int minor, const char *caps, + Error **errp) +{ + QObject *qobj; + QDict *qdict; + bool ret; + + qobj =3D qobject_from_json(caps, NULL); + if (qobj =3D=3D NULL) { + error_setg(errp, "malformed capabilities %s", caps); + return false; + } + qdict =3D qobject_to(QDict, qobj); + if (qdict =3D=3D NULL) { + error_setg(errp, "capabilities %s not an object", caps); + qobject_unref(qobj); + return false; + } + ret =3D caps_parse(proxy, qdict, ver_0_0, errp); + + qobject_unref(qobj); + return ret; +} + +static GString *caps_json(void) +{ + QDict *dict =3D qdict_new(); + QDict *capdict =3D qdict_new(); + QDict *migdict =3D qdict_new(); + GString *str; + + qdict_put_int(migdict, VFIO_USER_CAP_PGSIZE, VFIO_USER_DEF_PGSIZE); + qdict_put_int(migdict, VFIO_USER_CAP_MAX_BITMAP, VFIO_USER_DEF_MAX_BIT= MAP); + qdict_put_obj(capdict, VFIO_USER_CAP_MIGR, QOBJECT(migdict)); + + qdict_put_int(capdict, VFIO_USER_CAP_MAX_FDS, VFIO_USER_MAX_MAX_FDS); + qdict_put_int(capdict, VFIO_USER_CAP_MAX_XFER, VFIO_USER_DEF_MAX_XFER); + qdict_put_int(capdict, VFIO_USER_CAP_PGSIZES, VFIO_USER_DEF_PGSIZE); + qdict_put_int(capdict, VFIO_USER_CAP_MAP_MAX, VFIO_USER_DEF_MAP_MAX); + + qdict_put_obj(dict, VFIO_USER_CAP, QOBJECT(capdict)); + + str =3D qobject_to_json(QOBJECT(dict)); + qobject_unref(dict); + return str; +} + +bool vfio_user_validate_version(VFIOUserProxy *proxy, Error **errp) +{ + g_autofree VFIOUserVersion *msgp =3D NULL; + GString *caps; + char *reply; + int size, caplen; + + caps =3D caps_json(); + caplen =3D caps->len + 1; + size =3D sizeof(*msgp) + caplen; + msgp =3D g_malloc0(size); + + vfio_user_request_msg(&msgp->hdr, VFIO_USER_VERSION, size, 0); + msgp->major =3D VFIO_USER_MAJOR_VER; + msgp->minor =3D VFIO_USER_MINOR_VER; + memcpy(&msgp->capabilities, caps->str, caplen); + g_string_free(caps, true); + trace_vfio_user_version(msgp->major, msgp->minor, msgp->capabilities); + + vfio_user_send_wait(proxy, &msgp->hdr, NULL, 0); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + error_setg_errno(errp, msgp->hdr.error_reply, "version reply"); + return false; + } + + if (msgp->major !=3D VFIO_USER_MAJOR_VER || + msgp->minor > VFIO_USER_MINOR_VER) { + error_setg(errp, "incompatible server version"); + return false; + } + + reply =3D msgp->capabilities; + if (reply[msgp->hdr.size - sizeof(*msgp) - 1] !=3D '\0') { + error_setg(errp, "corrupt version reply"); + return false; + } + + if (!caps_check(proxy, msgp->minor, reply, errp)) { + return false; + } + + trace_vfio_user_version(msgp->major, msgp->minor, msgp->capabilities); + return true; +} diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 89d6c11c4c..7a3645024f 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -4,3 +4,5 @@ vfio_user_recv_hdr(const char *name, uint16_t id, uint16_t cmd, uint32_t s= ize, uint32_t flags) " (%s) id 0x%x cmd 0x%x size 0x%x flags 0x%x" vfio_user_recv_read(uint16_t id, int read) " id 0x%x read 0x%x" vfio_user_recv_request(uint16_t cmd) " command 0x%x" +vfio_user_send_write(uint16_t id, int wrote) " id 0x%x wrote 0x%x" +vfio_user_version(uint16_t major, uint16_t minor, const char *caps) " majo= r %d minor %d caps: %s" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324176; cv=pass; d=zohomail.com; s=zohoarc; b=F6XtMcyuO3hnLuu8291nJlJ8cNFItVfKj/RvdYqdYXsRxL/j46RZzSQ1WC9W5kPD3GeohKBK0SSdQa4nCRF3WYNWYpNob/r/8BF4wY8p1FTcVg+oEtKjk2hyb/C3wmd6LLrwxKey3X8zhN+Va857a57brotgRLzIEsb/5x1Hu4A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324176; 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=UH6f2tmI7ATg3KzwM9TyWxj1523guBD6/z5O7cFLNGY=; b=IbO1izoAmwh/ezwJ9Kjc8rSNQKW35w4hNziL2p5lM6ymCNYJ0VwlXWYR/boqu+iAL6IwmEtZjqKV+Z4W+JXvYOyi4KEyvUUlvhIz91U9CLM7CJI0WaPvfZTNWP7fTkkxJJi1svWAzKlRboERoZhTSNigg0p0/oLEG53Cwvli/UQ= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324176536740.1924070392868; Thu, 15 May 2025 08:49:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFan9-0000r8-RI; Thu, 15 May 2025 11:46: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 1uFala-0006OB-8E for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:04 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalV-0006ED-CM for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:01 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FBPdHa007971; Thu, 15 May 2025 08:44:55 -0700 Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012010.outbound.protection.outlook.com [40.93.14.10]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbd0we20-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:55 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:44:54 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=UH6f2tmI7ATg3KzwM9TyWxj1523guBD6/z5O7cFLN GY=; b=zeBLZ6kWVNx0dBoJSTKY6ofThymmBqD/X8j9ELnN6mb39LhxCzYXY707R V6xQvku4kIdrSmI7bcTWtD61ZH8mwpFmtE7FaZl6NepoBmgfGoDd17J4rf7vxZU6 qMs92XyWzpit0g60QsJ7t3r17sT8dZ5NERy6vPFM5g8YVKcR9oMs1e9JvTT5KTZc OCEg85dzgOqXJ1QjFX1GNiYC16l8fwtKU6ThyPWP2lRXLaEP4ki0IRh9SQd4MMyx Dg9o7Yc7bZAMCYjrG445sj2zqjnkhvJ8uUO6FKExb2gO6Aavy3GB/czVw+TSyUR9 6kjYZT5gL9CYDNbq+xiSvwZnw823g== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IZjK907shxxp3m1vGXdCDSFRXey+OYOw3lhvLm8qKJOiJ3ERWzaSeIufw2bjJ0jZ+Ez0sl0MResxXuKINr2sfzo7BSsPNCoodc9+1or0DxR0mXyWoYE05kNidPoR4XVgcxHTHsssXe2suqJyfO7uH1DJklGd6CmNaQTBtfnqnzXZGXXcdRK+NhseFxw4y0bmOy/xiNqO2xOmhyiQkBzo/N4JCDyUKzr+fAdI7zw9Qobijnmzn+s4TEosK0OZ4Pu6y99+6fFxcyuPw+1aX6mbhgdlK1dfaxpZ0oUoM/mncKxD0eFPGbwBIIm94LMVepS/8IYPgrV+vpouGE81Xqg24g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UH6f2tmI7ATg3KzwM9TyWxj1523guBD6/z5O7cFLNGY=; b=zEunaJpHOvEX2mSf1vS0iUk8M8fGzCVY+okWDtDkHPDN51LegiDnRQRPMCEVYo4WNccGKgZfAuRaa9FlaBM3474/QEsTy4DibmYaQ06UZRssgtzOTwH1080ozPaqoAT67Jl23Vko+7qCk17BULtTL8OR4R1A7n8ZvhjdGXMLN+21VH68lsi+8S58iJOP9a47Rhu54FroW5eOHjRvg6JRPcakb1WayClaTL8B3lKxRdrV4A9uZ57ARg9BVhhA7gNDZosqw1apbUKz8ZeZN4kJz6GDUPCNljIuRR+i3+JuqTxVZsp9tlO7m6wQLtbpL0kEDDikv5F5D7wPMRm5adorEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UH6f2tmI7ATg3KzwM9TyWxj1523guBD6/z5O7cFLNGY=; b=U13TxZmGYdKswzqva+0Aop9x06K1ANJFTDf0KN2porqQzO+cqKb+w8d9Kss9C5rE5AL8fa6KPPfOcPVnmKnRvwXLTRgfOOSN/TYnrdjwm8NJNmv3Qrcouba+eVmTe0B+GI/9CsY0LwTzdTGco5ODV9Tt+cBsXZjDfB58iaXOOFu2VmvOY03zDS6Ab/mW7RE4A0Xjn7a45LbpEj7iuyPxIVJbwXoV75y2McKzWCRmgeVnX8QYPZ2jOtej0Hd2DZiqekw/DbMlrJ6sNgE1cnidyeq8k0Q+EUg9YeTz7AenYmPDk7SnMcqHs3KRfAZ5CUXn4H8spBrZ0TAZ1ysxMtMc+Q== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 14/27] vfio-user: implement VFIO_USER_DEVICE_GET_INFO Date: Thu, 15 May 2025 16:43:59 +0100 Message-ID: <20250515154413.210315-15-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 68fc8fb0-df49-4fc1-af1e-08dd93c76fb0 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aFJYWXQxanIwYVJHVHZuVXVCbUZMM0kzeGc5WjFtdCtOdlJDUkhkRFN6UEsy?= =?utf-8?B?RFZ4UnRSVjEyVThpeklnOGpXbEU1a01WZGMvcXU2OVFEdmo0Sms4bTF4c3Ez?= =?utf-8?B?TnZzTkhaM2J3R2t2bzEyY0tPV25pQ2Jwd3lMeTZkN3RrYmo2RHBJRk1YRyt6?= =?utf-8?B?blVlblVWeU11OWdEQ2o2aXY0cTg1elNxUE54UnFLNEQ1K2NFYWpCc3RmTXo4?= =?utf-8?B?a0dFdzZSR0dwai9vQlVqUW5wb2FGMmo4WDdSNGRnWGdoTHR6UkczQWVXa1cv?= =?utf-8?B?cThXd05yRkExU3gxcUNoUDF3YjhOaXVNc2RHdG9lR2RWL2FaWXo1Sit4YmJC?= =?utf-8?B?WC83dVB4V1ZwbEpLNHVwUHVBNVZUVkZwUVE4ZzF6dXU2bnBFZkdqVmxTZ3NV?= =?utf-8?B?ZmxoRFhOOVkyQWJRYm02UklWQkhuNjRONkRxZEJBNEJ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MFk5a2dKRXZ5M0h6NUQzc0xIckUxM0RB?= =?utf-8?B?S1pTRVZqWGJpSkFlY0dBY1NIejUwUkJkRDRRWHRqR3J2REd6UjlQMkFSU3I3?= =?utf-8?B?RVU1Uk9zMVJWaFJmR0NYSTFNa2FtVENHRGx0YmJtVlB3eU4ya2FUanIwOG1s?= =?utf-8?B?S1B0OEVOaHd5TU9kT1FzN2d5RTZnOFBmNzVqWFZTTlFvalFWUmRROHY0cHNn?= =?utf-8?B?aDBSZDdxNCtpa24wT0tFaDI5K1MvNU1KVHpkelZpRzZNYjFqWDdwYUdkcEhU?= =?utf-8?B?ckhXM1pSS3FYbm1TZTJMSW1kbzFoWjhqazB4dEtOdGFGZTVsaHAvSS85Wnpx?= =?utf-8?B?ZEhyQitCSDZvMUxPZ1Rma2FyM2dqdWdtQzFjWlZLeHE0d3llTEU4QnRvMW44?= =?utf-8?B?UmtmSnJXb1V0b1VDTy9ieTZlYUM2SmZKU2o4a3ZDR0RzN3ErVFQ5R3BTNjJM?= =?utf-8?B?MThmenVINS9DbnRFcHRGNmd0dkNGUHpOZnBZaFhKQnNUQVp4RTJmYUlTRXUw?= =?utf-8?B?QjFjaldoOFp3S1o2ZnF4TE55djJ6ZHhhcFN6RlRKK3NUOFA2TlZydkNJRVRq?= =?utf-8?Q?JVGkp+Eat/M=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?c1dudXF2MTgxK3ZsOG5JeTRZd0lscXBjREJycmhCTExhMXRFdzlWaFNlMGRO?= =?utf-8?B?bmY1YUhQZ0tzbWRyWXluN1ppZnpWanpwME83NW1sUUdmcHZaSHNMVS9LS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UXloZVQ1eEFG?= =?utf-8?B?ZVpNdUc1YWtsOGJVUHZ0RVU1WDdORnUrcEtkQ3JaUWlPTk9jNEtWSHhnTTdl?= =?utf-8?B?SW9UdTErNkEreWxhQU5RZDR4Sm52djRia0ZjazhOME9UL1BKQkRld041dzlS?= =?utf-8?B?My9jd1E2VGZ3NENaZnR1M0tQVTZ2SXM0dGMzeXBjbDdiQjEyRTNzWW5NU0Ju?= =?utf-8?Q?VG0xlpoJU1VOnZYr3p6vUEw4n?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68fc8fb0-df49-4fc1-af1e-08dd93c76fb0 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:53.9568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0hCeq2EHZBLalzNHacBOl6xwZyYBUE3iYhljrgbKMUgCPm0L2lKhnqA7dbDYzkz6Q8Gl+jINFsV8rWwXRo0frQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-ORIG-GUID: PXDWcYO7l42vwPFyKbyrAC7Iu4jTasA1 X-Proofpoint-GUID: PXDWcYO7l42vwPFyKbyrAC7Iu4jTasA1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX4ARMFHEXA62i b9evb7u5fYnHkIJbTbHNM3cNw4caDT7Ab+XNhXA0ocgxDzrFh/AUX1ZIqimCSqe5IymBODjRV7a Cy3aBXR/kPin4S4c6Q8XKnq8x/7F7pkZTTF1Ke3oaG6apG7Wfkko1wWR/58b8XFx2ORngvpLn+L b52kegu9WH6NQ2tIkU5XzPQj7ltBRR6V+T30CAMBl/PW/W80/fjjJ2Qz5J9SkqwsFiS4FSSk4nL LCHOK5OachLhtwo7SggTI9/y3L1oFDze4n7QnjJlN+8ONrYjXUTq9d0WkCOGtBW0oX1WEFyTvXj q7U9x/THpTWf4r+Lzfrnv1nV/rj8Npq9vvKp/3vps/gv7o1hRMJ5CYNcIkZtTEkTZSLy4pluC4t g/g7GyHHe8YEuWUIQTythg85IuKMlpNP8TS0ndMbHhsG25RmxMnD2fMqw5LDYWNS+43F44tr X-Authority-Analysis: v=2.4 cv=KKlaDEFo c=1 sm=1 tr=0 ts=68260bf7 cx=c_pps a=5L1ZokDb34JZJib1CqSWiA==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=9e9T-0rTUHAn1w8HAtsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324178538116600 Add support for getting basic device information. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/device.h | 23 ++++++++++++++++++ hw/vfio-user/protocol.h | 12 ++++++++++ hw/vfio-user/proxy.h | 7 ++++++ hw/vfio-user/container.c | 10 +++++++- hw/vfio-user/device.c | 50 +++++++++++++++++++++++++++++++++++++++ hw/vfio-user/proxy.c | 12 ++++------ hw/vfio-user/meson.build | 1 + hw/vfio-user/trace-events | 1 + 8 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 hw/vfio-user/device.h create mode 100644 hw/vfio-user/device.c diff --git a/hw/vfio-user/device.h b/hw/vfio-user/device.h new file mode 100644 index 0000000000..f27f26b479 --- /dev/null +++ b/hw/vfio-user/device.h @@ -0,0 +1,23 @@ +#ifndef VFIO_USER_DEVICE_H +#define VFIO_USER_DEVICE_H + +/* + * vfio protocol over a UNIX socket device handling. + * + * Copyright =C2=A9 2018, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "linux/vfio.h" + +#include "hw/vfio-user/proxy.h" + +int vfio_user_get_device_info(VFIOUserProxy *proxy, + struct vfio_device_info *info); + +#endif /* VFIO_USER_DEVICE_H */ diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 74ea2a94e6..648badff46 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -115,4 +115,16 @@ typedef struct { */ #define VFIO_USER_DEF_MAX_BITMAP (256 * 1024 * 1024) =20 +/* + * VFIO_USER_DEVICE_GET_INFO + * imported from struct vfio_device_info + */ +typedef struct { + VFIOUserHdr hdr; + uint32_t argsz; + uint32_t flags; + uint32_t num_regions; + uint32_t num_irqs; +} VFIOUserDeviceInfo; + #endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 33e8a4d83b..9c6b2cdf35 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -15,7 +15,9 @@ #include "io/channel.h" #include "io/channel-socket.h" =20 +#include "qemu/queue.h" #include "qemu/sockets.h" +#include "qemu/thread.h" #include "hw/vfio-user/protocol.h" =20 typedef struct { @@ -99,4 +101,9 @@ void vfio_user_set_handler(VFIODevice *vbasedev, void *reqarg); bool vfio_user_validate_version(VFIOUserProxy *proxy, Error **errp); =20 +void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, + uint32_t size, uint32_t flags); +void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds, int rsize); + #endif /* VFIO_USER_PROXY_H */ diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c index 2892845b4f..6f0eb86a75 100644 --- a/hw/vfio-user/container.c +++ b/hw/vfio-user/container.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" =20 #include "hw/vfio-user/container.h" +#include "hw/vfio-user/device.h" #include "hw/vfio/vfio-cpr.h" #include "hw/vfio/vfio-device.h" #include "hw/vfio/vfio-listener.h" @@ -144,7 +145,14 @@ static void vfio_user_container_disconnect(VFIOUserCon= tainer *container) static bool vfio_user_device_get(VFIOUserContainer *container, VFIODevice *vbasedev, Error **errp) { - struct vfio_device_info info =3D { 0 }; + struct vfio_device_info info =3D { .argsz =3D sizeof(info) }; + int ret; + + ret =3D vfio_user_get_device_info(vbasedev->proxy, &info); + if (ret) { + error_setg_errno(errp, -ret, "get info failure"); + return ret; + } =20 vbasedev->fd =3D -1; =20 diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c new file mode 100644 index 0000000000..e081033ff1 --- /dev/null +++ b/hw/vfio-user/device.c @@ -0,0 +1,50 @@ +/* + * vfio protocol over a UNIX socket device handling. + * + * Copyright =C2=A9 2018, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "hw/vfio-user/device.h" +#include "hw/vfio-user/trace.h" + +/* + * These are to defend against a malign server trying + * to force us to run out of memory. + */ +#define VFIO_USER_MAX_REGIONS 100 +#define VFIO_USER_MAX_IRQS 50 + +int vfio_user_get_device_info(VFIOUserProxy *proxy, + struct vfio_device_info *info) +{ + VFIOUserDeviceInfo msg; + uint32_t argsz =3D sizeof(msg) - sizeof(msg.hdr); + + memset(&msg, 0, sizeof(msg)); + vfio_user_request_msg(&msg.hdr, VFIO_USER_DEVICE_GET_INFO, sizeof(msg)= , 0); + msg.argsz =3D argsz; + + vfio_user_send_wait(proxy, &msg.hdr, NULL, 0); + if (msg.hdr.flags & VFIO_USER_ERROR) { + return -msg.hdr.error_reply; + } + trace_vfio_user_get_info(msg.num_regions, msg.num_irqs); + + memcpy(info, &msg.argsz, argsz); + + /* defend against a malicious server */ + if (info->num_regions > VFIO_USER_MAX_REGIONS || + info->num_irqs > VFIO_USER_MAX_IRQS) { + error_printf("%s: invalid reply\n", __func__); + return -EINVAL; + } + + return 0; +} diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 0bc12da865..34df9bba7b 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -42,10 +42,6 @@ static void vfio_user_cb(void *opaque); =20 static void vfio_user_request(void *opaque); static int vfio_user_send_queued(VFIOUserProxy *proxy, VFIOUserMsg *msg); -static void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, - VFIOUserFDs *fds, int rsize); -static void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, - uint32_t size, uint32_t flags); =20 static inline void vfio_user_set_error(VFIOUserHdr *hdr, uint32_t err) { @@ -613,8 +609,8 @@ static int vfio_user_send_queued(VFIOUserProxy *proxy, = VFIOUserMsg *msg) return 0; } =20 -static void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, - VFIOUserFDs *fds, int rsize) +void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds, int rsize) { VFIOUserMsg *msg; int ret; @@ -785,8 +781,8 @@ void vfio_user_disconnect(VFIOUserProxy *proxy) g_free(proxy); } =20 -static void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, - uint32_t size, uint32_t flags) +void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, + uint32_t size, uint32_t flags) { static uint16_t next_id; =20 diff --git a/hw/vfio-user/meson.build b/hw/vfio-user/meson.build index 695b341547..19bdee688c 100644 --- a/hw/vfio-user/meson.build +++ b/hw/vfio-user/meson.build @@ -1,6 +1,7 @@ vfio_user_ss =3D ss.source_set() vfio_user_ss.add(files( 'container.c', + 'device.c', 'pci.c', 'proxy.c', )) diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 7a3645024f..6b06a3ed82 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -6,3 +6,4 @@ vfio_user_recv_read(uint16_t id, int read) " id 0x%x read 0= x%x" vfio_user_recv_request(uint16_t cmd) " command 0x%x" vfio_user_send_write(uint16_t id, int wrote) " id 0x%x wrote 0x%x" vfio_user_version(uint16_t major, uint16_t minor, const char *caps) " majo= r %d minor %d caps: %s" +vfio_user_get_info(uint32_t nregions, uint32_t nirqs) " #regions %d #irqs = %d" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324207; cv=pass; d=zohomail.com; s=zohoarc; b=inUW7CclyhAYFbGDFSGMtQjeRI+jYlpLDlZmg2AqjdBys6oY1PQnvmHo0cDz7ldPxrCaMgUei0nsfQUZCo+FFtvfYRLn06G8x7PVb30gqWN4mkFmAIx+7fL0qYP88WSd/sTb+I1CQLfPlQOnGBZysZa9xIB+fFjvWoyugPO9bCA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324207; 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=sNYeMkVPQ7+KeXT3OFKdXlqJPFksZ7JtNuqb9aT3d40=; b=P2+1m1Wd1dS/h0+tsaNZtcvRUcDbg519eQSFB+kV8/AjaWEwzuqAS+4hwnp6cRz/Ulw7XtZYtleVuGXIPkz6yd2f62/4xxpNbYPvfFSUbRs2Nm9esQxzP0qYzg7u7AHApyIE+9ILE4dhGF1kmVjRrcs0b4fHD3eQiS6G+q9LN/c= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324207484339.87691208084607; Thu, 15 May 2025 08:50:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanO-0001A3-W1; Thu, 15 May 2025 11:46:56 -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 1uFald-0006Of-RV for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:14 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalY-0006Ek-Sg for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:05 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FB1Jpn007532; Thu, 15 May 2025 08:44:58 -0700 Received: from sn4pr2101cu001.outbound.protection.outlook.com (mail-southcentralusazlp17012011.outbound.protection.outlook.com [40.93.14.11]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcwwdya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:44:58 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:44:56 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=sNYeMkVPQ7+KeXT3OFKdXlqJPFksZ7JtNuqb9aT3d 40=; b=IZr35fhZdFPCoaRiZF6g+E04YOyqDnz+lbTwIXvivJSoNAFhFXOqynGtg 1wkRmjxc/K+FkigADgdOMWZ2q+JhmVRV8LpMAKPSKnMX9/nOM8omkL1oSvaxk3lY lpYeDx3bMAZ3K8chU7Dx9LBll5pgZ3zKfkZAxQE2W0XN0IA/DW4QvOwP5RgxgMXU cdPT7D1nbCfSBMkb0BwOKsfmXX9icu+MMEPecQ7BG82gFfnjcgRCaGVXembKLsY/ CY0aKaJOe9NMOcAdTSxd2bWsZQULIKWYY+O3uapBgm10ibSZNe/Cy8h5kK578k38 Jo5RGlbj8W2K10n7ekSEo/Mfu3+ug== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WJ3BciNjhTDRhj1eSqQbXToHIZbgXAs8UQwDPt21Lc6GEUx3N+BaHzHzYfoZrCgcarZ+WigqcfchErerO+pEWjyUFgQChvGL+6mJV+lGt/DvN9X25qdU17vSctBjV6fVMVua0zUDQX1LyVUJFR0nq40w0h/F3mk9Vo8Z2UmxyH0nCmXw21XAgw4wG2rJUBBAC1mSoNQzMKIR3tGFACK0xA82Jsog0CxO7P4dJL3Mn44YgdQC46NCiASTcZuijBUq2QbyoEXKJzut+jBsjVyOwCgtj8SaJCCXJfKNMw1PQwWow443l+lNL4h5e9WFCTgbs6h+yVj3eycSSLul6Ej6sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sNYeMkVPQ7+KeXT3OFKdXlqJPFksZ7JtNuqb9aT3d40=; b=Sp3Xd/HLxCfkIx5Y0EBtX17W9ogIfQi4RV+v/Qide8p8/aDFx78VSGdC3c+WcARyinrJO/xjA3JSbEQmG0vNuNjpfzLwYidv7FVyIKp/71XgjFOYp9ZPIqm/pei32woo+6sbQiig8j1jK2HDOeSrk8pL9JoZYjZiSI/r7M+ttMmTOc2roIQhGQwVEpvSMsYROXwFv2ZSEEXvATCs/wVzOuhVh2yZHHGtY48IyVPHXE6OMx2lQe31WzrpT/hJ+q6BBUxjWg9ROGCaUDy9CopDzfKPDHn0p3liyK53NW89oqexAOxQ5ihmYgN2Dpowz9oT7vnLm9gnhmRE3FlQMFWt1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sNYeMkVPQ7+KeXT3OFKdXlqJPFksZ7JtNuqb9aT3d40=; b=jqRdh4YReEI/BZmq3HnBFeSGGjuQDcMIVS1PCMvaI0i0lqkRpMKqTELl63zfmF1oUDS0HS9QkWzVxGXCjJy/qu0gTAcRgELjwuKiMfNs4GdsOh57aDT9Ml9kjxDL01MRQoJxeMlnV1cUKVRmZzHMehaT+lp0D34/J0zJdnPbpSxPjyWsl5lruJI3tWAofIgjivkUGY0BZDuQx8Uq1FpG0TG9cfr9wIoT6Gwd4PQtPu/0pacX0KLHXod+mK2EzcCVeG3UU4aq8r5uC3O6BX7eYcZooPwMVjC+BPyPBlgK6wpKjcY6q3hpRxigs5gywx4+NWO9bFf1Q8VZ4O++XeeDtg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 15/27] vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO Date: Thu, 15 May 2025 16:44:00 +0100 Message-ID: <20250515154413.210315-16-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 027abe73-dbb7-4e33-3508-08dd93c7712d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3C2KnSaJ5d1okcwRKKLjq2qGaIFXU9Gk4jNgSeNNuRvn9wz9aVdPX0ZVAd+q?= =?us-ascii?Q?1xj58sgut+zAiNv4J+DlVLTNfVkgGAaDkd+k/Xw4Q1P3f3VTY94iLUpOM7v8?= =?us-ascii?Q?muuyzV95A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=?us-ascii?Q?4AVexyOpouCVVF8IlIE8f6yrUOICFtznrROHQQSlGiKDouQBvg6OP56imW9v?= =?us-ascii?Q?7uhKK5Xsvt8oLqULPoXw6KJlG5ol4oWuCyzub2Ufayvd/nNlrllfOnPp4VmS?= =?us-ascii?Q?DYtNBLPBYVzNQgbPSYVSyk4F67Z9Za0LXWYKBozy4uBV8NMDFIqUmkH8H+jX?= =?us-ascii?Q?AvR6NJIwdui+LU5pSdcNtDeESJwwoVSzrPrLaRM9jBZ2fCuAlhm4/iE59VhJ?= =?us-ascii?Q?ZMOkovOy6XQg6XN/k8oSdBFl5H2j9RB2EbOaK0JbJkdPB/07WzHAKiZBFuSz?= =?us-ascii?Q?ABfSsa1PnpTJaIxmelSP0hmdELVOWu/0/eSerx3MqyRrrjYx4n6DUKNPed72?= =?us-ascii?Q?Irfo6geDcPvIGN95hzxohJHMCOtBJHG6D6KNZhhuIYrfgy1DzQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?6LBDy2wBZU1tetCbApLhdZCYyi6wBMcZ2Fu91MagJB6gxjuy1bIRF73Z1o84?= =?us-ascii?Q?2RWUF99MpRJi/9XGt0Lvk08EdownsIw+QJYHYCgBB68EHfC62gYVvlIAZHEn?= =?us-ascii?Q?xPtQjbKnHShcw3qImRbws7oV8kcD5thdFHrnqRFW6KkhhkFedmxLXHy1eveE?= =?us-ascii?Q?iP/n1o4Fg+1ahK7eDff9S0oRTCHZZmTLUv8idP6wPa+hSZi+yWuEwpdWXCHl?= =?us-ascii?Q?S+vsalDC3PjIE/PLMtazlYXS3VZHPn2/coep13rVeXud0dM8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bbNytLsI3E4oMCLQRF5jbmXsoZZ+UJUVMba?= =?us-ascii?Q?SHvxlqIjYIV6tKd+mixVurHf0sra3ZjxM27DsFMfPS2oYp0jdBhIOpfR1kac?= =?us-ascii?Q?QNcD9Xf9ok1TtRomg6f54JUKShS3eSwXNw1aO/b2W6f37sAhoE1X2jd6KoOs?= =?us-ascii?Q?nKvnlyydfUzXj3QPaX8EWhIKYoaYBGf8+dpyHA81rWlJaN3TtbzAk6LrTebV?= =?us-ascii?Q?FmiJP2t4jIQZUYCLPKVPcvESVWvPxUipxKLCCrYLMuwZMEdBLVjNWfLetU3F?= =?us-ascii?Q?kyl5VQqUZXMLRiBlCvTHTYyIMxd4echUruq2XtHTVvucjpP/8jrKGyhScbr8?= =?us-ascii?Q?rwO9cclTHul0sPMZHu+siTtq3Tg5l5/eNdLHOZjH7ibwei2wrPfF+Qe0hze8?= =?us-ascii?Q?OleXGEmHkl4Aac7K/FDfoqo0V/G2i7FO00kNZ3OW?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 027abe73-dbb7-4e33-3508-08dd93c7712d X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:56.4930 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gN4wtYEGjG7eS9MYfsP2MBtJQb66dhVIXQSJIr3q/JTAysZbhYBJD5YOmV45DX8W44/+QZThPGEG7hogW/abWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-GUID: 89Y35tacCoSoHgj54-IP3yYVKEOASRuj X-Authority-Analysis: v=2.4 cv=fNg53Yae c=1 sm=1 tr=0 ts=68260bfa cx=c_pps a=1Yrorf0s+JG35OSy7nTWtw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=u1fsugoMv0NfKDGiTLIA:9 X-Proofpoint-ORIG-GUID: 89Y35tacCoSoHgj54-IP3yYVKEOASRuj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX6NXE9BZd8uOH zOUrXLfYnxrCG6P/4SkxQOSvH9QIEAAx+TL55GbvHdekxDnPiRZnXllhqEQ4gVfcdd0oX9C/Ceq 9YtegQrOAr1K9Wb8f3sKcsuEtivGGWBJnIZ3xcmgoZ9cF50vNJkDy2P7IGer7Rvjbp4AzeVG8p9 LaL+jlrzIudjqSxucm+7FT5TEJ0FnST3X1wXcr0xCieTr0BIrIUh+ji0cn1p/HqsdlgnSF4UUf1 Qf5Fp88VZIQhNng3h5wzV0mBxsFSYhY3yBfezV43d6Lc7u4qESJlmZzgNSB8Cn4x/g9aKcwOEc4 8MX4pEHn/zHNiXaEp1825+w4c/LmxTNUJ9+RKrkD8vuofgvXN6bEfCuPcH1mUwRlhHNMk8Bhr0K OZ34ZFng8LPZa8e08cs0EdNY1exYKvvNaEa8skC48d6tk3/zXqnhjGz+w/PQib/xIRzcGQ6W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324209151116600 Content-Type: text/plain; charset="utf-8" Add support for getting region info for vfio-user. As vfio-user has one fd per region, enable ->use_region_fds. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/device.h | 2 ++ hw/vfio-user/protocol.h | 14 ++++++++ hw/vfio-user/proxy.h | 1 + hw/vfio-user/device.c | 68 +++++++++++++++++++++++++++++++++++++++ hw/vfio-user/pci.c | 11 +++++++ hw/vfio-user/trace-events | 1 + 6 files changed, 97 insertions(+) diff --git a/hw/vfio-user/device.h b/hw/vfio-user/device.h index f27f26b479..a5a2aa9ba6 100644 --- a/hw/vfio-user/device.h +++ b/hw/vfio-user/device.h @@ -20,4 +20,6 @@ int vfio_user_get_device_info(VFIOUserProxy *proxy, struct vfio_device_info *info); =20 +extern VFIODeviceIOOps vfio_user_device_io_ops_sock; + #endif /* VFIO_USER_DEVICE_H */ diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 648badff46..1878d44c51 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -127,4 +127,18 @@ typedef struct { uint32_t num_irqs; } VFIOUserDeviceInfo; =20 +/* + * VFIO_USER_DEVICE_GET_REGION_INFO + * imported from struct vfio_region_info + */ +typedef struct { + VFIOUserHdr hdr; + uint32_t argsz; + uint32_t flags; + uint32_t index; + uint32_t cap_offset; + uint64_t size; + uint64_t offset; +} VFIOUserRegionInfo; + #endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 9c6b2cdf35..e2cfaeead8 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -18,6 +18,7 @@ #include "qemu/queue.h" #include "qemu/sockets.h" #include "qemu/thread.h" +#include "hw/vfio/vfio-device.h" #include "hw/vfio-user/protocol.h" =20 typedef struct { diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index e081033ff1..57793e6b2b 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -48,3 +48,71 @@ int vfio_user_get_device_info(VFIOUserProxy *proxy, =20 return 0; } + +static int vfio_user_get_region_info(VFIOUserProxy *proxy, + struct vfio_region_info *info, + VFIOUserFDs *fds) +{ + g_autofree VFIOUserRegionInfo *msgp =3D NULL; + uint32_t size; + + /* data returned can be larger than vfio_region_info */ + if (info->argsz < sizeof(*info)) { + error_printf("vfio_user_get_region_info argsz too small\n"); + return -E2BIG; + } + if (fds !=3D NULL && fds->send_fds !=3D 0) { + error_printf("vfio_user_get_region_info can't send FDs\n"); + return -EINVAL; + } + + size =3D info->argsz + sizeof(VFIOUserHdr); + msgp =3D g_malloc0(size); + + vfio_user_request_msg(&msgp->hdr, VFIO_USER_DEVICE_GET_REGION_INFO, + sizeof(*msgp), 0); + msgp->argsz =3D info->argsz; + msgp->index =3D info->index; + + vfio_user_send_wait(proxy, &msgp->hdr, fds, size); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + return -msgp->hdr.error_reply; + } + trace_vfio_user_get_region_info(msgp->index, msgp->flags, msgp->size); + + memcpy(info, &msgp->argsz, info->argsz); + return 0; +} + + +static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev, + struct vfio_region_info *in= fo, + int *fd) +{ + VFIOUserFDs fds =3D { 0, 1, fd}; + int ret; + + if (info->index > vbasedev->num_regions) { + return -EINVAL; + } + + ret =3D vfio_user_get_region_info(vbasedev->proxy, info, &fds); + if (ret) { + return ret; + } + + /* cap_offset in valid area */ + if ((info->flags & VFIO_REGION_INFO_FLAG_CAPS) && + (info->cap_offset < sizeof(*info) || info->cap_offset > info->args= z)) { + return -EINVAL; + } + + return 0; +} + +/* + * Socket-based io_ops + */ +VFIODeviceIOOps vfio_user_device_io_ops_sock =3D { + .get_region_info =3D vfio_user_device_io_get_region_info, +}; diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index ee343023f3..81fc91037d 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -14,6 +14,7 @@ =20 #include "hw/qdev-properties.h" #include "hw/vfio/pci.h" +#include "hw/vfio-user/device.h" #include "hw/vfio-user/proxy.h" =20 #define TYPE_VFIO_USER_PCI "vfio-user-pci" @@ -92,11 +93,21 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Erro= r **errp) =20 vbasedev->name =3D g_strdup_printf("VFIO user <%s>", udev->sock_name); =20 + /* + * Use socket-based device I/O instead of vfio kernel driver. + */ + vbasedev->io_ops =3D &vfio_user_device_io_ops_sock; + /* * vfio-user devices are effectively mdevs (don't use a host iommu). */ vbasedev->mdev =3D true; =20 + /* + * Enable per-region fds. + */ + vbasedev->use_region_fds =3D true; + as =3D pci_device_iommu_address_space(pdev); if (!vfio_device_attach_by_iommu_type(TYPE_VFIO_IOMMU_USER, vbasedev->name, vbasedev, diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 6b06a3ed82..1860430301 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -7,3 +7,4 @@ vfio_user_recv_request(uint16_t cmd) " command 0x%x" vfio_user_send_write(uint16_t id, int wrote) " id 0x%x wrote 0x%x" vfio_user_version(uint16_t major, uint16_t minor, const char *caps) " majo= r %d minor %d caps: %s" vfio_user_get_info(uint32_t nregions, uint32_t nirqs) " #regions %d #irqs = %d" +vfio_user_get_region_info(uint32_t index, uint32_t flags, uint64_t size) "= index %d flags 0x%x size 0x%"PRIx64 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324287; cv=pass; d=zohomail.com; s=zohoarc; b=Nj8ygiUQ5sTQiMxAnSTuU0dw9DThGeqY/Vm2f59NDnWP+0opmUYb/0IGoT9G9DPoCtVBXaPYlDEGhDmf1l7Swhb+M9UpSILW0tegdXCa7eDghGJ1TSk7SFpl3s1jOQsoRkLPRVeX1201vFoCsFXI67vuCCJ38zSRF6Pj8ZBvAos= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324287; 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=zxCsFErulNbPOxCKbF3UavilB4wcwM+IwtZ/BHwWHH4=; b=Qg1xB7KKv1inyxNr1qCpc3seVTLn3YkEU8sC1hBr9Y0Hq41u4fOPO9zJ7vCtssdc/oqWcLxgCbxNyUZ88a/LEZnDwYgtv79jbMsGPPAmHYKDbrNMydCAR0divnIKs6THNG+8nR3LlpSZkE0ICIX9UHgY95Ns+JOg1xU0RjJQLfw= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 17473242870518.755225043818314; Thu, 15 May 2025 08:51:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFamm-00009f-HE; Thu, 15 May 2025 11:46:17 -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 1uFalx-0006gd-Qe for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:28 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalb-0006Fc-Uv for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:06 -0400 Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FBMJ3t017677; Thu, 15 May 2025 08:45:01 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010006.outbound.protection.outlook.com [40.93.1.6]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mxgjawge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:01 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:44:59 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:44:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=zxCsFErulNbPOxCKbF3UavilB4wcwM+IwtZ/BHwWH H4=; b=1ajlk7Ynm90iNClko5kn40CLv6xVrBOYns2cJ4P1x4QPWoI/1tRpMPr1f 4fSoSuWIoCpuQMf4NdMm+Yd3gsF93MVb4CwRpJ/JEQE9Hob5m87BYSKYYle1ttpM QbjpsU6RJp+PyIaHQKgJ2zzklwN7LGJv8WsOiXlrUsbh8Bzx/GyuM294PasJrSOc uu0vpq/QuRGqbXXxoTaeMAmjkBKswFeGM4d8E1jqhfgrDaboBBnGamaDb0poSpMG V6tKfrTnLO0NpjoQdvKMvMYRVrTIeel+LnWgu98klT/WUEAyxD8Sg4DbjY9n7pd9 8JLZ+Pe/MGbNivLnjzb1kVvRXcBaw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ESYx6E8EWRb4wPFptfPWc3Ho7N98a806U6vZ1+oTOwEPjZWqB+D29WlwaYE0rUrplh8bNkR+0eMjUUzGV7zXdmJoPHB7mDkc9Hqy5Jua4WUhDzOdujFLJvdL7dz9CmxREOhFmPTnKClGDDO21QhsLJNKEWzzqSEeS7M0ODfwbwzw05GXVlHDqiy6oS7AvBY6vLqo6OezU/K4nkaAfiOPFGuatk62TUUkTfWZYsBzfqd0Zb1PznY1W9T/4nny6f/xsvgVnoQPn9gPnRHJZnfnjtzK7gjGmTo+8iarJLIbxvn0+gwttrf5lWDb2unnLGec80DZ57smKHSjVABXjAY8RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zxCsFErulNbPOxCKbF3UavilB4wcwM+IwtZ/BHwWHH4=; b=WuQ1XfcRzaTqB99hYVysVATRDMwHdeg41qJTjm9ccZkh7S6oUC8Mfy1gYgQ86vtHqOs618399Z0PFP4OhRl9HMxWwJPcsFGXqWUFJ0mPk2tQrS3cm6eDf0SwquFkKjGm9PnAVwQUIgZyy97nGS++vUsBhJYTs58t3KfaNdFaAN4kZuFydfaMead5dkPdVWwaf3I+k2xxtCCh31BQ8+ZV+zyp3XTdsl6KfBP8ZJD0XeGArXy1+kIj96sHB0rTUm4VvpdNmEgYe9/pPiqZZOE/OG22bhbIoDAjH1ZMGd4pshcr3AGnJ9xIgEsJTkClOjYZxPipWg25RfS2e0Oh2zrnEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zxCsFErulNbPOxCKbF3UavilB4wcwM+IwtZ/BHwWHH4=; b=Di1XxnHXEUkkQ1UC6GVNfCS92xh6GPRhRUgGKBamlq4+Sq296+uPmx765JqtBAFwCpGJpPvPVAEixgWh7G8CKDXr+oavBZq0OagnE+IpM01SobOyg+/YMb9AagD3BqtAVlniXYmTlyLuEe6gz9lXgyCBtsxFx+6yHA7J2QLMYG3WTS+PeP4qljX7P02jOeacMGqHPNVL8EmRGh9HmYzHOzSK5DZlV1iqKhh5eBCTGsk1TxkdwnWHoz7LcgIFiYmTMsA1d+Kjxof4fcJhXfj6GtG9m9zgoo6KoZzvTgMU3gvekPF3TmpEfIr0QFrDFhuVjfb0sQvqOSGBFyZ4MKpBog== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 16/27] vfio-user: implement VFIO_USER_REGION_READ/WRITE Date: Thu, 15 May 2025 16:44:01 +0100 Message-ID: <20250515154413.210315-17-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 34e783cf-a32b-487a-d7d1-08dd93c772b9 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LX0TzCKq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?= =?us-ascii?Q?6j6aBggCi+GkTEU8iReW/GCxU2ZWJZ0RMlt/5baD1Pna2SLMmtg5Gu/5R917?= =?us-ascii?Q?GXOFGMxyGKj6MbUlZqg1uF2dbolUikKY5gANfqEKj342Z8eVBtbXLQR31uLN?= =?us-ascii?Q?ydwfcv/ETeA6/QR8Wb12fkn7E5TH/ZTv39eTnzuB23OhAL3fl3RPC2CTmh9P?= =?us-ascii?Q?aKjhB+X136K6aYNCbLBteWGL69sPOxMxtLzFRzZIpUp9tvpcj342q5JyDGLf?= =?us-ascii?Q?gwOrWulBPRmXa1CO07NGN69lGAX+Cwt8QSnWOJbrnCxIUlQVWJHvstLyEwdL?= =?us-ascii?Q?5s4lxp0vUqL369S2gOoWROVPMlfjzjeCptzOKdDZ/BYzWqQcU5vu+0K9qvk4?= =?us-ascii?Q?Wb23rTI+cPRBUBotgF7m50TpLjNFX5VocVzM4L2zIVUh9MCAKr6iwHvwcFd4?= =?us-ascii?Q?7ZBdG6qkAFWqmxFlQeVFpXDrKxwHF3O0uUbrEf+98tJJr0eLZxDH3SF/RfIN?= =?us-ascii?Q?NnyVvbZ8uX9MeanRySs3gj/eEhSyNzhrxyAeeJT/c+3oLjhe6jpcyIcf/euB?= =?us-ascii?Q?sj7euo4D+/0=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gfupo7ZzNWPYcZVypsqLPH+Nc2QeUyFctUVJuqvMve0CD/ntJe3sWwZI0MYK?= =?us-ascii?Q?Nj07WkLAJtno3d1pPJmVnuJlyJAHRrEAOqIk6V1V4NZBZXRiWlEy2dKnGbHX?= =?us-ascii?Q?YZeq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drU?= =?us-ascii?Q?mAlzd8qL+bHVLlFmpdi5jaIgi8dbwNScYgSCFHaPhF0WrrQmyadOueqsAp0m?= =?us-ascii?Q?lF8YfNn12Z77xlg4bO6yYyoRoIR0LasgrdsDQ3CcGOFgkMHAsIyaQpVe63ZD?= =?us-ascii?Q?C6an7ITgeBvqfGh0yxRpsYmAZZ2KFfgrPhabXpgwLCCANB78ViYD3pgjOa2C?= =?us-ascii?Q?oxbOiuvGbBhbOyompqyvMZAd2vIJGGkov3mOBw7HD/hieQxf3Q/j6pd3azc4?= =?us-ascii?Q?GDclrUsfrvYMQK8hmG3gWdXAO7RBc9jOdsNgAn4Lf1+GV7ECcqzorrGu5ZTi?= =?us-ascii?Q?kGhuGAUg6DigngWFgquCKAoEqU0JGqjbUMANuTTSu/CKPNLGksL1SIZ0Gz8R?= =?us-ascii?Q?d6/5SBT4i7I/CPcptO1EbbuB+Hi87T2ITArnmcWFP+y7Z9iXDTMUJ4hqiLBT?= =?us-ascii?Q?+Si92H0RI3Dbr4YyvHR3zMYgZG5RXBHeG3P1CGzMuPmI9p0dE083FYl9Spof?= =?us-ascii?Q?pYujLIhu2lAIckr1pNft6j1MkTKjbDDo4kV58i/KlTCJRT9gVB85B34cFYl7?= =?us-ascii?Q?aj0Ztg3ldxUVpJRPIv1y0dHPxaSpXr2TlDRb84Vp?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34e783cf-a32b-487a-d7d1-08dd93c772b9 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:44:59.0652 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lREoE3cimwW4YIN9uwkLlZp8J2rpnr16WEcLsfRxftwpg7N8SVI3G7BgfZNgMYLmqcnrcol5EOV66ytYG8FYCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-ORIG-GUID: qK_hSzYJxEtPzCipf4B6JrxT9j6XjQSs X-Proofpoint-GUID: qK_hSzYJxEtPzCipf4B6JrxT9j6XjQSs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXx95/tb+iOHMl deTdmpShrolhE/OOZVKFVSwijpelBaD7JxCnNJc/qvZwF+l3lJUjaEl7rPjrBrqdAm6AUvAAG1C nIVEZS4927lHOqYusYgaJNQRdeHM2ux6u/MhU86NbCS696OeG3woukzxU+I/Y6VceXcJXOSqsM3 xuu445r9oLL3M92I4D0g84ETDU4Pwb2l6jDyW5EFJ6mR2GgtrIRzGHGTB+1rqBbOjWPwjBEzFrE mbqWFsrKJFfTSZSzDLEN3apHxDrGqX5faScuQ6t0rDuxLBVK0VkFR+4ZGfGZqmLCpX5LJGhnpKR rU66ASIjfgjPCYeApSBS+It3qvNDmowpaR5Oc+XSlYKWd1jrwXnaJk43N/WmeiAnL8vFgYqPlEO Yjs2aMgZ6XeRXySvT6XbzsBs31nIgftJOB87+SCFUXhM9wHad7ACDZ7bF4n7Un8bSoGPO34c X-Authority-Analysis: v=2.4 cv=U6aSDfru c=1 sm=1 tr=0 ts=68260bfd cx=c_pps a=CbxOEkXH4sIw/lcH++vrDQ==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=lEmlVuBv_BsZ2DPd9E8A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324287667116600 Content-Type: text/plain; charset="utf-8" Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/protocol.h | 12 +++++++ hw/vfio-user/device.c | 67 +++++++++++++++++++++++++++++++++++++++ hw/vfio-user/trace-events | 1 + 3 files changed, 80 insertions(+) diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 1878d44c51..8e6ccbe9e8 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -141,4 +141,16 @@ typedef struct { uint64_t offset; } VFIOUserRegionInfo; =20 +/* + * VFIO_USER_REGION_READ + * VFIO_USER_REGION_WRITE + */ +typedef struct { + VFIOUserHdr hdr; + uint64_t offset; + uint32_t region; + uint32_t count; + char data[]; +} VFIOUserRegionRW; + #endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index 57793e6b2b..a767e4fb01 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -110,9 +110,76 @@ static int vfio_user_device_io_get_region_info(VFIODev= ice *vbasedev, return 0; } =20 +static int vfio_user_device_io_region_read(VFIODevice *vbasedev, uint8_t i= ndex, + off_t off, uint32_t count, + void *data) +{ + g_autofree VFIOUserRegionRW *msgp =3D NULL; + VFIOUserProxy *proxy =3D vbasedev->proxy; + int size =3D sizeof(*msgp) + count; + + if (count > proxy->max_xfer_size) { + return -EINVAL; + } + + msgp =3D g_malloc0(size); + vfio_user_request_msg(&msgp->hdr, VFIO_USER_REGION_READ, sizeof(*msgp)= , 0); + msgp->offset =3D off; + msgp->region =3D index; + msgp->count =3D count; + trace_vfio_user_region_rw(msgp->region, msgp->offset, msgp->count); + + vfio_user_send_wait(proxy, &msgp->hdr, NULL, size); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + return -msgp->hdr.error_reply; + } else if (msgp->count > count) { + return -E2BIG; + } else { + memcpy(data, &msgp->data, msgp->count); + } + + return msgp->count; +} + +static int vfio_user_device_io_region_write(VFIODevice *vbasedev, uint8_t = index, + off_t off, unsigned count, + void *data, bool post) +{ + VFIOUserRegionRW *msgp =3D NULL; + VFIOUserProxy *proxy =3D vbasedev->proxy; + int size =3D sizeof(*msgp) + count; + int ret; + + if (count > proxy->max_xfer_size) { + return -EINVAL; + } + + msgp =3D g_malloc0(size); + vfio_user_request_msg(&msgp->hdr, VFIO_USER_REGION_WRITE, size, 0); + msgp->offset =3D off; + msgp->region =3D index; + msgp->count =3D count; + memcpy(&msgp->data, data, count); + trace_vfio_user_region_rw(msgp->region, msgp->offset, msgp->count); + + /* Ignore post: all writes are synchronous/non-posted. */ + vfio_user_send_wait(proxy, &msgp->hdr, NULL, 0); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + ret =3D -msgp->hdr.error_reply; + } else { + ret =3D count; + } + + g_free(msgp); + return ret; +} + /* * Socket-based io_ops */ VFIODeviceIOOps vfio_user_device_io_ops_sock =3D { .get_region_info =3D vfio_user_device_io_get_region_info, + .region_read =3D vfio_user_device_io_region_read, + .region_write =3D vfio_user_device_io_region_write, + }; diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 1860430301..3f5aebe7ac 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -8,3 +8,4 @@ vfio_user_send_write(uint16_t id, int wrote) " id 0x%x wrot= e 0x%x" vfio_user_version(uint16_t major, uint16_t minor, const char *caps) " majo= r %d minor %d caps: %s" vfio_user_get_info(uint32_t nregions, uint32_t nirqs) " #regions %d #irqs = %d" vfio_user_get_region_info(uint32_t index, uint32_t flags, uint64_t size) "= index %d flags 0x%x size 0x%"PRIx64 +vfio_user_region_rw(uint32_t region, uint64_t off, uint32_t count) " regio= n %d offset 0x%"PRIx64" count %d" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324286; cv=pass; d=zohomail.com; s=zohoarc; b=SXvjdI705lxrkXVKCoqUi36ssmkZzUKee4gh2HpJ5ow3a40aOJuIWg21K2GX541YgFwf8JepuF59NXoRX+v1ToL5Qkmn1sNaPK6cGOnZpJ08TWbGucDloyjXZl6Qlc7p0QdfCaIzwjUS96+eWAKWAYWJdYBkgN440tjQeL29JeE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324286; 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=VftbLE4bsz7OCy4Q8sPnflGuB3T4mqCxAfz5WEOghB8=; b=X91UFt7ozsy+Z2cMq4XMOo89yKl61q7ChOWzxjNkzOkuTnK845+tW7lAe1hOqt6HyjcYJEBwsA6bqHl5h7nRSVZSfdGZo4THY1UUGaiuEa7Imntv+v750KkJEdMdqPbScyK5L3a7dyIhz4zdRu5l9dPYEBqypYJnK6RayC16Fjc= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324286099458.3762605005527; Thu, 15 May 2025 08:51:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFan6-0000Sg-Qa; Thu, 15 May 2025 11:46:37 -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 1uFam3-0006ne-52 for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:31 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalu-0006Qo-JQ for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:29 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FFP29G001036; Thu, 15 May 2025 08:45:04 -0700 Received: from ch4pr04cu002.outbound.protection.outlook.com (mail-northcentralusazlp17013059.outbound.protection.outlook.com [40.93.20.59]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcsdhtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:04 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:45:01 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=VftbLE4bsz7OCy4Q8sPnflGuB3T4mqCxAfz5WEOgh B8=; b=MD7Yw/A5MWx/u7pjMA+78RDNWu9WxuF2fnGQ4Y4yA4Zkfc640BwX4V6d+ I3w25G1IHWjfQA46uimbAkzipLsIQKnGQ06Qskj7nCklweDnA3ZTvcL6aH/tTy+P owMRYdieJFoWpyc8LgCKLZKyR7GoQZ1ZlDldD+71k5zr4WpimlFa5Yt0V6/SDQRd fWeFihqAYPXvTPfR+ZlUwq98vsKrLUgcttk/6+xVhjPgPVevnM80qgQmD4/35c4x 0f7htHQ54V6S7/r5nJIDl0qqjXabzzKMq6/f3Bcr9OfIeGmJHVQ7waeI3LAZmyQS zEI6+7dYZ1C4t4rSnl99VdJDpfA+g== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DlFJUsrOnOWFEvQXx7oiNhpheAPVImAcShc7S10Ko01seGcW8n01sOjs7B71Dg9oUfkLcWm+CY0OHM5+gZuSUN81dgNZS2+VS9OXUUbVKxKi7REafuz1Ml2xLrWehQwNGKZJjXWtdi3nxihTYFxhyQmera4W4oNNM8ipUZAfywUR8NCHYAO/OxcxmXwJuvtBSumOmJ6p2nde4PdyorLd/F6FoeSN/fIO5Wd511A7LMaE2Oa5TkFuxU8kyKCe/t51WtZj6fMAuGcXnsQiM8iCjQzdIv+YwOC05HhWIbQVXQ1YbsQ27snKqdYRuBZ5iIZ0KQ3MxwmL/I4YhHUs4LbLag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VftbLE4bsz7OCy4Q8sPnflGuB3T4mqCxAfz5WEOghB8=; b=UphB7IliBLed5tJJ9pVADbVx27qOTaRvOxaU89hNSx4jvgt2Dq5MZ5cQuY+VARtQA09LN4UnV9/8Al+wa8wmNbAACx3TtQB2CCapMCue5j/tp/XSXnG1Z2O98dbXJbZ8dAsiPxAe8+sZSjHqd0QUR+ODadn1qBUw5x6xEcBPGSqOnaTRZz2zUHRE0fvD73W9S+8L1ihwsDTSWVSijKpcv7sUV+tKuQAB6Tr/9/MYp0yJ4hbMu4vLldtypAUnQ1vNHC1yignK3nEYX+kSSR3/p22J8g8R7xtxFVujWjZ9A62PkpWu85KmRMKxuYXU4NIbii9Dm+fxgybkknBxMo5Z8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VftbLE4bsz7OCy4Q8sPnflGuB3T4mqCxAfz5WEOghB8=; b=eI82LHYyJD+n93dZWIODc8Zvx9helpI/llIVyMIja+HgfiG9qFdGegT12YnD5+t69uX73QwC1AsRssdhjH2rI/DIgTymGOB40H8F81Hy8qNEcHhE4wJgQVCOnSXYsO0sYC1TY1E4UR9Zr9eryefsDv835Tf7C8eDD37EocRvWyE19tpocPi7RjQIqN+tGFVKydKJa1HP+dUNBSLnrgPpHVy7C8Hl329QqrHrrHVzK/Trj8a0kryOhDaHLoYD7YWc79o5+/YrtyerXJCPJYtYBw8IfE5+FQg9rManTcq24IW/jvnOLxzBuKd3/JxlUm8pHtli4+ZGiM9JYRXbcqE0Zw== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 17/27] vfio-user: set up PCI in vfio_user_pci_realize() Date: Thu, 15 May 2025 16:44:02 +0100 Message-ID: <20250515154413.210315-18-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 723f5b10-8288-404a-63b9-08dd93c7743d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vXkV3oYdvXjH6Z/0xhsrl5hnFB111xAgdyMU5bdKs7JlKz4fLbpV/xeWPUyl?= =?us-ascii?Q?UNOrQJ9KjE/xPsqofiFdx5xzfL57KLpo4GdlLlfIBswpbUMpw4BufaXLzyWx?= =?us-ascii?Q?k4YMA5aIFDATDUQ5s72x71Zf4o18BD7DyV7FjPMDktRbahZVj2aMwirbqsF9?= =?us-ascii?Q?XrTaRyYbf/aPIrWzuAZrLcRdhIq0DqC5nxpNG4OvHMHMEqTwZFq1x9CHklly?= =?us-ascii?Q?1Y4V7j7enFtWVrYBcgZfFL3MpphNRkzbLBN8gPG2bGU0awGt7p7SdyfiquvT?= =?us-ascii?Q?Zf2u2KnYVUb18l1WFFxEJ/McdPmDbzFnUO/2PS/lesWjhpcep63LzehXANg6?= =?us-ascii?Q?BJrxbH5+GprI+rJPtGwiX+14jjSGyozLkptn7MKaMA0gbB2Uv4oEnPLERsus?= =?us-ascii?Q?LeQpdL2Q2mEGQ6P3NLLNCvLKTsScTAZcBjDNxVCZXNSxIo9Ymn4iGakCZACB?= =?us-ascii?Q?16p2NYYrhmI4q6pyRxVvZgBrIMeV2Mmm3Kj/U0qhqjEXoLZNN2QKGgK4wbDf?= =?us-ascii?Q?33yyFNtkNnA5ccBCUzUHUUY7lZuow29FRWw45nCZT1bIaKNklD0j6gyQ6dO/?= =?us-ascii?Q?dAjveHDu+GGs4T8hIUNLqz2B45AFtZDoGuDJub/xiYxTwFzKdJW1LkZQ+JTk?= =?us-ascii?Q?OKcMLgAwHg1Fv/z45FmHwis/jed3JhZNgLnVnrN4oNxZC/of/VVDQinVXx97?= =?us-ascii?Q?uyPeiZ74EUFyIJZyoFRojDaUtv1H8y9gbatjLLNoVigEagI+oaOLwlv5GYqu?= =?us-ascii?Q?cl9twYfJicJ1S5B//PZrrBv9hg8bMT0MzsSsTqz4ivKQ/wO69Jb/VfqaxFe9?= =?us-ascii?Q?8twRG0LEzqwenM4IC8lOXpy0T/2R40tT/hNlk0BIrZvHOBoHhmWgOHMRBUjN?= =?us-ascii?Q?AUlYxuOKmLhdaSHb/nQzrR3BrlzuK9mj7wVHJHv7QnkkZzuFpg6uSGsIzpF+?= =?us-ascii?Q?T5XMHjm3ha91wC08Sgqnfc3MzR5eOYM+PxzYfCFB5FANejsccWn4V+m4jz9w?= =?us-ascii?Q?p6BBQCrwvP3YOxiOBiNe8ZkUnPzWVyAbnDct20Yj4V1HgJplAiAKjT8a4ycp?= =?us-ascii?Q?OHyCKPK04hoe71B4Kp89AINc/Ppn8LeI2AKUI/tskZleswS04tl0CIynfWCT?= =?us-ascii?Q?O8eC1DT12LXH1xeObovBVq3jtU7Lc8QmOo7kLf+6mZF4noej+tKw9+wK9lsk?= =?us-ascii?Q?cmUfcdXAHlvzULi1J6Bp5PfeCaFTU2psiQl1h+G1ZfkBFid07gSkdlSkqVuf?= =?us-ascii?Q?ardSd1kUVM6AHSr78yymAGfdDxNsQRTvXA3oKZ+PbITH4vFrxY9i8YcX9agR?= =?us-ascii?Q?ZlUB8rjgVYo/XhNLICnxR9ozoTNvvhg9QnPX6iqziU/4alqU4q9TNasAkvmG?= =?us-ascii?Q?708V36lg+s1fd5bhrk+icy28PlBrX4VcuD+x+hRy58BXTXROVqheP7RdwGKF?= =?us-ascii?Q?SYyGZwxGpFI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?B4w5EjTVAZ77Q63qtiDXvwCMEafAEM2RcBvbQHtm/QUA2L+BOqtxUyjAcVio?= =?us-ascii?Q?KtM0eURRbVLNnlX1IvXz7N1lTpl0e5ZFGdalHhtQo35dHmPxSkHeL61Zi20p?= =?us-ascii?Q?U9lBDe+aguVZ+idXF+4lp6fzIb29IVNo9WkBi0XfDGUj8DF53fcmkTyMeuru?= =?us-ascii?Q?bucP1WoU7n9lxVk8aKCqRHLxCWQTZ5qXUNBfLT6h0E+wc6rhjgmU7tkL5VmM?= =?us-ascii?Q?tZAOV410r8fNHfVS8+K09AJnWOJMPeZAzNM4kYDhaaEJyV9yf3XZp/w4yKy1?= =?us-ascii?Q?1JvP6Ujny9AFM+qwgwUjo//sgiglMl927sZ4ot2dDXAETkXJkdCyrBe+Wp6u?= =?us-ascii?Q?KDwzTbNzoZQUwPmhTQrAHPWnvsSo5z8uQTywBF8NGLpR5rPCEeNpj4ePn89y?= =?us-ascii?Q?6suUOSIBRi2OVaT/RfQKivC1EkeqxqdY+oPnJqKZgw6qyVx07AIuhlFkHdNM?= =?us-ascii?Q?fVKES1+jND9wOIQ0L04Tv82rbVtSIijkaRTs3Bp1Fu01zkWAPvaHTq9P84M3?= =?us-ascii?Q?Tl6JGv5FJNpM0bj25YsSXD1pJ9JZvpbAZJNeFjvDVz//5XZVzcCmHOb7hbYi?= =?us-ascii?Q?yXPrTQKgoMznpp2vG4jcY7bypuu4Yy1DDxoaB/Opmz1dALblgXEXEpVueTYo?= =?us-ascii?Q?490SR8QRJMmzZ+5y8M+6OS1hxtWblmxjKxc8Fz96HnUMxEGL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pe+YxHO8R+z03Ckq?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 723f5b10-8288-404a-63b9-08dd93c7743d X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:01.6194 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OQEU1gJb0HZ5aBnxl5FpN/clL5fQeOc1P8NRfBY8LNVZn92S8Y9rRzG5I7HxNK/mOShIlsm0u0NE3MuUDIGPMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-GUID: Th9HaLYxZtmTUNTRx7y25l_ZBwPCGO6F X-Proofpoint-ORIG-GUID: Th9HaLYxZtmTUNTRx7y25l_ZBwPCGO6F X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX1WkmGtTyt0/3 GYY7KU905qHJ65hEcZD4hwSoAn5+e0D9ZUXmRzyqF30g17ThZysB+0mj0tbAeNWLPwudyHlXb4z mPHt7Q48sKx86YrI9TsCA5u+TlYsUtwDTxN9aRW/55c0mEKWKedUJq/lXkjPIsoazYLLm+H73// ZBJ2gXs/kg1lOohxq6VVcw87qjfu23X+erRayMujb5LVuq57zHMXaZJOR5EvaI3LoylSyJhdFt9 2sJ6vkJ5dG2rQZd98drio6yCH74pvIQFO6QQAppV+jrzI3Yz8pzb2W/R6e/LAlCyfVN5TOKUnYL c5Sl1iQim4U6yAbiJV42Zar6nik7gOBuJEeywc1Ud/tgMt7DaQh3hcwGkahTShMh75+QtXY5ZFX 54MiCYXLHKzOLKcXvn6N3ET8qJp9lY0/o1gsrn4SnvFF1lpgLwX+RA3w1PtNlHpYlbXD2+VD X-Authority-Analysis: v=2.4 cv=EKMG00ZC c=1 sm=1 tr=0 ts=68260c00 cx=c_pps a=rrMtUIbNwx6LnGB7sifIYw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=y95Tuok1ttcdGOPXAz0A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324287581116600 Content-Type: text/plain; charset="utf-8" Re-use PCI setup functions from hw/vfio/pci.c to realize the vfio-user PCI device. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio/pci.h | 8 ++++++++ hw/vfio-user/pci.c | 28 ++++++++++++++++++++++++++++ hw/vfio/pci.c | 16 ++++++++-------- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index c5fc4aa500..f6524cffb5 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -220,6 +220,14 @@ Object *vfio_pci_get_object(VFIODevice *vbasedev); int vfio_pci_save_config(VFIODevice *vbasedev, QEMUFile *f, Error **errp); int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f); void vfio_pci_put_device(VFIOPCIDevice *vdev); +bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp); +void vfio_teardown_msi(VFIOPCIDevice *vdev); +void vfio_bars_exit(VFIOPCIDevice *vdev); +bool vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp); +void vfio_register_err_notifier(VFIOPCIDevice *vdev); +void vfio_register_req_notifier(VFIOPCIDevice *vdev); +bool vfio_pci_config_setup(VFIOPCIDevice *vdev, Error **errp); +bool vfio_interrupt_setup(VFIOPCIDevice *vdev, Error **errp); =20 uint64_t vfio_vga_read(void *opaque, hwaddr addr, unsigned size); void vfio_vga_write(void *opaque, hwaddr addr, uint64_t data, unsigned siz= e); diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 81fc91037d..08edb611ff 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -115,8 +115,36 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Err= or **errp) goto error; } =20 + if (!vfio_populate_device(vdev, errp)) { + goto error; + } + + if (!vfio_pci_config_setup(vdev, errp)) { + goto error; + } + + /* + * vfio_pci_config_setup will have registered the device's BARs + * and setup any MSIX BARs, so errors after it succeeds must + * use out_teardown + */ + + if (!vfio_add_capabilities(vdev, errp)) { + goto out_teardown; + } + + if (!vfio_interrupt_setup(vdev, errp)) { + goto out_teardown; + } + + vfio_register_err_notifier(vdev); + vfio_register_req_notifier(vdev); + return; =20 +out_teardown: + vfio_teardown_msi(vdev); + vfio_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index ef4095b3ad..fce41cbf1a 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1770,7 +1770,7 @@ static bool vfio_msix_setup(VFIOPCIDevice *vdev, int = pos, Error **errp) return true; } =20 -static void vfio_teardown_msi(VFIOPCIDevice *vdev) +void vfio_teardown_msi(VFIOPCIDevice *vdev) { msi_uninit(&vdev->pdev); =20 @@ -1869,7 +1869,7 @@ static void vfio_bars_register(VFIOPCIDevice *vdev) } } =20 -static void vfio_bars_exit(VFIOPCIDevice *vdev) +void vfio_bars_exit(VFIOPCIDevice *vdev) { int i; =20 @@ -2460,7 +2460,7 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) g_free(config); } =20 -static bool vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) +bool vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; =20 @@ -2807,7 +2807,7 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **e= rrp) return true; } =20 -static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) +bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; struct vfio_region_info *reg_info =3D NULL; @@ -2943,7 +2943,7 @@ static void vfio_err_notifier_handler(void *opaque) * and continue after disabling error recovery support for the * device. */ -static void vfio_register_err_notifier(VFIOPCIDevice *vdev) +void vfio_register_err_notifier(VFIOPCIDevice *vdev) { Error *err =3D NULL; int32_t fd; @@ -3002,7 +3002,7 @@ static void vfio_req_notifier_handler(void *opaque) } } =20 -static void vfio_register_req_notifier(VFIOPCIDevice *vdev) +void vfio_register_req_notifier(VFIOPCIDevice *vdev) { struct vfio_irq_info irq_info; Error *err =3D NULL; @@ -3056,7 +3056,7 @@ static void vfio_unregister_req_notifier(VFIOPCIDevic= e *vdev) vdev->req_enabled =3D false; } =20 -static bool vfio_pci_config_setup(VFIOPCIDevice *vdev, Error **errp) +bool vfio_pci_config_setup(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; VFIODevice *vbasedev =3D &vdev->vbasedev; @@ -3162,7 +3162,7 @@ static bool vfio_pci_config_setup(VFIOPCIDevice *vdev= , Error **errp) return true; } =20 -static bool vfio_interrupt_setup(VFIOPCIDevice *vdev, Error **errp) +bool vfio_interrupt_setup(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; =20 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324091; cv=pass; d=zohomail.com; s=zohoarc; b=RB993aV3lD633ouiR3RPEevnSJIy0dG10JdwoV0rSjFrSqtQj+phEdgeawtkS/x7x8rzjCvYg7iNYhEkehsLX4bTUOQvNUlXGvc0wXaY8wq0XlqnODu4H2c/FooblMceJ+geosw3HZyXArstmtcg1PlqKQIsU+3h688nKNy8fpQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324091; 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=gLSKAir9CownbVZp50Jw3pkCn369NuhHnd0TmbNavzo=; b=ZPS8St6qaLZkV0ctQLBQQhAx3F4Z82pirSEb7Zxwe2Y001fN6Mi9bAWYrrPFYrdyY4dEChkFju+vsZpeXfxw5vxa+L6uirDJPsznICRpioVj0/kwJO5BMvNZzOyJTZP7r4WmGarYGwRCxiDyvo9Fbg1Zx83qUb5r5C6NddQay4I= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324091215614.6882506995701; Thu, 15 May 2025 08:48:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanc-0002YP-Bj; Thu, 15 May 2025 11:47:08 -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 1uFam6-0007Fe-2B for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:35 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalz-0006RG-Fu for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:33 -0400 Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FAchHr004938; Thu, 15 May 2025 08:45:09 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010003.outbound.protection.outlook.com [40.93.1.3]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mxh32ymh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:09 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:45:04 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=gLSKAir9CownbVZp50Jw3pkCn369NuhHnd0TmbNav zo=; b=A+sUzVwCGxv1DYppAz1OkmkAAVE4iN2xfYnGp2mtXY2K88bUzCeSCEufO UyYegYlIzdUS04ti24ywmbKZq2CFMpukW5GMlYwUdKIDfE+7uNkaEETh4Inpey38 CRwFrH6IP+xO8O9aG6BiqDYJjK4zZnM0gbkWZwf2z4oxDzD2MeBpXmYAxMxcznI/ +YyRZGw+UVUeNVdlCe06KMoWMHDNAhCV36nAjk2ObjIkQTG4L7wa3GLIWN8fUDa4 WBHNgIZrxkLma+uBHQz6x8RVwMHWXI/v1pXbKvHiGNMupH/il/6OOImsZgFb+7V4 8EtMKhcrST3GLodBzB1UIvCyUBt4Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jW3iVM+6NNtVfxazfWPGm64l5wS3fjBoh3Qy/HWLAxHVFMn6q3VC6z0ZgTchzGLRlzBP7CfOPQafbge0x3y4RvyhHMJDewgF0XnZeNn58U/dOPNfERBx5O4ac0jkhb0J4eUNCImph+BnELRCdN86bHHgUVh9NcvCcL4/fILdvMev3tC3G6vjSX002lIDs/wpcpSFqx7s1DpeNGIIeEf32vXwpNkRypgVmFdK9jUP9PkPN1QhX4m+N2X+5FVvwy6iBK+kKnPbdVluLx6uS/l53nVi+DfYpedtRM5GXv1SSKmpfbcRfrJ8RpaAHor6I3RTtNKEvdU6RpwXs0u/BTiwLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gLSKAir9CownbVZp50Jw3pkCn369NuhHnd0TmbNavzo=; b=C56Fl6RDNW4X6u/Ix6J1pOAVC7jNGfV4nb122szEZ1MhsRDCntAGKVlg3O8gystGg5vexo4gF1/KBIBzrsBbG+WmnNSFnzZUAbGPuSj1dQBCdaYYi7bm2SSuyw8oUf3Dxp/lvU2jvZ4IDPhm5hw8IvCvvoeRMlE9/kV0KsmIZx/kZMM+0fG9KI8yeSLGGbFmADgmDrW29XdNqrA4fqrHV9Qm0eU7e6ppFVPMD1W0BSWCfr3I5HVgUy3sQ3MMuGEwUbZ4r7D17GQx+UStNCaBRP/QmJ4D8LGsGcG247D1KTadRHCNSnxYQ5XPAdH/Hi3Xzt+gww+Dw1nv3nO7Dyt16g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gLSKAir9CownbVZp50Jw3pkCn369NuhHnd0TmbNavzo=; b=avGSreu8+Mqyn6zaCg6zVh2JtFt0YlQ3gOLRjv131WqWRCtCiW49XbLcj5w3bQf0m/DaC7aC358guhlxuTSxqhVz0LVBPMY+843q3PmvmMOZLsLwcZjePWuW20aby3ZZ0Yy5/r5QLASDPHoS23q8iHA5gEDdVRKK/i2J4slXeuNDycx+c5otdXoXLwVBkzUi4eLNsHhbxN91jQhrIzUNlamep/3Ve3FJF9wdVpricpKi9Nt9BxICwgS9r1Z5DPwGig6BcBtsUCOmeSTlbQ7pQv5A9APfFfRV21oS9fTOutMevOPAQRPkpfttiG2UjQVgOOfs4ovtcn0AMUJSmkAfVQ== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 18/27] vfio-user: implement VFIO_USER_DEVICE_GET/SET_IRQ* Date: Thu, 15 May 2025 16:44:03 +0100 Message-ID: <20250515154413.210315-19-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 185ab4b4-303d-4f1a-b0b4-08dd93c775c5 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Bs7mtDdRCEJOuNxm3SfeZpq9sOON90hjrk/cQ3w3gH5F6Ewdj4APgDa0bSi+?= =?us-ascii?Q?bShV8LAXSZyFiK7/I58v/ZHut+6d63QCeIatCaTdmkMycT5atYYPxNcLhplz?= =?us-ascii?Q?rl4kPIimCnOSufSrIf2k72lMtJSLfFu9VOuxB2vOTAO+Ja/+xfo4bwbewe5o?= =?us-ascii?Q?HFxHyIhSJQ6xnbPTTM5s59kSdXfwNbe2Dkw8Ek72W8OPPD8tEplnledi6Ukk?= =?us-ascii?Q?F4pjcErZMgzSTSg35UcQ4QNu2O1xIEjbPkjk8xgbJMm+To7ulHN1TgbL8hi2?= =?us-ascii?Q?Tda3u5zjofyWz6lQRL4MV+PzdmiZipcyZWr0k/vubgzt/pcm0oT7rLrJdR0t?= =?us-ascii?Q?IYawsFsbV4yxcn8WsFVZAdHPYuUzZbx6RedNnDk/SXGriL5CJGzu/Jhf11Gg?= =?us-ascii?Q?NsMNdMFSr4qzwd5B/OQtwWFtrB/UHlhSg58A7kR5F+j1sfogF8+QevYNBJ5u?= =?us-ascii?Q?VxPeQHQCjbZ3WOZPizg6dj1kQpflWhZCwW2otenYJxAZ7ftlkyhLHBgFYF5P?= =?us-ascii?Q?pu/I2fcgacc38KOeto8Zo/t3HJmYdu1IGyQiWhbiJAo7q3cQQz0kNEV1r/ow?= =?us-ascii?Q?BQbclyEtPCli6ufJtU4CH8JtE5R9dy+TA+GjjTroL3w2pjSn3kGVwk7Ibe8H?= =?us-ascii?Q?3ENZ5h+uNa6y9Q76eq1/K4axlZxLlRatdJ06D6l7LOaA+6d5+MFx0MwsmIYQ?= =?us-ascii?Q?XXFFY0DUzm1FcpmJ7Ua2E9EEKxUqjSLIRgMdEOsQ7K1yCEUgnKbqAci9PxgM?= =?us-ascii?Q?3+eQ3sgua7IQzsUluoComcuMraEDnIT1zlxT/HehGH+pWZAso3tfORKZODOI?= =?us-ascii?Q?IXJW1OGQOBikiwgIgn5l1/XLjlI99/Wq+Z/QfpuoyJ3AP7P31MQIeJ5Hdpm+?= =?us-ascii?Q?VlsnBHqhtxTvrAsaj5QBqAYQsGDymGxgNRFtaPzGRl+1S4CdNOZHW9BCeKZv?= =?us-ascii?Q?JHk1Sb183anjXTKu/GYSCRj6jPvhMLc7+NmYDmzddUi76fzfJcPb2rZ+T1rP?= =?us-ascii?Q?LCQjnwjBCD673jUueCO9KMqyuUlFvWnMvHFLPxuUQLRV+8k2+Bm9yVzmv7Hm?= =?us-ascii?Q?DopduQyquchhGRw7S8vW33sA4fdZd39Ue3cqkXfwlADDOpS5l0+OWKDrRRHd?= =?us-ascii?Q?lxHQnvvSUgX+GoOc1fiO24flr5cZu/2lw7Okbg0pix1RJI56Hm9Ba0kR22dj?= =?us-ascii?Q?UfxXySmwmabjH1IaJxv3usx7VlSZ+aLBNoo4SAv6ajE6EBj5PdhjpQODSMGC?= =?us-ascii?Q?5sZXRUPv1gRERT5vyLsCHoRmgZddHizJCr4zcdBG4UbdYE/WoPL7nufuBEka?= =?us-ascii?Q?IKORhw5UtZHkrd/r/oh79ehgNU4QPg8A+QSIET7GY7SnrFN3i1JnHaB5avk8?= =?us-ascii?Q?jNO8QfGaW1FVhnk9FgeM0SdDrHC4CzizuAQxmEBfqjUDjSL5hA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?N7VHBGlRZO/hui2R/KSzMQ2ckQifc+IAYEStewVhbv/HnmTSXL8uMPuw+xyc?= =?us-ascii?Q?ZgbFm7J0IkMJoc1hWId1SEUuCh21Fczh14f849sxEH5nd6+J6ftXz1Wslv8L?= =?us-ascii?Q?fknqKcfeTRHmniYwzHMwqbhsilzOs2YP/dSFePEB5koOFx0XprSbFudOMvNM?= =?us-ascii?Q?O06gmrP/wc0cuIURhIJQaz9s9y1R/i/Ud7OLQz38Gs48lW4uci3VAsup43YC?= =?us-ascii?Q?8Nx6QkMjEJm/BT0pe4xY17DRnGH8LpbjsB1KD9Ufk4yf1h7N2q2Wx3TksHnz?= =?us-ascii?Q?cjTkEDIOXKPYX6JoL0CVxoV1rFHpMKLj8eiq1ny69SCvW2b3FTaGOL4QEMMn?= =?us-ascii?Q?4Rl55WbUpl+7d+nMnBm28SZ4LaMqz+b3LNcrBFNK1vnJbwa9h2ENVNJsfPgl?= =?us-ascii?Q?6ecVNsaX5L4eUdQ5/KVeGsub8nVBeEuk0ciAKYAi3XIJ0vmZm5F7AiXbYpH7?= =?us-ascii?Q?fH4Z7dM9gMqntPLzbUgEJ0hyE3VSz1UgqQVQvgVSyAcaHzTPqcZK+3izjggP?= =?us-ascii?Q?aQB8nEFA+AiRako2wfKHbouoRfSPbNL5rjwlAukVxJ3lIInRpIAINtgVr/WJ?= =?us-ascii?Q?XcXcR0kt4NOUADKWgu2Nhdeq6FdMmT9jUYk1zU92xshorrxPE8+jCd+fEncN?= =?us-ascii?Q?UKGKnJb0vV03wijuMJ5MIs1VlXh2bsbDvnBDR7CBt7U1H1iUpq+Dx4VR/9KH?= =?us-ascii?Q?0G6jCOwX5eyWdKTZRvP8oKf/lq0FU4s/u6dFK6IeeXz99KmQqNRg0BjLdO0l?= =?us-ascii?Q?1I73RMG5s3kboz5qBtKIzKtBGHXfCPGbjl665ObXCn6B3u2nCj2ScfgZBUh7?= =?us-ascii?Q?OB25e56XGSB/m5Px226892B831vXkd+GlAx77WubqXcaQuHwr+roai74WTNG?= =?us-ascii?Q?rTnuigwMyhgToON+LVXSMzLhcmrqdoH2kdtqJJ3mx2++XJkKNBGyRhfJXCpX?= =?us-ascii?Q?klUpDy3g4Wa21roeSqD8HGuvVnssStjRlkdytwS0X9FSaXZtmAYzb/Yd680H?= =?us-ascii?Q?rGJhiShS9CSptbfAjClqBdW7mgo5v/1w5wVRyH9iQlYvDghtXnnwoyoUNcM0?= =?us-ascii?Q?zJRr4bmmefTR1Fx0E4SZ1I/tdvrayGtO1wKJ8+n4QUK/s7KifElAvYdVkFzb?= =?us-ascii?Q?u5f75EBpavYA0/AqIuPn6rgRXFX/HYaTrzzB3WrbWlOryhzexzYTHUpL1gxw?= =?us-ascii?Q?W/2ls1ayuizSN5FjQIozDzpY3PTaxqw5Hw9RlnUFC1uX+1lMkR/sYX16DiwM?= =?us-ascii?Q?TI9gLY2NzS0z+S865lhxENzINPMnNwM+SCZLpDezxC1TkqI/nr13mr+u56Sh?= =?us-ascii?Q?638GTaEK6mBBwLieu+6BmTlJBz7z1Hg8gBAG2r1kmWLFUm8wp7p8OjKWxcOx?= =?us-ascii?Q?gcQYBUmK4gvHeWI/nZUJCMlnIwHRA+aoFVUGOubAg5CaHl6Nt25ymAqODFw5?= =?us-ascii?Q?ggbN30ZqehZeH/Lgm7a9rzonhfEOMRPQJ4pDjOpiFIVgvBBBGao4k4wh5hwi?= =?us-ascii?Q?7S8K6IIdMHCBufYX7id9cF9iEpUmI3T9/vlAeec68U6/m5JX4JMR0EneTWiI?= =?us-ascii?Q?4ZXf0WYthWTNkSAswGvZY2Q5fZZB7mnVchjyfIOW?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 185ab4b4-303d-4f1a-b0b4-08dd93c775c5 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:04.2102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: l/uDvQrR2PUL+qMeTIz/9YTsM86H4LOCw4scZfz2TW8qh6k5HIxOodyV2bBZgnAk8YqiMRaCeF97Kh3TcCT4CQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-ORIG-GUID: ZVGVfpAnQiPi7mdxMEwRhMVc3WR1uxmB X-Authority-Analysis: v=2.4 cv=TeWWtQQh c=1 sm=1 tr=0 ts=68260c05 cx=c_pps a=X0MiYUndXFlT04tAhnTHEA==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=03k_OfxykpieI8sgW_IA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX5T/WLPooWMd5 K2ytPaep6wlg56mJCK5zjQ8hIjBRy2ubneKCKwzIW9x3PSnho3l4HGSSeac/HVef7gW0S3Bfu+0 B6kHB305pcDao5vFlzw9WVwjI4ZRKRsMKwDE5fVVGaWlmeOaOXdrqclar6PwtbyOX0lzuwSpU1k UDFdcdBs/Dm0QaddMioZh/NftNEhjuxQS6+/D0TGCJmaoZvAsb9ipLZQWp3FDBxVoYoaCuvJaDi A559q5UF2qWEkg+NkCQKgsSsuQpFN3Dk0rSonzzqwvC6E1tNYzLhDoJ4M+5IcStXF3b1U6vD/eZ gcSEhKlLK3yqaQxhIDYn4cFMEB9nzk7ioA0C4qWpsWPB0kXmcbUrvdpN5qxVSo+wb4CFoJODOWh XcC0Da5rHWpJGBXz4/m661iQK/ZWEbmmgD6uPZxWuDiXCpHKjPAyNz8QroA1zrBZjGeRoLqu X-Proofpoint-GUID: ZVGVfpAnQiPi7mdxMEwRhMVc3WR1uxmB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324093577116600 Content-Type: text/plain; charset="utf-8" IRQ setup uses the same semantics as the traditional vfio path, but we need to share the corresponding file descriptors with the server as necessary. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/protocol.h | 25 ++++++++ hw/vfio-user/device.c | 121 ++++++++++++++++++++++++++++++++++++++ hw/vfio-user/trace-events | 2 + 3 files changed, 148 insertions(+) diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 8e6ccbe9e8..920b9c44ec 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -141,6 +141,31 @@ typedef struct { uint64_t offset; } VFIOUserRegionInfo; =20 +/* + * VFIO_USER_DEVICE_GET_IRQ_INFO + * imported from struct vfio_irq_info + */ +typedef struct { + VFIOUserHdr hdr; + uint32_t argsz; + uint32_t flags; + uint32_t index; + uint32_t count; +} VFIOUserIRQInfo; + +/* + * VFIO_USER_DEVICE_SET_IRQS + * imported from struct vfio_irq_set + */ +typedef struct { + VFIOUserHdr hdr; + uint32_t argsz; + uint32_t flags; + uint32_t index; + uint32_t start; + uint32_t count; +} VFIOUserIRQSet; + /* * VFIO_USER_REGION_READ * VFIO_USER_REGION_WRITE diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index a767e4fb01..45b91d22f0 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -110,6 +110,125 @@ static int vfio_user_device_io_get_region_info(VFIODe= vice *vbasedev, return 0; } =20 +static int vfio_user_device_io_get_irq_info(VFIODevice *vbasedev, + struct vfio_irq_info *info) +{ + VFIOUserProxy *proxy =3D vbasedev->proxy; + VFIOUserIRQInfo msg; + + memset(&msg, 0, sizeof(msg)); + vfio_user_request_msg(&msg.hdr, VFIO_USER_DEVICE_GET_IRQ_INFO, + sizeof(msg), 0); + msg.argsz =3D info->argsz; + msg.index =3D info->index; + + vfio_user_send_wait(proxy, &msg.hdr, NULL, 0); + if (msg.hdr.flags & VFIO_USER_ERROR) { + return -msg.hdr.error_reply; + } + trace_vfio_user_get_irq_info(msg.index, msg.flags, msg.count); + + memcpy(info, &msg.argsz, sizeof(*info)); + return 0; +} + +static int irq_howmany(int *fdp, uint32_t cur, uint32_t max) +{ + int n =3D 0; + + if (fdp[cur] !=3D -1) { + do { + n++; + } while (n < max && fdp[cur + n] !=3D -1); + } else { + do { + n++; + } while (n < max && fdp[cur + n] =3D=3D -1); + } + + return n; +} + +static int vfio_user_device_io_set_irqs(VFIODevice *vbasedev, + struct vfio_irq_set *irq) +{ + VFIOUserProxy *proxy =3D vbasedev->proxy; + g_autofree VFIOUserIRQSet *msgp =3D NULL; + uint32_t size, nfds, send_fds, sent_fds, max; + + if (irq->argsz < sizeof(*irq)) { + error_printf("vfio_user_set_irqs argsz too small\n"); + return -EINVAL; + } + + /* + * Handle simple case + */ + if ((irq->flags & VFIO_IRQ_SET_DATA_EVENTFD) =3D=3D 0) { + size =3D sizeof(VFIOUserHdr) + irq->argsz; + msgp =3D g_malloc0(size); + + vfio_user_request_msg(&msgp->hdr, VFIO_USER_DEVICE_SET_IRQS, size,= 0); + msgp->argsz =3D irq->argsz; + msgp->flags =3D irq->flags; + msgp->index =3D irq->index; + msgp->start =3D irq->start; + msgp->count =3D irq->count; + trace_vfio_user_set_irqs(msgp->index, msgp->start, msgp->count, + msgp->flags); + + vfio_user_send_wait(proxy, &msgp->hdr, NULL, 0); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + return -msgp->hdr.error_reply; + } + + return 0; + } + + /* + * Calculate the number of FDs to send + * and adjust argsz + */ + nfds =3D (irq->argsz - sizeof(*irq)) / sizeof(int); + irq->argsz =3D sizeof(*irq); + msgp =3D g_malloc0(sizeof(*msgp)); + /* + * Send in chunks if over max_send_fds + */ + for (sent_fds =3D 0; nfds > sent_fds; sent_fds +=3D send_fds) { + VFIOUserFDs *arg_fds, loop_fds; + + /* must send all valid FDs or all invalid FDs in single msg */ + max =3D nfds - sent_fds; + if (max > proxy->max_send_fds) { + max =3D proxy->max_send_fds; + } + send_fds =3D irq_howmany((int *)irq->data, sent_fds, max); + + vfio_user_request_msg(&msgp->hdr, VFIO_USER_DEVICE_SET_IRQS, + sizeof(*msgp), 0); + msgp->argsz =3D irq->argsz; + msgp->flags =3D irq->flags; + msgp->index =3D irq->index; + msgp->start =3D irq->start + sent_fds; + msgp->count =3D send_fds; + trace_vfio_user_set_irqs(msgp->index, msgp->start, msgp->count, + msgp->flags); + + loop_fds.send_fds =3D send_fds; + loop_fds.recv_fds =3D 0; + loop_fds.fds =3D (int *)irq->data + sent_fds; + arg_fds =3D loop_fds.fds[0] !=3D -1 ? &loop_fds : NULL; + + vfio_user_send_wait(proxy, &msgp->hdr, arg_fds, 0); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + return -msgp->hdr.error_reply; + } + } + + return 0; +} + static int vfio_user_device_io_region_read(VFIODevice *vbasedev, uint8_t i= ndex, off_t off, uint32_t count, void *data) @@ -179,6 +298,8 @@ static int vfio_user_device_io_region_write(VFIODevice = *vbasedev, uint8_t index, */ VFIODeviceIOOps vfio_user_device_io_ops_sock =3D { .get_region_info =3D vfio_user_device_io_get_region_info, + .get_irq_info =3D vfio_user_device_io_get_irq_info, + .set_irqs =3D vfio_user_device_io_set_irqs, .region_read =3D vfio_user_device_io_region_read, .region_write =3D vfio_user_device_io_region_write, =20 diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 3f5aebe7ac..053f5932eb 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -9,3 +9,5 @@ vfio_user_version(uint16_t major, uint16_t minor, const cha= r *caps) " major %d m vfio_user_get_info(uint32_t nregions, uint32_t nirqs) " #regions %d #irqs = %d" vfio_user_get_region_info(uint32_t index, uint32_t flags, uint64_t size) "= index %d flags 0x%x size 0x%"PRIx64 vfio_user_region_rw(uint32_t region, uint64_t off, uint32_t count) " regio= n %d offset 0x%"PRIx64" count %d" +vfio_user_get_irq_info(uint32_t index, uint32_t flags, uint32_t count) " i= ndex %d flags 0x%x count %d" +vfio_user_set_irqs(uint32_t index, uint32_t start, uint32_t count, uint32_= t flags) " index %d start %d count %d flags 0x%x" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324053; cv=pass; d=zohomail.com; s=zohoarc; b=eC41p1E+SxYLFIhmRBwiiasSDqLRAuoSTlrBbkXX7mJ+0A1eUZCcDiGeoQSzB1KyrjMFyHqKsa3/C4Tt9rtOb3i1Gv+9H1Yn6sOZANmjhDBU0XvXwS7PAVYb4r2akNarZxYZZ1aY/H35voa46g3WrojLyXbwcBip4JJbx59txPw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324053; 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=9iyNzh7B2IZNZV3nwRHLF27AZsGzUwzs2PSyVUeviCQ=; b=ATAiIgXgkVbScR7hifsWy+aC2LuOvzMvFwSiNVtiX+BuVdJTpHYd5xHN/MbaIis7bja8ZxGCimnL8gDKRiLC3kJe7R4eKfUB7jTuWbnypQot8d5nbkOD8KVPnMPbZ7y9bKXfwjO0gUd+Jg9THmnDtHsi8TW4HDMf9boMxwsVPXA= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 174732405373863.40059114752262; Thu, 15 May 2025 08:47:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFang-0002y5-R6; Thu, 15 May 2025 11:47:13 -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 1uFam9-0007VM-Ao for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:37 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalz-0006RK-Gg for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:36 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7p8s4009723; Thu, 15 May 2025 08:45:10 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010006.outbound.protection.outlook.com [40.93.1.6]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcwwdyw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:10 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:45:06 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=9iyNzh7B2IZNZV3nwRHLF27AZsGzUwzs2PSyVUevi CQ=; b=J+pB4I/b46KakSyPzGYZfD1IIs6VvoqJNLS0w/nI7er413mud5kds8W3Z QBsZctwQsfZfQ7bmmhlWAJ9ZJTEY7w7O4EBFKsoeGQL2K5jNhjhcSFcyGuKs4el6 O1DhSGiYlgH39XMAXx9yiALCEmln/tI2OLH9jhc2ndRqGpsqhECZ6nCmFbe03i8m DDvwD24eZLu6dj3/ZDkr5yW/lb2XmZ/O7NmD7gR5XI2x8gcdRq4IUXDJPhZ5hMsJ ggs76Mm8ngqZJFo7k+OIw7H6ZE0AwRok8wsqY3ZqAutFSFtijJtE731ZbxKumhwQ GB/s899eQSnieR9ywYX7x5vv4ioyQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=F3a7rxBLnT9Cm2NyDD+C3nPBu0dk5iQ77SUNV0ix/Sic672gwn9zc/hBr12Z5OSto07obsvyaIaFs4RPlx/77hGZt1mYJCEeMPLI/0u7Jb/uDK+AJU8bKNti87zBpDI2/aOBvar7XFtpkKFHrRs+NotttoDCz/XPz0+DiCinXnSH+07GeptTzKQecB0YMvL5z9ErtjmdgKqCIZcNcQNFq3fmdbQWiQ94o+8qR8H2TxzagbRINtNhnYPjjVzErG8Mg/u48gPNJ/X8Oel7i4zx1i0GYE3NTW2M/Bxjiws8r+YS7bdOugUYPpHhbx2IHPn8kiY2fCPPrSVznvsotQY3pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9iyNzh7B2IZNZV3nwRHLF27AZsGzUwzs2PSyVUeviCQ=; b=jdGVZuSnk6hoGE19lWbieuZQ3dE696wJZOhq7ioRWSHxaVjbfTBjLfzkscB0vrr/guAR58eegABY9x6RTcebjHTWcD+dVOPopPjADY0jANw1hav2kNDooUsp408QtPREZfOaQAG52MhVN7/HEidyFTzlyUAoQzR6dZR/uOkDDXxPpijC6hdz0QxEWohKCPXlxdhpSp+vAky0RRBNoTIloEWg4W1W7fpKmGC009d0uLiOJrEtBrSZacrUJIUu7QyVDCjuBJ2e3NdTs3xxwjMegbDiBgbx13NXfin1Qdn1bzYa27qTFiHl5X1cJGsumd5lzmCljmXQG+aU0mnGTyLuoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9iyNzh7B2IZNZV3nwRHLF27AZsGzUwzs2PSyVUeviCQ=; b=QHWm5XxuLT2wJ+vSBvgoDwEpicz30JGK4Eg0ra4Wkob1afr0wZ3/h+40vSUEf6ILI9E1+U9T+NniZ7lDtKHde9zcGgl7sTTKITLGNXtBkZeaKl+or+n/M9pdbVrzSU6WCiEeVNUehMsN/CSFsUq1cLAxD+CmjGKD9L0wMcthOIL+30N8AjER3sZb2D7cJ8Ci408yug7hg/oWb6OHtoVMnuBsZ+An6HEyjPnCnWiXkvcLoeMGPNjNkEnO2eG7hKcS1BtwSNJ3Qtcd+pQCxjfgLTO7oTJebJFznUR9h6Vcb9+7w22QNzdVTraZ1IyM2XJSOIUiLZ7eMH+nMkNlu7acpw== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 19/27] vfio-user: forward MSI-X PBA BAR accesses to server Date: Thu, 15 May 2025 16:44:04 +0100 Message-ID: <20250515154413.210315-20-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 04dc9342-f991-4025-9cee-08dd93c7774d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7u3R1LQoHH8+pnhL7d3ch9pyZelMrplWpVJorzB5wTyrWGJIhH7NN2t76jra?= =?us-ascii?Q?oZp98TePMDGb/GyQ0Aq2t8Z9sMlxGpBhjGHW5kgbOKFyke9vBapMgXflKWzf?= =?us-ascii?Q?9RpprAye42/9GQBjK+vTp4eSH6xwbxtawSY+5X03lQwUAVNNQeq1A1wgxwdM?= =?us-ascii?Q?mb7Eb8wOa+QEKjBmgt0p5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oXvn8+ZH3PfSvHulzRcMOH12R7xQuIBQCAptRUOill7a+ZQbY9Ag6H4tL3nn?= =?us-ascii?Q?BKdXYtdMx2R5xmO1Vp/cKu2oNhXYR7J2nf0Df1GfIFXz1aFz/mtr67pRlmki?= =?us-ascii?Q?88P5mYTkE3UFpY/JgmpL6swsAzC057K0NjQml2wIRRnUWXsmR66plpXemKfU?= =?us-ascii?Q?mvsbgxr85amqmhbB4BSME8UTZKO7v/qXhcVzSZb823v1jvevARNmWAu+b5Yo?= =?us-ascii?Q?k+ZdVFsLoe+g3PBw3npqvTI73OXI3szYTxuPtc10cZgWOZ5xMvXrkK30N4pU?= =?us-ascii?Q?Ivh7ZWMM5Ny3Xz90Fb2Q0EOwUT85+PaceqgSVyZfGwq1iihQG0oYho27nonY?= =?us-ascii?Q?cG7GR1fx9yk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?E5bap1N9IBvosQ0xWv3r+N7hN77dc5+sre1rAsgwh6nChlxtjjAAp4I4XJ69?= =?us-ascii?Q?6THEFbumlkYzUyYtLv5H92D99gJag8Yz51B4MTxR1Ld1U0BnpuKylVLvOm7Q?= =?us-ascii?Q?bECeSSaeM/PBtc/Ew1yy5Yw40RiyJV6lcRUeC/dyWaUUvyRshBhJGvK+vpLp?= =?us-ascii?Q?njzv/LJj8EUzL7Mn+Im4nSCT4YTnkuul/539rXd9ROmqDkhrBgxH9gPYOSZn?= =?us-ascii?Q?SNGQAqC2n3PFSteDhbNrja1HDbeYvpkZ1Dzdzxh3Fy0uPpa+/x+DyrO9b59K?= =?us-ascii?Q?Qipgp7cPheDD/2Rk3xEBz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ascii?Q?AIr/eDwqfd0oOSNQLDtD/1c/FKCLIswWNxgW8684HhpM9wrrNgrNcsPOOKTS?= =?us-ascii?Q?oM+ZQ0+Ao8tru3OVuLlok87MdReSY8X604fz/4pbgySK93llPmZU7zuuzkoK?= =?us-ascii?Q?gUTH058qrVkVnJe2+PM7QjPxsIkQG0t12H7D2fdnsmL/5MlLe9Ii9HaIDdmE?= =?us-ascii?Q?Pj6Qi3pzz77+0MyfF3krOUASBOt646jUWUOB46tc+pzzoDzO38H/hAem1EXE?= =?us-ascii?Q?3H1IxyUFSNV9svluH0jOomlydp0hCmkoS1+ykyVu/R7fmwCv5QCV7Hwap9NA?= =?us-ascii?Q?P/E2oZUR0qoTdxMjR9FrFnBnb7JbY/zm2qj7XaJMHdPaAaH95P8TAz7U1uK0?= =?us-ascii?Q?N19UBVbVsUHdlCCqp9NoUhysAg/+0kbN0FPZ4g7j?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04dc9342-f991-4025-9cee-08dd93c7774d X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:06.7372 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rNDXUHz8144pKtaYqKZ8qxQGEIhPRxr8mdgq+Fsk63X8JMPnekhjoPEtvOmnzJ1nChs6VG1T0k/pG1VPNssWcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-GUID: rELKMHEX_VUY5foCBBf0OmNOFCX6HttV X-Authority-Analysis: v=2.4 cv=fNg53Yae c=1 sm=1 tr=0 ts=68260c06 cx=c_pps a=CbxOEkXH4sIw/lcH++vrDQ==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=P96-NN1LHiVJMZ2xip4A:9 X-Proofpoint-ORIG-GUID: rELKMHEX_VUY5foCBBf0OmNOFCX6HttV X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX58d7uKa8mncP 0QyXXyzUZUD4nAWCPhI5EzMYkq8cOzUBdex15uH3SWi4kFbuWWGQ2NdfCjiE6LvePicWZBOEmQT TsIp83AswC5ljcaAYZDw26ccA5D2NcEJd5SM5s8FsAJ0zgSa0jLAtqCVzi9nkEppm5V/lv98r64 os7OHCuPCedwRcsUF9H+B29WvT70J0lXwDlx0OQNNX3voNQi0ciVYlz37smXsr+XFqGxUL32Nig 8uI4DpWFqm2YJ3fv4z1TBtkvu+xe4rSEtKGm1SZoEWqJ93HwnsXDfBNQVEFz2TWlVZ0sQiwV5Vk jlIRQ2MzQkpUxD7VB8/L6Oq8MZoKKynGYjHiuLuuJ5Q4Qte9kqYYbEtIRSKUqfb+jqLSIzHcAMv 4xF8p8rN2GTwY88uYvfNLmiTaH8w3jIiZ1a6O+MaPWLNDemcUByDuVXX6mCVLcUjx0OPKody X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324055205116600 Content-Type: text/plain; charset="utf-8" For vfio-user, the server holds the pending IRQ state; set up an I/O region for the MSI-X PBA so we can ask the server for this state on a PBA read. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio/pci.h | 1 + hw/vfio-user/pci.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index f6524cffb5..80599454d4 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -116,6 +116,7 @@ typedef struct VFIOMSIXInfo { uint32_t pba_offset; unsigned long *pending; bool noresize; + MemoryRegion *pba_region; } VFIOMSIXInfo; =20 /* diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 08edb611ff..a6921a8f2e 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -26,6 +26,62 @@ struct VFIOUserPCIDevice { bool send_queued; /* all sends are queued */ }; =20 +/* + * The server maintains the device's pending interrupts, + * via its MSIX table and PBA, so we treat these accesses + * like PCI config space and forward them. + */ +static uint64_t vfio_user_pba_read(void *opaque, hwaddr addr, + unsigned size) +{ + VFIOPCIDevice *vdev =3D opaque; + VFIORegion *region =3D &vdev->bars[vdev->msix->pba_bar].region; + uint64_t data; + + /* server copy is what matters */ + data =3D vfio_region_read(region, addr + vdev->msix->pba_offset, size); + return data; +} + +static void vfio_user_pba_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) +{ + /* dropped */ +} + +static const MemoryRegionOps vfio_user_pba_ops =3D { + .read =3D vfio_user_pba_read, + .write =3D vfio_user_pba_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + +static void vfio_user_msix_setup(VFIOPCIDevice *vdev) +{ + MemoryRegion *vfio_reg, *msix_reg, *pba_reg; + + pba_reg =3D g_new0(MemoryRegion, 1); + vdev->msix->pba_region =3D pba_reg; + + vfio_reg =3D vdev->bars[vdev->msix->pba_bar].mr; + msix_reg =3D &vdev->pdev.msix_pba_mmio; + memory_region_init_io(pba_reg, OBJECT(vdev), &vfio_user_pba_ops, vdev, + "VFIO MSIX PBA", int128_get64(msix_reg->size)); + memory_region_add_subregion_overlap(vfio_reg, vdev->msix->pba_offset, + pba_reg, 1); +} + +static void vfio_user_msix_teardown(VFIOPCIDevice *vdev) +{ + MemoryRegion *mr, *sub; + + mr =3D vdev->bars[vdev->msix->pba_bar].mr; + sub =3D vdev->msix->pba_region; + memory_region_del_subregion(mr, sub); + + g_free(vdev->msix->pba_region); + vdev->msix->pba_region =3D NULL; +} + /* * Incoming request message callback. * @@ -133,6 +189,10 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Err= or **errp) goto out_teardown; } =20 + if (vdev->msix !=3D NULL) { + vfio_user_msix_setup(vdev); + } + if (!vfio_interrupt_setup(vdev, errp)) { goto out_teardown; } @@ -180,6 +240,10 @@ static void vfio_user_instance_finalize(Object *obj) VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(obj); VFIODevice *vbasedev =3D &vdev->vbasedev; =20 + if (vdev->msix !=3D NULL) { + vfio_user_msix_teardown(vdev); + } + vfio_pci_put_device(vdev); =20 if (vbasedev->proxy !=3D NULL) { --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324290; cv=pass; d=zohomail.com; s=zohoarc; b=d4jNXo7NMfiukfBgLTS13brnSQYahlKh2T+D98+aYK7567Lz69ng0lJ9mE4GTFcz9EiuNQtmZtqCmaaEp35tek1W8DaC8zslaCqEfEDnXWqruBzwkANmg/qivw6jbMnC9sycxTy3NJXFF9fYgFrBzDEMaIXjjz4vZ4DQ9y/k8ts= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324290; 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=le0NKHZtXWjCySeTO7S61i/syVWzvme3vUpWwRiOyn4=; b=TYg3whPfMkZxcPQ1m6/o6e2+JAkSF1EmXgdlWO8HskMxtIACg0tvx32mqke3jT/cJqB1gchpT/K4UTYJ5EEAPN6TowULrx1oEGoAci5Fu12/k8qYYrjqVesNMLoKnF29M0wHZ+d2Iq9XVhYgSC7HuFG0hyRD65cq+YwKvS3GfPg= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324290464176.73996559778413; Thu, 15 May 2025 08:51:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanL-000175-Gz; Thu, 15 May 2025 11:46:53 -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 1uFamF-00082P-Ht for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:44 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalz-0006RN-AE for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:43 -0400 Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7p8s5009723; Thu, 15 May 2025 08:45:11 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010006.outbound.protection.outlook.com [40.93.1.6]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbcwwdyw-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:11 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by BY1PR02MB10459.namprd02.prod.outlook.com (2603:10b6:a03:5a8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8722.21; Thu, 15 May 2025 15:45:09 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=le0NKHZtXWjCySeTO7S61i/syVWzvme3vUpWwRiOy n4=; b=NlGyOucS73oL6DVyHsdnO9kxonOphUfFnmeEg0ljoEnygeOr892renGmR oXjrH5eitha70AFGwvW9jlGVf8TEgArmOcuB8V5PQGzXc9vQc5OfC7fYvAux7mhF ykt1wAjyUTwOm0RNew3e1dQ10y8t4lWkq5D26ijYeoAsDROEjOzDjlYZmsxKEkk9 y2QuApAJAoSkKAbixsn57F/ivv+ZW7mtrPidu6n6YSJRtBbUuYeewNbLhl+9qtI3 hW90brgC6M2XvRk1bGbTbRQuQ5TRQ/d+AQpTlw6JgwHMAjgGQeqg7SCbbX9R5Lv7 pEPqQcxdI1JO3gM7pIx7b7yXQkgKQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uEIPsTI9ZYuDuOT/06YxAeANq4+2Mtay3aB+fzxY9uYMaXRWIpHH9HDl/j4SYG2reJMAkCWxQFtbNtBkjXUk1+DNc2mJIqhKC6iYL1FXEo3t3L0bPteGFvm6UXVe+8E7obgzBWAKzDTfIoQD0L9oNidXt44pYSJPK7FjrRm/Ouj1s/lyZoI77MTaych6LpCQJovAExS6ot+AXlE1uG1yK2gJiY0NnRgi6zWHvYQ9xJQrbtAXBSHK7KshXWpVrvVQ+bYb+WBQiaOK+65uQuJgdJbeKfXSSDdXBAJ9fyYh0T17xBSfzubalRDr0DFSRYMz8/5xxOA4KeWnqSSy5NjiAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=le0NKHZtXWjCySeTO7S61i/syVWzvme3vUpWwRiOyn4=; b=qpBYWmBQYaLmDBCvXP/FCt/qbbJMtjUWrH9BTw5gwmrVrDGnN+rfEYukvEz1+jGNGTHxkyq5bwUR3arNpg021/MSs9hx25LovG9xFce0KjMqiPH0d8I69aPIIP5O1M6riutdRt9UQ6qGxOOf113ohsbUZi8uShCK7nQRfw1pa9gp+dAox7vFnFcFMO0oU4qMcXnV0PTe/tn5HTBkGXKA1ONcACxyItNThD997jI11f6AwcBhQRivOJ2LKY+XZdpjkTUDVKmkf8d9WaqP1Cpz73KbpHCmifvx4Wlxu8CJaIWnEVZPGjLvgwgHJQ1PwC407OVrfmRNX4gWC0Iu1zJXVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=le0NKHZtXWjCySeTO7S61i/syVWzvme3vUpWwRiOyn4=; b=T2WOEqLuNey61msYahZtJMlO2+eC2lt9raGKel+zxbvqH/Jdx6A1dmVsp40bYlLEjbfPlokLnnorZFiuHN6rWKIy7XAEK4ZRDq/7o9awxywXLbm7DJ6R//xYywmbcgHyzpvkHSo4tHj5HE0wOdc/6rIhkhNvJKz1X1x/hV5tytEVP9lDGe9QuoXeJbwKU/CQdVOR3wWRpKJilt/KXRlJbJbnkhd/4JJqI0EYVQG6ZLi2EGjSZlihDzgEDPBsHt6iOaqtjpH0QQnkqVxSgmBHJ7L2F5G/XyXnRZB+C7InL7D/DX9uai6WZE7UKb5c1aAJm/MV6DYJB9J6Tu1aWTjQvg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 20/27] vfio-user: set up container access to the proxy Date: Thu, 15 May 2025 16:44:05 +0100 Message-ID: <20250515154413.210315-21-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|BY1PR02MB10459:EE_ X-MS-Office365-Filtering-Correlation-Id: 0689cd97-5975-4d87-216a-08dd93c77913 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gvdlKTHVZOY3I2n894AMZqjEiPqfEJ0htx8l+RzHC2ZN5Ky/YD9TUi7n8/mu?= =?us-ascii?Q?pz3fIwcCXndfmPEH/Gct0/zLhe84ZhKK7XgbsQvOLKJrRruLqoNQpINpdAc1?= =?us-ascii?Q?5AvSDMGfu8fXAu7zCMjTI8cb33B7LgF49eVkOFDp43YFPBTuOV6K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2ujrd3S/8AQW10UGOaYU8LcHLDXdf/2t//xH7yr4BRN68AK?= =?us-ascii?Q?a5qdPKRyLl2DRg5zciWRiffb/ikE6ZPWAz9cSnU0Ni+E0Gx4L+ysLjSSy+6s?= =?us-ascii?Q?WFPTYcPm6AXlBPtRF1oD0AWQ9vdgUqxNASltVJSR0Gaf7CvvtEOpo1UI14vU?= =?us-ascii?Q?YYs3RzgfSFGEu6FFspU0NJvHjxXAZij1fXHoRYeAWVbnEQ3tjfKb4yC618e4?= =?us-ascii?Q?PIGp2IXZ2MO2+73IqVMpUrJ25kGBHLCNbIu8jQ40rDdsjKCzn6VRjQ1ENv4f?= =?us-ascii?Q?FrDdlqAJLzqFjKVtOaXcphEh7Kav0hNDdjr9WFuVtG3h9SuexDgYD1Z11/fE?= =?us-ascii?Q?YI5HIO+Y7yCEy1lKyOzV5sSKgsBwMdT9BXfMNzKD1RXycf5NnvRSEhQY5ott?= =?us-ascii?Q?fQ3Prk5hluA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ua77jbLPFmGAJs41wvXgGiFYDp6hN5dpMaXJ4MT7KaQqXnNmclRpXv41o5Lm?= =?us-ascii?Q?9eTfrbJkdFoslHafHqfllKrI0GYJ2O/gQEEhOaz3vibRERJ1hRLcWKNE/W46?= =?us-ascii?Q?rRinUd0wnb9KI6gV5Mhs87ZhUQoWRs7ZgXh1sG17az3pxGg3+tFsHUHD1U/f?= =?us-ascii?Q?H6erU5hFHj5mRUxjIiKQJJIIz5maHflNGalGPEQRkg7l4tHf84EQMFGL8gID?= =?us-ascii?Q?jWuBJBd+ciK1rsk2xt74vcs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AcR7?= =?us-ascii?Q?MFkNxqjIgt7zjjHrWYhLfzZ0cHaC6gNz9ReLOuVtx/A3r70mMJGPUN2dIo0I?= =?us-ascii?Q?DTKmc5NYLUjDaHPpeRWxcGdlE86yceuEFHY5gnMRtnME4e5VujgMayEUOBBd?= =?us-ascii?Q?jKJWz+2IXwASnH5Xe+XOHmf1eESLzYd7zhPBCLjLUwpaO0iAYYmpahfXynen?= =?us-ascii?Q?3JjXZ2IfKnBDszSuJ3LR5wgx53yhzmgFcXoSwx5+AdEWGdv8R2oI5JdEi8QB?= =?us-ascii?Q?T3nPRDLc7HS2XVqVdQb/idHc07Hv+yGmhIjFmPq5QMtboPXTuj5lmjVe6DEb?= =?us-ascii?Q?WYqWCr1fX66InEIgGpcTA6NEqqY+Og0VWES7Epno5CUqn4TKzdEjGBdMCuV0?= =?us-ascii?Q?ofctBABxyUDVKBB3VWTjrwi/ezd7112SUwGaoq/iZoTW6vCw4bqgg8UGQ7CV?= =?us-ascii?Q?7QRstXvWwbnDzeRr76vY3Z1EI0D8iL6Hd7lUPsf3?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0689cd97-5975-4d87-216a-08dd93c77913 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:09.6886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4Jl/dRu1WYvGAPZ9KbME1rLGVqn7CQdDcwvOtGzPxygSGfAiJBhB1kn91CV7+XGl//XuagWnG0WimelKQzX/6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB10459 X-Proofpoint-GUID: zbJq7kCxITLW43RRuleNrS2AiVLdOXiH X-Authority-Analysis: v=2.4 cv=fNg53Yae c=1 sm=1 tr=0 ts=68260c07 cx=c_pps a=CbxOEkXH4sIw/lcH++vrDQ==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=eNiANMbe5KInMaSQXcgA:9 X-Proofpoint-ORIG-GUID: zbJq7kCxITLW43RRuleNrS2AiVLdOXiH X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX4FHGV9HWuOtV yvGYuERQn0voAkjPdVHWpli51FOZxAmpOpX9u3jZiDigKwVDoNPspKqaJudiZ3ld7a0WZppKeTv 0PoPMK2/WxZkGLDU3lUp4E92G59Rovbei/SXXi0fWp9tlzkwtR3Y+9r2GLMRfsahcNzwPA6QdeL LDiP0LutLoZfzOAOviEUbQMG3KIQOYuGwyPR2nXNzZ9+8F4fec4rWk8J0CqM7ixtiK267sUvAN+ mU3vAWnbxPBmO6Se7exAoJxnl4tqbCvL8RVNaB/jIEc1QABm538cNDF0ZiW3hiwWMUl4D/0N3PF n9bUdcsRg3GXtyqyoWaOwIWWFg1B4+tPi262o4tLT2aB/73Z/j0G9fQqRfB3fTk6dQrz/f7KM76 7jjteFHmLuK+X8NSZf27YwEOc2SOx9kvippM9GR9+SCoj2R6BHUYSDDSAWa2N4WlXvlZouiU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324291806116600 Content-Type: text/plain; charset="utf-8" The user container will shortly need access to the underlying vfio-user proxy; set this up. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/container.h | 2 ++ hw/vfio-user/container.c | 43 +++++++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/hw/vfio-user/container.h b/hw/vfio-user/container.h index 3cd3303e68..59e14cf5b3 100644 --- a/hw/vfio-user/container.h +++ b/hw/vfio-user/container.h @@ -14,10 +14,12 @@ #include =20 #include "hw/vfio/vfio-container-base.h" +#include "hw/vfio-user/proxy.h" =20 /* MMU container sub-class for vfio-user. */ typedef struct VFIOUserContainer { VFIOContainerBase bcontainer; + VFIOUserProxy *proxy; } VFIOUserContainer; =20 OBJECT_DECLARE_SIMPLE_TYPE(VFIOUserContainer, VFIO_IOMMU_USER); diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c index 6f0eb86a75..38e9cf8d8a 100644 --- a/hw/vfio-user/container.c +++ b/hw/vfio-user/container.c @@ -53,15 +53,28 @@ static int vfio_user_query_dirty_bitmap(const VFIOConta= inerBase *bcontainer, =20 static bool vfio_user_setup(VFIOContainerBase *bcontainer, Error **errp) { - error_setg_errno(errp, ENOTSUP, "Not supported"); - return -ENOTSUP; + VFIOUserContainer *container =3D container_of(bcontainer, VFIOUserCont= ainer, + bcontainer); + + assert(container->proxy->dma_pgsizes !=3D 0); + bcontainer->pgsizes =3D container->proxy->dma_pgsizes; + bcontainer->dma_max_mappings =3D container->proxy->max_dma; + + /* No live migration support yet. */ + bcontainer->dirty_pages_supported =3D false; + bcontainer->max_dirty_bitmap_size =3D container->proxy->max_bitmap; + bcontainer->dirty_pgsizes =3D container->proxy->migr_pgsize; + + return true; } =20 -static VFIOUserContainer *vfio_user_create_container(Error **errp) +static VFIOUserContainer *vfio_user_create_container(VFIODevice *vbasedev, + Error **errp) { VFIOUserContainer *container; =20 container =3D VFIO_IOMMU_USER(object_new(TYPE_VFIO_IOMMU_USER)); + container->proxy =3D vbasedev->proxy; return container; } =20 @@ -69,16 +82,18 @@ static VFIOUserContainer *vfio_user_create_container(Er= ror **errp) * Try to mirror vfio_container_connect() as much as possible. */ static VFIOUserContainer * -vfio_user_container_connect(AddressSpace *as, Error **errp) +vfio_user_container_connect(AddressSpace *as, VFIODevice *vbasedev, + Error **errp) { VFIOContainerBase *bcontainer; VFIOUserContainer *container; VFIOAddressSpace *space; VFIOIOMMUClass *vioc; + int ret; =20 space =3D vfio_address_space_get(as); =20 - container =3D vfio_user_create_container(errp); + container =3D vfio_user_create_container(vbasedev, errp); if (!container) { goto put_space_exit; } @@ -89,11 +104,17 @@ vfio_user_container_connect(AddressSpace *as, Error **= errp) goto free_container_exit; } =20 + ret =3D ram_block_uncoordinated_discard_disable(true); + if (ret) { + error_setg_errno(errp, -ret, "Cannot set discarding of RAM broken"= ); + goto unregister_container_exit; + } + vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); assert(vioc->setup); =20 if (!vioc->setup(bcontainer, errp)) { - goto unregister_container_exit; + goto enable_discards_exit; } =20 vfio_address_space_insert(space, bcontainer); @@ -112,6 +133,9 @@ listener_release_exit: vioc->release(bcontainer); } =20 +enable_discards_exit: + ram_block_uncoordinated_discard_disable(false); + unregister_container_exit: vfio_cpr_unregister_container(bcontainer); =20 @@ -128,14 +152,15 @@ static void vfio_user_container_disconnect(VFIOUserCo= ntainer *container) { VFIOContainerBase *bcontainer =3D &container->bcontainer; VFIOIOMMUClass *vioc =3D VFIO_IOMMU_GET_CLASS(bcontainer); + VFIOAddressSpace *space =3D bcontainer->space; + + ram_block_uncoordinated_discard_disable(false); =20 vfio_listener_unregister(bcontainer); if (vioc->release) { vioc->release(bcontainer); } =20 - VFIOAddressSpace *space =3D bcontainer->space; - vfio_cpr_unregister_container(bcontainer); object_unref(container); =20 @@ -169,7 +194,7 @@ static bool vfio_user_device_attach(const char *name, V= FIODevice *vbasedev, { VFIOUserContainer *container; =20 - container =3D vfio_user_container_connect(as, errp); + container =3D vfio_user_container_connect(as, vbasedev, errp); if (container =3D=3D NULL) { error_prepend(errp, "failed to connect proxy"); return false; --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324180; cv=pass; d=zohomail.com; s=zohoarc; b=XvY9fliQlj8revbpVNDXYJXMx9bt+zcNwcxaysX7NFTv7FzE0JYqWEVHmwprKGkLdG4cGpiJJgu4IKLbAN60vrR80FDd+fehkSyBz0iqFqsLZjAl7Fdkk6xSIlLJFiuy/PRSM2rImGXkQvBHiWOYK+CYeGj1CQcGSyKzc52/a+E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324180; 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=bdEMl2PV2mxwHWts3yLqrjYyqtaVK1ua+Crr5QMLZok=; b=M7hYAiGc16SBJ0lx5RJIPPQGLlAlHiosYvHCUb8HYo6O6cCq0DiJoRay+FwaNYABRX3IV7pqm9fg3zP30w4oqB76cAuJCHsRB25LcM7LUa6ZoSTG+LVGX+GqFxEJ1zDAdCU9h8+8Zk97AK1WiBDtE0BopqatRoZOGkVJDJ3aAQ8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324180106119.28987506870772; Thu, 15 May 2025 08:49:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFan2-0000Ff-CI; Thu, 15 May 2025 11:46:32 -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 1uFam6-0007Gq-JS for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:35 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalz-0006Rm-8n for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:34 -0400 Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7nlpu026476; Thu, 15 May 2025 08:45:16 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010007.outbound.protection.outlook.com [40.93.11.7]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mjmtvrfa-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:15 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:13 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=bdEMl2PV2mxwHWts3yLqrjYyqtaVK1ua+Crr5QMLZ ok=; b=0gqG6ykCo3DVV1W4hOS4yxr7Fg8T+39J28LjoXHF45Oj90xNNUka3xbgG N8gt7CdPaqSanQhYcAccsJHF/8oAKGdhYnJDNoJiOy1FAIlFXnt+Oyud0nUAepgI Q474HBHvHfs1o04Nt1ODsZZY3mcClnP4mLj6nqwnREWCQXRDHxOx8Yq/svAN+Rdv rCEmvXns1c+m6XrPN7t1LmamC379biB2Lp4b7A6/vgo8hfhURQxVKxW8WkGDyDT9 4Ke+InxmvwgFsTclaH/KneuhVKZuhkhytAoX1yp+rlv87Y7oNIbPJULpjdKspxka ML4kyqgIsd+yqElImnekCxseiLpiQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XtjAn4hE/poY36he01sHsYq3HXDdEUzOdIY2dqp8dSGMf2Tdy0Avp0etcz5XYj+hQp8yyKK3shu+vgnNJ9kFLC+UWr2Xm1au23SE3aRfIUHT3JXBYEQU5ktLnJuTo0cFcX3aitQYNZr1Ak/qJs0fCO1a7HOt3vmV6FgfQclK/q8FlgBiPH0SKacZeWy5+uinjEVq8XoithxPpwXVPv7D120NcYHJ5YkfBsCzCoxeHRxCj9Z/tdAWF0hee0FNVVho4nvO++Io/R9MdAhLpqOwXgDCX6yPnD798kVm+455OqF3x1Vau+umvcx7iRxzbqP89wD6AlU8N4ordx/G4L+EDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bdEMl2PV2mxwHWts3yLqrjYyqtaVK1ua+Crr5QMLZok=; b=KOF6iOwq/tsqBuqkNS90Sa/cXcMC9U7d3F2KNySAQjSyIGm60k8gtByT1BguInC5P5HH6VLa3tiM3xHILEf4Kzhaa1p1rwSwdnlw5MKINFbysGPgoRnjKt6Y40t+xKsTGzjEJDijbP7XvOneVkPHVk6TOA3DT0ScIxrqLgskXKIlAKGNYOZ9CT7yv6bvr0ZKOtGQjeoTx0a8eKqTKnDIsmNYEqpFlxdzQr896TA8yQEzy2mq1K9x5Rg5DUPAJz+8jEDflu81BuHyDsKcojnqvz22h63IbwCEIxLQZ00J81sx5+sMvrK40+049yPzt34LWJRTHhOXBl9e1ju9wLf5Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bdEMl2PV2mxwHWts3yLqrjYyqtaVK1ua+Crr5QMLZok=; b=yemxW87Gp6zlBwuaTNJkmGmVBL6vaeYZgFADDk3HfR9DnFpabWf7pIGw60F+iYTVO6ZCo9f8w1ra6dzoYtk2xCjsNLsqA+XGm/JdyPdKHSohIgmpgD0j0nryA7r0na39RrxarMMCMMgG39P2nOTTltwdGkq9XEhBaQzvCZ/ujCk3LWgFhUtbN79Fra8Yt0IFHstWp7bmmyhUbn13m7Bi8UW0QcGwEhPYpTQYJS5IDp9XBB+MAqbtm7uOlkTkoF9jS8MIg8m7A5t5qETFqoSt129ciwMkC19Ur4pb0cduFAFMRiW8b3/e93Ogcn/ygIkIbXgVxy40EivELrg364rxww== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 21/27] vfio-user: implement VFIO_USER_DEVICE_RESET Date: Thu, 15 May 2025 16:44:06 +0100 Message-ID: <20250515154413.210315-22-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 25a7c810-dabd-42b3-1ee2-08dd93c77a96 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GAUi6h1r+naPujyTkiKvDkRdm62v1ERfTD/zd/SkqNPjkyxZCOJKe7JsFFbI?= =?us-ascii?Q?b+WbE7QiNIuhSdcCURD0NjUoC/1X/WYBfy4cyRdz/k08NGxB7TTVwgxA61d1?= =?us-ascii?Q?rfWvio7IQbS3XD2X4NsgTkn3LMUv864Igr21J3GV2B09GWPBRz1FfvtYGgIr?= =?us-ascii?Q?me1g6SsllH1QGGGcqJT3++vim4bPUWz+5/Gjh/UpVxIWdQk47geMVoOvxOmj?= =?us-ascii?Q?ISH3wCV8zmvm0LRvYZASVo7PE6ztbySObTjFcuH91LlqWOmtlvzMRmGyPhyo?= =?us-ascii?Q?3G03Q/h8Ln+Ny1qAAzz73pk/ikCHS0KwR3uoxtPYsZK7yl/Z8D1XyPsQQXWk?= =?us-ascii?Q?sWgYY63Ylw7IEG8ph770fuAVdw45RLtEgmszTcZAZiSCMVOwOysNjbALorle?= =?us-ascii?Q?wC+PaePwm4I23K4iVQwhH28Her7ihfkgaUBMCMDXLL/yqHZjLadscq1N93AV?= =?us-ascii?Q?SHlxVndx/bPsEn1sfsKtpEU59fYGyABWdKWUkbm4Zhvw3l/1WGp1bSj65/M1?= =?us-ascii?Q?fG2nF5G8nKpUZwKDg7Sk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q?5CDHivzcfzw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?u+Yqt0XqbDT9k7HEBkVG45Pc09egz/qa0UYOixJq8NawiO2znYWl4oAnf35p?= =?us-ascii?Q?U/oaCOs99hCCf2gFi0rFWavXN7hYrDwMTFsgXQwi1iPCDL33x7rvkWsZFelq?= =?us-ascii?Q?Wr67ehrBH+0iQqsACMkiqurhWkj3fdcW3vP9tOmqpSlMZKcXn2qGHM6dkcV0?= =?us-ascii?Q?1p4TgX5GH6MQxnIkP8KR0skuWokf3oH2cYifCoavkqK1DLd8MO0p+eV06CTW?= =?us-ascii?Q?UXQwii4HxMGh3+n82H2W4yHxpA0x2u5aFrNi9LSarMu/aIwLgEqlqrTdyNtt?= =?us-ascii?Q?Cy3bXZqDeA6ubmU3V8GDEqTnM20tgk3oB21FI620gcHqLSXL1vpHg8SQdfIj?= =?us-ascii?Q?RUKtSbDIOJkzrIDyKSBAFVXBQ018Tk9u6yMPikIVpB5dE0xm668TlhDuIJb3?= =?us-ascii?Q?IBckropVWsoSe2KI2Eazny8kU3h9a8AeUM9ia5eMhjrSnmqeNZh+Z5Qe4Enf?= =?us-ascii?Q?3NX0dVrq+8d6h/uEz4wl3QJJuSZiPlL2YSN7P1Usz5EJKaHQMV3OVEL5xUL+?= =?us-ascii?Q?nG2rqjSjpD1QVKJAs6DzqaUzRLXz27nMf58jsWlltMtGvz+xJz+Ejvy0lnxW?= =?us-ascii?Q?pK0SbuXWz4cFShRPcARL8QUWzxKl7p4qYn0Dxywo7PSjjPk395gX9SbAhKxe?= =?us-ascii?Q?XNGfJ+mxNRsR3x+7h2y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LcPxyZg9xlO3CPgPF?= =?us-ascii?Q?3jj4IhMb22qMgSVlK3kt3scoi0pzhmd0LLKNrEIp?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25a7c810-dabd-42b3-1ee2-08dd93c77a96 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:12.2233 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oUsMWRnHsws1eldnY9ZnKS8gZTDkldH924Sf+AplByzCfnf50rbxUe/hkxUaqh8btYXPl5w1CXGOvI/9astpHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=TauWtQQh c=1 sm=1 tr=0 ts=68260c0b cx=c_pps a=kylQlKNaLH8A8Uw3zR316Q==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=70NfNXkHNs9el5T2m-kA:9 X-Proofpoint-ORIG-GUID: CgWOhvZY_RSK4jBWbRXpWa5xkj7qeMFB X-Proofpoint-GUID: CgWOhvZY_RSK4jBWbRXpWa5xkj7qeMFB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXzkhEiXchOw/2 adDmJPLtJS1mvMZGySJhyiTysBCL7qrAuS5Bh9HZnxD87DogJTL4yhBc5NPqVh/lxK3sFmtQLfv ANFN3u0caXcs50xPhNJLOJ/MHRv7nZ5wHWN3wW734EtBRhaHMyRBekczviV+oR5ouAMqzvAS5wL eNJtvB7dAxmfiMFqqmvxq6AMyxw4VcIWCAzdylzLgRGxtYkO1QG8URZtdmtbNpfOZi2rDgv7pjs K7/5KnWY3WW6Sfh+CNMleOCi+GyGwzgbPCamB1Krh8EXwdRgh/8vm+Y3bIGwKOjdFyO6z09u5Qf ygG/dd+z5iihOAUu4uu6AMF6yv6LNrXznN+UULXI6j06WcmA15suOcHKKLSTLvxOwD7l+qct244 k+vwsgZqGsR1zfVgH8nTeg0N8k3nDH2vyc1n23PlAA9J8Kt3IhTQkzp9ZzGxgdCnSaoOGgU7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324182426116600 Content-Type: text/plain; charset="utf-8" Hook this call up to the legacy reset handler for vfio-user-pci. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/device.h | 2 ++ hw/vfio-user/device.c | 12 ++++++++++++ hw/vfio-user/pci.c | 15 +++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/hw/vfio-user/device.h b/hw/vfio-user/device.h index a5a2aa9ba6..25cd4c8a00 100644 --- a/hw/vfio-user/device.h +++ b/hw/vfio-user/device.h @@ -20,6 +20,8 @@ int vfio_user_get_device_info(VFIOUserProxy *proxy, struct vfio_device_info *info); =20 +void vfio_user_device_reset(VFIOUserProxy *proxy); + extern VFIODeviceIOOps vfio_user_device_io_ops_sock; =20 #endif /* VFIO_USER_DEVICE_H */ diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index 45b91d22f0..b37f7329a1 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -49,6 +49,18 @@ int vfio_user_get_device_info(VFIOUserProxy *proxy, return 0; } =20 +void vfio_user_device_reset(VFIOUserProxy *proxy) +{ + VFIOUserHdr msg; + + vfio_user_request_msg(&msg, VFIO_USER_DEVICE_RESET, sizeof(msg), 0); + + vfio_user_send_wait(proxy, &msg, NULL, 0); + if (msg.flags & VFIO_USER_ERROR) { + error_printf("reset reply error %d\n", msg.error_reply); + } +} + static int vfio_user_get_region_info(VFIOUserProxy *proxy, struct vfio_region_info *info, VFIOUserFDs *fds) diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index a6921a8f2e..55cc811d3c 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -251,6 +251,20 @@ static void vfio_user_instance_finalize(Object *obj) } } =20 +static void vfio_user_pci_reset(DeviceState *dev) +{ + VFIOPCIDevice *vdev =3D VFIO_PCI_BASE(dev); + VFIODevice *vbasedev =3D &vdev->vbasedev; + + vfio_pci_pre_reset(vdev); + + if (vbasedev->reset_works) { + vfio_user_device_reset(vbasedev->proxy); + } + + vfio_pci_post_reset(vdev); +} + static const Property vfio_user_pci_dev_properties[] =3D { DEFINE_PROP_UINT32("x-pci-vendor-id", VFIOPCIDevice, vendor_id, PCI_ANY_ID), @@ -269,6 +283,7 @@ static void vfio_user_pci_dev_class_init(ObjectClass *k= lass, const void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *pdc =3D PCI_DEVICE_CLASS(klass); =20 + device_class_set_legacy_reset(dc, vfio_user_pci_reset); device_class_set_props(dc, vfio_user_pci_dev_properties); dc->desc =3D "VFIO over socket PCI device assignment"; pdc->realize =3D vfio_user_pci_realize; --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324045; cv=pass; d=zohomail.com; s=zohoarc; b=Y7283z1iTaHXsU1J3t2Kla4bBuxRXGYl7O6vJ+2oXr1db2jzV6IoS2GXz6pdxIUIBaJtIOn75kv9cqHr2EnZgBQwQAn0gIZ/v46Phd3Q7Ki6MM/Lrk+3/PLHM3VJwwVa5wAjB4dGvLUd+qDw1ytOQGf7XQTB+4dHDoq4WGOzVmk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324045; 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=9s8GGmvHd7YbLvsT1cNsRFjqwTXQbF/N8tWvGuRlBX4=; b=YsBT1V4ZU+GYr/68roefLI88SRZjFrA0SjzOj8phMqbmFa9y+cG6K3iLl1Dp4wWzb5S9l9Esd/9HWVQAdOjTI//0ToiEQ2eH7GB6nxLovuHLkBlwDPgcGoSBu7lxXw71i89NbMqeyVJZVdd9o/JZLsfkU2ZtXtPOKYYq6OuUVc8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324045359286.53877585126634; Thu, 15 May 2025 08:47:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFamG-00082R-Qa; Thu, 15 May 2025 11:45:45 -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 1uFam7-0007M7-Tr for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:36 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalx-0006Rz-IN for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:35 -0400 Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7nlpv026476; Thu, 15 May 2025 08:45:17 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010007.outbound.protection.outlook.com [40.93.11.7]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mjmtvrfa-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:16 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:15 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=9s8GGmvHd7YbLvsT1cNsRFjqwTXQbF/N8tWvGuRlB X4=; b=Pm92cO8DNnTtEpbr7n9ijRTEmbtgexAnxqDkPf0iVvgGhAXKL4NAy2EjP MMqr0HpqX8E3wDNrOFJdCVwqCnMNKdFyC0y7up0z3okwTiL8k9gp3T5B21jNSfqX /kv4Hd7vOCvfiX8hcfhetNv0dvfeiuGhVrfocwCzJSywUOx4BkqiLuvfdzDR4rdO dAlirVAthvGqwUYeLn2MZxZ4damUMBzg1z7D+vFhlMxs9qhjaOiqU7nKFbqd1YZI htmo4uWDb7WYjsg0agqmaNa0wfIZ5bVTN8682IeilZiUxS03D98yDmD5p4g8b0wC mtvtinWLpGi5GY/cUhByILK8oGxaQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rl65DumPqmjCeV1zts+f1RLr2MZRJ46hALaltZzmI8nEnMbnobbZ/Xt16McK+Qsh6FSVZQjoECswxYxM3zx5JATlnx8YdqJbIhRMcC6QqGnk2hsHfdb2I/vh+DxdrQw4PxTiX4U2YT+UKiSD9ZpeBp2Ohf8NDRaBEsFXz6EGoLkZ3KRdhJUCg21e3ICVc/m3pUeqEOy1NVPu7bv9bA4oqVD4rMxbXWS1rmgN0yNjeB6R0LnGRWg2KfLPWC09zTrlV0klg7Z8UiQHJzRJjZ1zKFT3n7JQymLgPyvRrRTcMUqQJGGnSW+InqcWQAgy3it9bqJGTitQIAJ7IhLSgMR08w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9s8GGmvHd7YbLvsT1cNsRFjqwTXQbF/N8tWvGuRlBX4=; b=x4Blp9aMb+UlCheTm0HMbbfax9cFE3uY2v5WmH8n1RSAEViqBhl4rJf1hpGxlVijmUpOlBiT5Ak+taKbIM5kX4jHxfPX15TkovJXA8BnNZoRTmEiN29vWDx23OtoQ/p7nabwjgUFpGOcuF2wS1o0d9DmqA41HFCFgNu1pT1iJTpD//3ebY0f9wMkc4Xu+jxHw54OYijIaFWvdSdhWSl32hd7Z2YzU3mPVB5oc6vHqkTpjZvHcMCKgNqLUBDS5vTLKjw4QIt05v+dk4n+1luerCKsAVqXvgwdMfTc273QM1kuKmA7k4/iBG4bFFKDJU7FqP8oOaM7ipEEpo6Wjjz5kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9s8GGmvHd7YbLvsT1cNsRFjqwTXQbF/N8tWvGuRlBX4=; b=ih6ki/cS7KlKtVq2mimIfgkroT7F6OC6VZpmk+hO6L4W1zhBq4aVHI6vh/YJTx1nNy+7s0DWnHGf7qW49gJHWu9QJd/aXti+QtKel0g4R0hzHF2B8lUmF5sPMsNlhlGH4NLabS7TA/bYBtnP4pmaDdHTQft9S1vrHElaHJT8Vhj6DwsAUik+oGwnwNZyO0uLbXIEmT3xKhHaZXwpoS1VUtfIVxUKGH17ujnHk5yx03dB7bqXSkx0J+FtQapXIlU3YLyG2Xw1ABGW9LCiOvmOD16GuqtiG9hpPkkBFEAxbjx6yKrOFlwGBzhyIlnHbH5tx1hHPO6aEL0cdw5LbFWNDA== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Levon , John Johnson , Jagannathan Raman , Elena Ufimtseva Subject: [PATCH 22/27] vfio-user: implement VFIO_USER_DMA_MAP/UNMAP Date: Thu, 15 May 2025 16:44:07 +0100 Message-ID: <20250515154413.210315-23-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e1e952e-be04-4ca8-ea55-08dd93c77c28 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?shbC0WYSetAKL9PqWj7gSxRd8jdftr9E+b+n9Mk5s5BihX1cxzZwiLKYLE9i?= =?us-ascii?Q?yU/WJtJKTH4LmXHiTmA7ESSRZwmDimsZrVgny1M6UiMOUW9DZLJiRAW5X2vY?= =?us-ascii?Q?4BS2cZcIwctny1HGdfwWWhgoboHfAKYrszuEfLoHLFeNP/wXG6f6rq//myWt?= =?us-ascii?Q?WBbwzRJPtU4Ah1aIWlh13BtdV3gUeUtydy/2lwC7rXadxwQBtajVLw5fDOnD?= =?us-ascii?Q?Z4uMhLCmyukdM9VBx9FXLVR0KxWiNpU8mD3geW5EgQ/+xw8siEMrhELkM/Ag?= =?us-ascii?Q?c639vfJ5TRs7GZ3b7ti78TF2mHRiT69CE3ZdBEG3O95YSFWRF9PDbmtcezgQ?= =?us-ascii?Q?EhuJJXFe5qMmenqYfTv1E+Ynm7Xj0Ej6S0WOCRY2Z7LCrjJ8bCMmgfqi/5ue?= =?us-ascii?Q?OiTMJCeceeDT6rgsVsKnWUzKdqA+01cvb32H614ckfzw7Dj/NDvDzx6rWomx?= =?us-ascii?Q?e0Qr55l19XlunQLmg42VcXU12lZbUiRFmDeWoL+Wcf2bJkudsicMQ3q3i6/j?= =?us-ascii?Q?jmvHFpqKNHoVugC+tyqmhiHna7P0W5piV8gLGBXSgglKhDFiYhM08cgLtfPL?= =?us-ascii?Q?qf5lIQ7zpqrtuY7xhoP4V1dLLAmuOEdfOtzy6J34otg3ekwTICQFkRu0VZL9?= =?us-ascii?Q?v1n+TPiNRwpCeK37M7mH5yGpywSvM41JZgjCT6+R/lJ1jxS3VwDWRnWaxwn8?= =?us-ascii?Q?wYlHahbl3njtlH7LdDoJl1bBfGDicmGywUnpDTJdhUqEVnoSThp+FC4LEwSa?= =?us-ascii?Q?PV4fg65NEEIkmLsztu9nDFRq/0lZfNpiSGZoinUl1k4lRw3h7WETMsI8+wEu?= =?us-ascii?Q?OYrcsaT29JdeT5mb3GNRkXYSlNRM7MoKbtZhCvuciFRIl9taNC3MIl2k/tcg?= =?us-ascii?Q?R//1Ogj3zumqlCf4FScEZTFChOkvhG3I9NbxV8DufZ15he/29ddZ32iGYA6N?= =?us-ascii?Q?icxixdem1JeNIKwqDrB7Z/6iUXMlqHFIYFkAeOPEDandX8VnWf66ZDmBlNgm?= =?us-ascii?Q?cHq4ouNWGJezO9XZE6/JotAsyrcY4Kf69ql/zW7sBxLBkT6XfJWJNLkhlIo+?= =?us-ascii?Q?VFrTKsTPXMOLFt7VeIkkTh9eC8mqisNhRwm+eelkpFSOzfqubBZXzIUXHQSl?= =?us-ascii?Q?UveSInuvC23ID7TVb3v4MDqyGWNYDuwUauQPlAym1LN2sDNceMwy6UIpof3m?= =?us-ascii?Q?t6bu4jQQCqJTvrEpadAHe1IMfjDMeIxHdTCLWhX/Y4sN7vLWh7Xe3FEFpKGP?= =?us-ascii?Q?dhTPS+CER6jtujcS4PegVGbOfd5NC803W0HuLOLkS1fILX+B7p92xK/b94nj?= =?us-ascii?Q?xycuayky3IhdwP+GBXtk4INfydB3qk8HFNFxQjYKYCm4dQ5mj2VvNkrfZBp6?= =?us-ascii?Q?qSsw1zhn2SbY1047GU2hw+ACoRvHrohqkDRkqqvcipn/0R4loqOOQ9/Rw+xd?= =?us-ascii?Q?+cj9k70qq/w=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?d5dg1tIJSfh+zph4UzsKb0MKAusd+w8VoqAo82v1GUUHgd0T0DXDd1Yw3ORj?= =?us-ascii?Q?/LB85gr/sGjsN+cEEnWi9K5mmunEOaamgFdynmqPj54rPSQBpVdRBrwIPxzY?= =?us-ascii?Q?iXP5l6V1ezi3JYnZGBo/QENJGwrMGwnhghgkn/QR0W4/P+NYY+YEJN9pcDqN?= =?us-ascii?Q?WQT9lzMPLtUYUxHIQJgn6QfJ7W1xzm9BD81xxlivWeGWB067mp+UUhGeT/rq?= =?us-ascii?Q?nyDKBujf/STFIQJFRRzPRrHHHF6w8Hn6fcJSqg1Bgwr+VJyrV0Fsomu9Q+A+?= =?us-ascii?Q?5pPBYChzSmp/1YDh+NqJ8pG8d3iZixK83yF4RNNqzAzzsqNzIaatfg+LHRSY?= =?us-ascii?Q?tVa4gd2YAtrI2JiI+O3zz5ThS8Z4TaZbk1t8GbHhlORPBBakNfs0eQECK1n1?= =?us-ascii?Q?gDlHA4myWL605sy6SNTngaOjzgaSKc8+jHGqGi8zy+TEsPuov6LDVWQN5BLD?= =?us-ascii?Q?uGIiGH8PeVw5joTVIoYR3GOTB7B5pllOo5fWgWugq9YbPKxe67/h2kne9MJf?= =?us-ascii?Q?T0LbGLp4Fce5g9/o6wX+P6Ls+FEnGyfjJwHHVoCw9SNSJ1mSqGQzcFkS9h+J?= =?us-ascii?Q?EeAY1xHkUdvZgbHNNr2WClZaeevae8PBht6d7FDMCuKKmNVdfssyBSHZJcn/?= =?us-ascii?Q?MNzMk3axXZ6jSKIG4kVEUYxSb2LxZofpcXZIpbnK2VkZ0xaD9CQwu+27vZKc?= =?us-ascii?Q?8E2nAsrE4ivfKFqDK8wYGMO1iLkMODLX8LQYOyUNONQ+mtVqajW47BsU49hy?= =?us-ascii?Q?QHLGg1gDiA6EyBivRuyZouSMiOo4ztPSWWWFp1eExSNrujkrCEPtovDsAS4y?= =?us-ascii?Q?xax15cyrLYwHjzVMiVIukn6Gl3m44vXIPVDyeTy88qtCRtMN4dezAHYAKeec?= =?us-ascii?Q?1+X0+MmnW5l7+RIuhLXTPupuuRTjq8luO6JeqiivG0zr5YMg3VHlwEi2XwfD?= =?us-ascii?Q?f4iZceQOUjHeby6lWjSVgWpu25LUoKD783zGZj8tPZqr2sByx3aTKVOJNUw6?= =?us-ascii?Q?SrzxzWnorGjEdJCFI5omI+rwOItQJlRZMOxG6nqTo1rcbJxepM58K/pAOCGz?= =?us-ascii?Q?z9fNQFdHscm0DYpijr/UqRexFylGz7KhMZ5tuxh3JSrqTlhIVcHUv67qXISK?= =?us-ascii?Q?85UbIbA0/z3Z8fE9PMfaHDfBIUxbbNovX1h9jDEcNEur3/AFtLfJLv2PvP5G?= =?us-ascii?Q?Py8qd+XyL68bNOm/qNb0gm/+0nV4lgyoikeNZN0WIPxkOfdrHUpl0PpFJrLp?= =?us-ascii?Q?apAd8eSsfef6xMDG3Bizw2OB8CesZM+I5Xl6foeadyos3AOUaNq8eA7B2qpc?= =?us-ascii?Q?Ud/n7EKvA0ehdNHbEySIf4WmeW1W+vtjbo1NgF99Ht50R8DMh+MlOxOD7ncd?= =?us-ascii?Q?aEE3CR3pQ/3R8XluLj8qrCltFvx7B8KQ8Lj9Mqnn+0MRyLT27sd6pOGT9MBC?= =?us-ascii?Q?9SqWZ1hiXkRLg1JHbssoLa4jQJvs9wi5q6FOy2jJNedwrJVe1zUB5y1B6pL4?= =?us-ascii?Q?RDf4vkLzFFZ4AfB3XQUPvdgHiO7luG9xluvYog/J/Zscmd/jK2RcWdxvrNDr?= =?us-ascii?Q?zbggnCUr10J9oE0tYuOM7y/KqaMSzUf8ST+HFF2/?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e1e952e-be04-4ca8-ea55-08dd93c77c28 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:14.9578 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HZKaUEDmAvBxc7zs1DDLgrILevYzh0Tql/pll6AOYKJPGlC+6ca62eMCMzYcdG1I25ROstahErnXkJOONqb56Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=TauWtQQh c=1 sm=1 tr=0 ts=68260c0c cx=c_pps a=kylQlKNaLH8A8Uw3zR316Q==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=RQZ_2NmkAAAA:8 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=QltQKaWwH6ua0DdkohUA:9 a=46pEW5UW3zrkaSsnLxuo:22 X-Proofpoint-ORIG-GUID: liKTQ5hGsyPa1R-04eB33BQ_K6_E8yNS X-Proofpoint-GUID: liKTQ5hGsyPa1R-04eB33BQ_K6_E8yNS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX96531ehAAff6 sd4DzCC0aRSdUygWOmr0s2WUJLA50r0M6Aj5aDbauB0mOxdhAK1zgEia3+NzoT0yHxqlKzeES7f 76+lmAuUMVoW+AZUDk0FbyZ4mJCWXUG/5oGV+0q235bsaeodqWaDLbi/lbxqJcQHgVyPcSHeigz xn1EV8J3B2fadrGgbo2+y4FCa4v1kfbm9g7r0GnJah9Bo3JydIVuDpVOaLB+uGhPZO30SuDxJ// vjENM7zhzAIFoYN/sX1MQBJM50kf74BmlsrJ741ZVowvn44ZFth5yUm52uB1Paz6bPRam9BsNBE OYkrpjsHoEyJITfl+sTslZBmx+nu7GAHH4/14S2rmRfNiVR55JY5c/Smu7B2BYpHdJ9fQzbvJbU mGC3xpVZixLksp0AAwxDmOcNece4jaMgvcYoiI1l+7l6JuPQlFiSDaS/hAaVSF7JEKsWJNgK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324047175116600 Content-Type: text/plain; charset="utf-8" From: John Levon When the vfio-user container gets mapping updates, share them with the vfio-user by sending a message; this can include the region fd, allowing the server to directly mmap() the region as needed. For performance, we only wait for the message responses when we're doing with a series of updates via the listener_commit() callback. Originally-by: John Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John Levon --- hw/vfio-user/protocol.h | 32 ++++++++++++ hw/vfio-user/proxy.h | 6 +++ hw/vfio-user/container.c | 107 +++++++++++++++++++++++++++++++++++++- hw/vfio-user/proxy.c | 77 ++++++++++++++++++++++++++- hw/vfio-user/trace-events | 4 ++ 5 files changed, 222 insertions(+), 4 deletions(-) diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 920b9c44ec..4fa6d03b3f 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -115,6 +115,31 @@ typedef struct { */ #define VFIO_USER_DEF_MAX_BITMAP (256 * 1024 * 1024) =20 +/* + * VFIO_USER_DMA_MAP + * imported from struct vfio_iommu_type1_dma_map + */ +typedef struct { + VFIOUserHdr hdr; + uint32_t argsz; + uint32_t flags; + uint64_t offset; /* FD offset */ + uint64_t iova; + uint64_t size; +} VFIOUserDMAMap; + +/* + * VFIO_USER_DMA_UNMAP + * imported from struct vfio_iommu_type1_dma_unmap + */ +typedef struct { + VFIOUserHdr hdr; + uint32_t argsz; + uint32_t flags; + uint64_t iova; + uint64_t size; +} VFIOUserDMAUnmap; + /* * VFIO_USER_DEVICE_GET_INFO * imported from struct vfio_device_info @@ -178,4 +203,11 @@ typedef struct { char data[]; } VFIOUserRegionRW; =20 +/*imported from struct vfio_bitmap */ +typedef struct { + uint64_t pgsize; + uint64_t size; + char data[]; +} VFIOUserBitmap; + #endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index e2cfaeead8..01fed3f17d 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -73,6 +73,7 @@ typedef struct VFIOUserProxy { QemuCond close_cv; AioContext *ctx; QEMUBH *req_bh; + bool async_ops; =20 /* * above only changed when BQL is held @@ -102,9 +103,14 @@ void vfio_user_set_handler(VFIODevice *vbasedev, void *reqarg); bool vfio_user_validate_version(VFIOUserProxy *proxy, Error **errp); =20 +VFIOUserFDs *vfio_user_getfds(int numfds); + void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, uint32_t size, uint32_t flags); +void vfio_user_wait_reqs(VFIOUserProxy *proxy); void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, VFIOUserFDs *fds, int rsize); +void vfio_user_send_nowait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds, int rsize); =20 #endif /* VFIO_USER_PROXY_H */ diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c index 38e9cf8d8a..5a109c591e 100644 --- a/hw/vfio-user/container.c +++ b/hw/vfio-user/container.c @@ -21,18 +21,119 @@ #include "qapi/error.h" #include "trace.h" =20 +/* + * When DMA space is the physical address space, the region add/del listen= ers + * will fire during memory update transactions. These depend on BQL being= held, + * so do any resulting map/demap ops async while keeping BQL. + */ +static void vfio_user_listener_begin(VFIOContainerBase *bcontainer) +{ + VFIOUserContainer *container =3D container_of(bcontainer, VFIOUserCont= ainer, + bcontainer); + + container->proxy->async_ops =3D true; +} + +static void vfio_user_listener_commit(VFIOContainerBase *bcontainer) +{ + VFIOUserContainer *container =3D container_of(bcontainer, VFIOUserCont= ainer, + bcontainer); + + /* wait here for any async requests sent during the transaction */ + container->proxy->async_ops =3D false; + vfio_user_wait_reqs(container->proxy); +} + static int vfio_user_dma_unmap(const VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, IOMMUTLBEntry *iotlb, bool unmap_all) { - return -ENOTSUP; + VFIOUserContainer *container =3D container_of(bcontainer, VFIOUserCont= ainer, + bcontainer); + + VFIOUserDMAUnmap *msgp =3D g_malloc(sizeof(*msgp)); + + vfio_user_request_msg(&msgp->hdr, VFIO_USER_DMA_UNMAP, sizeof(*msgp), = 0); + msgp->argsz =3D sizeof(struct vfio_iommu_type1_dma_unmap); + msgp->flags =3D unmap_all ? VFIO_DMA_UNMAP_FLAG_ALL : 0; + msgp->iova =3D iova; + msgp->size =3D size; + trace_vfio_user_dma_unmap(msgp->iova, msgp->size, msgp->flags, + container->proxy->async_ops); + + if (container->proxy->async_ops) { + vfio_user_send_nowait(container->proxy, &msgp->hdr, NULL, 0); + return 0; + } + + vfio_user_send_wait(container->proxy, &msgp->hdr, NULL, 0); + if (msgp->hdr.flags & VFIO_USER_ERROR) { + return -msgp->hdr.error_reply; + } + + g_free(msgp); + return 0; } =20 static int vfio_user_dma_map(const VFIOContainerBase *bcontainer, hwaddr i= ova, ram_addr_t size, void *vaddr, bool readonly, MemoryRegion *mrp) { - return -ENOTSUP; + VFIOUserContainer *container =3D container_of(bcontainer, VFIOUserCont= ainer, + bcontainer); + + VFIOUserProxy *proxy =3D container->proxy; + int fd =3D memory_region_get_fd(mrp); + int ret; + + VFIOUserFDs *fds =3D NULL; + VFIOUserDMAMap *msgp =3D g_malloc0(sizeof(*msgp)); + + vfio_user_request_msg(&msgp->hdr, VFIO_USER_DMA_MAP, sizeof(*msgp), 0); + msgp->argsz =3D sizeof(struct vfio_iommu_type1_dma_map); + msgp->flags =3D VFIO_DMA_MAP_FLAG_READ; + msgp->offset =3D 0; + msgp->iova =3D iova; + msgp->size =3D size; + + /* + * vaddr enters as a QEMU process address; make it either a file offset + * for mapped areas or leave as 0. + */ + if (fd !=3D -1) { + msgp->offset =3D qemu_ram_block_host_offset(mrp->ram_block, vaddr); + } + + if (!readonly) { + msgp->flags |=3D VFIO_DMA_MAP_FLAG_WRITE; + } + + trace_vfio_user_dma_map(msgp->iova, msgp->size, msgp->offset, msgp->fl= ags, + container->proxy->async_ops); + + /* + * The async_ops case sends without blocking. They're later waited for= in + * vfio_send_wait_reqs. + */ + if (container->proxy->async_ops) { + /* can't use auto variable since we don't block */ + if (fd !=3D -1) { + fds =3D vfio_user_getfds(1); + fds->send_fds =3D 1; + fds->fds[0] =3D fd; + } + vfio_user_send_nowait(proxy, &msgp->hdr, fds, 0); + ret =3D 0; + } else { + VFIOUserFDs local_fds =3D { 1, 0, &fd }; + + fds =3D fd !=3D -1 ? &local_fds : NULL; + vfio_user_send_wait(proxy, &msgp->hdr, fds, 0); + ret =3D (msgp->hdr.flags & VFIO_USER_ERROR) ? -msgp->hdr.error_rep= ly : 0; + g_free(msgp); + } + + return ret; } =20 static int @@ -224,6 +325,8 @@ static void vfio_iommu_user_class_init(ObjectClass *kla= ss, const void *data) VFIOIOMMUClass *vioc =3D VFIO_IOMMU_CLASS(klass); =20 vioc->setup =3D vfio_user_setup; + vioc->listener_begin =3D vfio_user_listener_begin, + vioc->listener_commit =3D vfio_user_listener_commit, vioc->dma_map =3D vfio_user_dma_map; vioc->dma_unmap =3D vfio_user_dma_unmap; vioc->attach_device =3D vfio_user_device_attach; diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 34df9bba7b..6d1446c38b 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -31,7 +31,6 @@ static void vfio_user_shutdown(VFIOUserProxy *proxy); static int vfio_user_send_qio(VFIOUserProxy *proxy, VFIOUserMsg *msg); static VFIOUserMsg *vfio_user_getmsg(VFIOUserProxy *proxy, VFIOUserHdr *hd= r, VFIOUserFDs *fds); -static VFIOUserFDs *vfio_user_getfds(int numfds); static void vfio_user_recycle(VFIOUserProxy *proxy, VFIOUserMsg *msg); =20 static void vfio_user_recv(void *opaque); @@ -133,7 +132,7 @@ static void vfio_user_recycle(VFIOUserProxy *proxy, VFI= OUserMsg *msg) QTAILQ_INSERT_HEAD(&proxy->free, msg, next); } =20 -static VFIOUserFDs *vfio_user_getfds(int numfds) +VFIOUserFDs *vfio_user_getfds(int numfds) { VFIOUserFDs *fds =3D g_malloc0(sizeof(*fds) + (numfds * sizeof(int))); =20 @@ -609,6 +608,36 @@ static int vfio_user_send_queued(VFIOUserProxy *proxy,= VFIOUserMsg *msg) return 0; } =20 +/* + * nowait send - vfio_wait_reqs() can wait for it later + */ +void vfio_user_send_nowait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds, int rsize) +{ + VFIOUserMsg *msg; + int ret; + + if (hdr->flags & VFIO_USER_NO_REPLY) { + error_printf("vfio_user_send_nowait on async message\n"); + return; + } + + QEMU_LOCK_GUARD(&proxy->lock); + + msg =3D vfio_user_getmsg(proxy, hdr, fds); + msg->id =3D hdr->id; + msg->rsize =3D rsize ? rsize : hdr->size; + msg->type =3D VFIO_MSG_NOWAIT; + + ret =3D vfio_user_send_queued(proxy, msg); + if (ret < 0) { + vfio_user_recycle(proxy, msg); + return; + } + + proxy->last_nowait =3D msg; +} + void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, VFIOUserFDs *fds, int rsize) { @@ -647,6 +676,50 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUse= rHdr *hdr, qemu_mutex_unlock(&proxy->lock); } =20 +void vfio_user_wait_reqs(VFIOUserProxy *proxy) +{ + VFIOUserMsg *msg; + + /* + * Any DMA map/unmap requests sent in the middle + * of a memory region transaction were sent nowait. + * Wait for them here. + */ + qemu_mutex_lock(&proxy->lock); + if (proxy->last_nowait !=3D NULL) { + /* + * Change type to WAIT to wait for reply + */ + msg =3D proxy->last_nowait; + msg->type =3D VFIO_MSG_WAIT; + proxy->last_nowait =3D NULL; + while (!msg->complete) { + if (!qemu_cond_timedwait(&msg->cv, &proxy->lock, wait_time)) { + VFIOUserMsgQ *list; + + list =3D msg->pending ? &proxy->pending : &proxy->outgoing; + QTAILQ_REMOVE(list, msg, next); + error_printf("vfio_wait_reqs - timed out\n"); + break; + } + } + + if (msg->hdr->flags & VFIO_USER_ERROR) { + error_printf("vfio_user_wait_reqs - error reply on async "); + error_printf("request: command %x error %s\n", msg->hdr->comma= nd, + strerror(msg->hdr->error_reply)); + } + + /* + * Change type back to NOWAIT to free + */ + msg->type =3D VFIO_MSG_NOWAIT; + vfio_user_recycle(proxy, msg); + } + + qemu_mutex_unlock(&proxy->lock); +} + static QLIST_HEAD(, VFIOUserProxy) vfio_user_sockets =3D QLIST_HEAD_INITIALIZER(vfio_user_sockets); =20 diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 053f5932eb..7ef98813b3 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -11,3 +11,7 @@ vfio_user_get_region_info(uint32_t index, uint32_t flags,= uint64_t size) " index vfio_user_region_rw(uint32_t region, uint64_t off, uint32_t count) " regio= n %d offset 0x%"PRIx64" count %d" vfio_user_get_irq_info(uint32_t index, uint32_t flags, uint32_t count) " i= ndex %d flags 0x%x count %d" vfio_user_set_irqs(uint32_t index, uint32_t start, uint32_t count, uint32_= t flags) " index %d start %d count %d flags 0x%x" + +# container.c +vfio_user_dma_map(uint64_t iova, uint64_t size, uint64_t off, uint32_t fla= gs, bool async_ops) " iova 0x%"PRIx64" size 0x%"PRIx64" off 0x%"PRIx64" fla= gs 0x%x async_ops %d" +vfio_user_dma_unmap(uint64_t iova, uint64_t size, uint32_t flags, bool as= ync_ops) " iova 0x%"PRIx64" size 0x%"PRIx64" flags 0x%x async_ops %d" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324173; cv=pass; d=zohomail.com; s=zohoarc; b=oIoff9dTNpSHefALgj1kIjaBu20VdpgfhrknuiLY7CqA/lNSPmB0JT4uqxQ9szQyIt43rxlrHR8vkdWx743GFK4owTiPmq4v+AGlAMNaJHK9B+DWVzScV+p0AGmlgBdChzTc+HFYftRiKj315VZC2kV5FN5DXOU4No3WaVYbCmM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324173; 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=EP6LNxi0OkTDKZVHQpL/4sevJ46U+iDmQuqSFoRqciw=; b=gSDIMIse5vEQZQOlNZXQHKioQ/mMZY1E99BnTnETYvjtKf6g2kJIRTWyEG0BQmWE8A4KeXx8KGgLO15wrsKZ5fAXok0hPcCPT6YYkRmHWgxCRiYl6Gq2DOesJHQqGjGVKl4mi9jewzNN5neIt3b1UDNq6wEy+TK0XJwxV3YUJYI= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324173164171.14871279170256; Thu, 15 May 2025 08:49:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFano-0003SP-3V; Thu, 15 May 2025 11:47:20 -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 1uFam9-0007TZ-40 for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:37 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFalz-0006S4-8h for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:36 -0400 Received: from pps.filterd (m0127839.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F7nlpw026476; Thu, 15 May 2025 08:45:20 -0700 Received: from bl2pr02cu003.outbound.protection.outlook.com (mail-eastusazlp17010004.outbound.protection.outlook.com [40.93.11.4]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46mjmtvrfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:19 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:17 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=EP6LNxi0OkTDKZVHQpL/4sevJ46U+iDmQuqSFoRqc iw=; b=R2yXdYIwz6au3zNyFfHKNpmKSCt21KqamOvaWTpjsXIIVw4gSPT5zUmss fKJ/I3c88dT9f0mFx4TjLqXgW1z7OW4Sd9Dk0QbqINnWPgW1A+wSBG8SMz79oBlC DVi9MDLs5OVRS87k0s/EdCcnQzxvU4Fqsn/zyukb48cWiLFkPhOdHZiIGqL2uuIZ YaCJGNrLvDykXsb0BHIe20/oJr0UchOXPxf98YqeA+vgWnicX36N0Zuy4yAAH8co O1odE2hlBNvro21+dqhq6qFdqlkLLunuiGajNUA2zd0oWckM/bRLWI5WYWMLBfjz 4KK7ufeQNhX+Q5m4y+x1lv9ACjv3Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cbdva2adC/Fe9qyxFDT7xIxC5UgDDgCT+KrwFCJpLKUEQ8IIZeNec+mLsPVk+/WPgqUdR8LLA0COEJyU/5aYpFTJ9OOYCLarcHJ+B3pNi2WherjA96Nqo1eFibKxE21LTPMQZKOUpaK2VnYFMRuMWjyWcHWJ6HLFDs1RbTj5g7g10u9QMfgcmjfSzPkkuc36odC+bH5aB6iesFkdGnqYw5GrnsSE6bA0EL1foj03UWGS11oc7Olxl2QWibVyet5Lulq8QPGoBzfw05UM73xiv/BPO/UD6tV05fMonMYOleoel4GHoWWmC/88+35QhJ5Aa1AukJf3VgbGNsOQFFEPXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EP6LNxi0OkTDKZVHQpL/4sevJ46U+iDmQuqSFoRqciw=; b=Ie2Q8uCvodVLXDBkvREGflZxPG4RMvhHJF55KbPOiHvWNP5Vz3qTIEL1vm6YCUpIkZxoqlaCQBx6uwLAea3NkJcGqBeH4GgxiFS+6Oqrsv++WfJGdKpE6czJ4E+b5MzRxV+LGkymLivSlbenkLp/Gy2ZoMZS+e5elqq10vmz3FdcL0qxpRkBT9iZ4as90MQsWr2ffTGPntz64Vha7y6T6nmUfybPt7e1gsdbE2cJpuQyMAfmoqp8odM5XEkRDhlDxWahhqsi5h4ulYciiekvbyp8f1/XGzSFLpxkiHBoumSWkv7JVnnugP25PosQcUfydXwfvZHzgzEVG9OtI2r2Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EP6LNxi0OkTDKZVHQpL/4sevJ46U+iDmQuqSFoRqciw=; b=othVWCMEGmcL7A3GYNvyUydPU1uidF31hRzfrDNB9pTCXxOevBhBkElky2grY+Xw2WHfLCnFDwyadrQct6Ius4vhzW758Umj9ofuLETj0guMmvlKKEsIZC90WoVykDzEDGMeP9Z11uInMLhkToGJwfChdDGkMsowtZ0FwszKxkuS4kIvUaLy1Y0GQ/+E5dXw+6IB05p50/9Fcc73mx2aUWUH3gLfHj1iH5KHNtpLgxxTb21YF9f16Z2hYi75FJREBSKFBxvEalAJrU7VbM+0zOBG5aD7splBrLQrGA51P9KXKW+2lWksdAJkCrp13L8WHxdmPRvOzsxfrhVbXh4kdA== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 23/27] vfio-user: implement VFIO_USER_DMA_READ/WRITE Date: Thu, 15 May 2025 16:44:08 +0100 Message-ID: <20250515154413.210315-24-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e68cadc-eceb-46c3-5b2e-08dd93c77db3 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dgp5RobE/C5S/E78fArUHiUG7spAWpiWbnxZJljqdnMySi+VYGcGkLeWcJP4?= =?us-ascii?Q?cLSlulGarJBUwNMVWnpI/QOzLq8LMq2jVUgr25djKxNOg0DpC8JgWvkKOTTv?= =?us-ascii?Q?II/PaVwLx9JQ4h02rCZ+1VSEQnboFSg2aQuPUr3S7TOyEpQ1R/8iEhocj9uQ?= =?us-ascii?Q?EFNWo8bdeDF5gjSyMpw34vfI24yx+LjoLSna8sY9FGjmMXnpEV5/ElbP2sOD?= =?us-ascii?Q?SHdrjaFPd3H8ZlS8+vVxNr8eBKlRi1Q+fB9Cgwl0LlgsJaxEmH1vGUqS3qE2?= =?us-ascii?Q?t734b6V/sl0b4L8pDeAGK7dPv7DIRCHnLxbkyCvo2vooqQuiHj8eCHzWQ02z?= =?us-ascii?Q?kprQvX0VRUkR1dKQrej3j7cDyYYGncmcuKKD7iPP6RG3KM33dGE3pbzfyt9E?= =?us-ascii?Q?F8ypah8vHY5LofywNPVw2TDfzVKpON93uq0K9+cxkSiIrkOmkxyZsowStFqL?= =?us-ascii?Q?f0tOLeS/rS7t2fwF4Cdxo4sbTmiVZuuUrfG0kT6KU62W7t9WV8yxqECCmkz8?= =?us-ascii?Q?y0INvGAkIyKzK7YcJDRZ7parlejNgxELTWyoLFzK37572a6uUwyE/78OO9ax?= =?us-ascii?Q?gHRSRRXgIUoQducrn6cv7pw+gr9cc47yx2Xx2VdRwzqKPt4y/rGwdF4MX5e8?= =?us-ascii?Q?MLONOx1uq3dLEhArP7sNXNDaQ+scaXnuyWIJUsq8H7bhkwBT4SUayMsZkK8U?= =?us-ascii?Q?/X9MKfH7mCCDhHwBZs0kYhankD8YWyEu4Sf/pIPmlyz75ozBPl8VWmBHEslS?= =?us-ascii?Q?sJhSYYsFDBupaPQ3QIHhue47i8Rdjp00WUV1dv0AGMo+ZkjAF7KXxEOmQ4Zy?= =?us-ascii?Q?rTn6d8T/4iMR1iBwIShpQpYLfae8UdF7dXP2VHxKF3leED8dUWfTMhY62gxR?= =?us-ascii?Q?PaHXeVwflYDZmQ3xxZ2nN6t/7GHhs4eaA26u04FiMNZucYtr6h/UxNn1Mj4m?= =?us-ascii?Q?7m/jRWwJPglJxjW58u6y4HY8NVdHQqE03Bi6LGvAW0FEe0uabuyx8JcG0EmP?= =?us-ascii?Q?dAcDIUAyBKXNR3kEdHE7qt7+RsY7zcRCZtw8eYiJznYl9Sg6yEuLMyjg9Qxr?= =?us-ascii?Q?PqtElL9FRxUo1MEV0EPgknzir1vzC15UXMWetibfvRgVGpz3fwz1b9NY70lf?= =?us-ascii?Q?p/MHgTmmOE9USPAVPQm3Qs5EQJEK4DvqyeTBHlpjrvPXklH1doD+gNxRorzL?= =?us-ascii?Q?Z2QvE82ppPzODUiE6NqnIwZiunQwn0b1iuaMui8RddRjOXgt1J9hWObtuABj?= =?us-ascii?Q?ufKW2otEJryIw5aOSfJsmWbHYixzlbx6SiSRfLodiegznau56Z2orX2kfxo/?= =?us-ascii?Q?TtPly7rsUaqmRSV805yNAU60BrW+VuEvRZCtrflxncxnmJHEXbxgyH5n2rmC?= =?us-ascii?Q?bsEwdX1dLkXhSAoKra35SSbSYl8sR4hM17TakpXdXo1Ui6IhBA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?48yCuf8eLefk0y9iWEtGIsEnpD1qMBglW2Gu0J8Nqdpyah0RQBpAPiASoliu?= =?us-ascii?Q?Mj4nkkow+LeQDh2r0hyoGb7DwGnL8xtBd7pQuxq9DUqI6udz5uL/oA2Jldpb?= =?us-ascii?Q?fOMGY8e7xN9X8nTkUluI28kNNfzKXt9NpWbcok6V1QQYvDtR6ABx1zMiwnYQ?= =?us-ascii?Q?qX4HAeDVRCqERsDy5mko16l5PVl1/UecqjWZtUDS5qMANROSmWqQelDo/76P?= =?us-ascii?Q?Ht8besHF30rgs+s7Cb3FWCaw4xwLIO8IidO4Xfohz5Z+xfFAAwsgdcD524TJ?= =?us-ascii?Q?JgYXa2r25sjaHv/Wei2notKgrXpNBO5zqhW6/4lU/kiMVVoHUwRyWQDK77cJ?= =?us-ascii?Q?lkjbeBmhtnKNCbGmf5HwGqMQy/bg3e0Nh7/GIYGZGvEGTe8fm4gxXo0URUMB?= =?us-ascii?Q?O4G2wWgPQJlvfJmLhbKa69EAU6O26hE3SI6fS23+87E/XWg8nzs48fZpuUXb?= =?us-ascii?Q?3mzxTmuCIpU1UqCqYi3JL51Qsf0h3ylqKOxrLC2o90iIUZc302EnnEtvUDnG?= =?us-ascii?Q?WmFLo5iE/wL+Q9qmGtumbbz/9fp56ZnBjqW4W4UrCYwTntP31AegCiPZJH7y?= =?us-ascii?Q?dHXK3eGoDvEU6FswFAjvav5xCU6KJbaQY1h3AoERSAqe0WkyM8vlGHS+Fvms?= =?us-ascii?Q?dXSA3d4RHnsoiFtP0KuQiM4dfeyxmmyaLly529HpwnlMaPZGsU1n9epMBbhA?= =?us-ascii?Q?m9hCjr/keVMgDA81VAd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-MS-Exchange-CrossTenant-Network-Message-Id: 7e68cadc-eceb-46c3-5b2e-08dd93c77db3 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:17.4756 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oYZFGYM0VUjI6qZdjzsBh9JyXZnXS0Yn+PgQLOL2Zd1pEvkNxDnELUYVSRLUn2G3Khudnr/PdKyfDPfe3yGFJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Authority-Analysis: v=2.4 cv=TauWtQQh c=1 sm=1 tr=0 ts=68260c10 cx=c_pps a=uYdjBAypVXkA+ZVpDPXefQ==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=qTvU7B1ccVJYr7cy3AMA:9 X-Proofpoint-ORIG-GUID: HQs8iF1CMexSwQpCC9EatLxtxb_06Z17 X-Proofpoint-GUID: HQs8iF1CMexSwQpCC9EatLxtxb_06Z17 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX8nMmb65rhEJD q3VlvLQ318BiFZcH6GTNP3lC7Y0uqj0Uqo+nlaW+b6HdUSYgDVgBapb0UGzuJ/P3DQsCxLPNAcW rnHY6Hm97uJ8RJOw5eofLaqLjbXYT9JFUuWKNJlGcWt/e1GdhyExie09sfIYfMIEkWOx/GsL0VD yzQ3kfdR512iAzVhuFZqEZcCE0EkpcBym0lq0pVOnPeaa55BT/aXVlrbKOxOmWMJOPRJtrb05Zq gH+RHlGG5Cq8KWrMPHQ2DPhTw67xFvR6k8nU5bHNp0/S6FpoeN+Y/Yh23h8wAp6hD7a1ArRlhHI kDn8s4nulWgtXJTFs66gOkWTz9T9qI3c1hw4vPUEprNoNLITjfQpLLGSNMP0j8DMbZYwP+fSZOu tM2cWV511/jw+8zakWlJAWaKrOB9cpkhvbEmNhTyhRQ1iC4WpunjjYyAFRNWG87F89kvE6Xa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.151.68; envelope-from=john.levon@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324174552116600 Content-Type: text/plain; charset="utf-8" Unlike most other messages, this is a server->client message, for when a server wants to do "DMA"; this is slow, so normally the server has memory directly mapped instead. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/protocol.h | 13 ++++- hw/vfio-user/proxy.h | 3 ++ hw/vfio-user/pci.c | 111 ++++++++++++++++++++++++++++++++++++++++ hw/vfio-user/proxy.c | 84 ++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+), 1 deletion(-) diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 4fa6d03b3f..8f589faef4 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -203,7 +203,18 @@ typedef struct { char data[]; } VFIOUserRegionRW; =20 -/*imported from struct vfio_bitmap */ +/* + * VFIO_USER_DMA_READ + * VFIO_USER_DMA_WRITE + */ +typedef struct { + VFIOUserHdr hdr; + uint64_t offset; + uint32_t count; + char data[]; +} VFIOUserDMARW; + +/* imported from struct vfio_bitmap */ typedef struct { uint64_t pgsize; uint64_t size; diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 01fed3f17d..8f2d529846 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -104,6 +104,7 @@ void vfio_user_set_handler(VFIODevice *vbasedev, bool vfio_user_validate_version(VFIOUserProxy *proxy, Error **errp); =20 VFIOUserFDs *vfio_user_getfds(int numfds); +void vfio_user_putfds(VFIOUserMsg *msg); =20 void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, uint32_t size, uint32_t flags); @@ -112,5 +113,7 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUser= Hdr *hdr, VFIOUserFDs *fds, int rsize); void vfio_user_send_nowait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, VFIOUserFDs *fds, int rsize); +void vfio_user_send_reply(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int size= ); +void vfio_user_send_error(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int erro= r); =20 #endif /* VFIO_USER_PROXY_H */ diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 55cc811d3c..a55a0a0972 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -11,6 +11,7 @@ =20 #include #include "qemu/osdep.h" +#include "qemu/error-report.h" =20 #include "hw/qdev-properties.h" #include "hw/vfio/pci.h" @@ -82,6 +83,95 @@ static void vfio_user_msix_teardown(VFIOPCIDevice *vdev) vdev->msix->pba_region =3D NULL; } =20 +static void vfio_user_dma_read(VFIOPCIDevice *vdev, VFIOUserDMARW *msg) +{ + PCIDevice *pdev =3D &vdev->pdev; + VFIOUserProxy *proxy =3D vdev->vbasedev.proxy; + VFIOUserDMARW *res; + MemTxResult r; + size_t size; + + if (msg->hdr.size < sizeof(*msg)) { + vfio_user_send_error(proxy, &msg->hdr, EINVAL); + return; + } + if (msg->count > proxy->max_xfer_size) { + vfio_user_send_error(proxy, &msg->hdr, E2BIG); + return; + } + + /* switch to our own message buffer */ + size =3D msg->count + sizeof(VFIOUserDMARW); + res =3D g_malloc0(size); + memcpy(res, msg, sizeof(*res)); + g_free(msg); + + r =3D pci_dma_read(pdev, res->offset, &res->data, res->count); + + switch (r) { + case MEMTX_OK: + if (res->hdr.flags & VFIO_USER_NO_REPLY) { + g_free(res); + return; + } + vfio_user_send_reply(proxy, &res->hdr, size); + break; + case MEMTX_ERROR: + vfio_user_send_error(proxy, &res->hdr, EFAULT); + break; + case MEMTX_DECODE_ERROR: + vfio_user_send_error(proxy, &res->hdr, ENODEV); + break; + case MEMTX_ACCESS_ERROR: + vfio_user_send_error(proxy, &res->hdr, EPERM); + break; + default: + error_printf("vfio_user_dma_read unknown error %d\n", r); + vfio_user_send_error(vdev->vbasedev.proxy, &res->hdr, EINVAL); + } +} + +static void vfio_user_dma_write(VFIOPCIDevice *vdev, VFIOUserDMARW *msg) +{ + PCIDevice *pdev =3D &vdev->pdev; + VFIOUserProxy *proxy =3D vdev->vbasedev.proxy; + MemTxResult r; + + if (msg->hdr.size < sizeof(*msg)) { + vfio_user_send_error(proxy, &msg->hdr, EINVAL); + return; + } + /* make sure transfer count isn't larger than the message data */ + if (msg->count > msg->hdr.size - sizeof(*msg)) { + vfio_user_send_error(proxy, &msg->hdr, E2BIG); + return; + } + + r =3D pci_dma_write(pdev, msg->offset, &msg->data, msg->count); + + switch (r) { + case MEMTX_OK: + if ((msg->hdr.flags & VFIO_USER_NO_REPLY) =3D=3D 0) { + vfio_user_send_reply(proxy, &msg->hdr, sizeof(msg->hdr)); + } else { + g_free(msg); + } + break; + case MEMTX_ERROR: + vfio_user_send_error(proxy, &msg->hdr, EFAULT); + break; + case MEMTX_DECODE_ERROR: + vfio_user_send_error(proxy, &msg->hdr, ENODEV); + break; + case MEMTX_ACCESS_ERROR: + vfio_user_send_error(proxy, &msg->hdr, EPERM); + break; + default: + error_printf("vfio_user_dma_write unknown error %d\n", r); + vfio_user_send_error(vdev->vbasedev.proxy, &msg->hdr, EINVAL); + } +} + /* * Incoming request message callback. * @@ -89,7 +179,28 @@ static void vfio_user_msix_teardown(VFIOPCIDevice *vdev) */ static void vfio_user_pci_process_req(void *opaque, VFIOUserMsg *msg) { + VFIOPCIDevice *vdev =3D opaque; + VFIOUserHdr *hdr =3D msg->hdr; + + /* no incoming PCI requests pass FDs */ + if (msg->fds !=3D NULL) { + vfio_user_send_error(vdev->vbasedev.proxy, hdr, EINVAL); + vfio_user_putfds(msg); + return; + } =20 + switch (hdr->command) { + case VFIO_USER_DMA_READ: + vfio_user_dma_read(vdev, (VFIOUserDMARW *)hdr); + break; + case VFIO_USER_DMA_WRITE: + vfio_user_dma_write(vdev, (VFIOUserDMARW *)hdr); + break; + default: + error_printf("vfio_user_pci_process_req unknown cmd %d\n", + hdr->command); + vfio_user_send_error(vdev->vbasedev.proxy, hdr, ENOSYS); + } } =20 /* diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 6d1446c38b..0935b72e9f 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -362,6 +362,10 @@ static int vfio_user_recv_one(VFIOUserProxy *proxy) *msg->hdr =3D hdr; data =3D (char *)msg->hdr + sizeof(hdr); } else { + if (hdr.size > proxy->max_xfer_size + sizeof(VFIOUserDMARW)) { + error_setg(&local_err, "vfio_user_recv request larger than max= "); + goto err; + } buf =3D g_malloc0(hdr.size); memcpy(buf, &hdr, sizeof(hdr)); data =3D buf + sizeof(hdr); @@ -676,6 +680,33 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUse= rHdr *hdr, qemu_mutex_unlock(&proxy->lock); } =20 +/* + * async send - msg can be queued, but will be freed when sent + */ +static void vfio_user_send_async(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds) +{ + VFIOUserMsg *msg; + int ret; + + if (!(hdr->flags & (VFIO_USER_NO_REPLY | VFIO_USER_REPLY))) { + error_printf("vfio_user_send_async on sync message\n"); + return; + } + + QEMU_LOCK_GUARD(&proxy->lock); + + msg =3D vfio_user_getmsg(proxy, hdr, fds); + msg->id =3D hdr->id; + msg->rsize =3D 0; + msg->type =3D VFIO_MSG_ASYNC; + + ret =3D vfio_user_send_queued(proxy, msg); + if (ret < 0) { + vfio_user_recycle(proxy, msg); + } +} + void vfio_user_wait_reqs(VFIOUserProxy *proxy) { VFIOUserMsg *msg; @@ -720,6 +751,59 @@ void vfio_user_wait_reqs(VFIOUserProxy *proxy) qemu_mutex_unlock(&proxy->lock); } =20 +/* + * Reply to an incoming request. + */ +void vfio_user_send_reply(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int size) +{ + + if (size < sizeof(VFIOUserHdr)) { + error_printf("vfio_user_send_reply - size too small\n"); + g_free(hdr); + return; + } + + /* + * convert header to associated reply + */ + hdr->flags =3D VFIO_USER_REPLY; + hdr->size =3D size; + + vfio_user_send_async(proxy, hdr, NULL); +} + +/* + * Send an error reply to an incoming request. + */ +void vfio_user_send_error(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int erro= r) +{ + + /* + * convert header to associated reply + */ + hdr->flags =3D VFIO_USER_REPLY; + hdr->flags |=3D VFIO_USER_ERROR; + hdr->error_reply =3D error; + hdr->size =3D sizeof(*hdr); + + vfio_user_send_async(proxy, hdr, NULL); +} + +/* + * Close FDs erroneously received in an incoming request. + */ +void vfio_user_putfds(VFIOUserMsg *msg) +{ + VFIOUserFDs *fds =3D msg->fds; + int i; + + for (i =3D 0; i < fds->recv_fds; i++) { + close(fds->fds[i]); + } + g_free(fds); + msg->fds =3D NULL; +} + static QLIST_HEAD(, VFIOUserProxy) vfio_user_sockets =3D QLIST_HEAD_INITIALIZER(vfio_user_sockets); =20 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324316; cv=pass; d=zohomail.com; s=zohoarc; b=hpjVocVETyIRTHKN9XeESCu/xTKfneHMyPCMj6f81ohpuYKkj+zQFEaBLhaJ8UW4g5XwP6dyd8AkziB5JgNP3MvARv7RW+6pv+pVhl+ZU8gbkZDC8hRfXkn329fwuip0t27AGKi/u2b1SIDnXqf+NB49RwGYoYLR00aoXQtK0pI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324316; 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=9dGMxStAEXVrqnkq/UwR1NKDWitb8XE1YlNoGCuiqG0=; b=Cna854TQ6JhJwxJHmkJtKK9nhYsezXarhtqMmwCwaua7M1O43Aq3onGnphjXqWfhVhSB6LexNdvmwjTxgey+1ZRx1el82CIXBy/VrgKL6V5IQTxLxvEfIEj12zpFd0GqFTikwqundwAlvR6MNO78wjG2KWnHQkFcBTBUSA3VbB8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324316701544.755369274579; Thu, 15 May 2025 08:51:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFani-0003BK-RH; Thu, 15 May 2025 11:47:15 -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 1uFamC-0007pq-Pu for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:41 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFam1-0006SW-7X for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:40 -0400 Received: from pps.filterd (m0127842.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54F8OI9n011847; Thu, 15 May 2025 08:45:24 -0700 Received: from dm5pr21cu001.outbound.protection.outlook.com (mail-centralusazlp17011029.outbound.protection.outlook.com [40.93.13.29]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mxh32yn2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:23 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:20 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=9dGMxStAEXVrqnkq/UwR1NKDWitb8XE1YlNoGCuiq G0=; b=ZJ0Z3YJ4q0qBcM3I4sAkGrEiyqhdvqODzvs1sa75FOpTkJdM9URHHtQfP sJiC0z2+l5ZyL3/3sKCH2zV5vHjQ8dxh09bK1wv+24u5FgrxRkLQH5iY75Lp/qOG E2XfcnoffndhpvYR4CDOMWKvfSKPHBv88XDOOlyD3k0aF9lq5q/VT8eaBSI3DU57 cNgtTa0Ta69Ck5XAuP38WGeRQMtd9aBIT0zrgBl4I06322CmNw5vsgr0EssuIm9s +8vmcBpqzs2bV63r7mUbIxgloww/M5yDUasiU9kC78IWo82miZGrUaJYy0XKqIxR 2o03J3BHeFWRx6sAix3PwTE3yY0Fw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ocGisLPvo0UUIjWwDeAANL0pycWsJiyPJbajzG8qon9erc8e0eXAk/Hxm9yXA17KWIETLnfjQPHlVIQwGYGCT7ARxzd3BWm3rrn8gImT1SPmDU1PQENbzNfHFgr8kl2Je1mrWxcI+g+tpUDTcFzU0H/bdvr6yg49+9O+loR6RXM4Wznucy8Un+/C/4oXlGT4s48G0bz/+BKfwPd9JD70FVMAB4YVwMazX76/cCgOUeYylscbXABmwQXPOVTYV2BXF67V9lC7R5BfQwa85PZK+jrLUCuqBlLNSfcbtIH2RRu2Jpsr5gTs58aKywGvQMGPTJdAcfnYwJfb8W7s+G3GIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9dGMxStAEXVrqnkq/UwR1NKDWitb8XE1YlNoGCuiqG0=; b=SsXnptLLh0ZFSjCIPSRthDf6Ja+oXxt0D90CCz/2tUQElX8dNDec4Kp1lHvTbbDCc1lx7tbX8bNBayxy3Btu47a8iLTzDgyBJWnaAzQuMWKNpWUB2FoCYlTDGplHOQpNFW+5JY8D07xyLThKQdFNdVsK3a2M3CMjtJiD3/i6XTIFy8/Z2qEFnCWigddJC+n0tNXpg+uisI5flZV6kspM8b0zfWCgftN1OyPsKaj65ZA8u0txHEEUHOeg1c51uWGLa1R+rL9BAuXqPRcXy/1HKpURQF8ar5P1D9yF7Qf4aZE44gijmahYH5lHfmqwy2Tqsi901Pg2gQ8uiLQchQpqDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9dGMxStAEXVrqnkq/UwR1NKDWitb8XE1YlNoGCuiqG0=; b=Eyu6wjV80GSVF+ZJrvqbmKq1HQZJDP48Q5XibDDteDcDcOjc4sm4zym3ft+Ed15YMS4jrMQnzy53wZ/cSeh77sPIW1JEljL4kD/lUA6fjDUbPZJoJGwipRiApGo93s1jP/FrYW/4XY14wbIENhPspF+2Xx0gwm5fVti20xinP9eZqr67uhPX1SgwWuJBHvL8VjFZ6N4qd7UdevFUPNYaP/FkgF2t7KLflA5nlSULQA1TYzDgtuNSbKtA1cX/EyPUCHnJzGQFB5c88p1qXozcpoKlLISyREIgemlxan8k3nBNbGOBDuHKZXaxRSdKj8Dtg5o0wSQEeVHh2iwL7qRqWg== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 24/27] vfio-user: add 'x-msg-timeout' option Date: Thu, 15 May 2025 16:44:09 +0100 Message-ID: <20250515154413.210315-25-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 85f8ee66-204c-4d41-3218-08dd93c77f3b x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?UncoEMnP8ts1FQR665yDaotoDkRzy/NoPDmhwgpLyxgkp9dt1wI5JRCypBlp?= =?us-ascii?Q?jDw4zCqMxlyRQQ/VFLlCs+UICdK0/d5wEHMAGm14cjgTi6IAr7foqAJx39B/?= =?us-ascii?Q?HihpYj1ziEsQphl/4z/j/qpnGzEbWQhip8+sa7H94yCAkME7Ps7op7mHQS8y?= =?us-ascii?Q?u70NT1BQHtkTep6nLydVWiMWhPqHFxAzL+gxj3bfrzM+A6e7FkKWYD6T4H+B?= =?us-ascii?Q?PWNeRTOV5vHdrEGrlEHzwd9Rfjhwz35xXd6F2wY7YyFgcFwbJh7ZB8slHvUx?= =?us-ascii?Q?vDD8n5JpI0vIJyeL4cif6UGvX+AYqFS/dInceYBgM0bzckM+CJAGCCjDP5ar?= =?us-ascii?Q?22HQBG/TGKw0sf7MbeojkDlxamFyRhLUDuVZckdA6A6+AwKE/ntppxn4517g?= =?us-ascii?Q?yBpPFU9WaQACrzSY6ikf5eIaQUEyrliXdN0SsbUOuNV13/0xFOmMnFYABJE/?= =?us-ascii?Q?VT8X39j+2ch3w8sIKsYu/ZjjyvBMJDgTUbkWB80bsuKlHV/J8RKT3coPNGJF?= =?us-ascii?Q?92r18wvmYCz9uMoN2EpgTzVccKFBRTrZvwiDwAgIFnT2j0G9aapIVPa2GRVy?= =?us-ascii?Q?mXC7QWGQtl5V1lM5lFOFCo/TN3BgPksSDX/kz+HCmCiUMZRYY4OeWoH8ZEVP?= =?us-ascii?Q?a8oPIOjYeYrBSLHv2dlxOpmWuVCIiwtoJXlyGGBU89PCSVoAH2pBdF4vBUa9?= =?us-ascii?Q?bTZgyQnP5SogEbyry8EasFQwKFKqMtmUVoc6SM98aFdNOvrakF3o9yloV4Hs?= =?us-ascii?Q?ssq0Ajs78O9zDm5B2WdShanS6HdaAjuT8X05URhz6hQJYId2i6LXZoPFpzaV?= =?us-ascii?Q?zf/vRvqyXvhLEB9aK537fUkpt79PACR18MlItV9NDPjLJaWaDdPUASqz29Pa?= =?us-ascii?Q?UMHfDPgp0I0rfbtfq29pwA3VbOczx+ajdV7GEiYphlc3vl0z3EXGsrCchE9b?= =?us-ascii?Q?aYgdm2Ha/bkdQVVh5a5A1Dpn6C/aDueLUvweIO87OEE3Bd/cYMblz8fGJY66?= =?us-ascii?Q?7HEOzDeum5hxM42G5fW0FSMXYP2lLdH43F488ETcq60WF/2CryZfuoKsZDHT?= =?us-ascii?Q?4n+eDFhmEHoMUwyI9jMsPbwUlFlfp30a7hJYhOWyk3KGtA5O4je8RQWExiHg?= =?us-ascii?Q?b1A+Auw41fudfCg8coQ3L7I8EJA930RxZaQaNsLWabTRVxgwtMcbgeuIOMnK?= =?us-ascii?Q?jpSPUFnHY/ALNwHMHAGAtuzPxvXowOVjZjEysFUJ9WxtWijDdV9qkLdoQjWs?= =?us-ascii?Q?8EKqJ5zeCpdrPJsLN2IbGHByT5QD+zdJyXFw5zuwCIUyo8zxCVQQjMpQSNB5?= =?us-ascii?Q?yRU6RofRAemRuE1xF8+rZqCD3kqyYFjb588Yo1k9PoohhhUWehAyxWwXZ+2L?= =?us-ascii?Q?QBOnnSkMchmbGciV3Nyl2PVFKL0wx1X38DG3kEUwWnkBHaK8pQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9FyhzMW71nE/hwi/kwAeP0jciQn5W9MyVh5pdKIeNp6ErFXyFNI1hrD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bGhzHVS5wIrL02g9EoS8VMKeDCS3wHtAIpBUaAg?= =?us-ascii?Q?6louDoOcqDcP0sHMpz9OZUM8KoyCE7QpIjJkRj5OzFuaM/o3JuYQ1nv/fQ6m?= =?us-ascii?Q?j4C6IayFJQcEj0iTFHgg8CsKARKw9Xa2SIwI9IiURuS3txZ9Xlhu4ADWP4Qc?= =?us-ascii?Q?1B01Sb+jyJ2MKlKHCud8kBvIjkJu7ZcxcansOA9w9RffW2MiNqz1ngn2cLwV?= =?us-ascii?Q?SwILDZ/LJU5+RNeaPVoMmhj9XB5YJE7q9t02LB+/K4n1fYoEJuoVb7NutN7+?= =?us-ascii?Q?2+YWM43AUDHqsEO01krE9a58BUjYWfbJNaCpfKBkKjrtUMVxzaLL5acKvkLe?= =?us-ascii?Q?R9WczkBZzh8eJrFvWygWnsURmjiomFRSgyQqQ6flkRMg+0QS0qJpF9GyDaLF?= =?us-ascii?Q?gi3GEynU3AZV59+8w9ufrGvVqlc3jAptAU+QqKWZAHm2kRVaL0+zcSwh/gFn?= =?us-ascii?Q?WTl4ionjAos2zl+TlDoMx8+u61zFpJlSDlZu2RWv6OleXEdp6trsQMIBR9y1?= =?us-ascii?Q?8eFcb6qrVZUtH1/FTjmL/JJLXXuyYGG5wCx3t7pXPtIA7KPrsQrUjxp9krAk?= =?us-ascii?Q?jgwcWOXRdic/IDkKlc3i3jolazm622Z2Qv+gKtBYqOHPk5jRXMyL59YQaA2Z?= =?us-ascii?Q?bA5TYAZhe9zRxh/fiY8qVT8ZamZSOnN6+6cCWjJN?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85f8ee66-204c-4d41-3218-08dd93c77f3b X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:20.0206 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fdhGKWqV7X9XqclmA3tguIs1pJ9EUH/pHb9Fe43aALMn5ZpmTRn8n3xGXCP+R5ByR7Xfpq7QDRVti6MH8D8NVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-ORIG-GUID: ze8bdAUKGu7w-52LMiHmecj5_r4iZrX4 X-Authority-Analysis: v=2.4 cv=TeWWtQQh c=1 sm=1 tr=0 ts=68260c13 cx=c_pps a=SA2dW19TPv9rE6CiBNbh3A==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=Ql6ANm6PklPDYutWWPYA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXxurMqFSSX6et GD2eH5CjWU1lA3vRIXmF+tbWSCk8L9fl6ht2v7Qawedxg197xakR6w38WP7oQSKw9GZ3BbCj3ra yZ6snsXR/CCcJPg3Nyg7H+OgZy0J4oVpJ49kuEHbdVl2sgGCT0ZnOx2V1ErxJdz8KX+dyEZIGql 7hd/tlw1T25U5suNypJhIB66HiZ5OZ44skuddxd2ZyCxRSjSU5vElBPWdelxkRl+lDpZnNQDQcA ROYLYWKjJVYIJ9SrFQj+rX6KLOXUsvcrEUa/6ooeW0PyGPdU8TXNVWTr8C9W6ORM1Cpyj6Ner2F YTG7avr15Yzj6m68GqvL0y4pur7tS4hAkr01xftAPgS2rBnGeBPcCdqdU1k/pYbYRZs13S3o5Mf YQf8VzgERFmBB/ag+VQmIOO+HXVP+ifZZaP3+LsbJWqHqdoligVr+ZD7UyaJGcB1+rAbOBsU X-Proofpoint-GUID: ze8bdAUKGu7w-52LMiHmecj5_r4iZrX4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324317959116600 Content-Type: text/plain; charset="utf-8" By default, the vfio-user subsystem will wait 5 seconds for a message reply from the server. Add an option to allow this to be configurable. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/proxy.h | 1 + hw/vfio-user/pci.c | 5 +++++ hw/vfio-user/proxy.c | 7 ++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 8f2d529846..da29674fdc 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -70,6 +70,7 @@ typedef struct VFIOUserProxy { uint64_t max_bitmap; uint64_t migr_pgsize; int flags; + uint32_t wait_time; QemuCond close_cv; AioContext *ctx; QEMUBH *req_bh; diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index a55a0a0972..3df92acb82 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -25,6 +25,7 @@ struct VFIOUserPCIDevice { VFIOPCIDevice device; char *sock_name; bool send_queued; /* all sends are queued */ + uint32_t wait_time; /* timeout for message replies */ }; =20 /* @@ -254,6 +255,9 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Erro= r **errp) proxy->flags |=3D VFIO_PROXY_FORCE_QUEUED; } =20 + /* user specified or 5 sec default */ + proxy->wait_time =3D udev->wait_time; + if (!vfio_user_validate_version(proxy, errp)) { goto error; } @@ -387,6 +391,7 @@ static const Property vfio_user_pci_dev_properties[] = =3D { sub_device_id, PCI_ANY_ID), DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name), DEFINE_PROP_BOOL("x-send-queued", VFIOUserPCIDevice, send_queued, fals= e), + DEFINE_PROP_UINT32("x-msg-timeout", VFIOUserPCIDevice, wait_time, 5000= ), }; =20 static void vfio_user_pci_dev_class_init(ObjectClass *klass, const void *d= ata) diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 0935b72e9f..74cfaff6fa 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -24,7 +24,6 @@ #include "qemu/main-loop.h" #include "system/iothread.h" =20 -static int wait_time =3D 5000; /* wait up to 5 sec for busy servers */ static IOThread *vfio_user_iothread; =20 static void vfio_user_shutdown(VFIOUserProxy *proxy); @@ -665,7 +664,8 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUser= Hdr *hdr, =20 if (ret =3D=3D 0) { while (!msg->complete) { - if (!qemu_cond_timedwait(&msg->cv, &proxy->lock, wait_time)) { + if (!qemu_cond_timedwait(&msg->cv, &proxy->lock, + proxy->wait_time)) { VFIOUserMsgQ *list; =20 list =3D msg->pending ? &proxy->pending : &proxy->outgoing; @@ -725,7 +725,8 @@ void vfio_user_wait_reqs(VFIOUserProxy *proxy) msg->type =3D VFIO_MSG_WAIT; proxy->last_nowait =3D NULL; while (!msg->complete) { - if (!qemu_cond_timedwait(&msg->cv, &proxy->lock, wait_time)) { + if (!qemu_cond_timedwait(&msg->cv, &proxy->lock, + proxy->wait_time)) { VFIOUserMsgQ *list; =20 list =3D msg->pending ? &proxy->pending : &proxy->outgoing; --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324286; cv=pass; d=zohomail.com; s=zohoarc; b=QMXmsMl9M/4Mx4EEX9KlUZolSn95hPgig9wlBgQmsPDPX3ZswtscWwP+ta5CSRiw670pD2v8Rnr3I5pX3qQYtbnnHFWIVxVyp7oU66oxxLhjTLDmySgsLNEUA354cbWc4tiR8csCrrLtDCBnP2e/E/Iik1huSSEX2kTRqNnCAE0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324286; 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=mNWFporxuSTDjSLYQBOHMt7nZPKS0zVOBkEl7cC864s=; b=JvI+H4zKasSdLTQYCAs5u25NkHDN624JeGQSXwaKB9PT6h5/9YM7VMEP4hkQMy+8+tc+UM2AJlZA0BSdf1L2YkillMEBytEbtR6/SeDvIqkMqql4v0XQzUj5kE5D4nkklmjS5sHhvUbFx32zaq+t0uu3dgJ4tqKc71vcvXT3rt8= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 174732428633126.21563440111845; Thu, 15 May 2025 08:51:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanY-0002AI-LY; Thu, 15 May 2025 11:47:04 -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 1uFamH-00089s-VI for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:46 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFamF-0006W7-3C for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:45 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FBNZKX014714; Thu, 15 May 2025 08:45:40 -0700 Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azlp17010022.outbound.protection.outlook.com [40.93.12.22]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbd0we36-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:40 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:23 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=mNWFporxuSTDjSLYQBOHMt7nZPKS0zVOBkEl7cC86 4s=; b=zbuIi6c9W4dYlQVhVhqrpLnCqzKyytCMm9rs8p8oWKxYXfEElSaCCaNUv dPo1yGdkFUt8eJxthrof1SS0Pb9Y3shx3oQvXBFlMmgNEmpE5Um8G2C3ZUAWcdvo BxOrzInEq6iB66Hgxvk/2lYqCOqm+C2Rd7DIbSTN5h4ZftzIX9LDH/bN0A0nQKhp UUVuq6ycR+29aUMCUj3YatxnDhmcrv9IY3xw53PmfJsaI7rSEzvL+BtUWCJV1vib tvSH4KvxvKs6IFID65m1dJj/9zOk0sNbAteFhZrM2fPVOOnX7OlXTsiBax64HRzX mifz/uqcxoy3a5aaMDE1+Kttjgm1w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ioaxLvfhc7vk4TwNGe0ZCTsvvjI1XzNQdQtDOGsyoYdaMFISLKzZveJR9QWmCdjBwmiFIC9yp9VqQRybSuKD78yx4LP9tlLmR9Jl/5bslyJSnfd8E1iqmxg3Hyfb0baxzYaaU4BPzsqPbg63XkmPRmkmOofbw4qef64x5k3VYJYrGgol7c1qnm4JbqjUymriIDlgMWjvZ5fsu2wa6MrGUi2StHYZwth0HKPQSzfh99xIXFvVn3LUck7RUItpD2Jk8/s7velK6YdnzUJ05A3Gyjmpk/Z8lN93iqMbhE9WhuuypNrqfYaQ13cJT1BvfhPMaKgHKZDs97ytUGSFDlU0Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mNWFporxuSTDjSLYQBOHMt7nZPKS0zVOBkEl7cC864s=; b=qQNvA6Z99G41JbGs4pVN6jmQs9/v6DYWJXck21ts71xEfLOZEy1Wr6AeL/sQsTPYzmWGKypg+1AFEOY6q3pWNZ9N4MOQQMgawdDrLDA+uzjS+REAJD3rtZANPQe1b22+O8mIH9MjjNgsJaIvWCvQpPWNCRhuY8Pi/mrim5OaPtK0TeBUGxXdk0awiNML8yRwEg40oOVAzXOVZgzSVOXvytmKH/ip7mTV7DOt80HvHO/BMWGTUaAa9XTkWjgUiwxVkJLY/jwXow0+pb9IxO4bCPqPpK6Ytq5KL9iW/BSCPTEY6s9KnsaVHa9cM5QkWymUpyJfBFW1BBMUnHP+6tJMVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mNWFporxuSTDjSLYQBOHMt7nZPKS0zVOBkEl7cC864s=; b=w5z+cgC0AXAwu3zGF2dXPiRsV1cg5qxjGGtTUgLvTfDX5R2N9FASvCo8yzhVgOF1EClezngnuj6L/jXg3Szb3Q/XK2w5pzeVX/ZTKio2I3PRi9NSBfFH7eCP8jqZM6TR4W3Dhiu/op8OY+LnRXgDZ5BBh0gwsoBqpW3HLN0swTOInAg/SBbGtYLLoOH6o7PhNSYRWUTbufDQVFIvJjA0c3kFKIKiTBo9V6zwhRD2/akQreIeFGmVOaLnVlQqLJr42HDnNN1jU/pnCAL5GZCE9RjFAY9QZsj+CXgViZ22CHhfdn1DnEuwGhlFUnADR9QTZE+pHpgbBKatQQ5H+6lGIA== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 25/27] vfio-user: support posted writes Date: Thu, 15 May 2025 16:44:10 +0100 Message-ID: <20250515154413.210315-26-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: d6e47425-a891-4598-0244-08dd93c78084 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?n+fcUaUZibvew84PivkKYSSgAtulnFjtJGkJJwrbAfY+PPY4rKVO4pB1vtuk?= =?us-ascii?Q?6hK8sIBD02tWidKiAalJ5Si8GuFznIeCoGNFryn2XdX/S73s4XFsNUf6BHLh?= =?us-ascii?Q?irZy/CYaj20WOJWksA0gtNZW1FK8/Abgufa2SDV8GhXeI6qbBL7hRNahpXEo?= =?us-ascii?Q?P4OHi+kfSFeWII8OuZJqGSRnUoqaRqh8P5iTheO268yzz2Rm6MEBXpY4NHUi?= =?us-ascii?Q?2jaSp2rasEtFB2BKSYK4QDbA58NFMDV6EWficVdurLrMzWHLIawbrwxUpiIj?= =?us-ascii?Q?Cy6OJ9Y+JhB1vvrR6/GeFi6NbwSdydPc6qtyOEoOB9MItz0vplgZjxDeQnvT?= =?us-ascii?Q?xS0Y2vZAYCiSyFRZBqF6E0CVn+U1ji6Xs9lKcIMgDQSqyYg/n8EEaeBBQeTA?= =?us-ascii?Q?oUKZZ2jhHsIX5hqAtwmfb2rgcpYqtqL3A0Bf11gcPDnr1vDJpwvSpIVcapRG?= =?us-ascii?Q?ZiHvFoakoT7CEoAIOG1tZVTpt6oKrEhRxt+jxiVu1X465ZHbsc+IZEX2zQPA?= =?us-ascii?Q?DMCO4Zr7dwKc8bYU+Rgc/3v3NlfUJPJCEIqlwazAWMhDNxH8pP1g2fzEM1KK?= =?us-ascii?Q?aR2gk0Q6/SsoDlYMPKKEpeMY+nkblJf+46pWulkazU2UrLV+HeBA4p5c6G8Z?= =?us-ascii?Q?zPXuH9pxC+guUUIpFBUDTWgdxkhTnSKlak8vHyBH0TuNuJctnI4O7HtsbBYY?= =?us-ascii?Q?wlvlwkLO28QAtqwoNTQDjiRFvFpyiA+iBYQ47sLIJVD+A7mTSXzFMQIXUTBc?= =?us-ascii?Q?x4CdzZR5W03iVKEugWeEjoyaJ4kYeekKHMXA2FhsygRgxFTHL9hPndEG31hM?= =?us-ascii?Q?df4ZZNAr8H14VnqfeVqL/8cCxkOSWL8pElWo8E+fxvHq0u2mecgA8+9MXgXW?= =?us-ascii?Q?zJIC4bTimx+1nrn17j0V2qbDqAQgfOaM3DDgrC0LbS7lbCdtjGSKyBVLQ49a?= =?us-ascii?Q?ESMrrR+6Q2dRw0hhecRjva/A2V1pjj0MQICzqSqUVTDMuJgcinYeVaFuDyFr?= =?us-ascii?Q?2FQdabFNXkytDrFrYMmu5YJheSuUvkvUG6OUCZU0kmT0eloNjlcmnGL6jRNa?= =?us-ascii?Q?F0tCWpBECjnY3Ak8Hp34tJRa/yM8E0TNJJX3gJRykzZlMzmyRIMm9/wR4p9d?= =?us-ascii?Q?pREvs1TWv8bpxM0OQYZG/0HaVLoAG7dj73xuzdJbQWB4AlGiUoUDFZxDo1fy?= =?us-ascii?Q?GUWPMM04rG9i45dFnuncE0Mi43nR79Pov9AJS1Pb7yY20wukxdCwnThimGuQ?= =?us-ascii?Q?kSFmMdwBvwcvZVhTys8p2JxbNl6SUuG34Ha5yhr3hLtyYmK0z7Yca7p9LyDZ?= =?us-ascii?Q?fM0m0QZ2Mersbc1V9caqala7VM3ObMEmrVLv4uNbuYDgVX2kDBNQ0f0S7M3E?= =?us-ascii?Q?TxXlqe58HN6S+SVIxBqDxiIok0f+u/TOVD9SHmzTmSa9bKlcdUqqvo9tWXnp?= =?us-ascii?Q?xwzGQabzkbU=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?r94JeAlVlvih0kRKv/dLTDA/hllpghUbf0JO/1qgo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q?sHE1nhKygvLHEgb5yTjO0m7UQw4zWYt611Fq0Czvob2Cur9zEiagRxoEzQrg?= =?us-ascii?Q?mbUZ8i8Y7r15YqjpL+LrLnMX4JGZenVw5vHq6f6zEKqe3Mnpb3qlvgT6jMRs?= =?us-ascii?Q?xw4efZLApU6i94kMbFJCloY+G11uV+VNRD5htJA++wvZj4+4xYEYGY3VPQlw?= =?us-ascii?Q?Xkb5bMPh1XgO6TwfT5PJlonhip911NXqcZSxWnbvMFB6oHoullyrF3HXOdBz?= =?us-ascii?Q?u89tQ+c0QTx87CNJUT6Cd47zSln5QqaC7M3Ke0g3OGvJ98gesPrsq4hz5vwI?= =?us-ascii?Q?GrZ91DZkqcwirPgtLWenqTuNfb3m/PPHRKeFJJG6tKi4LQrBZHhzP/P4A62d?= =?us-ascii?Q?vZ/S1vpQPEZxiSdR2nKHr2XZwnb7kKdVFhjDiGTO6oSRNM70Dk5JphBK4EX2?= =?us-ascii?Q?WGxBbDXTkwP0WbLqefgkaUiOcwP87i97LEm+Okzoz8Op5eC7YOe24PioKHgi?= =?us-ascii?Q?v5/FNAjDuIgcc1uSTqk/iiwN221rRm1K6cKV+ZucBSTUB8kIcJd5snNWCqN4?= =?us-ascii?Q?7MCB+RiJavvETNzsR1Fq82f/o8/7T8f1P8iYBSg7lGt1Xkm6NQZsPWBxt7iI?= =?us-ascii?Q?q3QrW7WLLIbc/Va1wzc0MJWCNiFIElWNweFEZ2fXMs78JvVOUxz16EbnzXQ2?= =?us-ascii?Q?6NSPAQNDNOw6v2AG/IV8mGJPWcKgtjpq/4LxhnG/?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6e47425-a891-4598-0244-08dd93c78084 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:22.1693 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bcpePlvmHdq3PAkmr4Dc0j8kKkuyslA74/M15OepNlcpJPG2YyejKhKW/bm617ch3eCcBHWVz7WkCYWeOlNB6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-ORIG-GUID: bNFNT-W46qPlCrQrUl_9ITdAsFhhKvUS X-Proofpoint-GUID: bNFNT-W46qPlCrQrUl_9ITdAsFhhKvUS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX/VaPcndH2/Ml 0mDrFUdDC28sFnJ1A17X7qwjibe5D4oWXz5VG1+INZoyz6IqQFpLEgc8xP+RHHVTwc7IYRjVMn7 7oyqvdqlaxypUrsLAYyp2UAzCiJWaUoJpQKD78IcBuL8ZBiGRow/X6VX/h1hPr9i3mf0IFimxww UV0yAHDxMvkL77aGRywQWoPY7F+C9nbpQpa1zC0AcQNxFub/VqLgMQ55WzeXbZF7tpqDidE45Lb iSE2vcAKP9nfdvllkHyzZBXsei9Zubp7uNN9KuMs62Cvc/EOUZO7DTi0wCmJxkp0Gb1IBcP4RBR istdDSkRsIvMOHuwuXp+G2xCdp8xuikPskLKdSK7d8SLSCdIFoLqZq5UcFW6EcsjVTHxLEMBudV pUff84PB9pat6Hd6ChAyfRd/5uy7Wa6U3MgD6+oGQzPpkJhGwqouq/JjgtTRqCqfpgZ420df X-Authority-Analysis: v=2.4 cv=KKlaDEFo c=1 sm=1 tr=0 ts=68260c24 cx=c_pps a=tQsPtMi3p37jOgXbkrwZvw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=64Cc0HZtAAAA:8 a=hLZCMK2IaNhFlHKNMJgA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324287728116600 Content-Type: text/plain; charset="utf-8" Support an asynchronous send of a vfio-user socket message (no wait for a reply) when the write is posted. This is only safe when no regions are mappable by the VM. Add an option to explicitly disable this as well. Signed-off-by: John Levon --- hw/vfio-user/proxy.h | 5 +++++ hw/vfio-user/device.c | 37 ++++++++++++++++++++++++++++++++++--- hw/vfio-user/pci.c | 6 ++++++ hw/vfio-user/proxy.c | 12 ++++++++++-- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index da29674fdc..22ed66c54f 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -94,6 +94,7 @@ typedef struct VFIOUserProxy { /* VFIOProxy flags */ #define VFIO_PROXY_CLIENT 0x1 #define VFIO_PROXY_FORCE_QUEUED 0x4 +#define VFIO_PROXY_NO_POST 0x8 =20 typedef struct VFIODevice VFIODevice; =20 @@ -107,6 +108,8 @@ bool vfio_user_validate_version(VFIOUserProxy *proxy, E= rror **errp); VFIOUserFDs *vfio_user_getfds(int numfds); void vfio_user_putfds(VFIOUserMsg *msg); =20 +void vfio_user_disable_posted_writes(VFIOUserProxy *proxy); + void vfio_user_request_msg(VFIOUserHdr *hdr, uint16_t cmd, uint32_t size, uint32_t flags); void vfio_user_wait_reqs(VFIOUserProxy *proxy); @@ -114,6 +117,8 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUser= Hdr *hdr, VFIOUserFDs *fds, int rsize); void vfio_user_send_nowait(VFIOUserProxy *proxy, VFIOUserHdr *hdr, VFIOUserFDs *fds, int rsize); +void vfio_user_send_async(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds); void vfio_user_send_reply(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int size= ); void vfio_user_send_error(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int erro= r); =20 diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index b37f7329a1..eb2194c0eb 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -93,10 +93,21 @@ static int vfio_user_get_region_info(VFIOUserProxy *pro= xy, trace_vfio_user_get_region_info(msgp->index, msgp->flags, msgp->size); =20 memcpy(info, &msgp->argsz, info->argsz); + + /* + * If at least one region is directly mapped into the VM, then we can = no + * longer rely on the sequential nature of vfio-user request handling = to + * ensure that posted writes are completed before a subsequent read. I= n this + * case, disable posted write support. This is a per-device property, = not + * per-region. + */ + if (info->flags & VFIO_REGION_INFO_FLAG_MMAP) { + vfio_user_disable_posted_writes(proxy); + } + return 0; } =20 - static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev, struct vfio_region_info *in= fo, int *fd) @@ -272,6 +283,12 @@ static int vfio_user_device_io_region_read(VFIODevice = *vbasedev, uint8_t index, return msgp->count; } =20 +/* + * If this is a posted write, and VFIO_PROXY_NO_POST is not set, then we a= re OK + * to send the write to the socket without waiting for the server's reply: + * a subsequent read (of any region) will not pass the posted write, as all + * messages are handled sequentially. + */ static int vfio_user_device_io_region_write(VFIODevice *vbasedev, uint8_t = index, off_t off, unsigned count, void *data, bool post) @@ -279,21 +296,35 @@ static int vfio_user_device_io_region_write(VFIODevic= e *vbasedev, uint8_t index, VFIOUserRegionRW *msgp =3D NULL; VFIOUserProxy *proxy =3D vbasedev->proxy; int size =3D sizeof(*msgp) + count; + int flags =3D 0; int ret; =20 if (count > proxy->max_xfer_size) { return -EINVAL; } =20 + if (proxy->flags & VFIO_PROXY_NO_POST) { + post =3D false; + } + + if (post) { + flags |=3D VFIO_USER_NO_REPLY; + } + msgp =3D g_malloc0(size); - vfio_user_request_msg(&msgp->hdr, VFIO_USER_REGION_WRITE, size, 0); + vfio_user_request_msg(&msgp->hdr, VFIO_USER_REGION_WRITE, size, flags); msgp->offset =3D off; msgp->region =3D index; msgp->count =3D count; memcpy(&msgp->data, data, count); trace_vfio_user_region_rw(msgp->region, msgp->offset, msgp->count); =20 - /* Ignore post: all writes are synchronous/non-posted. */ + /* async send will free msg after it's sent */ + if (post) { + vfio_user_send_async(proxy, &msgp->hdr, NULL); + return count; + } + vfio_user_send_wait(proxy, &msgp->hdr, NULL, 0); if (msgp->hdr.flags & VFIO_USER_ERROR) { ret =3D -msgp->hdr.error_reply; diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 3df92acb82..3d6a1aeb4d 100644 --- a/hw/vfio-user/pci.c +++ b/hw/vfio-user/pci.c @@ -26,6 +26,7 @@ struct VFIOUserPCIDevice { char *sock_name; bool send_queued; /* all sends are queued */ uint32_t wait_time; /* timeout for message replies */ + bool no_post; /* all region writes are sync */ }; =20 /* @@ -255,6 +256,10 @@ static void vfio_user_pci_realize(PCIDevice *pdev, Err= or **errp) proxy->flags |=3D VFIO_PROXY_FORCE_QUEUED; } =20 + if (udev->no_post) { + proxy->flags |=3D VFIO_PROXY_NO_POST; + } + /* user specified or 5 sec default */ proxy->wait_time =3D udev->wait_time; =20 @@ -392,6 +397,7 @@ static const Property vfio_user_pci_dev_properties[] = =3D { DEFINE_PROP_STRING("socket", VFIOUserPCIDevice, sock_name), DEFINE_PROP_BOOL("x-send-queued", VFIOUserPCIDevice, send_queued, fals= e), DEFINE_PROP_UINT32("x-msg-timeout", VFIOUserPCIDevice, wait_time, 5000= ), + DEFINE_PROP_BOOL("x-no-posted-writes", VFIOUserPCIDevice, no_post, fal= se), }; =20 static void vfio_user_pci_dev_class_init(ObjectClass *klass, const void *d= ata) diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 74cfaff6fa..13f2407845 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -683,8 +683,8 @@ void vfio_user_send_wait(VFIOUserProxy *proxy, VFIOUser= Hdr *hdr, /* * async send - msg can be queued, but will be freed when sent */ -static void vfio_user_send_async(VFIOUserProxy *proxy, VFIOUserHdr *hdr, - VFIOUserFDs *fds) +void vfio_user_send_async(VFIOUserProxy *proxy, VFIOUserHdr *hdr, + VFIOUserFDs *fds) { VFIOUserMsg *msg; int ret; @@ -805,6 +805,14 @@ void vfio_user_putfds(VFIOUserMsg *msg) msg->fds =3D NULL; } =20 +void +vfio_user_disable_posted_writes(VFIOUserProxy *proxy) +{ + WITH_QEMU_LOCK_GUARD(&proxy->lock) { + proxy->flags |=3D VFIO_PROXY_NO_POST; + } +} + static QLIST_HEAD(, VFIOUserProxy) vfio_user_sockets =3D QLIST_HEAD_INITIALIZER(vfio_user_sockets); =20 --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324199; cv=pass; d=zohomail.com; s=zohoarc; b=k8pU7QqAeRZg57g7JJrhz5+Jt/TzuLdrbqBJqcq3XSnZyxLwg9xOJIUFlUWUg8O4Zr9kiC0PjfR3u8DWA9zeohMGo+G7NrTETcta7w8AXHvAP5m+Chr0O4UPqKsTUlOX8KYFStPWpfvXutAgHW3qPgFmH8dtzDlspDGEUy8/hT4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324199; 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=CXd2NeK/ET6uD8gmkhbk2vh4nYzQVltKbqv/Wx4cyuA=; b=oAhi1DB0rybJRQ3t4iZZ6EvDiV2C+RXRj2FAJWRm0g9mOA+8jiQSvNYF+i6ZFYcIihEjW25XMLU+8qP3CooOzwqY2Mzz1WA4tx2ioyy5SVlZzDUfjo9MawM/tc9E1odPnuqhTS/2G/PZLl1mStHJTj5KJQbkEnBBXmDZH0X3JMM= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324199732572.7867496314836; Thu, 15 May 2025 08:49:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanR-0001Wy-MY; Thu, 15 May 2025 11:46:58 -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 1uFamN-0008JU-7b for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:56 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFamH-0006WC-La for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:50 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FBNZKY014714; Thu, 15 May 2025 08:45:41 -0700 Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azlp17010022.outbound.protection.outlook.com [40.93.12.22]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbd0we36-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:41 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:24 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=CXd2NeK/ET6uD8gmkhbk2vh4nYzQVltKbqv/Wx4cy uA=; b=vtgM3K+FjPraJmyKPEPqC8t1WSMQndMH+lE6fSZUlf6nRjHNzz9pqAZ7r 9vapgwNOOWg/7S/j5NekbNlrMOGwYdzlWbCKgxgaEkra0fJNXs9pZgs8gKAaxFw6 UQqwrPS0FtxPtf5hWFtvEdVNw34SwBUjMZIHxGKCnFXK6R2H+3eE4RskwoLSVXOr Noq4TolyeRNEqXJYB4vI+E4NZpFrLStXjEYNmqDw69uersGgnFbtQoNpd2KH09D9 kNMMJ5MrZbsosPWG2EBhQUr4PAghffVuvq5r9xzmVTogRNaUSBhaNt1PV5diKO62 V+DlNXpm/FYXt0dP6DnMqMXHdgOfg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LQdzPx9ODJqwkmGO1eDay/bf72ArxeUXW9db+PZBj+Wo/04NWTygbXsNb4JoLDX8XVqRIlhlGYEs4h2VQFvH4lmdMQKTkl7NFQwudySBiVS7GT02rVAP0+8TDZEgJXoHefvJ6Hczt/5AP8VK8ppnA24z1xpt8UPsXJTNdYCPhDONfNaQCJ4HC32yELg82sOzz1qqh5D67K70as7cDgO3xNoKoYC87UUfF/8OnE5KuRwjJLdAREWuThkKTjHW1rcFwLFo2ZFPnQ+SSeaBadzbtDaKylr12Prww3o5hcTfAAL6hpnbssoO27zIGLYanZqFVOgNlXMXRCe1FTd0GMY0Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CXd2NeK/ET6uD8gmkhbk2vh4nYzQVltKbqv/Wx4cyuA=; b=ot9E6sBBCOurFE70FvoN6/xaYFdFiW1Q+pkl528E6AlEabi83w8vQICEVipVM2/8rbrZ07fwtU92a7AmucNsqID3GRLl6gUvhfOWB1aYLHltOk8QXg/UudchCkrcCf0wB7+l6WAYCOC1hhMaj3bAe/QO5F6PYj97TgQp1IRMxrrZ6m6v4uG1Eie3B0sVTP+UB/AlEiYpCeFWnu9r1UWGGa1H4o3ELpKKaJN9HWUqxFSpr7e4SsESTn6njJk7ZEs90Mbz0a7dfb9oYzE5Sul6A4pgYxaNQvLZXAh24kaLpPtd+qJAt4JpyM9L5ADjAbyzNH6vJkk3UoRUV80ci879Cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CXd2NeK/ET6uD8gmkhbk2vh4nYzQVltKbqv/Wx4cyuA=; b=FdOQ4jUv/+wWixcpqjjcMD97K7lpMDlKT9U+FSYfTQxveq6NLwVBWeKBY+/vpTAkguFreqebt0KUoA7lfxFll/cGcp7xP1tvlT6au1tVJ3tL8yIcZSR0Mu08eA4nqDr2h4Lg/ztRYRQcZxulrbkh5WzziqckjNfZaruoEs1h4zysfudzDF22ipoD8E7oDHkGTBxkz9MIEztUdPsT2bKjSFmTPhfKq0ItXFb5ClM6dEtZSLWWlwwhRtRoIIFMkJdlpCrZzJVAmXGNfGaLf4/6XjxcyDxs5aM6nWluPJt2LwsFmVFOdYftG5KTYKO6vRFMulBH1RYQtOjclVFr0vBSvQ== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH 26/27] vfio-user: add coalesced posted writes Date: Thu, 15 May 2025 16:44:11 +0100 Message-ID: <20250515154413.210315-27-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 40db95c5-fa9a-4031-419b-08dd93c78201 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mqMxpjufUpFgB5ooDKTD8sKQjoT3EYOcxyHQ270hc3uxkEChs4m1wjgmBEQx?= =?us-ascii?Q?NjgTAtbNQ311YwlHy9/Mi0hUXVFsod/4yPKB+lsdF/CfOim9hNK7LuBJWXrP?= =?us-ascii?Q?lFjD2hM0Z4zm540p4NbuTkJKgdt2k86Rs+/O00k7JJg56yAFgn48hkPJYCDM?= =?us-ascii?Q?3/HLgI9mLkhfTV2e63s9fpTSRDsQilWshjkhaN7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M3Z7tT350tM1BtIJxTHf7VR/pIgpvGgHVDUb28k?= =?us-ascii?Q?6n0c0+Uxzb/OWo06I1s9c51golMaUWnwP/SzgpbsKHZCc1OBDWuid6MW2Wb7?= =?us-ascii?Q?hn2Tzqtj0tUeyKDQBv22GhILf37FQfFRHL7xlkO9ngPQU1vts/s477XBusEt?= =?us-ascii?Q?1uwdyH8EhaU9wBSYXJzTCJXEx3Ol02pJJ/a9QbV5cr8hSBAlJ2NsR7jV4fnD?= =?us-ascii?Q?hRjFTjiExqMkst+BJvKNtY4qVYoWu7U7V9VzLSw3R0l3pvh3XPw2O8SSgk+C?= =?us-ascii?Q?yO/xpnoifuDmwxnarXixAFSNaOdN5cKl3wiOshahBhMOd/E0xQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pEYR/KdT25ssWuJPS3aE7FjT7MdS+hcyZaQNWHk9n7GA8LTxn/a2cMCABmlW?= =?us-ascii?Q?J9gEHSRw/SXhAJowprgWgxAZv3XQpJl8OQlLYBUWfSzkrhnoXqO/bwk6GblV?= =?us-ascii?Q?BxpeX0g6BTo8VZTfyMgqH5A67tZYRx7AsT+YMWkPYbtgfnEOxonCBFuQo7am?= =?us-ascii?Q?F2J+mNNGqC5leMMsRgPeB1eCT97kfgVFGGccFnz8zOMLCsMDZyJL+JwEp+EL?= =?us-ascii?Q?PF00t57WY8Cx7j2FR+BifXwbXsDCXdYxqwQUrh9Cr5xdcNcT79Ad5D182eli?= =?us-ascii?Q?o6x55qV8njzsaQ1S/MFZjpyoevO5mXQqOxWI0QpYzRJVXHCzGQVicw+D8UOh?= =?us-ascii?Q?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zMP1kPGFBUOp1f+c5/+suSVk9D/8B?= =?us-ascii?Q?QjLhRSdDJyyRriITl59Ez4uWK6o3Xea9kkKa/etBhStzP8A2LuEw8SmaDZ4t?= =?us-ascii?Q?2IJ4tLBV50/LnajohNdl5M8XSUppfLnTcr+t/yJUxsNw0oK9NVOajkgTPhK+?= =?us-ascii?Q?RaCnV5qgsMWT/6M7727ql2rsJhWIs/W3y/z6o016kgm/hd2lkUVKH6S4EedK?= =?us-ascii?Q?Aezg4XeHKEFLMG/81dsqDRpfPc9kmt9TP+FGh3uFO1iGJ1GmfBKtVLsIt0Rs?= =?us-ascii?Q?YWVV4tXJGNvN5+J7XKUg2sgHej6z3UHhgkK3SrPP4xjof5jPdlgEdP95EfYU?= =?us-ascii?Q?jOJVXIYe9frIkqc2aOjME31YzCGvmZnNwcgN8T2J?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40db95c5-fa9a-4031-419b-08dd93c78201 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:24.6974 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: E1V/jvoNLtcmr6olSffqqOnUs/KeR15bMHJedD1pfhqE64pNM0HUbCSsPsSLU8voCaMdGl5OD/axTcPUrRbzvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-ORIG-GUID: cL9egMB7G3occNn61QgjbTElbDBYZVWh X-Proofpoint-GUID: cL9egMB7G3occNn61QgjbTElbDBYZVWh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfX7KLO9870q5rs buPQNXkoi4Au4QhDnbvlCdAfa7JkHk39lMxISl/HQJGVdAVvcRYWJExRfEwJuB9R5vn9OcMuHV8 vVEALS11jgPhJVI2YBGYPw1FNwgsQayVvf5U4AHtaiDXz9ZvicdLHl1k42hWlhu6q/2G+2NrKy/ VsgaPIvGGFxz+WpOWVErmbVD7BB3kaQJcuWtdOOHQJIfE5nGQarS3x9qvz6bFwZVq/81bo5tCWf Yuxt/2tZZhpxT+xf1dnqVr+KBou+EeoxXjO+VYMR5w9weaDtF/WcjikifX61ayMGM7kAmR8IS8j i4ox1ULVj2mZsKBFssRPXqkg5ZO0POia7pyMGvx33Qxa5JshrYCM/caIJiOFG645p/RTsnMVBY8 d5aMMhScIpgJQtHoHKmF4Fgi6nWqlR/R+czFSVRNxnmIk9DkqG43haXRpYzTbNIJPKL6qAHL X-Authority-Analysis: v=2.4 cv=KKlaDEFo c=1 sm=1 tr=0 ts=68260c25 cx=c_pps a=tQsPtMi3p37jOgXbkrwZvw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=yPCof4ZbAAAA:8 a=64Cc0HZtAAAA:8 a=pwxC0n7aooic8zlvp-IA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324201077116600 Content-Type: text/plain; charset="utf-8" Add new message to send multiple writes to server in a single message. Prevents the outgoing queue from overflowing when a long latency operation is followed by a series of posted writes. Originally-by: John Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John Levon --- hw/vfio-user/protocol.h | 21 ++++++++++ hw/vfio-user/proxy.h | 12 ++++++ hw/vfio-user/device.c | 40 +++++++++++++++++++ hw/vfio-user/proxy.c | 84 +++++++++++++++++++++++++++++++++++++++ hw/vfio-user/trace-events | 1 + 5 files changed, 158 insertions(+) diff --git a/hw/vfio-user/protocol.h b/hw/vfio-user/protocol.h index 8f589faef4..f747e70e50 100644 --- a/hw/vfio-user/protocol.h +++ b/hw/vfio-user/protocol.h @@ -42,6 +42,7 @@ enum vfio_user_command { VFIO_USER_DMA_WRITE =3D 12, VFIO_USER_DEVICE_RESET =3D 13, VFIO_USER_DIRTY_PAGES =3D 14, + VFIO_USER_REGION_WRITE_MULTI =3D 15, VFIO_USER_MAX, }; =20 @@ -75,6 +76,7 @@ typedef struct { #define VFIO_USER_CAP_PGSIZES "pgsizes" #define VFIO_USER_CAP_MAP_MAX "max_dma_maps" #define VFIO_USER_CAP_MIGR "migration" +#define VFIO_USER_CAP_MULTI "write_multiple" =20 /* "migration" members */ #define VFIO_USER_CAP_PGSIZE "pgsize" @@ -221,4 +223,23 @@ typedef struct { char data[]; } VFIOUserBitmap; =20 +/* + * VFIO_USER_REGION_WRITE_MULTI + */ +#define VFIO_USER_MULTI_DATA 8 +#define VFIO_USER_MULTI_MAX 200 + +typedef struct { + uint64_t offset; + uint32_t region; + uint32_t count; + char data[VFIO_USER_MULTI_DATA]; +} VFIOUserWROne; + +typedef struct { + VFIOUserHdr hdr; + uint64_t wr_cnt; + VFIOUserWROne wrs[VFIO_USER_MULTI_MAX]; +} VFIOUserWRMulti; + #endif /* VFIO_USER_PROTOCOL_H */ diff --git a/hw/vfio-user/proxy.h b/hw/vfio-user/proxy.h index 22ed66c54f..ae09b9cc60 100644 --- a/hw/vfio-user/proxy.h +++ b/hw/vfio-user/proxy.h @@ -88,6 +88,8 @@ typedef struct VFIOUserProxy { VFIOUserMsg *last_nowait; VFIOUserMsg *part_recv; size_t recv_left; + VFIOUserWRMulti *wr_multi; + int num_outgoing; enum proxy_state state; } VFIOUserProxy; =20 @@ -95,6 +97,11 @@ typedef struct VFIOUserProxy { #define VFIO_PROXY_CLIENT 0x1 #define VFIO_PROXY_FORCE_QUEUED 0x4 #define VFIO_PROXY_NO_POST 0x8 +#define VFIO_PROXY_USE_MULTI 0x16 + +/* coalescing high and low water marks for VFIOProxy num_outgoing */ +#define VFIO_USER_OUT_HIGH 1024 +#define VFIO_USER_OUT_LOW 128 =20 typedef struct VFIODevice VFIODevice; =20 @@ -122,4 +129,9 @@ void vfio_user_send_async(VFIOUserProxy *proxy, VFIOUse= rHdr *hdr, void vfio_user_send_reply(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int size= ); void vfio_user_send_error(VFIOUserProxy *proxy, VFIOUserHdr *hdr, int erro= r); =20 +void vfio_user_flush_multi(VFIOUserProxy *proxy); +void vfio_user_create_multi(VFIOUserProxy *proxy); +void vfio_user_add_multi(VFIOUserProxy *proxy, uint8_t index, + off_t offset, uint32_t count, void *data); + #endif /* VFIO_USER_PROXY_H */ diff --git a/hw/vfio-user/device.c b/hw/vfio-user/device.c index eb2194c0eb..79375ddc96 100644 --- a/hw/vfio-user/device.c +++ b/hw/vfio-user/device.c @@ -10,6 +10,8 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/lockable.h" +#include "qemu/thread.h" =20 #include "hw/vfio-user/device.h" #include "hw/vfio-user/trace.h" @@ -296,6 +298,7 @@ static int vfio_user_device_io_region_write(VFIODevice = *vbasedev, uint8_t index, VFIOUserRegionRW *msgp =3D NULL; VFIOUserProxy *proxy =3D vbasedev->proxy; int size =3D sizeof(*msgp) + count; + bool can_multi; int flags =3D 0; int ret; =20 @@ -311,6 +314,43 @@ static int vfio_user_device_io_region_write(VFIODevice= *vbasedev, uint8_t index, flags |=3D VFIO_USER_NO_REPLY; } =20 + /* write eligible to be in a WRITE_MULTI msg ? */ + can_multi =3D (proxy->flags & VFIO_PROXY_USE_MULTI) && post && + count <=3D VFIO_USER_MULTI_DATA; + + /* + * This should be a rare case, so first check without the lock, + * if we're wrong, vfio_send_queued() will flush any posted writes + * we missed here + */ + if (proxy->wr_multi !=3D NULL || + (proxy->num_outgoing > VFIO_USER_OUT_HIGH && can_multi)) { + + /* + * re-check with lock + * + * if already building a WRITE_MULTI msg, + * add this one if possible else flush pending before + * sending the current one + * + * else if outgoing queue is over the highwater, + * start a new WRITE_MULTI message + */ + WITH_QEMU_LOCK_GUARD(&proxy->lock) { + if (proxy->wr_multi !=3D NULL) { + if (can_multi) { + vfio_user_add_multi(proxy, index, off, count, data); + return count; + } + vfio_user_flush_multi(proxy); + } else if (proxy->num_outgoing > VFIO_USER_OUT_HIGH && can_mul= ti) { + vfio_user_create_multi(proxy); + vfio_user_add_multi(proxy, index, off, count, data); + return count; + } + } + } + msgp =3D g_malloc0(size); vfio_user_request_msg(&msgp->hdr, VFIO_USER_REGION_WRITE, size, flags); msgp->offset =3D off; diff --git a/hw/vfio-user/proxy.c b/hw/vfio-user/proxy.c index 13f2407845..dbaa322952 100644 --- a/hw/vfio-user/proxy.c +++ b/hw/vfio-user/proxy.c @@ -16,12 +16,14 @@ #include "hw/vfio-user/proxy.h" #include "hw/vfio-user/trace.h" #include "qapi/error.h" +#include "qobject/qbool.h" #include "qobject/qdict.h" #include "qobject/qjson.h" #include "qobject/qnum.h" #include "qemu/error-report.h" #include "qemu/lockable.h" #include "qemu/main-loop.h" +#include "qemu/thread.h" #include "system/iothread.h" =20 static IOThread *vfio_user_iothread; @@ -444,6 +446,11 @@ static void vfio_user_send(void *opaque) } qio_channel_set_aio_fd_handler(proxy->ioc, proxy->ctx, vfio_user_recv, NULL, NULL, proxy); + + /* queue empty - send any pending multi write msgs */ + if (proxy->wr_multi !=3D NULL) { + vfio_user_flush_multi(proxy); + } } } =20 @@ -464,6 +471,7 @@ static int vfio_user_send_one(VFIOUserProxy *proxy) } =20 QTAILQ_REMOVE(&proxy->outgoing, msg, next); + proxy->num_outgoing--; if (msg->type =3D=3D VFIO_MSG_ASYNC) { vfio_user_recycle(proxy, msg); } else { @@ -571,11 +579,18 @@ static int vfio_user_send_queued(VFIOUserProxy *proxy= , VFIOUserMsg *msg) { int ret; =20 + /* older coalesced writes go first */ + if (proxy->wr_multi !=3D NULL && + ((msg->hdr->flags & VFIO_USER_TYPE) =3D=3D VFIO_USER_REQUEST)) { + vfio_user_flush_multi(proxy); + } + /* * Unsent outgoing msgs - add to tail */ if (!QTAILQ_EMPTY(&proxy->outgoing)) { QTAILQ_INSERT_TAIL(&proxy->outgoing, msg, next); + proxy->num_outgoing++; return 0; } =20 @@ -589,6 +604,7 @@ static int vfio_user_send_queued(VFIOUserProxy *proxy, = VFIOUserMsg *msg) } if (ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { QTAILQ_INSERT_HEAD(&proxy->outgoing, msg, next); + proxy->num_outgoing =3D 1; qio_channel_set_aio_fd_handler(proxy->ioc, proxy->ctx, vfio_user_recv, proxy->ctx, vfio_user_send, proxy); @@ -1112,12 +1128,27 @@ static bool check_migr(VFIOUserProxy *proxy, QObjec= t *qobj, Error **errp) return caps_parse(proxy, qdict, caps_migr, errp); } =20 +static bool check_multi(VFIOUserProxy *proxy, QObject *qobj, Error **errp) +{ + QBool *qb =3D qobject_to(QBool, qobj); + + if (qb =3D=3D NULL) { + error_setg(errp, "malformed %s", VFIO_USER_CAP_MULTI); + return false; + } + if (qbool_get_bool(qb)) { + proxy->flags |=3D VFIO_PROXY_USE_MULTI; + } + return true; +} + static struct cap_entry caps_cap[] =3D { { VFIO_USER_CAP_MAX_FDS, check_max_fds }, { VFIO_USER_CAP_MAX_XFER, check_max_xfer }, { VFIO_USER_CAP_PGSIZES, check_pgsizes }, { VFIO_USER_CAP_MAP_MAX, check_max_dma }, { VFIO_USER_CAP_MIGR, check_migr }, + { VFIO_USER_CAP_MULTI, check_multi }, { NULL } }; =20 @@ -1176,6 +1207,7 @@ static GString *caps_json(void) qdict_put_int(capdict, VFIO_USER_CAP_MAX_XFER, VFIO_USER_DEF_MAX_XFER); qdict_put_int(capdict, VFIO_USER_CAP_PGSIZES, VFIO_USER_DEF_PGSIZE); qdict_put_int(capdict, VFIO_USER_CAP_MAP_MAX, VFIO_USER_DEF_MAP_MAX); + qdict_put_bool(capdict, VFIO_USER_CAP_MULTI, true); =20 qdict_put_obj(dict, VFIO_USER_CAP, QOBJECT(capdict)); =20 @@ -1228,3 +1260,55 @@ bool vfio_user_validate_version(VFIOUserProxy *proxy= , Error **errp) trace_vfio_user_version(msgp->major, msgp->minor, msgp->capabilities); return true; } + +void vfio_user_flush_multi(VFIOUserProxy *proxy) +{ + VFIOUserMsg *msg; + VFIOUserWRMulti *wm =3D proxy->wr_multi; + int ret; + + proxy->wr_multi =3D NULL; + + /* adjust size for actual # of writes */ + wm->hdr.size -=3D (VFIO_USER_MULTI_MAX - wm->wr_cnt) * sizeof(VFIOUser= WROne); + + msg =3D vfio_user_getmsg(proxy, &wm->hdr, NULL); + msg->id =3D wm->hdr.id; + msg->rsize =3D 0; + msg->type =3D VFIO_MSG_ASYNC; + trace_vfio_user_wrmulti("flush", wm->wr_cnt); + + ret =3D vfio_user_send_queued(proxy, msg); + if (ret < 0) { + vfio_user_recycle(proxy, msg); + } +} + +void vfio_user_create_multi(VFIOUserProxy *proxy) +{ + VFIOUserWRMulti *wm; + + wm =3D g_malloc0(sizeof(*wm)); + vfio_user_request_msg(&wm->hdr, VFIO_USER_REGION_WRITE_MULTI, + sizeof(*wm), VFIO_USER_NO_REPLY); + proxy->wr_multi =3D wm; +} + +void vfio_user_add_multi(VFIOUserProxy *proxy, uint8_t index, + off_t offset, uint32_t count, void *data) +{ + VFIOUserWRMulti *wm =3D proxy->wr_multi; + VFIOUserWROne *w1 =3D &wm->wrs[wm->wr_cnt]; + + w1->offset =3D offset; + w1->region =3D index; + w1->count =3D count; + memcpy(&w1->data, data, count); + + wm->wr_cnt++; + trace_vfio_user_wrmulti("add", wm->wr_cnt); + if (wm->wr_cnt =3D=3D VFIO_USER_MULTI_MAX || + proxy->num_outgoing < VFIO_USER_OUT_LOW) { + vfio_user_flush_multi(proxy); + } +} diff --git a/hw/vfio-user/trace-events b/hw/vfio-user/trace-events index 7ef98813b3..64fac9137f 100644 --- a/hw/vfio-user/trace-events +++ b/hw/vfio-user/trace-events @@ -11,6 +11,7 @@ vfio_user_get_region_info(uint32_t index, uint32_t flags,= uint64_t size) " index vfio_user_region_rw(uint32_t region, uint64_t off, uint32_t count) " regio= n %d offset 0x%"PRIx64" count %d" vfio_user_get_irq_info(uint32_t index, uint32_t flags, uint32_t count) " i= ndex %d flags 0x%x count %d" vfio_user_set_irqs(uint32_t index, uint32_t start, uint32_t count, uint32_= t flags) " index %d start %d count %d flags 0x%x" +vfio_user_wrmulti(const char *s, uint64_t wr_cnt) " %s count 0x%"PRIx64 =20 # container.c vfio_user_dma_map(uint64_t iova, uint64_t size, uint64_t off, uint32_t fla= gs, bool async_ops) " iova 0x%"PRIx64" size 0x%"PRIx64" off 0x%"PRIx64" fla= gs 0x%x async_ops %d" --=20 2.43.0 From nobody Tue Dec 16 03:21:13 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); dmarc=pass(p=none dis=none) header.from=nutanix.com ARC-Seal: i=2; a=rsa-sha256; t=1747324091; cv=pass; d=zohomail.com; s=zohoarc; b=Q3FjaPi0yi/4QT2Y0N5bOQxUGVXSXJAUBlEh6zhSHFkPjcz22rLlLsReqKsduYaLNGM7LRYn4ekR/etK8YmuTe1DxrIFpv+O4ye2ahVyDFiGe4vNAx9hhekUAITh16s0JadfKLQK8xtUqGjQn8czCO5SPAQOaIPuh8WgSolY298= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747324091; 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=NYHfEYolJYtB7ztdkTtSBJXJfFu8OJVZtPxqxjVBUgw=; b=fiqxt2QGsqVr3CxBoN6lHAJHbmYEDdn/S5nhn7OlAArUp/tabKNMxYEXVFyxikKdLZUpOkVS2YhYRPmf/lu0jYaoarT9cJjxOw+WybTu1LezNh9/tGnCDn6xZWoXpS+VpnvCmhBAQTh0hxipcd7syzKH0c8kIkcI29uvP9LOrGM= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=nutanix.com); 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 1747324091570726.6180013930812; Thu, 15 May 2025 08:48:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFanb-0002PN-0M; Thu, 15 May 2025 11:47:07 -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 1uFamL-0008IM-Od for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:49 -0400 Received: from mx0b-002c1b01.pphosted.com ([148.163.155.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFamG-0006WK-A0 for qemu-devel@nongnu.org; Thu, 15 May 2025 11:45:48 -0400 Received: from pps.filterd (m0127841.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54FBNZKZ014714; Thu, 15 May 2025 08:45:42 -0700 Received: from bn1pr04cu002.outbound.protection.outlook.com (mail-eastus2azlp17010022.outbound.protection.outlook.com [40.93.12.22]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46mbd0we36-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 May 2025 08:45:41 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8470.namprd02.prod.outlook.com (2603:10b6:510:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.17; Thu, 15 May 2025 15:45:26 +0000 Received: from CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51]) by CH2PR02MB6760.namprd02.prod.outlook.com ([fe80::fd77:ea65:a159:ef51%6]) with mapi id 15.20.8722.024; Thu, 15 May 2025 15:45:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= proofpoint20171006; bh=NYHfEYolJYtB7ztdkTtSBJXJfFu8OJVZtPxqxjVBU gw=; b=t2R3AjEEC8v9QkWWSaLen8A6Rue6k33TTsOmohNp79sNh2LHUVD389HuK 9qsAyQ/B691m90e4T5wRSIDnIIw8T1Apvhp00AN0OHkTvLTg6UyNVw387FXiv+ir i4Jv2KRivEQeVK0syaSZ3Kg9I45kawI8A0VB2s3mqRnFx+NPwkPZ7CORnBvUupPe +Fpi3taOTtsDetgN1sLqVLnhjGxeHdvHOR154jOaFH66VXFzbTjT+0TUxpinZmXr DmiwzSuvwP1ehcwk+6Vnr6Oo+gVPjtP8+Z6DApM7FHg/bZ7O72Zag1GYQ11bL2vg GUU+Ey2Opj0Sy6YXzCQwQMYbvUUcw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NDwfFHVunbCO01BcusS41Rq7waPigY3E1l9uPXFxyjeWxdfCW7X4bCVu8d/OIJmKexCZn4pm+6GF+YtrF23niVjwWhdk9ck0S/jn/v1d4sP9hhG1gPGYlnE+OwNpxSfuPFwcRn0Z6a4oxJmvMOvdTOxhsAbksUnMQi3c7b381326ib8B/S8khNszPsd2iQaXB9RW+iVNRIcHukzpUX6Tv1BpyqFLPhCZesJP06ofpytHQWVWlIXxaxH7QQh3Aj0Y+x6m6IAIV+su4G7NcqDo3JGFHk6PDshvHCT+FexDVgRpxt0z0N2dno9LLlo8sw+/VyvPG28IesTpyaCx5RpxzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NYHfEYolJYtB7ztdkTtSBJXJfFu8OJVZtPxqxjVBUgw=; b=GJbdTRYNwN06GMHngUk2q/8QHi4CTCiuhxe3/5z0ATY/eP8XF8dpGQmCYJ040BqZRTalw0jOZHEPRQKepsSZRrZ/X5wGgQTP/d10P6PONMMnGaZausH5hQZVcUIpAYgKeurap0qY3oO8BkY0+p2fEcTuzRAa4FBDY8luas1qmE6iseOjEh0Lj7XTSrFO31nUwdouDBVWG35GAnnS0nVH8nmYTs8ICaCGwkZ1KwJW57B6O5EmULRx7zg+rXZJUN/s4PoRTIerXJMnWPlzaa4exWRKzQRJJGr5pvdTtARSC2ysFdPN7N0VZflQu2X0uiddLs4K3v8s2Iql7pe4D90bbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NYHfEYolJYtB7ztdkTtSBJXJfFu8OJVZtPxqxjVBUgw=; b=g8t8DKnIGmNeJGlGvRz2PxzsEwCPK2R2hG0pebESY0hx0d2MYvlccFUxFtPlrHs2CE1DTnLkiVPDImitzIPrJf/75lIe9WIaqzFxCK69PZwixZHjVniyNrGTS7hYXuLrk5Tr5RM17hzLi/66WRZGdgvw7TDr5lZV/isqEyOPFfo8xhz8ls43XKEd+/0z5FlvkKuyu+hL5wlKzwx0fUabyBQjdPtIppKppO1EPMvrlewb7jhw1evJleU6BIbSLnugixSFUZvRn+oyz7/Fe/qS8xzl3DJAOtysYdItXZTIIPSH7QBgOFykWFk0F4YYXAho/SN7OHwOkgKo4Jt88pv2Bw== From: John Levon To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thanos Makatos , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefano Garzarella , "Michael S. Tsirkin" , Alex Williamson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon Subject: [PATCH 27/27] docs: add vfio-user documentation Date: Thu, 15 May 2025 16:44:12 +0100 Message-ID: <20250515154413.210315-28-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250515154413.210315-1-john.levon@nutanix.com> References: <20250515154413.210315-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM8P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::15) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8470:EE_ X-MS-Office365-Filtering-Correlation-Id: 826a0cc4-7c6b-474b-ae11-08dd93c7834b x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?m2th6gPUpYxLwy5k5fssUB9hPilmwxGiuryDSPo2TOHxDUmlUQ395knAFvgw?= =?us-ascii?Q?g6T9yIqTqE48b+I0VLqvCibl9/2mAgY+Ua5Nbuv7KBjbyo2N1FDphXpEHlkr?= =?us-ascii?Q?opZnV9v12Yi8FHJvcgzAMjX7OLHxCQWoABsDaTGnrg8bDD+UtRoq6yI7J+KL?= =?us-ascii?Q?tZ0nVhMfqEXYpvr3bNwnm9wvs9le84huu3lmisoJTbnJZKFFvmCVeO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V2MbgUtFL73apTAgIxb/gUeBS3imEQ?= =?us-ascii?Q?L3W6jfYSNhwZHYB8GuIRefN9ZkXDbUpB1y278OnwbT3N40OahrjS2KoS6Yf7?= =?us-ascii?Q?5O77dpwa4UZKlclt4Ucd2jPJ9weEjeByIEwrXxtzAP3q6WmpPv8bKpywC2nK?= =?us-ascii?Q?i0sQTkAue8s5pZ/DbW0QclZ+cCw8BbWXjm+031NGWVvs+BBJlfgzZyVZdD/d?= =?us-ascii?Q?wkjtm9BszbT3gnv/b0DFndQcnGFeNl6IcMi6Ou+WRlIwvPHXq+eKb1KVzjIu?= =?us-ascii?Q?AjqZPMo=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR02MB6760.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?UTpTpAEgWTGqv2V6bc/sdKT7YsCv+B6IoOWEMswcnTzk00NzOf91mYXcwRS0?= =?us-ascii?Q?jgMWNhtPGGW4rRQ523dFi5jxcexrL4IZdS4LtTanEzak+/32WrnJPCIkJHnV?= =?us-ascii?Q?e3r/oy+JS0T/hEGX2VrLRKrYIkyJWw16vjJegXRYyVHNOC9RSvO5V2O60aAO?= =?us-ascii?Q?J4aHPj8mpZVDOenBjIf0oMfwKuRu2IjwBeoSxmV+jJmVkWwHZkJXhHID3gOt?= =?us-ascii?Q?FdMP7n1+65EW2zHLBJQ4RRY0aO2gZZAIw6PVfFkjqF0mnSwow9reOfb7aEAC?= =?us-ascii?Q?ek0r/6YipUoSLDx8xx0zSKxpP3rWp9gTbMPbzl0GxwGDWS72MuHYKgni1Sxz?= =?us-ascii?Q?3RiiJabKIDmym4w3HbHDENuLaBlHfmSHvNZ+tdRI2QwfN98EFlrJx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nMg8tFayBhW51XuIpu6HcG/fZSoj8798?= =?us-ascii?Q?MhBArQGZiNjDJKmSGqYoab6Q/w2g1QjvmEpLE87RqAkYo6uLhs4xwQEKT27J?= =?us-ascii?Q?aJOdf/vhiKJ6noMIOITPd/DrUZOAOwDBiT0G1wK3cr/dEsnAeBJtAqqi466+?= =?us-ascii?Q?6xaOyLWr2/W2ISWn1+QJ5HQSDmwj6W+Xb8CyTmzpf8GoxUfFR+FJugLin1B8?= =?us-ascii?Q?Rh0D/uKR37Y8L0MdcMaNFw7Z0cG8T/psEHM4m+mxrShNPBApsxDr1bKLUaVm?= =?us-ascii?Q?1VSpJaIDBBz1CosM4HxB5KnrXhzUvEZbQjkGx0vu?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 826a0cc4-7c6b-474b-ae11-08dd93c7834b X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2025 15:45:26.8295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yMxh93cdX6HWsoutKqUzpxgqF0Fc0LkVmZOiUnyI1wD4dukkDZRgQlVqZe0PxIh+hDtch5VHq5H8h48fIXbWiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8470 X-Proofpoint-ORIG-GUID: 8TRk3EHgkDYTqoEJwI4fxfAqi3KiF3Ho X-Proofpoint-GUID: 8TRk3EHgkDYTqoEJwI4fxfAqi3KiF3Ho X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTE1MDE1NiBTYWx0ZWRfXwuG9cq9jwLn3 aKqKyokS6vlSlHZSimrNQsmse/INlahRw9vIAl2f9HedGnbpjVblAX9CzqWA9gn5N220RLNsRJ2 anQlcRdwApozfs57BBhwdRHb3yyZctYF59W3r5joNIWLW8y2d3WwEc3LMqWJNtDXiFOR+//YpJU dcUDuFHI158MahQTyDJg3JBs8KwbPlbrl4Rrg+zEUAvKcqyS3ih5WocBC2IeKqQqXwYR4lqKND2 sK47r7FUJYBbq0xMbJTX6kB1e/NzcJ++k+1VoryE5yzqoXsdfZi+yuL8h49r9kbXrEUqj9ah58M mBGocaIA8rLaFXvYHvVSKWiS65l3oo5pp2q4OGpADH2PspEtUifaEVVLF30jiSyXV1vhWQ5sa/c Lq+aWi12kfCZFPPAWeYtUd+5K0EtK4j4P17n2Zp08XBeFYUgLBs8b3cjzDs6faDcQwxtt8hb X-Authority-Analysis: v=2.4 cv=KKlaDEFo c=1 sm=1 tr=0 ts=68260c25 cx=c_pps a=tQsPtMi3p37jOgXbkrwZvw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=dt9VzEwgFbYA:10 a=0kUYKlekyDsA:10 a=NEAV23lmAAAA:8 a=64Cc0HZtAAAA:8 a=LOSiUy74ef7l4vre4JwA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-15_06,2025-05-15_01,2025-03-28_01 X-Proofpoint-Spam-Reason: safe 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=148.163.155.12; envelope-from=john.levon@nutanix.com; helo=mx0b-002c1b01.pphosted.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.686, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=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 @nutanix.com) X-ZM-MESSAGEID: 1747324093453116600 Content-Type: text/plain; charset="utf-8" Add some basic documentation on vfio-user usage. Signed-off-by: John Levon --- docs/system/device-emulation.rst | 1 + docs/system/devices/vfio-user.rst | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 docs/system/devices/vfio-user.rst diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulatio= n.rst index a1b0d7997e..911381643f 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -85,6 +85,7 @@ Emulated Devices devices/can.rst devices/ccid.rst devices/cxl.rst + devices/vfio-user.rst devices/ivshmem.rst devices/ivshmem-flat.rst devices/keyboard.rst diff --git a/docs/system/devices/vfio-user.rst b/docs/system/devices/vfio-u= ser.rst new file mode 100644 index 0000000000..e33e49d283 --- /dev/null +++ b/docs/system/devices/vfio-user.rst @@ -0,0 +1,24 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D +vfio-user +=3D=3D=3D=3D=3D=3D=3D=3D=3D + +QEMU includes a ``vfio-user`` client. The ``vfio-user`` specification allo= ws for +implementing (PCI) devices in userspace outside of QEMU; it is similar to +``vhost-user`` in this respect (see :doc:`vhost-user`), but can emulate ar= bitrary +PCI devices, not just ``virtio``. Whereas ``vfio`` is handled by the host +kernel, ``vfio-user``, while similar in implementation, is handled entirel= y in +userspace. + +For example, SPDK includes a virtual PCI NVMe controller implementation; by +setting up a ``vfio-user`` UNIX socket between QEMU and SPDK, a VM can sen= d NVMe +I/O to the SPDK process. + +Presuming a suitable ``vfio-user`` server has opened a socket at +``/tmp/vfio-user.sock``, a device can be configured with for example: + +.. code-block:: console + +-device vfio-user-pci,socket=3D/tmp/vfio-user.sock,bus=3Dpcie.0,addr=3D0x9 + +See `libvfio-user `_ for further +information. --=20 2.43.0