From nobody Sat Nov 15 20:52:47 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=1747753610; cv=pass; d=zohomail.com; s=zohoarc; b=gAQRxYpUFsMi5dK6/VkcrdSCsTOhepU6WrCbMNqjmvheexwVYy70NygCowpVnNdi8vmNClEGeTVcuDRDlS7JZBMGx+aK/tLGzeAXwC042okEesjHUDvQXguCXgEw1zJsvylngW6eChVDcs26jcuJyoCPMu1hHrmS+AXz0AUyC2Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753610; 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=bpWehmf7MN0fSB2ReUF9Kx68krZ9XDKB46l6jV1yuLs=; b=Vqe+8npZHOXUM3fYb7Mfl9W2YoByEtazpkkL/UGQHynxPROMYEXDD/m4FHf5kUL6GFIFPJ9/u192weXSoY8yJcPDNRGppZow1nKpGBBqDpMvlygpwCuoZ86cd9EzFdmo6ZbyOLpNgDj9iL1gZillTSgcz4PsYsB4TnstHoD6ZVc= 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 1747753610547641.4211593398497; Tue, 20 May 2025 08:06:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWH-0002zI-GK; Tue, 20 May 2025 11:04:41 -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 1uHOWE-0002yi-Q7 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:39 -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 1uHOWC-0002Jt-Mu for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:38 -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 54KBfwAM026470; Tue, 20 May 2025 08:04:31 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010001.outbound.protection.outlook.com [40.93.1.1]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheabe-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:31 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by CH4PR02MB10612.namprd02.prod.outlook.com (2603:10b6:610:240::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8769.16; Tue, 20 May 2025 15:04:28 +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.8769.016; Tue, 20 May 2025 15:04:28 +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=bpWehmf7MN0fSB2ReUF9Kx68krZ9XDKB46l6jV1yu Ls=; b=xni7JwscIHHtBp16/Fj2EboArtrSlM07sLWTmA+RlPazdNqNJ/kj2Hm/Y vXRKmJdqOYNlLcPFGT87lRaegvjUZkSbreBB8H+PnG+SMxZCutZJX8GdT05IRHZG sparBOJRTBAPQ/2B3JSTyVM9Sst9BmxrEvFWqA4yUKRet2PFvhf7bo4oOV7NmKDB Kei7me4BoflifONp1re4LjbUY9jMhAQPShA5sl2GgRbqqm9ccfACmmreB3OAchJw o/7bzEq8XRPoniU2E2XWQWnISHQ418xMUL5hKdNK9tdl/jjyM5wP4+7kgY5esng7 8Nf+kPQUEy9QxhPZ7uTfxnk9+k3RA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MO/RPjgpeCkfmt+eZQ233tQpGL4AZ5CteALZyA/RIXVyTkDgdf660/fsB5M8pZZI1ZYY2B/Nk0Nnk9UEOw4hUwUrUL0/Gxgz2GomH6Vhke24WhixmPb5bsFJhGxdsKw+8jknOYtRd7Zve5LsoD6TcwlSJ2NeQJT4gVKeqkhnlA9qocopGGi4oVP+TbvUkdi9cKpkEw+SlVixERV0OR/FB9mMkXQtxD6CfQpH8uGGtlbnwtnLi50qetez0xoAE2xrjMOAjR1mcbDNHt6/e386hOQm7D66+qFTK8lxUeoKQZP2qjZU0x6d5vfRwRFUodpZbP9V33UU+KFKM2Dgtp85xA== 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=bpWehmf7MN0fSB2ReUF9Kx68krZ9XDKB46l6jV1yuLs=; b=XTwo66aFGU/uTL9C4RM19oycESG80KWg2rjieTJeswCzFsdR7TVBQwX9kyiaNvsvpYzMk+NObyJebNV8W/OK3UHBrQzpFUoEqzpWc+ZcNk9qwVS3lD3PNwFvy6xLkOXWmG4GBiU/Z7YfW518YLKwBALSgrqH8fiS5N64pVlknH4i8Vl1zigPFE1PHPFVv1YZH73spr/d/VAjMR8frON26FQTIKiprqZ58uuXFlHwEAbK0dS+hZcT/zOo1sYFQ+YRLhtUW2c3KOmVNSHTZKzGEG6C+buMi1fJTVM2oz9qcLdspTx5MvSp+7wGrajfEQZtrd0GLSEio/sRaj4t0R8npQ== 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=bpWehmf7MN0fSB2ReUF9Kx68krZ9XDKB46l6jV1yuLs=; b=eSBTmAV/BaKdNaDMeu9Z5HoBnttcWVxT6RwtMWLn8+0pCoKvCOO5hYLxWa4/L7s3r6xn08lawDphmnMFIm95g9oWrXI/bNXFvLA9EbKoEi81KjSRZlAavAZDk4kThpcGelgLqNlSUq2ibzfQRS6J8NUPEkwjDOaA7PG0a0P0LiokyO24QUsJcQA8XJ7FUDGuSuQESxv7M1PmBgo1xL3y3KoY8IMiZgtrOJMpSFhtuK5A0wnNSdCihRFX+AryimUtZJsR0XxwLjVCrivJ51X1ub+vdbqhyV8Wd8jLGqJRk/dtbka+tI7WSsVvWyfKypY/OxXW4bQr8d6Fmsj8KnIA7w== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 01/29] vfio: add more VFIOIOMMUClass docs Date: Tue, 20 May 2025 16:03:50 +0100 Message-ID: <20250520150419.2172078-2-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|CH4PR02MB10612:EE_ X-MS-Office365-Filtering-Correlation-Id: 45ad557b-0508-4967-8bb0-08dd97af9e04 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?kZQGNicbSnw+iMwPH5QCWXoMmSxch07GTEKr2t7YZX6BdsP6aZTOfGguVzLH?= =?us-ascii?Q?zBtI9Ata7gntxsm1ZwgmGhcfHLsiP6qo0bWg9+/CZYqStLGSzblhKivcjAOv?= =?us-ascii?Q?s5xKGVpmJYvk+fArLiNtk3FnHSvzOx3Z+JUQGsI4cC9EDVWMDXsBsj5LVcHN?= =?us-ascii?Q?jYXtkp+SarhRr4p3yYJTgANchE94yIrMxECb2D3FOB/2AbFG7jh2man5N/Qr?= =?us-ascii?Q?a8gRzF5htP4s4zJx/tiilFTPfZdujfZ5hADuIq8CuvWBDx6u//5d4Tw47NCX?= =?us-ascii?Q?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qlPj3WEoC1Ct?= =?us-ascii?Q?9dcSizE8LqdUPonRYIMJ+FtJIJ+J9y1AtGuEcQZl64HXqqWb9kfZcwSn6ote?= =?us-ascii?Q?2PD6X1Xp7eM/WfgkFsl7yc1UmyBFsaVbF+3voIWgj9CnSR+SZhPVZ5WaM0cI?= =?us-ascii?Q?knBXn/i4fEU/ipj7AkTd2+QBvyq2+6cgOX4PjCWkuq3kbpXSW88gW/3oK5sT?= =?us-ascii?Q?ZpLDU9MOGoFN8/dWS98eIgvpkjksnO8PbxULjNY8vgHV6NkPAHhUQBiQ6cj1?= =?us-ascii?Q?+c+VMCx8Xgs=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)(7416014)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Gv4JaJdRcL+Z+leSXrGwE6hmEjij7ygLnGzEFZimbhW3U+V+ZAZOmix8yCKh?= =?us-ascii?Q?Evr028YucMDh9HKzy9OObQn32DRrWfijijAggsGFfN1YwBKYEC4Onb/AGMi3?= =?us-ascii?Q?vbiTTCdUrAWX+rh6PMyVwJ4of32neCATfk8VVhg+Z+7KHecD69cWwEKBj+TE?= =?us-ascii?Q?/U078WuM1WRWWghPRI1ute8JxU8VXeXCvG+xa4X//2ahIUPmiM6IbfPcY/bW?= =?us-ascii?Q?tG11Ze0FEi7a4ZaRVzl7zCQqkI1X8iRj8NFeb+BhVNF3wCd2/g47fY5T2kw4?= =?us-ascii?Q?46LDK0j47vrFfwY1a3k4SqINDEHaNk5nqKCybgfXz8XtFuVTlNx2AtvNHp2E?= =?us-ascii?Q?XGlm9kMoopOuzCBlV6ER9V4/GtWFuDJxsydJH+80nYqUvKBDo7AViDeC0rs2?= =?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ger2qkVH53mC5NCJ2lKqZAIrGKIjyZuscBobE8y?= =?us-ascii?Q?SEzkaN/h/TFMFqzh/qvEnPr89mAX1TuWQEznUlRY+RLMo2WpxdjJIXUO+Ks5?= =?us-ascii?Q?DdlchWyMPuNu+COH/yLoeYhu/mfWyxfNrqs3Jm9KwlLan1Bs1VGYhJSFc3J7?= =?us-ascii?Q?Exd8zK+1Q+RuAVswL+0GT64Jz3x2vvte2xC+Y4PJ/jcQhlkgvUao+EGvGUl8?= =?us-ascii?Q?r73MfyxY3zyRQahlXXmY38Qg0lqFpepSvlHuLIi0X98zTuOlwnFLd2+gZIx2?= =?us-ascii?Q?nCkyNyoYh5C2M7DmlUaAudrqSlxlVEqMigITdow0?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45ad557b-0508-4967-8bb0-08dd97af9e04 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:28.4377 (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: rsiNmTqeymeNwMrSiyHZ18xDTrtLqaLZGpECB9TI1+t6D1NqxZJUUX+UANxpSh4s2u97MYo0a8E9aMoyyfqbKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH4PR02MB10612 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX9aKOXXQLhU4y HMGCbZWzST1n7XHTiu9LmBRunv4e3QtwABAgxZjt/6TAeiYwCZCJKFjeYibQv1RQzECeY/pNV4A j92HXJ26YBDM0pQxcE7kWZllL+zyTE7mzhDM1YoPcz8u6h4yFjI1F+AwhyxdF8A3MKsJXjd8ndp hazNG9VB4vltcgz93pwdTJCj1wU61JtzuGG/1ol+KZQyceyqdcx+KrYwDWIRd07GZf1rpo72ppe aD+q3s/uYKcgzeKX8qZMWtDE45XUq04kfuD569MR1T1iMTm4dT4+5VMaQLMBtSL3GUWDZqv4Jfn OyCcqpWqxYXt+H9Qdi5ZfJBAsXg5viXZEOrJGkspC4V4arputIOJ7lxoCAGZ6jqkjU6rBdg8so/ 7bFLTq4AcfK59/lAxWPlhRB1wlsAC41+fpfqsKHE+8cckuaJe93ICrXbPjvKNWUb+46vewvN X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c99ff cx=c_pps a=zbudaZmfUx0dwwhLSrpPog==: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=PpfnBm1fC9UCdYKfmFUA:9 X-Proofpoint-GUID: _DR6w3bDnQVcLu1eqnhOAeiIBIqhADmV X-Proofpoint-ORIG-GUID: _DR6w3bDnQVcLu1eqnhOAeiIBIqhADmV 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753611638116600 Content-Type: text/plain; charset="utf-8" Add some additional doc comments for these class methods. Signed-off-by: John Levon --- include/hw/vfio/vfio-container-base.h | 64 ++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 3d392b0fd8..41c49b2aa5 100644 --- a/include/hw/vfio/vfio-container-base.h +++ b/include/hw/vfio/vfio-container-base.h @@ -115,13 +115,52 @@ OBJECT_DECLARE_TYPE(VFIOContainerBase, VFIOIOMMUClass= , VFIO_IOMMU) struct VFIOIOMMUClass { ObjectClass parent_class; =20 - /* basic feature */ + /** + * @setup + * + * Perform basic setup of the container. Returns true on success, or f= alse + * with @errp filled in on failure. + * + * @bcontainer: #VFIOContainerBase + * @errp: error filled in on failure + */ bool (*setup)(VFIOContainerBase *bcontainer, Error **errp); + + /** + * @listener_begin + * + * Called at the beginning of an address space update transaction. + * See #MemoryListener. + * + * @bcontainer: #VFIOContainerBase + */ void (*listener_begin)(VFIOContainerBase *bcontainer); + + /** + * @listener_commit + * + * Called at the end of an address space update transaction, + * See #MemoryListener. + * + * @bcontainer: #VFIOContainerBase + */ void (*listener_commit)(VFIOContainerBase *bcontainer); + + /** + * @dma_map + * + * Map an address range into the container. + * + * @bcontainer: #VFIOContainerBase to use + * @iova: start address to map + * @size: size of the range to map + * @vaddr: process virtual address of mapping + * @readonly: true if mapping should be readonly + */ int (*dma_map)(const VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, void *vaddr, bool readonly); + /** * @dma_unmap * @@ -136,8 +175,31 @@ struct VFIOIOMMUClass { int (*dma_unmap)(const VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, IOMMUTLBEntry *iotlb, bool unmap_all); + + + /** + * @attach_device + * + * Associate the given device with a container and do some related + * initialization of the device context. Returns true on success, or f= alse + * with @errp filled in. + * + * @name: name of the device + * @vbasedev: the device + * @as: address space to use + * @errp: error filled in on failure + */ bool (*attach_device)(const char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp); + + /* + * @detach_device + * + * Detach the given device from its container and clean up any necessa= ry + * state. + * + * @vbasedev: the device to disassociate + */ void (*detach_device)(VFIODevice *vbasedev); =20 /* migration feature */ --=20 2.43.0 From nobody Sat Nov 15 20:52:47 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=1747753694; cv=pass; d=zohomail.com; s=zohoarc; b=OuIK1YEqyhgZorVW03sAYWHjNcNxfEA3xGwMobvaACWXJVQBsw/ihx75hcIeaQel47Hoxw00OxTdMJ9kZe9rgnkYNcy9tF1cE1Z1mHOkMu0FMKh9oqGIcpjzNCrDa4Zw65xtHyWITWdA8hLE4q6uhTizBhtzdimTsAY6LkgYlA0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753694; 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=QqjzyRIu0Q/79dyxB26Wi1evx4jj+/CdPWsp1vaiaS0=; b=ac/+8Vb+va00AuhhZyu73pNa5WbsKLqeTILhLKaxAmd+tNKr9SLH1Wgvb9PS+7XYMunvVcJxvaMsEl4pEFgOUCtGudUqpDnWcM6saX9Xpli6r09j2SIDEdV59VgR+kKinlcTWk0b6TggOqBsWnT1Q0gVBkXwusW4SUiIVx5zql4= 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 1747753693992681.8438072323513; Tue, 20 May 2025 08:08:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWK-00033d-7u; Tue, 20 May 2025 11:04:44 -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 1uHOWG-0002z2-7d for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:40 -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 1uHOWC-0002Kz-Pb for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:39 -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 54KBfwAN026470; Tue, 20 May 2025 08:04:32 -0700 Received: from byapr05cu005.outbound.protection.outlook.com (mail-westusazlp17010001.outbound.protection.outlook.com [40.93.1.1]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheabe-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:32 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by CH4PR02MB10612.namprd02.prod.outlook.com (2603:10b6:610:240::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8769.16; Tue, 20 May 2025 15:04:30 +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.8769.016; Tue, 20 May 2025 15:04:30 +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=QqjzyRIu0Q/79dyxB26Wi1evx4jj+/CdPWsp1vaia S0=; b=EzTNr2vXI9DM1N44J3cQnVYhsKPa35zfkRzAMT70HKYhZV9xpSJdKm54D rquvE83q2vUPyh5TTjgRfm/LfnM4c9ESxoD1kW/IoWURPLLqtg7TErr6y0vUEN+F C/IwNJuSEhdezubd86xy7sRBMTs5ynhWdMkVLsUzGWB6wKOjohgtgLYuBYJ68NBO Cey52x/2ge8t4btQeWFWhH9l8fqgytukxbatBP/w6uxQtsLECPt8jetVNHOpxmFU mMFzIPQ0EKTK9kONSBz+QReG9yLZYKVtaUbkwmVp37P84oWmtL0HdHc44twXJk5M PESJzE9cl7y5RO+A9DtJkfg0xPrJg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rLAp+jsNkksxOJ6ffjMB+0MkvKFHZ01Rd0pawrBFnjY2i64OAwwc54vlZ8MMmgdrud8fFU2Qc2bVi78s6AgRtVQ0DwGZhp6kDrHoBsEE8ksYr1TcCnUiDDQMx8uKCTGjZ43hEKFJkKWqO2181gcqzW9TWBDbaydM3ummlaxt1qCcpRbrT2o9Ms7pDBZmmQogv90gc1EFEm4Cb+7Lp26wglHCMUgAmUxHPWGbLCSNx9LIXVwOJXs7GQ9MuzkUCcbmfB7sdOkC7En45ppIfBIT/z0lQdlrGvbF0SbZyXdZ8QvDU2BGqbBj3Z11uvkuDxvZTuwWQOTkDHoDpolSPytFCQ== 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=QqjzyRIu0Q/79dyxB26Wi1evx4jj+/CdPWsp1vaiaS0=; b=ZveuiPYasN6Hoau+f9T6Su4WAhUX0chlQSAuu3omB/gCG7VuWPZFRr6mxarYPmCjTJTmxUhfqM01VqsxToS7SWs0coTMqs06cHaRbRGdh4kGEDhkP+OLrzB86Z+9SyEdarxQ6Rm81XRyp5WW6cVmFLKgvZpmnA9WMpkYvEiv2+nmDxW8IIM1j0KJB8ABD0LeQUUz/4gDRss1uOekDEuhw+lY1VJ/GW3STtq3HgFYAtBac+aivvhfbwkRt/nVIMqawI5KL6gvrvVUO3or/lJHttq6TuvCDcPT8tdtdN6I1+xAeXocvjxxfIloP8cWNRqVbv+YCvVtoJuOhXkM2YUnwg== 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=QqjzyRIu0Q/79dyxB26Wi1evx4jj+/CdPWsp1vaiaS0=; b=CvZHgzPho1HglMPfjzMXRHq1OfdjI5JsTYNOhG4O33zpnSEvIb1JjR4rBAsmkakLKvZ9i/kbNW1MOs810H4ihP3iZgolz0FDa+uWKgrTERNj9/U/+x6uCR1i8RUJGHAiz0yOo5JYpgPTMS30J/XYudFU7NqMR11+PoYGG2O5uZY7H4oBjsyN6ETr53N3RIDLSGDMaWE6A0CePXsTF3wVMv7VMset5KWH/uvHekzZLxhNwoy9Et34jSCRYaS8/2fpk6KhYCF8eslQQw0yPw5WUV3IgMivtcLYxtoVebw5UTmctiQbdGfd9dxNvnpjgxy6snVT7r4Pgp1R3CzU3gUWoQ== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 02/29] vfio: move more cleanup into vfio_pci_put_device() Date: Tue, 20 May 2025 16:03:51 +0100 Message-ID: <20250520150419.2172078-3-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|CH4PR02MB10612:EE_ X-MS-Office365-Filtering-Correlation-Id: 76f0b72e-1ff4-4006-918c-08dd97af9f5a x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aEo0cEZJcURzdkpLLzRhVHRoL1pKZXU1R3F0aXhCUExxMzNob0ZMK1FiaXVo?= =?utf-8?B?TmYzQ1BaN2VsN0s2cElrdjEweGxpTUUveGR4L3VpaVVySDBZS3hhdEdpRUpL?= =?utf-8?B?UnhYMlVOdVNQM202R2l4clQ5UmxYVjRqemtOUWNMZS9xQzJiMDhvaFdWZ0NK?= =?utf-8?B?eEhOQlEwY0k1eWdzdWVzTi9QOXdHSDdEV0Y5eGczWE40TmxaaFVKVHNEQ1FO?= =?utf-8?B?aWhLUVQzeFZlTkFaKytGVExMSnJicGhxSGlndFBZaUZVc0tPVTZjZTI0MmJX?= =?utf-8?B?VkFQZEM3NnpFN28wTFFzdm44MGY2T0xCN3RLSFViT2V3ZTBnTlhxOTM4NzdV?= =?utf-8?B?MzNjenlYVmhWelZUSURBN2MvYWpKZTlMYnV3MGdmeDU4dnJURldMZ1ROaThi?= =?utf-8?B?TEVPZEtrWVM3ckdmN0FuTjJhblp3cXBwMFAySHZrVkdoZDBjdUpOUlgvZDVl?= =?utf-8?B?eVhhZVh1dHRCbDhjaDJaS0h3RjVYQ1ZKVVM5QVlqa2I5cjlWK1V2RURqZWpa?= =?utf-8?B?K3d3MUlpcjFSQW96QklYTTBwR0E0M1E4c2cwTS91NEZIaUNCazdsNlNzeExx?= =?utf-8?B?TXNmaVRCd3BGaUxtYUhJenNkVWQxWGlEZUhQNGFGZnJOV00xOU9lcFhrU1pY?= =?utf-8?B?RGQxZmFsL3lmZ1VaNEVNWkRCbExmQ3FzL1RVMnRDMW4wbnJMc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Zkk2ZE9QdkZXdVgzRmRHTkxNbGRU?= =?utf-8?B?aFp6UjFZT282SGdWVGhDUE1KVFQ1RWM2OHNSUmpzck4yUSthWTdudVRyay9L?= =?utf-8?B?VU1Uak1rczhLQURTQjNXaE5reTcxN0pVTFlhaEtPc0hmbjNtNGFjSGFWOU42?= =?utf-8?B?V2hqZVd0ZU5uNkFKbEZmSFV4WnR1azVOWGtGSjFweTUzd2JpZFNnRUUwZ1dF?= =?utf-8?B?bW1rT2djMnB3QTdzYktwUTl4Q29WOTg3YkVxaWpEZnRlV2RvL0hiU1ZtYk00?= =?utf-8?B?R2hBbFJCYW9QZzNrRFN2RmREUmgzM2VCY2wyOXcyNW94bmhSNVloUEFuNWcy?= =?utf-8?Q?zblKJrCwoR8=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)(7416014)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bXBiNU5yRkFXcmgrZkp0MldFRjhnRW5NK1hFOWdVUmU1WmxuSWRyMGFrOS8v?= =?utf-8?B?N3EvMVdXU0FxU0JXbTgyNGdtRlZmaXkrc213RUVxaDF6bkFBZVhxQTR6VzlV?= =?utf-8?B?T3p6bkJXZjZmdjRSaWE3S1JkR3BsdFlTdjV4MGtnYldHQXdjS0lQWkwxWUVK?= =?utf-8?B?SER3UHA0YWxSQ3NvL3RyVjg0TDNacWtZTTBndzNlUng4S2p4N0RmME56UHhn?= =?utf-8?B?NndqTkhGSFcwUDdqdU9FQk1YWEkrRFYyV1BnbnBXQnIrbjdBdW9iQkFOb3Mz?= =?utf-8?B?c1JKT3ROTGdzR21IdjlXWnRhd3hQK2J1akxTRHgyQWZkWDlIMjRqaHNXK3lt?= =?utf-8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OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76f0b72e-1ff4-4006-918c-08dd97af9f5a X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:30.6438 (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: Tf0Ov13RFyDb77L8DewVwHlU/WwZ+M6ryqnzUpyodMCpZCZSKD9o0ul5eV/53vloQuzEwleRPmOVZOeeSFYl3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH4PR02MB10612 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX+WOmh7/Fg3Pi R5hL01Axr7KD5BM6amu2V/bM2+F+zgMRlSBIufrvw/YD/OXMIDuz34W6U/Blr/2x0yCT23waYSU Ntci9E7ymogu3pgaAIO3u7UfF80VyXquLB1n6+OycQcuD2M26evQABThwujDVg/wAEbmeFBVWZF hv1Y/V4ETQAfZYBBZ3a9RhlLXHVyVAeZlgUbWE7mI7VNFUaWu2/nCXvoF9j0lTDN6GwWCYStj9d L9JyacqP2469brasxjY6bn16M0eyGDihqG//WsLsyzeOjIGk0yXpRvYboteyHDbI332nvp2sWHW ZaUrR4maZuCuHDlGd8rGUMyL6kB42hJTAIRBMUqXvQIDrBuw7qJ052T2Nj1tIJhUZhDT0mTxJdh IO37RRJxDje+/pPihL7/hV8GGZdl58nbNl1jNSQOyVObZDvrK920uGk7oJmLtLO/j4h9cT8a X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a00 cx=c_pps a=zbudaZmfUx0dwwhLSrpPog==: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=64Cc0HZtAAAA:8 a=20KFwNOVAAAA:8 a=_mo5Ov_VicZQ5TNRUswA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 3lk5PqEfqbahGAw4JRqVcKBeeX_-6Mg5 X-Proofpoint-ORIG-GUID: 3lk5PqEfqbahGAw4JRqVcKBeeX_-6Mg5 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753695554116600 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 Sat Nov 15 20:52:47 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=1747753741; cv=pass; d=zohomail.com; s=zohoarc; b=Cw7tEDX6qZ1I9RaXTi/O9yK71ljvlT6NvlMfBXplTuLU+rjAvU2GrM5tpqOyxmC2T+XVOfO8gYpjwQYyRQznUNM/mlGZVM8OyVkwq8IIQ42QBKwzVQoMnqQTgfvNYfFWGIE/jg2+hyZKbCMsRh8zGatL2k3TONOy7b1I8pRRmjI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753741; 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=eWP6uHNLUeLO4UNzBVhqKB0I4i+YBFTfg4JH5mpqVBM=; b=RpMmmv04fBFdSbs2CMDmyfokh4Qb8hNwvjjoKLtGoQJ2TQZ2g0HCJsMdxh7J2w8aBXyUWlKpUlsM9GZc3ChTYu8RmfFYqc88SZ1GynOyQmj8AOA8qRevSHNiAiCAbUh9qyIL8SOg1pkeHaBwZ9m9Fy+pLg24YDOcyxBKPQz0i+U= 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 1747753741400622.7419273668798; Tue, 20 May 2025 08:09:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWJ-00032q-EQ; Tue, 20 May 2025 11:04:43 -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 1uHOWG-0002zC-HE for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04: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 1uHOWE-0002MC-6Y for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:40 -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 54K7Liba032060; Tue, 20 May 2025 08:04:36 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheabp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:36 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04: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.8769.016; Tue, 20 May 2025 15:04:32 +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=eWP6uHNLUeLO4UNzBVhqKB0I4i+YBFTfg4JH5mpqV BM=; b=BhasDBRB0kwrLS+kLta0UU+bWtDUld+px2IJCw0W4toEl2AV+3/PUUC7z 6saz2joCRpOVkhuWLV+PCrvjZsUA+90nywq55CmcGJcxI1cN5gWLtnoYOD6kRKhY Tc7Is3kw0Md8NepTB/3CLdhoeGGZz4YYwUTb4XVFa6XgCil0uPpnSKDT5rnhw4Si anDFI2U+jRO3aAcLreANRPgipot/XKbqMpwJocawI3PrMHpvTL7Ojsv44v3tkDmM 7+yGwu5knonlRk9Rv84EVEccuIGeNRFAaMCdKvgTq+ag93yOB1beaogAD+uSwxmq Lc5tXQ2vcLybFs75SazbVJlFcJneA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uTKGxsMCgkHMQJ6PxL8b0jn8ZAI/qVbh9UIE4A4X7tCf9eu3byP9R+IupD0QtImwYWvOsMt0ISK1YBvIugjfNgVOv2GrSa2Q8BtBdWUZBc/acdo3UrM/n5wVBQ8LW8aNk9CFRI+t3zJuFw3ZQjuMSBM2b42Zr6kr6aRBRyfKrWRMtcnqEYjfTc6+ncafLG13sYQG6xZGrh8ySckbmqRwUaMtpUCRBpvosqw6i2+tR6XeiDI2DqdcAp20ETBylCAFWnstu/q3cmlR+Do1aC3ruStT/sozgKUUENM0bb24kilOeC2h9sjjsUstpbA5Njp6NO2y5LPz4DKRecU6pqrQKg== 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=eWP6uHNLUeLO4UNzBVhqKB0I4i+YBFTfg4JH5mpqVBM=; b=F8m1FOE95+hQuRu/otqobphjyoVsfAN5AitePTE79d13oY/dSr8+Rj08fGOTfjrmyWgPCkY4MaFMws0NaAMWRwtHTU5W2n/zI8JlQSpic6APpTsgokoV5AXmpp664HshCjhJrX/IpzwWBwFHWGRGUcEweUCHRj0i49PdShk84rJmSfrD4gAqHgSJh7sBsN4+kIFPYitYuKKmtTGiZASjpMAedTg6pW8i8NcdexRE8lybckJnLcWh6uuAz9fBsuOvRE9WHgLJPc2qenqR4hT10bphw3OGeM3M+RgwVlhfQPgxO7kWFUeSum/56lms5WB563PurKmAdzlbEsjzuD95+A== 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=eWP6uHNLUeLO4UNzBVhqKB0I4i+YBFTfg4JH5mpqVBM=; b=PrN9N9o0HUO1D0F1YFk80alF8q4zslyeaK6fa81aurLInuxmVlhK3/n6wtXaQQvyvp830TP0AvEQr3GeRmzLSh4XD5YtrUl7my7LA5NIKIe3pY+N/G1po5Rc1LnhCTwTGghmtmcXaEZPtT4Qaha2FUZqngbEZYtsZz4h4RI4BjxIoDIUoN8kBaAnrzaMVhmrGlUAExKXdqE3CYAxmUpx6OHqsurnipi+qTupw8B0ENX3tawnNUC3wHbWsneceOZf2SwT3FxR/Bymf3K1A/M7Gp1k7FQcI34ykPKSvcdTkvWbsBjN3nPQCuMeyEvkP0N7DczG6z6EP2I8SYEqsvA5ew== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 03/29] vfio: move config space read into vfio_pci_config_setup() Date: Tue, 20 May 2025 16:03:52 +0100 Message-ID: <20250520150419.2172078-4-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: c6f1bb70-68f3-4aed-e5b9-08dd97afa0a5 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?elBwNERENlJscHYrdFcvNjBmdlVDNW5WeHhRUHhXQjBDRUUxMTg4N2RCRnpG?= =?utf-8?B?SnNRUFRrd1k2QitZc1haNlViWmhsempPbDBTTHRFbVhtb3VnYnJDbUJ6YjBE?= =?utf-8?B?enIrdGUrUFVhTEpQRTJuUW1jaFY0bmVESG5laG1ZMFhCeGhqWUY2eG1OTklL?= =?utf-8?B?Q1Z4VDhzdE84MlZwUkx4aTBkdFFKR3R0RnVPdWxCRkFtZ0NaUEphajh6NnQ3?= =?utf-8?B?RzhoWlRUblJ6SWxZWWliN0ZwbTdlM1B3QUpZT3ZYeTR2bEhIME1ISzg4SjN6?= =?utf-8?B?RFhGZkRDSm5XUDE5ZklBMkw1UFFrVENGbWY1MnNJVDB5Uk5yUjY3UEtGOHZm?= =?utf-8?B?NzJCNEEzNUh0NGlmQjl3Ni83NVhIdlZhMUFEeUpSeVRPZmc1QnZhQnNEZzFp?= =?utf-8?B?UkJKZkpvQURZc2w0U2pKUUlYQjUydWtJNlh6alBBMk42cEc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tURC96QndvSFZzSjVTd3E5ZG1LNVpPaUY1?= =?utf-8?B?dVBYaXBzU3RPdG5vSmtqc1JSVTlIVHQ3U3VZOU5pbnJJZXo1SnpyZVVFeE8w?= =?utf-8?B?bEpoR1o1ZC9rdlRsM0VBcmppY0M0eTRXMFAraGttbkdkcjRzMTVEa1pLTXlJ?= =?utf-8?B?VGtibGEzMkVoaWlZdFRLamtscW9JNzdCQS9jMExHYnNLc01lcHp5MGUxVzhR?= =?utf-8?B?WWRsMGJSSVM2N1N1ZldxRXBSanV2OHpTNWNLVDZpMitPNWpYaTlkejFLa05H?= =?utf-8?B?bTVvWmxoejBQZFBuVGphOGJPdzRuQ3dqU3pXY2xadFdsMWVUTExST0VMQ2N1?= =?utf-8?B?eTRqMUJsUWNjT1Vpb0dIc2pMUWxCMSs3NjB2RkJPcHhvL09HL04rcnlYZkdZ?= =?utf-8?B?OU1wYm82RG10UzZNclZQSzBTamgwWHlSTytCbmVjQkRzQXRNc0h0aEFXaHJZ?= =?utf-8?B?RDdjc2JoNFBTUjlHdlprNU1GSVIvNnl0UFBxT01zMU91anpFV2g1UVNKQ09M?= =?utf-8?B?d2NGaVFhaGZ4QXdTd2FtOWx1b3VHY2xOVCsva1RQdTNZNkQ4WUV1UXF2bTNF?= =?utf-8?Q?WA882db2wf4=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Ujk0MzF6ak0vQzl6WThOMFA1SlRyblJWSTdCTUI0YWhNWlZodk1rQzNqRkYv?= =?utf-8?B?Sm1BZlAvMHl0ZEJLYlRJYVZ0eEJTYUdhQU0yUG5obDBKNmd1V0NYNGRybi9S?=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HppVEZZajZEdVY3N0U5NUY5b3dTR2VMZ2xBQWc1U3Qra1RtTk9Ha3A5?= =?utf-8?B?c3ZUSUJ1TlRXTFJ3bDNUSnE5K2FtMTB5Qm9XYzBPZ0xPdmIwK2lDNDBLUFNK?= =?utf-8?B?VVNERXhQT3gweGFiNEJIOWFhVmJ1c3RwUjlDUTFyanplZXVZSlczMmF2aEpL?= =?utf-8?B?VStzajVuZnA0TlV3VWo0TVNmQjYzTnp3d1J6TGtzM054c3Q5bzhqWXNLaCtX?= =?utf-8?Q?2SzLf+ftDkCzGToHCzvRUzwwR?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6f1bb70-68f3-4aed-e5b9-08dd97afa0a5 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:32.8105 (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: pT+ElHkIlmWK+ZyM8jPKjQEcHisDIdcrYv8HlIH1XoqezlWHsAZtSPcqBuI0DyP8OFkfira9KIlHMU6aZvMnng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX5K0oLeY5GmTv hf9wbAalbNgC/QdWzZra0dNudMOgcdWq2kjLP3+07ZcaWS0bayQUhAYU8k9zN5KEJL89MFGCZh/ 1H2Z4JrIdT3FxD/E3shCPrPAxC0yoFTBSK80bDhCdmqXKnoWx/2vHzGXyBVRx8ofWu/DYf63rRa pJnFMzi4S+JQPHyTHpQJlaQwR8nmqDPxf5w7vQU9xPzyMzTApNYNWR6d+pSlKG26LG18/ZUNWpt lFiGxX7JtzeUwWuALLF5xuYkWn43hXJRDiZl97wV1F6NQFlMlPISMeGfEf5k+Q4aVOZbSQaKHu2 ZwB24M71gKa+1UghTsDJaMj7NbB4RzKBLo0uJbAv/YqYGK5OYHZh8w26h1+g7o66SzAPbi/iTQz tezcAvJRTcIF8jkhOgGt+0sKMpKgTN3dO61NTnJXqaFU5yN2GzDtMqK1G+DOeFx8IgVHMPXu X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a04 cx=c_pps a=b6GhQBMDPEYsGtK7UrBDFg==: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=64Cc0HZtAAAA:8 a=20KFwNOVAAAA:8 a=FCJwmHiiXP3F3EZgyVoA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: swow5s0IQ_xmvvWBIp6ocg3YgZMaTtAN X-Proofpoint-ORIG-GUID: swow5s0IQ_xmvvWBIp6ocg3YgZMaTtAN 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753742615116600 Small cleanup that reduces duplicate code for vfio-user and reduces the size of vfio_realize(); while we're here, correct that name to vfio_pci_realize(). Signed-off-by: John Levon Reviewed-by: C=C3=A9dric Le Goater --- hw/vfio/pci.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index d96b55f80c..a873f82aeb 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); @@ -3138,15 +3151,14 @@ static bool vfio_interrupt_setup(VFIOPCIDevice *vde= v, Error **errp) return true; } =20 -static void vfio_realize(PCIDevice *pdev, Error **errp) +static void vfio_pci_realize(PCIDevice *pdev, Error **errp) { 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; } @@ -3515,7 +3516,7 @@ static void vfio_pci_dev_class_init(ObjectClass *klas= s, const void *data) object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd); #endif dc->desc =3D "VFIO-based PCI device assignment"; - pdc->realize =3D vfio_realize; + pdc->realize =3D vfio_pci_realize; =20 object_class_property_set_description(klass, /* 1.3 */ "host", --=20 2.43.0 From nobody Sat Nov 15 20:52:47 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=1747753706; cv=pass; d=zohomail.com; s=zohoarc; b=dPJc5IqEvMhcsO0BNsaKbIkqvGifH1RnNwNzu/4A2AUpnGK1UDCz1zXYw1eKmgzNIADolQGykn88zXFIyedFBjVoWEiwBhmiy+0U7uvVlOcq7/fU17L+75OzdO6CXdcdyCoQvyiMVYVV9OWx54/GZT7v0aoJBooQo+5hrnA9rLI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753706; 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=URMg/JTDKgSVu9CaS09GshwwqVeUo3seolEV/0rUd7Q=; b=JBDyBQv8rx945xrAhaMNtarPI3aMbKIQk7PEP5VVKV7ve852vuL6CKQsR5O/TqAeUEtlnCUARkh5bUtAEmMJp/rba9uhIIVIZ2NLxOiz+HRPu3339GjcrzX90A8T/wGgmrvVT+lt3qmN4wNPSXyfkDufFpzjbelgCV7vzDIRTGk= 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 1747753706145204.41270539632706; Tue, 20 May 2025 08:08:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWL-00034o-56; Tue, 20 May 2025 11:04: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 1uHOWH-0002zM-5l for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04: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 1uHOWE-0002MH-L6 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:40 -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 54K7Libb032060; Tue, 20 May 2025 08:04:37 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheabp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:36 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04:35 +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.8769.016; Tue, 20 May 2025 15:04:35 +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=URMg/JTDKgSVu9CaS09GshwwqVeUo3seolEV/0rUd 7Q=; b=LseE85JNmqgBWAYJ9oYdPVjhJxCykdD7xuJLisIvwbvBsyDBHOAYSYvuR tXgKwuKDKq/mTogrIUtJ6ag/mAIsaHzH1xmNRzvEWLfNNV/5VQmlVK7FWV2+FEQU eUw40AksetdJsV1stoc1ARNUGE7GEsp9+xudQsHycUrOq3UcMQMaxwXOeVHLmySa xRVXxclo+R51VeJQZOpxhlsnVUNTKynjFvzObk0aN85KGY1szJ2EBdUpLBANWAjQ WsabcgL9KaKz1VPvhTIk61wU3Ams2k/h/DYQJU7LYtCDPSdm5C+8aISv8W12//ry gMf3dduo9lpnk/KOxhOgbcowLgEdA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xrv3QP5EbOZ+bKcGjYvXmYyASowtSicinfLuD+mSAQgBgLPCaHN73wLdcNwFSFTbS2BcoTkk1Jp9q04sAdtpDokEyH6WG6HBkH/cThjRKn/PclSLZ0LgaOfx4TiJpFUOaaPt7r5jy/SPxFOs3YSp0tN2NYVoIURBGvCqP/GopVnCQSLWc6TujqoMLIA6n8oc1MxslRNI7E6Vc9bc14ni2oLmccxf19+BGnqvEvrLy+NIeYb0XrLMXy2bkqgq5qwmRrfWctmpjvdaI8AcJLyJJm9uWIF4qSAAKVBLielI4kcXJPaVIORCKaEMNASWQmZVBnnMryeOZw8BQFcU13Q3sQ== 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=URMg/JTDKgSVu9CaS09GshwwqVeUo3seolEV/0rUd7Q=; b=PMpcWzNwrpJPhddpKWLELTKcppfgW/3vmDmJV/02+gkmnBLV83eFnfqfRGYBPMsDuTC/Kaz7z6py864HSQzLScd3AlPUmrfycGwRIwAivEg1z7ssCNWffVoOvm0pNYdlOPxsnRLcwO015w0mg3k7V9C2+4CAqXEkG+CYtx4Wz6Gw8Iz6bRzWbiALiWMvxmx1A07ZTQtUdtQaVO6dCpveLFlSwQvXUClVrotsq3cV57C4GnBvE4UE05cTK21MivhE+azZY/cA/WbCDVSCMjAhZUQxiBNt+ZixCovIoFOXEyY1HwlGQYLV9QUhka6Eei4VZOxED+LB3pJ93uSoYN8EUw== 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=URMg/JTDKgSVu9CaS09GshwwqVeUo3seolEV/0rUd7Q=; b=v/rxSpqGS3+hNLh0tZa6TGhpkyVeM9HSg5KpQt8QkxE5gKK1kSVYv9YOQvGhjsMCsdYuoTxnjViiUmQgLESk5d1wJmwz6Ffjfg4eqAYoaMkP1s135rbYVcAYW2HpT06zrR9jhHHhag/wG4Q3NuzdoFNIjwaYC8ArpU8TB1jOViLtH7SK+a94D/CeiRayE2kbhR474BKm6eBcAEL0PgcqnuUIIiPw0xbmDofm0k/TG8An1TunOeBY5yvWHutGUQvv93Ex9j6a9/VPL+eh3Zq2lPR72hatV0RrjXH+Ly3+ya2+JtVzKV/mbuz7QCsxhpokd+2GkK3Xcfqp6J7laArzog== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 04/29] vfio: refactor out IRQ signalling setup Date: Tue, 20 May 2025 16:03:53 +0100 Message-ID: <20250520150419.2172078-5-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 9db6e579-3044-4026-9068-08dd97afa1f7 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?eGpWV0pOMlIzSHBRMHF0WHd0Q1FycFlHYlRJWEhOZGFuaWJFK3FUOCtmV0NG?= =?utf-8?B?TWNYUjgxVTZsRHZyb1FpSWZPNE5rVFN2RHNZV2c0QXRHektkaDRzVlZMbnpj?= =?utf-8?B?MUROUUJXWEdhd3NSK2xKSFFLcy9WM1dKekN2dDJ6aXN1YVM2MitIZEt3WDdU?= =?utf-8?B?VllRNC8zeW9tbGo5VGpXb1lWMUgyYTY5NlZBSUtlMjlBeTFJOCtGeldXMGpT?= =?utf-8?B?MDZFSmxaLzdPd2pPNmVKVUpKdW5aUktMclUrbVcwWFpoTFJDUHl1RHBQYm9V?= =?utf-8?B?MFJYOFBKZ2ZDVC9MeGkxSkpwa2p3WE5FZFhIVVMyUU13blg0T0NHVzFFRjN3?= =?utf-8?B?NlNveDhKTVp4bUJ2ZUhYV0xtT2l1RGdsU3pVRGs3OWRpOHRJdnJRbUh6bVYz?= =?utf-8?B?VmlGYWFsMHlZd3duOWtwWXVJUzE3cnlxV2hoM1UyVU1uanBjWHUxRXhlVmhM?= =?utf-8?B?eDIwa0hFbzN2VUJ0amNmSngwc09YVHZYRHJyL1VwdFovY1AwUGRncFBnUFFq?= =?utf-8?B?c2RJazQ2RlZFdU9WODdxSkFPNEl0cG8x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wQ3F2blcvNWh4RUUxbUNOL3g3T1NHVlcyendGZVBiaGF0?= =?utf-8?B?TWRENHF1dFYwV09DUVNNNFZGSUdORVJnRjY2OXdacFBVZFpFWmppbU91ODZS?= =?utf-8?B?bkhjTHBIVHFzbXVJMUh4c2IxVVpVQ1ZoMnZ3YzdvdXFsMmpDdjJyNm5ZZU9o?= =?utf-8?B?d1lMb0RLbHZ3UkFCZm9KUVp6RmtLMGV6ZmdsSzNpeUd2dXl6aU1sTnd5ZnVN?= =?utf-8?B?Tkc5ZzlKNnNjV3lXVnF1MVJHYjF4UU10WG9Za0xvakVvOFg2eDZsYzkvcy8w?= =?utf-8?B?L1ZoeUdWRU9KWDJqWkUzYi9KU1RUYUR5YWcxcksxQkFVMzJIQVhGUFd6cDNr?= =?utf-8?B?aHNPL09XKy9GSTF1eTBmOHZwZUwyL21abEdLOTdvUkVDUll4cGY5b25zdjBR?= =?utf-8?B?dmo1S1VOOXozRlRCa3U0Vi9Cdmg1bnVDNVRSbWFKRG9neVFXcVJMUHMyRy9S?= =?utf-8?Q?HpuK0HN4kt4=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a04zUE9JUmZ0RmxXbFByVUI1OTg4Wk1kSXlLSHFKWXFyNUhJTTBKaHkzOHBI?= =?utf-8?B?TFhnVUwrNSs1Nys4Z2VBVm1RNEFCQ2tXcXNhZGdQYWFMK2szY1lLK3ZMckNU?= =?utf-8?B?TjNQcjNONXB3eThvZjZQeHkrYW4zbDZyajZRVTQyajRNZnZhTWlZTnlaS0hB?= =?utf-8?B?MzJXM1NvSWZxTlYyYkFzcU1LOWF6N1FmRXB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VcvandzMGdoZmJnelh5WU5tQTZMZDdoell2SDFhN29CblFiUFJFTmJpbkZx?= =?utf-8?B?eXZ6ci9rKy9tbytXQzIzNGJ4T3ExNVFSdTZpWmxSTmFKUFlhTkhkNzMyVEs0?= =?utf-8?Q?ygyqoiUSFXJkkqrZ6R0dcpDuy?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9db6e579-3044-4026-9068-08dd97afa1f7 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:35.0440 (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: CgR8DLFLzunKIWxcTIe2X6zuamM/pcajs9VuNfPujaOVafnm+uTlziiQLOyGHRQN6G9wIcHgDDaCSjvpIHTLVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX/5dEVYxlqSLs 0G7JwfUGmLAhp+Zip7OIHtC1ZzGWtD+wPgfP9TbqAEWcXA9LalF5cPEpMDGoYMDxeJeTGffAgIG Y4J/4huMdgxQuFqDrM4n783sAvZubz1629Zb+P8b9EM1x0yOKWTPbiWlWa5V7hVifSTnUzAiBLc 2A03caIAAA1svD3RvasHnbGe7ULmVxuXPeMjpvXFyIDLYcpOUDnAnMzBE1jA7Hd0Evdy0xRCUJD 0qHpF9bNdYeEWPEIk0a4LCgvaIRK059alBPb+/NSxngfyvm6m47PIx/Qg6S3Nb4t1LNYowdSZwF JL4R5pRd/valR92EGa30hVY/CyYjeAMLP5iVnIXCx4DRSB0MBiPAQaxvMiaSbJzfAXT5pmjJrm5 NfAfHu6LXS1SZyTvYeWQOVAj9Vc/QKRV1wKsov539ii8zklGh9DAPgDsJCHikPlTWOTmkleF X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a04 cx=c_pps a=b6GhQBMDPEYsGtK7UrBDFg==: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=64Cc0HZtAAAA:8 a=20KFwNOVAAAA:8 a=Cuy1blySaGDMMkobshQA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 7SNO8Kjm298CgIYaRvdGSwUCAOupdO6H X-Proofpoint-ORIG-GUID: 7SNO8Kjm298CgIYaRvdGSwUCAOupdO6H 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753707612116600 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 a873f82aeb..b1250d85bf 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 Sat Nov 15 20:52:47 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=1747753706; cv=pass; d=zohomail.com; s=zohoarc; b=RJiBVVajnTWm7VORV2dY505Kz7N+Rz+bKv9Vn8512EYGmrCnkoK9P3JdgImd4V2hcriiOZsn3aMhqgiGUWiue90mjAjw97NNjGwkJ+i8idQ0gcrDCOw2ZCjwfMRDRTWtpb9If/eNxG8t5qP5JbDQFcEOZF2v5DIWtc0b8a+yNNI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753706; 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=1FgpavB7je2j4lSr11kMPwXjriZvMwCrXGLR8tcPiio=; b=AJs0mJEsr4aTu2BxiD2VFF2BbHz5Vj4YVfBzvTdIYNex2CiRPQbtEYRMvl+DYKSSVMOswqjC5rZeSWBWm/peAjUq9Z39gSs4kmfkG2CjlZjG35a4a7BE7IP//YivBv09EJbpT9Aq/iqgamr1rBnG/JliJ6ClDDYnx65S+bKOO+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 1747753706887961.0929848211944; Tue, 20 May 2025 08:08:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWP-0003AC-IH; Tue, 20 May 2025 11:04:49 -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 1uHOWO-000394-0w for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:48 -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 1uHOWJ-0002Nc-SW for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:47 -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 54K74Jhi000844; Tue, 20 May 2025 08:04:40 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhebv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:39 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04:37 +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.8769.016; Tue, 20 May 2025 15:04:37 +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=1FgpavB7je2j4lSr11kMPwXjriZvMwCrXGLR8tcPi io=; b=1baSfdA6pABq4efp4wcNYbXSwhCMr6rZfkp9NogL2tzaLH9XlcvssoPkd V7h+zR1O6DrUEnrp7TnmXV13mwRvQQbQ4PD7l5EeI/GJgQvgMcAeHR2SWulLdK/B G9b9QDk24uGtQcAKu6JdRXiKUjaWoGvYHwpHeYSCSTd/Cez2lKFh7Gyv3lxv7EDB mbAZUk2LoEdvkSbt/3WiJpZzygMGR+soTiClTIggrDbqxV+TesnrS0cDi29ML0qW 2uaOxKb3NmmVf5NNBjlXc3sjxWMGbVVkf8gfBso/NYBlxDzSBGjnjXCCmwdP/bCV TUTitS11G7dqznXzixy3zKg36HgEA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mWbFzpf1lDyLyeCw0Pb42Z1MD8O/A6ewGK+6o2lm/ogdKP7/Mtgp7PoOGhek1wL3P3l7TKwisnXRhLJaIz77i8DC/CNBzNFHKijXc21aq33ff8en3Z2YuAkbeKtzKaak1Iadg3xQbIQBx3D52ETbJWTmC26ime9alvauO+Gq7+Tx8euDkASjO9MtTQBU9SDAblXkj62g+tMgjZ6UIrQyY+3BZJGNxQkiiZsPxEqI1El7Zs61PbwVbBDJ+HGrJl4sqnPhgQFGGcTWQDEgojoaxjQ4EcERKm71BGGRIpAPt6lVPx+oXbqVINi98nvGXZ3QKvQWSgmrKOlfT6h0ED9eAw== 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=1FgpavB7je2j4lSr11kMPwXjriZvMwCrXGLR8tcPiio=; b=oinIMqm82DaUzb+7NmrRhKWExFXofFYOfcT2VyOgLZMIbM/s421wwiG8svRK06emiiBLPCnMl5NB0fbc54K2PgTEiJeGUVPflkOfAxP2dPlAPjF14GXrS4tNZr40zeKvhdO41uEaqJF9XJL3LB7/QjU7XjJVY1iKboLR6EYZoXd0Bb+ih5yRhE385DTNSsTE0XDqWwFd6JXH5Wo6QLIMSumVe/G6mZZYykglC4912xNtAk1bdZC5UcYzbKiyT8dcGKAXnYkqkPsmu1z9YbgUd+ljfyx3SCmV4nnZMgnVwHfrXeRAz7E+9ajXaIbhbqs+hbZrnAgTgmU9X4A3Gy51lA== 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=1FgpavB7je2j4lSr11kMPwXjriZvMwCrXGLR8tcPiio=; b=wrQf6u/sQ8a850SKw9eVHCNsKRlhBvT/WohI2D+wufyPnApHCxdLlWgdySM1lbD+7OUCeq1S5EFKhqGmF2hkrPKplVDdw9mZWIisbGFNaW3LlFRGX3xRCTzsGa0FdUVAaQZTrfZBkvUDrt5T3lotyR7WadhY7zBuZik0jLFORMGOzUttkGb66SwW158aspmQ6nR9YWM3t5dTYdSIg1IOZWWbcsvJEhskkpGcZv+eGYMFtOPhwqmfOef1NaVJ+fJwg707p9ABsBde41KSi/MCTsjn91T8qd9t5+LLGhxzrLru/jI1X+caFssieXJiSGDtqVZgjcmnbP0tZkSk9E986A== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 05/29] vfio: export PCI helpers needed for vfio-user Date: Tue, 20 May 2025 16:03:54 +0100 Message-ID: <20250520150419.2172078-6-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 073304a1-8a6b-40ad-d598-08dd97afa343 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DOsZ9+FVfnQUwCFLk2pQWPJ7zQKrLjFbUsZpx9/zDre6fYOhzca2S1ydIfM6?= =?us-ascii?Q?cXPjyCjDwU520v0gy1lyfCNNKRSp67Y3MUpBk/GbAyL5dcItqjRnTo8yH9li?= =?us-ascii?Q?+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p+XBpUNqV0FoEw?= =?us-ascii?Q?t4E9pj/zfnobl3YEed9+Qc22pKRTFaD30GGwxmukDijOjThK3f+IONGc8tDj?= =?us-ascii?Q?g7YfhaAbRx2h/n4G+ubNB6RKs6vnu1EDUhCwWVn7EPOUdKrsuT9yZDrHDvK/?= =?us-ascii?Q?Z2ydCo/X9UVr0B1/2oOIskC9F5fG2euOVbYBnYEwT/UhzCmMwA3wPbHtgTIs?= =?us-ascii?Q?S3y0iDfMOhYQmcRPz9MQNV4rcNTTfW+v0plw52fhJndxirKMs+12hU3TpyI6?= =?us-ascii?Q?NN8gsHun8XhLcfsG0cxn2JRQ34zHogsGNe6soguRaDq38Bb+SGcLhraQd3Pk?= =?us-ascii?Q?yAAT1Ct8H2C9+JA+xodYxam9jw0k5AER/0BxMdrph3aYsqDTLpqwxxK9kYsR?= =?us-ascii?Q?hWjzk4ZIk0woJ+X4SSVPsQeXyXmtGfXa2d3VnnxbWF/tDqTjj7cNTNN4ZUsC?= =?us-ascii?Q?lSrLymiNSV0=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Y2L/mCflirkIS9Ri4hGz0Qs+x8/bxKu4fptG1Cpzl76ciGyT25QFNFJ+qIBt?= =?us-ascii?Q?rvoVbMwKZspqOVG3Upl+9yUS20oQfFVLsCCPUHvuIT96m8GYxxFAwkQu85Ji?= =?us-ascii?Q?WnEevFc6z/vAcS9FP+cLflas4Qa3wixfW8ZxjrJRBXlgVO7upiutDQ/3CnT/?= =?us-ascii?Q?Y8Pz1fCHXJ0YvI0gKws6CT6oGCFi7uItLJJpFt51RVzjZbqUeM9N95lBGjvF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KEZe4Bk7iu7g1ft5qFt9ik69VFp6CCVO?= =?us-ascii?Q?e13PxaBw5fCTBtlCRjXXOhge7RiSnbWweIWJLxSUicNVXfJRV1ON+pJ/WjnC?= =?us-ascii?Q?9ARyqv8G7zchTvEtWEKv4u4EvUjWkuiJulf9LHxBknQjeeuoQkqLnGYK4+D5?= =?us-ascii?Q?9Z156Q0dgvmWnwx5AhaxkYqwzaGm4lhPqjWkoCrmdbDvoiK4O2X5lnHkjpyx?= =?us-ascii?Q?atMm6oTIRRGiRECLosCvb8wpP9lghIDY85fn2XRdXlKklScGN68etWwSJriR?= =?us-ascii?Q?b2DHjPh1BVQ8ZUJdnne5kYcsO/bOOivrGHnkieg1nHzO2eE3yy2CKhi6Aref?= =?us-ascii?Q?7XGfPx2PsxqypODIQrdhBWruqL1ngF95VQSaOrCIoO/PfAjLRG05+ma8/4LX?= =?us-ascii?Q?MZleRZNnD4CMQJ8deDYo0or/o46W3fOP7CUyxHG9YYvbBnEgC6kfaJjZtCCp?= =?us-ascii?Q?S37UtBFghny+SOKGE1NluAFxCAZ8qYFZ9TX+0uP+?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 073304a1-8a6b-40ad-d598-08dd97afa343 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:37.2495 (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: iyTGODvzqZkRO9A/j8P31FMB0c+z+I/YAP1/eQZSwMDyh35tzc2SGJ3vxB8afbRPYSeoFn6SszNAvrqkye4Rdg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-GUID: pXFZx7ZH6mJ_l4Ih4ruol-fdXsmqCRF8 X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a07 cx=c_pps a=qvBKVd3KFl3zkoLf5jvq7Q==: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=8_AniDzTzyVSuhZCgjwA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX6eNhcgArcL7r 4tvDcV80zwt/xfR07jlNkMwBAWliGolic43uGa1UdFJn6uctOmDUU7TRP9hK6bLvpFr9+jWeFjj a6jvo0cIINYlPWMuFtFxN1RM9Us8qWX3oiADGI/fCEncu/JFNaysDF6UBMWgsoVMp7+cNHCKLub d60q4gPkdWxSpiBZGvoqVPg03iRagUiGU+uaV0TaHV77UD6oYY0mWzUW/gxIS3TeY+Ohw18pLsN Mu3sdlDyTCQVzQqxUhjLm1QKGvYQ9YQtUOo3LrTNG7Kdt2oarwXdewvds77Cj1oKqA324YC4ItU cE8lvPjXcxODULJVHhc+CCh2TytQSCY2rZmROWOMioyd0gmuYjuYFRrnE9Pr/QmPIaye2gz7F+M zX7N2zO9l3h3CosStLbmhZrE2xfLdBD4a2GSoRUbFjDAN7vQbPTUNSw8MGFERTKSNTDGlsNf X-Proofpoint-ORIG-GUID: pXFZx7ZH6mJ_l4Ih4ruol-fdXsmqCRF8 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753709710116600 Content-Type: text/plain; charset="utf-8" The vfio-user code will need to re-use various parts of the vfio PCI code. Export them in hw/vfio/pci.h, and rename them to the vfio_pci_* namespace. Signed-off-by: John Levon --- hw/vfio/pci.h | 14 ++++++++++++ hw/vfio/pci.c | 54 ++++++++++++++++++++++---------------------- hw/vfio/trace-events | 6 ++--- 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 5ce0fb916f..61fa385ddb 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -248,4 +248,18 @@ void vfio_display_finalize(VFIOPCIDevice *vdev); =20 extern const VMStateDescription vfio_display_vmstate; =20 +void vfio_pci_bars_exit(VFIOPCIDevice *vdev); +bool vfio_pci_add_capabilities(VFIOPCIDevice *vdev, Error **errp); +bool vfio_pci_config_setup(VFIOPCIDevice *vdev, Error **errp); +Object *vfio_pci_get_object(VFIODevice *vbasedev); +bool vfio_pci_interrupt_setup(VFIOPCIDevice *vdev, Error **errp); +void vfio_pci_intx_eoi(VFIODevice *vbasedev); +int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f); +void vfio_pci_put_device(VFIOPCIDevice *vdev); +bool vfio_pci_populate_device(VFIOPCIDevice *vdev, Error **errp); +void vfio_pci_register_err_notifier(VFIOPCIDevice *vdev); +void vfio_pci_register_req_notifier(VFIOPCIDevice *vdev); +int vfio_pci_save_config(VFIODevice *vbasedev, QEMUFile *f, Error **errp); +void vfio_pci_teardown_msi(VFIOPCIDevice *vdev); + #endif /* HW_VFIO_VFIO_PCI_H */ diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index b1250d85bf..5159198bdb 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_pci_intx_eoi(VFIODevice *vbasedev) { VFIOPCIDevice *vdev =3D container_of(vbasedev, VFIOPCIDevice, vbasedev= ); =20 @@ -111,7 +111,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) return; } =20 - trace_vfio_intx_eoi(vbasedev->name); + trace_vfio_pci_intx_eoi(vbasedev->name); =20 vdev->intx.pending =3D false; pci_irq_deassert(&vdev->pdev); @@ -236,7 +236,7 @@ static void vfio_intx_update(VFIOPCIDevice *vdev, PCIIN= TxRoute *route) } =20 /* Re-enable the interrupt in cased we missed an EOI */ - vfio_intx_eoi(&vdev->vbasedev); + vfio_pci_intx_eoi(&vdev->vbasedev); } =20 static void vfio_intx_routing_notifier(PCIDevice *pdev) @@ -1743,7 +1743,7 @@ static bool vfio_msix_setup(VFIOPCIDevice *vdev, int = pos, Error **errp) return true; } =20 -static void vfio_teardown_msi(VFIOPCIDevice *vdev) +void vfio_pci_teardown_msi(VFIOPCIDevice *vdev) { msi_uninit(&vdev->pdev); =20 @@ -1839,7 +1839,7 @@ static void vfio_bars_register(VFIOPCIDevice *vdev) } } =20 -static void vfio_bars_exit(VFIOPCIDevice *vdev) +void vfio_pci_bars_exit(VFIOPCIDevice *vdev) { int i; =20 @@ -2430,7 +2430,7 @@ static void vfio_add_ext_cap(VFIOPCIDevice *vdev) g_free(config); } =20 -static bool vfio_add_capabilities(VFIOPCIDevice *vdev, Error **errp) +bool vfio_pci_add_capabilities(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; =20 @@ -2599,7 +2599,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 @@ -2655,7 +2655,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 @@ -2663,7 +2663,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; @@ -2706,7 +2706,7 @@ static int vfio_pci_load_config(VFIODevice *vbasedev,= QEMUFile *f) static VFIODeviceOps vfio_pci_ops =3D { .vfio_compute_needs_reset =3D vfio_pci_compute_needs_reset, .vfio_hot_reset_multi =3D vfio_pci_hot_reset_multi, - .vfio_eoi =3D vfio_intx_eoi, + .vfio_eoi =3D vfio_pci_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, @@ -2777,7 +2777,7 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **e= rrp) return true; } =20 -static bool vfio_populate_device(VFIOPCIDevice *vdev, Error **errp) +bool vfio_pci_populate_device(VFIOPCIDevice *vdev, Error **errp) { VFIODevice *vbasedev =3D &vdev->vbasedev; struct vfio_region_info *reg_info =3D NULL; @@ -2823,7 +2823,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) return false; } =20 - trace_vfio_populate_device_config(vdev->vbasedev.name, + trace_vfio_pci_populate_device_config(vdev->vbasedev.name, (unsigned long)reg_info->size, (unsigned long)reg_info->offset, (unsigned long)reg_info->flags); @@ -2845,7 +2845,7 @@ static bool vfio_populate_device(VFIOPCIDevice *vdev,= Error **errp) 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 */ - trace_vfio_populate_device_get_irq_info_failure(strerror(-ret)); + trace_vfio_pci_populate_device_get_irq_info_failure(strerror(-ret)= ); } else if (irq_info.count =3D=3D 1) { vdev->pci_aer =3D true; } else { @@ -2857,7 +2857,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); @@ -2905,7 +2905,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_pci_register_err_notifier(VFIOPCIDevice *vdev) { Error *err =3D NULL; int32_t fd; @@ -2964,7 +2964,7 @@ static void vfio_req_notifier_handler(void *opaque) } } =20 -static void vfio_register_req_notifier(VFIOPCIDevice *vdev) +void vfio_pci_register_req_notifier(VFIOPCIDevice *vdev) { struct vfio_irq_info irq_info; Error *err =3D NULL; @@ -3018,7 +3018,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; @@ -3124,7 +3124,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_pci_interrupt_setup(VFIOPCIDevice *vdev, Error **errp) { PCIDevice *pdev =3D &vdev->pdev; =20 @@ -3214,7 +3214,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error *= *errp) goto error; } =20 - if (!vfio_populate_device(vdev, errp)) { + if (!vfio_pci_populate_device(vdev, errp)) { goto error; } =20 @@ -3228,7 +3228,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error *= *errp) goto out_teardown; } =20 - if (!vfio_add_capabilities(vdev, errp)) { + if (!vfio_pci_add_capabilities(vdev, errp)) { goto out_unset_idev; } =20 @@ -3244,7 +3244,7 @@ static void vfio_pci_realize(PCIDevice *pdev, Error *= *errp) vfio_bar_quirk_setup(vdev, i); } =20 - if (!vfio_interrupt_setup(vdev, errp)) { + if (!vfio_pci_interrupt_setup(vdev, errp)) { goto out_unset_idev; } =20 @@ -3288,8 +3288,8 @@ static void vfio_pci_realize(PCIDevice *pdev, Error *= *errp) } } =20 - vfio_register_err_notifier(vdev); - vfio_register_req_notifier(vdev); + vfio_pci_register_err_notifier(vdev); + vfio_pci_register_req_notifier(vdev); vfio_setup_resetfn_quirk(vdev); =20 return; @@ -3310,8 +3310,8 @@ out_unset_idev: pci_device_unset_iommu_device(pdev); } out_teardown: - vfio_teardown_msi(vdev); - vfio_bars_exit(vdev); + vfio_pci_teardown_msi(vdev); + vfio_pci_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name); } @@ -3338,9 +3338,9 @@ static void vfio_exitfn(PCIDevice *pdev) if (vdev->intx.mmap_timer) { timer_free(vdev->intx.mmap_timer); } - vfio_teardown_msi(vdev); + vfio_pci_teardown_msi(vdev); vfio_pci_disable_rp_atomics(vdev); - vfio_bars_exit(vdev); + vfio_pci_bars_exit(vdev); vfio_migration_exit(vbasedev); if (!vbasedev->mdev) { pci_device_unset_iommu_device(pdev); diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index e90ec9bff8..f06236f37b 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -2,7 +2,7 @@ =20 # pci.c vfio_intx_interrupt(const char *name, char line) " (%s) Pin %c" -vfio_intx_eoi(const char *name) " (%s) EOI" +vfio_pci_intx_eoi(const char *name) " (%s) EOI" vfio_intx_enable_kvm(const char *name) " (%s) KVM INTx accel enabled" vfio_intx_disable_kvm(const char *name) " (%s) KVM INTx accel disabled" vfio_intx_update(const char *name, int new_irq, int target_irq) " (%s) IRQ= moved %d -> %d" @@ -35,8 +35,8 @@ vfio_pci_hot_reset(const char *name, const char *type) " = (%s) %s" vfio_pci_hot_reset_has_dep_devices(const char *name) "%s: hot reset depend= ent devices:" vfio_pci_hot_reset_dep_devices(int domain, int bus, int slot, int function= , int group_id) "\t%04x:%02x:%02x.%x group %d" vfio_pci_hot_reset_result(const char *name, const char *result) "%s hot re= set: %s" -vfio_populate_device_config(const char *name, unsigned long size, unsigned= long offset, unsigned long flags) "Device '%s' config: size: 0x%lx, offset= : 0x%lx, flags: 0x%lx" -vfio_populate_device_get_irq_info_failure(const char *errstr) "VFIO_DEVICE= _GET_IRQ_INFO failure: %s" +vfio_pci_populate_device_config(const char *name, unsigned long size, unsi= gned long offset, unsigned long flags) "Device '%s' config: size: 0x%lx, of= fset: 0x%lx, flags: 0x%lx" +vfio_pci_populate_device_get_irq_info_failure(const char *errstr) "VFIO_DE= VICE_GET_IRQ_INFO failure: %s" vfio_mdev(const char *name, bool is_mdev) " (%s) is_mdev %d" vfio_add_ext_cap_dropped(const char *name, uint16_t cap, uint16_t offset) = "%s 0x%x@0x%x" vfio_pci_reset(const char *name) " (%s)" --=20 2.43.0 From nobody Sat Nov 15 20:52:47 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=1747753585; cv=pass; d=zohomail.com; s=zohoarc; b=dZeoS2D97Yqv32vchW8KQ4NH8G0KQp004X4PHpa1zLAEqddqryzptuCpnHj2cZ8dB82xSiOFU6/rAzq+zbdJjWorFgAH8I7KLR3v9HOSWvwllPfAOdqJV8sFgqpBemryXJOy/opO9bIRMohMlU4700wuTm8MgDWtd6rnBptgYWY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753585; 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=NPawAWoNC+uXrHhvCEVORa5TwP5yxncau6nPhBYV/2c=; b=Js5ueJUGXleTqC3dlIUA8g8q8i+yhynu+ttbZj7scE9K9GRXjhHYeC1n1ZcgzI2sSlYYHEm0UNS2EVPNJOiPKNq5At0iRXRkuGt2LuKifvczadZFxwf5z/OOmMlnU6IDcMfCl9/3FIv1bJpMI+naQ4XG49mJtJpbQjf8Dilqp8M= 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 1747753585073331.4671027692058; Tue, 20 May 2025 08:06:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWP-00039v-4F; Tue, 20 May 2025 11:04:49 -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 1uHOWN-00038f-Ls for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:47 -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 1uHOWL-0002Nv-1R for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:47 -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 54KC9YJr030516; Tue, 20 May 2025 08:04:42 -0700 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhebvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:42 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04:40 +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.8769.016; Tue, 20 May 2025 15:04:40 +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=NPawAWoNC+uXrHhvCEVORa5TwP5yxncau6nPhBYV/ 2c=; b=a0IHxPlnRGf6r+H129oSV95Igh5cPmus7gbJKH0l2YzjN2z2ciYUW+k+s d4l+lsV+bQyuDABmfwGZd2V3NnmCyBlo+q0cBSWsYGVLCpfS7Q2ESbTCrLDdarAv U3w9e4lzr4x/RBrqz7M/xq5EGHKXQQIQb2QlT47/Wh0lauiJPxi6si4LpTUl52xR jWAc7cVcCKUDcfjnP21v0zDeEzqVbneHjn/zMfQPlIJG0NJXwEY8+L9pK4YwJsuI 8x7mEDkaV2RRdPC9aR/qjeBzbiZSpXxvf2SvQHNLnjF5bVuUFfPWkHOEhftVDFus Ua3AuoUhuzD2CRF5sLLUtKelk+QfQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mjbKtMQSeZJWbQjdDPBJiTwkfXPXvbLhJGBWQek58af5IZtjtVKzu6F+37KFfmZzATTUCAgNE16j1p16wFjit3aORpmdF2Zvqe+B5h6RcGRSJaW5CfLN0mkXx9ZKbsVG4iSxOwu7TM7/wb4y/OqHWyVoyo8im2mBrpTl8LyzvzZffYisqNGoTopgk+mBQUgoBzD3u3/YCVO/V5g6FLc6ZH1heevTNwz1/rVK/VlNgwSUG75LF0hwwg7gwoumL9VHL9cyp/mgpH3HgQhtFbFQn6/RLNtiZNuRbu3RLzm8NmFeYbTWD58DCwTv6qbDKG6TSIKuHygzK8Y3f9h00Ry6vg== 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=NPawAWoNC+uXrHhvCEVORa5TwP5yxncau6nPhBYV/2c=; b=bl3fa5pTlUsIjho4nJM2jP7NwYwciDzUjoK13jiAz/xePSmz78PUQV7lleeV9xifOwiRxmqP0gpQpeA/M/WFNGRZeA1re/eNL91AjX9PZFBpIeYD/67LsUGTNU3SSwGm77SUGzegkVMrgDHuNGgPSHX3bPC1gxtuqecTOXkKDLHWlQfefsvjEwyTS8EGE2ZfrvWW/ccX3JmeppIHZFc0vNRvRJZ/ajz+u1zB1CY6i6tNWzG4wdSVPgSUrDRq/LKV2TMP4RZHHzI0Ou+N8b2gM78xk714s2+LkSoVFMebaiOmdXyJzcu3BfzVI+WdM6YILTZPVyWJiEay4n0RUHpo2Q== 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=NPawAWoNC+uXrHhvCEVORa5TwP5yxncau6nPhBYV/2c=; b=tl6RWhtsoyepJIn2nfc8/OciB0mmm3az5VxiUWQgGRIEeoVIOxO/n+NLcAm7Zz+vGjeSLVdRuSnQPw9hiWTvWwwGaOieIL9cOXm2JvuBEUbVIeLrtTsAppGPV80vTTtRSLM1PiYnSLATvFuMMg7aE6tT+g0ckK5Z+orXPW8XksVAMcXIyHwisueSbZnf+QB+LI8DN1h7fb9CQBWD6Vw4I1xsItTkpFg33i6I7qjGXKHifLCpXgbY2B89gy1rkLzu+d022P69JrLMk6dcvxb4aFwni431KPdWRXmM/5bFYJ3fsDhG06WqCSlYla0Q6EHWWrJJnsMpvTd7rsxg5cyH9g== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 06/29] vfio: enable per-IRQ MSI-X masking Date: Tue, 20 May 2025 16:03:55 +0100 Message-ID: <20250520150419.2172078-7-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: b14d8ea1-1325-4aac-c974-08dd97afa4e7 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?FI8jcLDvKKtq7UMh6pSI0Gkb2ECk9FV2Ykrm51JGGKlbunVNHI56eoZNb0+T?= =?us-ascii?Q?gGRaiIlaTzlv5Y3aBSz52DfamDFh+afszmKVb38wX0t6WgoXCIuqPXmF98NK?= =?us-asc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4bBtLa1BGE87yOJf6ZXJmXbu3MKx2cr?= =?us-ascii?Q?Z3lwGaD+QxwFZQfMqsWryv9TscSTXn6zSRJ/U+7dMfoTSCrAS6OOXkKImK0K?= =?us-ascii?Q?FqhZ622hDnOM6AiTOads0IMj57fQ1umgUWPTMN1P4rTHaC7Dln8x5C8+ykSn?= =?us-ascii?Q?McxNiwlELvcToQzYSdfuo6+uYPPi7MYTNg6aI+KTlSe5t1MUTIAlGZS22j4m?= =?us-ascii?Q?WW/e6wICbOJSDtAAVpvq1r8DUjWfYReulyJjVs8HiqoDC9GXEWIBY+/hWy+M?= =?us-ascii?Q?nVtUVSfVhud2j3PBou9qtV9oXjOo5N8e/E2ukC9PUAofgmg/ELKh1wiI3WnH?= =?us-ascii?Q?MYZRKs1BwYcxWOHgwg40Ai2TRqAP7zQ3g/+/pIC1l5MqoB++XjIL0bexGvjl?= =?us-ascii?Q?dgomiGIoCYVRg9D6Dp9gBPyrJwtfdsv0l7XbZ7EIjV4CO9j7DfUlGUfb5ZRN?= =?us-ascii?Q?695DOccPYjs=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Xx/lvPTiBxoDKlKTUx6uH2iPXTPrbrBFdp54VVjYbvNBupE1/4NAPyAgqCSO?= =?us-ascii?Q?4p5qvnWVISPPmIq/WLJwV+y0xkV5ImJ8YYGkRmUQVeFVZJlLy1efmNSlnI/R?= =?us-ascii?Q?ffmY8j2rDvM3KmiyHpEKDdM5z4f3zcK5cACi1NZ0PLyqHAvdkVfwqCJqbsNV?= =?us-ascii?Q?e6ydRObCVNcTqpxgeEdEGbbxIJhoP9mbe+jpQ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eNBmolbTYvh2HM1VVm3mlhjoEqb0rKMTUhdQcqWjdnjGAICDBi?= =?us-ascii?Q?5LYkXQR4zcHKlbgjARAGBaQ8y8Sh22W++RZ7U1t+X1g8caDojyHhJPmyJBaj?= =?us-ascii?Q?MhXqkokqN4yi0JOvXcKflmy+TTdQrXlLu2GfPJczYkPX1Qyjkb6UlCEloQ8i?= =?us-ascii?Q?fP+yxNFkiD12GaMvbjyGZlWkbiUuFp82eBaIrzVTT6fWby3IuRZRTzkt4Iwv?= =?us-ascii?Q?il/5XcE+TuB/pPHBymK4wmWBPyuEHsiEoVTJK6H0uzzDTtlaJxvUhT8DX26z?= =?us-ascii?Q?lroD7rQaXBrP5pxc7rjB7pH2b1Lm9v9AI1azLm/Nir+gVJQYc+sOiz4viDQg?= =?us-ascii?Q?ALqWvh1aRIZmAbFcueP4fqH4KJY1QBzbxoB9OJ46157SgoL2QU8wTVPyowXv?= =?us-ascii?Q?TQQ3YklRwYYjA4X2/qG2doRqorwjEBXgT0PSTONOzE057I7YNn5qMlKc5zLI?= =?us-ascii?Q?F/jSeMSqqp1I8zsRNcm3nd1OLA9chNQH7DBiuXs5?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b14d8ea1-1325-4aac-c974-08dd97afa4e7 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:39.9591 (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: 51ee28L3tOHyrSVGJ8VHr1J3Od2PZJbM93Shz8vTaXeg/MSG4LZSvKKdLcQgS2Wjovva6MalnzEqyeIMSPEZMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-GUID: yRPapSqIcVF35bCXkoZutB8GcBs-OhIg X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a0a cx=c_pps a=XlWNgFwcAB8XWrBhwjv7Vg==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX4fCv7K2E6pHU eiZR10fRgpVbiYTXmWu8ukw4gcIy9S87jobk+TsOLq7S5IJx4CKKYXSS0NhQyY/gbTqtqM9OIQ4 9new8Q/lccPx36D5LRuHqRUt5tLalGt8TlNia3JgsuT59x/3bO5RQVUvkhcaXZ+SC1QLxCPM+Cs TVHDea96En8GpgvUt+Iutf2Gy2PQwk0/XpEFa+mZkPLxUheDF1gBbjt+Omt54/5lcB106uEVkQY eTZmdIREeY3D2nT6NlkcMj29HNdA4nDNRsXrhEvAOVDY5OFlUD9tl1nYxwODeb3Y4YsKv/wxJZq hpQZ/vLO+HuV9UBWShh/M82mgLUub9kA7uWQq9UkEtsE5Ur5zRPnXjzPN0mo5amqMG9XlKb5qEX qZ75i08ESgG9JoHsCkA1RjNp/XnfNMyyeXhEzXoQjEkrW42vbbuKq4nxv/tHIhpdGMMfEEIE X-Proofpoint-ORIG-GUID: yRPapSqIcVF35bCXkoZutB8GcBs-OhIg 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753587307116600 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 61fa385ddb..43c2d72b84 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 5159198bdb..ef38b4692a 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 @@ bool vfio_pci_populate_device(VFIOPCIDevice *vdev, E= rror **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 Sat Nov 15 20:52:47 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=1747753733; cv=pass; d=zohomail.com; s=zohoarc; b=NUB+WRjQdsvPc5A1bxS7d91M/7tDOQoUsmRA/FxGulAsDsEXY4aWo2yVkJdN0I3AfP/T/E+eTKFDqPFqak/fCaTxR0YHN54O6Bw0RMkJY6RgDWonUh24MXmJyiX80r6XPqssKUtqsdMD1iWvlYILxXTU5zFRHKr6PLskedt5r40= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753733; 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=Dmhfl9PuWnSUZSGvDmpGtD00VcgoclBcQVBk2CczpnlLODDYXaD/n2wX6uERGJ2lCyrlfbRHOEdypfl0WF+UwAU/s4VR2REtT30Z4zpq1SX4vDwkrznJEvUm9AgsAxc588hptua+hYTBu0XY/8KuUEaEJtkUrGz/WMqfiKmLjlQ= 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 1747753733385138.4522399642666; Tue, 20 May 2025 08:08:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWQ-0003AS-RC; Tue, 20 May 2025 11:04:51 -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 1uHOWP-0003AE-NN for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:49 -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 1uHOWN-0002OI-N9 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:49 -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 54KChh78010177; Tue, 20 May 2025 08:04:44 -0700 Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2047.outbound.protection.outlook.com [104.47.56.47]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhebvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:44 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04:42 +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.8769.016; Tue, 20 May 2025 15:04:42 +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=N3ZT/3RGtVHa6C8uWEUB0x/cPlU2lh5NdQ387pnETJ68yMV5VliuEwawh GUGMirSHEOaRx7QFclbFAOZxaDxzg2JAxnDmWPKxFABerME8soo+oRL7SHKnlmNM yYwJ6RYUlXibptT7YpleSHPgs055y+nx/TPlGpyeA46losvLckbUHmHg9Pp9dSNt vHO9x7/4/voxGoTcnP7LKt1KGWtDo/NtIXzpXE1kCCwXOl6A/tB4oeXcA7WQachl sc4Cm4SHSosUE6G7Jc+RvnbXV1RZJN3HvHNh8NzIAQ4yKmhapDZRBL3URBe4QZmM xK4W5bufPJDUnPJGAYm7YtEMzE5gQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Chj7iGiO3q+N5LIqguAqCHwsAlwejYlT3BROdrIelJlP5176QXfoMsdFf7P3IXTv1dCs7+ocTNoSrQCGfVyQj8RIMAD03m++X1aSsGJQb2aqXSsYIgaCxx7JhlMDj6aLzUVsLaLA/OGt4OFbviOr9u3QPzYcCo/dJlUpTL62yjJXIwNzKyIhY1pnynYLldXL/2+bpBw5tN3mKac1tV1BZgH2Io0zSsoM0Oj0CKL1d3lCB4DSkPEjm9SKnRyxMVVv0r/3ZnLp5Vwyjss2Illmyb7wu+43/WczItMdk6tv5hbOvboGDS0GJxS87Eisrpo8mqiLCr2HfwapoS3o380+OA== 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=zKsalpHWoYhp+MHSNzbbFpi1o1YMld2kf0oA9qCjemwUgxO1o5jqhoZVsEmYiUalkQBmko8Y0yIk5AnEyVzV+JugC9TI88DXOASwL5VE1j9eH+QblVVGWvr8qcbMk7pWzgnfJzMG6qCWDB+vrY4S8xLbAT9k/DcFLyDz6bB78Ynsr0uSlipl1tgnD8fK/FV57vEjNvBLTNX3X3NHoOzgNMp3hDycqNVi6dm5c2zhmsAP3ODa+GNBYsmCzvHz5o3emdukIHW9OIpRVoaa6WsXPWJRFbXEWYRIRtal16JsuqV8/qpqL121195gTFfT1LKbPSvkVyYz+lpMU85w9WLRWw== 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=lsuhdR7NBnCoa/cQ/WR6Q9OxC7EnIT3E34hYDoBJEQkPuqkInthgIH8VGqGhs/RXvvaQx1R2icF/tLe2H+XpSQf5wV9RfTUIM/AJc4TlNKnDfXtinH7Wt+wMsrcwifhJ8t4MbBoXsLeYjojdNlz4sHqRdXl5PF9YX9/jL5KcDJS6kr4ie6wkFsPwo7brZymYuRzxTKG9ffC8m8ab2ajVpv/6Krbwnq3+0sUsgH+TDUi76DVncXiPi9/Ex8jpUrtZ6xSGqZpxUYclctukEnsRQWSf5C9BUvIzegAA/E7/asaNMRESHcZgd7//VXUiXMQ9bDjf2KfaW5hJ8vrIdBh1TA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 07/29] vfio: add per-region fd support Date: Tue, 20 May 2025 16:03:56 +0100 Message-ID: <20250520150419.2172078-8-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: ec7b472b-b5ea-4c5f-4cab-08dd97afa636 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?XBC0mIamrdYDMT69SDIUw79mn29643EXja4UV+TUil/1dK9XgCI1u7BESzvr?= =?us-ascii?Q?vM4JukfPFdiKNE1VvVDl9/Nw3lxBPidyvyV5mijVCGTmuuSn/Rpfbig1w4QC?= =?us-ascii?Q?/NfwSe9h/ckBxQZ4bslk6v9nnT8lRHlJ/WxwAmDgPVI+D0dNNiDuPyktF3NG?= =?us-ascii?Q?QYw94Nue6infu1uE1XdZyW+qyn/Ao0pHSzFvx9QQjH+ZseIGQaOZzuG4zRWP?= =?us-ascii?Q?N8J8VOru1bKS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XUzxneK8T?= =?us-ascii?Q?zd/0YNKsrG9R73kCmhYKwLT1DqgdP45ZKERrrMWplFFor421WsaqdgPuLLaE?= =?us-ascii?Q?tbTTVGpKXJFbXWse6ZI3w2OQoru0nIBaW/Y5XLle63wSeKtT7BU4rq69dwvV?= =?us-ascii?Q?R/Kdc2O1/VaFefowFG1u/ZS3O9FeKHYNG8JWgLjx/G8c9lF3k4aocIavdgTh?= =?us-ascii?Q?a1CUTl3aEI1sAf2e4cXfjOsFnA0CauzmZZKrZU1fRFg6wpjhQmbUzkY4wQQA?= =?us-ascii?Q?Be9KVnAop1x8cbOzjmVDJ7CP/qfBmb9eeaFyLPFnFV3ybj0o7/1RgKa4Qjkm?= =?us-ascii?Q?bJ3B95Vxy6k=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/Ukrj6/OiDb4+h4fjQkKicZtqaRYecBrsy0nzDv+6k0HOeKFAY3M+4WrgsFa?= =?us-ascii?Q?SHcH6NQDYCeDIjWtXXqzQzfn7Nncd5uuXXdr9iTn9pwxq1v/aU3a6Kl7koT6?= =?us-ascii?Q?Qqd4YSM6SB8WdmMvauDXqMALM/7vMBFPol20w+bu0JkVadZz1Pjp6HhSQ4u6?= =?us-ascii?Q?7O5GTQKTxYc3LsXlPxyzGgJqE6qQ6rTwtofkr9lO1+QoBqvqYIdlkh/av9nz?= =?us-ascii?Q?h04b48QifTeEqne/OXh/eL1kQvrCnNZHZWjqORoLSv8UEP8KaXQN52EoJ5Jo?= =?us-ascii?Q?W+N7jhqu3sHlnO4YdXjgl2nZPUQlvUOXh65MmUXih5jG0y0j5Nwuf09VCcER?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LZwLdNl4dnq+j0aQSCPRp27CxSuL80U28o2?= =?us-ascii?Q?jTyC37t71Yhb48tnApakoUk4H8n9OmZ2YJUMACstkEbZqKAbq6bzP5FUWHHI?= =?us-ascii?Q?YcXEMTz+6m+IrX0ADQf4yqXg1kUVlA8gvmxjjBoIcAGR96oLjYuBqgJDHnLy?= =?us-ascii?Q?U2NK1yTlqid5pEsPEf4xJ1/xtTowKTqAJ0kQYUUGJEyxTO3gTXOe6oCr3tIq?= =?us-ascii?Q?mPJxh4JqsrW8AMuJQObNLN9bbL6/GME9Gk9ZF7vGeCt0DKOzYDFL7opSAFbY?= =?us-ascii?Q?Llh77xAXwCOkkJxNxkjdoTfIJ6ENojWpxVNQiEXcUSuRE9qCYK/U7NCI4/PS?= =?us-ascii?Q?cVARWn8Not8uN2cu51apOUB0B1jGZj81LNji15pj?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec7b472b-b5ea-4c5f-4cab-08dd97afa636 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:42.1563 (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: hCoUCp1RMIU7dJvDVmoUr+XAc200FkxQnsi4A5EvfkSmoqgogsDtJpkc3eBgSu6zFAqtAYKH4bRwhzXTDzWFFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-GUID: 4KtuEGgrz2MilnuCBvw9gW0tPa7kmB5k X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a0c cx=c_pps a=e6lK8rWizvdfspXvJDLByw==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX1dqT8W9UQMWF YJXgj7Z5d2z9O64dr8Pw8RCoxltM4UQVGNzh5IxUHXTzkpg+4MSSuEzzhyz1jByNUEViFYT05oL MmdZ/I8tjlgcXOS68GjRAbc7zqfoYvjm+VDiBBnKVLv1onCGxcApzP0OtIc6N37GDZ5wmbALYTq jFME//M5j+8EMV2tI41ZIBt/cuSNaTabk8B7LwZRZYUJQb2IOyPjwvYFa41OshuO0lTGxJ+sV1I 9o4rk/+v35tVYskBXyQlZEtCiP5wNcr46XqXQnm8wi0cvtbw5WfrnGa6s0MZpNRzuwSTr0+32sc GOErOs2a0cCXH+j8SE0XwwVJXp+8mY2KwzbucJTDeZEZ3e5N76SG+ryquwSD6Pq2RqVnz9JUNuo MKBUil93yYpC0Xr4W+vQAekmedyQz0SCKzGna1fs/Lw2ERYsQ20vkOUytQZQn1uGXuEZubxM X-Proofpoint-ORIG-GUID: 4KtuEGgrz2MilnuCBvw9gW0tPa7kmB5k 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753734272116600 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 Sat Nov 15 20:52:47 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=1747753566; cv=pass; d=zohomail.com; s=zohoarc; b=c5av+dbn9TCAXyamPMdDGXkAToYXJ7+Gy/Ve/u9qjlloWvSbW3mwMqpKlPrPH+YBDqFIwD3b4ckDpjwZfGKF58zhVu2l0JZa/EHsJOpePlFqPOm10AwfbnbjCilPmz5Bosv6YC/p7y0SUrbfz1LcbuyWDxP5md5Q36hKOGP0p34= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753566; 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=GoZDkXZDuVpkYtV5ZrjkcwXGy0Yt6C0u28B1WtDoWG8=; b=I637CVNNsJENY3nGcQHosX0aIx/avKSDj58CSGRaOXX25ClPFUcmIRfVD2sdFQYixrNrjwDt7rC+OEaAXhMvMO3fAQAR8FK7fj24KK9OtoZx8YNi6S/GPhZoUoAaQYqPoD7MWZIyrHB8BPawESC7nmdSQDlhvGIA1vUky50mtjY= 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 1747753566697502.07776042767046; Tue, 20 May 2025 08:06:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWU-0003BK-8r; Tue, 20 May 2025 11:04:54 -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 1uHOWR-0003Ai-L5 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:51 -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 1uHOWP-0002QB-Nf for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:51 -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 54KAc4jG027978; Tue, 20 May 2025 08:04:47 -0700 Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2049.outbound.protection.outlook.com [104.47.56.49]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46qvhvc71q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:47 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04:44 +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.8769.016; Tue, 20 May 2025 15:04:44 +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=GoZDkXZDuVpkYtV5ZrjkcwXGy0Yt6C0u28B1WtDoW G8=; b=rM1daFpcUz9ZUKMAggq2esKi7XTNaN+t6+Ek41FJKYFDoaHd3Oi/DUahP NwfHa9t7CZWrq/UYEbLbtjuwNACiujeBTNnCGCpwanaWwYykeY3ELK1TWyFBxDJM xvcAahp1zwkdKbL3eIQVx3zV000kkPDsM9kA0VcvOgGzRK9PXUsiRJWT2eJ4lRv6 T3flbdH87Hh4vtaH4SsiQqL7d+w3L/CCf5EpyYicptgaeMKrFGxxLhCH1N3nyB2u 3kfDD3WbQwmuBKH3JBr4X/tJxlm7Hd70rbZ5SxEYQj98AJLYI1a6hplnJg6oyak0 +bg3vsWCCMYY/z8VYpQ1yWWKgfUHA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t1y2EhQc8zqAcbc95P9PrM0Z8IgHWmWe9FvcekkHoDs98MbPPCr8Y8NYvC/rZRbL4G++FHbD2qAaVTVE20s5f57hgl3mOGzv+aCEX67yCc/Ar72BI1xT+Sljiqam/9fyz3Bt49a9A0QnW6stE+1lerWFW5igwlQ8jMGDVXIh34MBXUnBw2DANYkj3WYC66VMPA/OAJyS4CIRFunorYHKlYfARUN+5HasKE13vxVazK+3SM+Ry+l0MKs9iPIDCUQCNFTca5PBuxu/03MTv+9lOGsJAXOdgN2rrRQ5BNyci56gORzkloPphX0H2svWizawr7FpkEceuyNUaT7JSv+Lfw== 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=GoZDkXZDuVpkYtV5ZrjkcwXGy0Yt6C0u28B1WtDoWG8=; b=jXAIWP85UuvDmso7lpHHzEw1LY7ffnAah/1aLg4cb7R0d5zLW+TkHNOaUd/F1raa2goIutN7sIt+U5L/+GABPFHjqR9p9lFYi77GrPrMc8synCCu4uyyLKZ3Xzu5YelKYRKEn74bYK3CCj7VXyCuIS4tTdADupMVqkTZjCbNwouptycZ+9ysVa2R1737GcZA8uvMZNSLuEe9il5kYXlB1uIAPJOZT0U3/+RobfmQ2fE5btOpwOvnlfzOJvkS9c59XCzMIX0FouM9JzgCFy9cJCkqwLDKF/ZB+4DXN7jN6fF5vYPKz47mP5cYq7SUUejfo0tBtvUGoxJ0HW2KavYWHw== 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=GoZDkXZDuVpkYtV5ZrjkcwXGy0Yt6C0u28B1WtDoWG8=; b=gql2yrS8+EY1RjHjqF1KyMiHaCuau6ngylSQIvvtB79Na8nZweCJfDKJT9DXgkJ6JBPTJPqSokfLU7XoqQ5jnAihhCINMPBrLjaYL435lND05rvwT27LCwFy6M7TfK1MQRU795Di5kcC7kmOGdc+kmJ2ACsrN7J9rNJhWgEm6UHvxFiNjZKH1/JEDm7DVZhYemTPzwLDJfTCyOC4jnUhCSX5z1kRAPG0v+KJbQxhIanko99Ps4l2GgCF6rxNbDLqgW4w16A6P/MIeUFbAjZ3jpmk76FagP0J+g7h3I/nA4ZQ5oBILywgxTl4NuMfjJ8zbdICS6QhiNCI82sX6FVXCQ== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 08/29] vfio: mark posted writes in region write callbacks Date: Tue, 20 May 2025 16:03:57 +0100 Message-ID: <20250520150419.2172078-9-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: aab83cef-c8b0-4938-8752-08dd97afa787 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?b92LGqmXoXRPJKwcV3OG4IvbXEjQmZOc58RoPJpPwD3Y+WJJjQobX4nJLNod?= =?us-ascii?Q?jvXS2edi/vBoQkJiRW6Aj4O/DX5CANDjt0hWjg0aWLDocBvKHv5S6rWitmc8?= =?us-ascii?Q?c/rwcMCXDMC6zOni4tlCe+l6/V7+ADpv6FeuDUS3dWH6aacS/lrbe3OB8j3N?= =?us-ascii?Q?nLU652ZN5BC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?Q?/OtIs1d+AejdjDdujHJ5dFnq2AXjLQ66vJlMHWYiFYka79yu51Qh6uitNSti?= =?us-ascii?Q?L48CQkFHKlso5vUCG+wG+bWsXR/WU7ob4GlInQruTBmIAZHhzlUhQrj15am+?= =?us-ascii?Q?Fk1Yanr+cyqRynOcqgbVoq7pjoSzMhDIDlgigQp6RQHw87c/lHgLunWFbxNW?= =?us-ascii?Q?t0rHt/3OWJ21s6aELP8BdZokwpfpssUsfJOHahM2LEC0xnr8GYi+kg1W2TBF?= =?us-ascii?Q?XzRp/OBEtKvrmGip2/ifucb1Jqg22E9vD6Bf79+xKZG64Uk+2bmOnOMVgzXv?= =?us-ascii?Q?E+C+hJnNDe/GrMRinCBaBrDKj+TEcYqsN4mlHQf1AKtmANj8OQU+kAIhylzG?= =?us-ascii?Q?scU4h3EBSyk=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?g3922siAzi00v9N8iiFvPaqXFdh+EtoY4c4tckQfFf4lG1p33IjNHam+bSMo?= =?us-ascii?Q?TscU25BP/zUZpsbvzTvwn6+NknrsARbvmuRC06kkzVxH3TEe/64OabZhf24N?= =?us-ascii?Q?KrPDOBZYjdj97kkgWe+I6D6fdbnhYjJCXR1FJVwEm5sGUwU0IncgbByqrnYM?= =?us-ascii?Q?Gd8lJIZH+tIOusRRuaA1kXlqHLGqBxmztZr1Fs54EIWNvxAu43pR7GfRBKcO?= =?us-ascii?Q?ROvHv/iA/3dLWi7ou9perJUg9KRgn/n5GqTox9J9gGAv45O5OaATZ4uJHYbO?= =?us-ascii?Q?Zkb5+YDrGk67m+sisaYYyLcHsUn5Y5+r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uQvU/Z8xUY5zRew7tBG1Xio+PHZfS651qicq7nlBp03?= =?us-ascii?Q?notRwBAbEAwn+xYjoLJN/PLXAGV75caCbGi+7o7Tr8FzGicuqmMdWeuSu8Lu?= =?us-ascii?Q?BcEOfqnu9szUj6YmtjuShdd3QDNdkBHNGSAlL+1rJhCmV9hVYocPF1tbsdf8?= =?us-ascii?Q?FcmvbECv7KQsTUnTFbckFwY53FsHLmURu4++064TzIn6CklMzTgr9bBxc1Yo?= =?us-ascii?Q?r3BuKst4urnwWl/EwtUc6+INEWXWFu1PzP7+NFs3mZZqJGRV6flc72JpUSPT?= =?us-ascii?Q?8qVXTD1uHHQ6ZqRfwBPQ2cbvOTFg9OSEDO0aAsMwrI/NFi+evx5bHSO97ttt?= =?us-ascii?Q?G05xLwhZbKg6um9O7f8RpuLswfrw5NHS8HA5DHb/?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: aab83cef-c8b0-4938-8752-08dd97afa787 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:44.4019 (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: nGTsgaIv2LmGdw437hE323m2Pe+JFr3ODiK7E/9xq+9xt4MiA9ubIN35rs7JqWdWo1c7cy9J8+1HJ/xMc49jNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX2Ahfa4E9RTKI FOTclLeYSMtPV+P0C1YxqmfUMSwYx1Z6kwRI8USOpQgGuRsmsmcF91hNpiqTMNdv7Ihs4U7uUhL z5VF4TBPZ+c4unMYOPct0OQEIhpLxSnfP+zov55I1RpISnK2Kzs5OHOrwr2a7SDkeJb2d65aXeK xmB4lZQbsF49XYCpG72fkjch3+Vz+Y3cYFK/9w4dC0GOzJyk8Om24uuPm29sRU7ilg3fKlqddrS gZIVyOjXsi+xzyTk44uA5nXQ8RBVQfLeUbbXIawzjiWTxyPNO2C53o0MUdcvOtktatRooi2Ac1H QKwCcV9k4KyfzESuGIMdGgsc5xMyLG5lOVV47uM9qRS25OTxhZkzoNbBZ1VsGgMqhEJs9OyTi9Z dv1CEKoOXIjAYWdYzS4DBsjqw1bbF6jgWN0oePlSsyKYfp71SPjh2CFak+fAWJVOxbeHRb+l X-Proofpoint-ORIG-GUID: rDDdY9MqPOpXsoYjWg4kQyyzsuJhkSXD X-Authority-Analysis: v=2.4 cv=KINaDEFo c=1 sm=1 tr=0 ts=682c9a0f cx=c_pps a=mbHLYBybxRkByWxHAZWYkg==: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-GUID: rDDdY9MqPOpXsoYjWg4kQyyzsuJhkSXD 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753570964116600 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 Reviewed-by: C=C3=A9dric Le Goater --- 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 ef38b4692a..3d1dbdac38 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 Sat Nov 15 20:52:47 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=1747753566; cv=pass; d=zohomail.com; s=zohoarc; b=PbHTUfUn5iq//k5Yfgb3lF1qYZQAQuj4li7v/oaPCEu9NyHvtr6Jfs1CO24TD2VuPs0l6dy0b5lvC8riZCVKIqJxWFYEU4+dQgm/LWgp5EMgHMwR45jiK9lRzr3V3dJ1YKCfNH0LvS78u/yffa5yI04TD73eHfENN8ba2c/vobk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753566; 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=xyolPWjgzFxF5Ne4ELx4waxp81CD9zh7bT7r6noG/lE=; b=EQHkQFkRaw/YMkuV/Ns+kgTLasKVLqBRoM7l5oU8HUX4hVNQrCPemz+J+dEcB32rJC6Xu5g2Yj2Yjsl5emfV8L6JRTuTwFGUOy9kG/eBSkxF/e9AV+3rv4mhtJ/Fvuq0J77YfMRFUlO9I5QQQ2t63OsQVKNOGwvBJeA/BHhRTbs= 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 1747753566186213.3822285566098; Tue, 20 May 2025 08:06:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWU-0003Bg-Vr; Tue, 20 May 2025 11:04:55 -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 1uHOWU-0003BH-0e for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:54 -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 1uHOWR-0002QW-N4 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:53 -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 54K9ibSO028781; Tue, 20 May 2025 08:04:49 -0700 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46qvhvc71u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:49 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04:47 +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.8769.016; Tue, 20 May 2025 15:04: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=xyolPWjgzFxF5Ne4ELx4waxp81CD9zh7bT7r6noG/ lE=; b=gcbDWI+nSxeo6BTIpDb4tky6Mj+x80u7KeNLhPTFCGzecvFyeqwnwsIOj LMeVnoEiI5HfCmPg4d6u3gGQAnz6J3xe+Q+7grjfwmX730k0svH1jL5MhYFYbDpF dq/sFjgDGKPR6o/ebpdP1HxxsDAEoUKSTOf9VeJNbcPUcn1s/mrHg0+V8kKAmJpV zA8VXblcRsPDmmz0ONQHrp89QBR/j6eGYdeRQKDY9fqXGFTqQl9RfCDo92MiZIzS N7UOgceas6JluV5Ewz7o0sEjtCeY6RdWNdqnZ47KeQrrg2fuoIMIzSV3FGQ2h9Gk /dAj6Nu4TElyNvGiIxnolQN0Haquw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BKBEjzAa2QgfU5gUXosvMXoCpsOpM6e8gNV6Ox0BaOKfykLmurz1NmPwtDc4P3W15KvqNZvTfuw4WO3zoLQMnkf+OTLRqgiKOFZXDbhQblQVywvv8Nex4M8EkDNw2VsSOandifBDL3VoGJoxwDetTN8xls58LE/OFCYi2CtCbyPeZthPRtj1LoGL4Xpd69IEwYESU8hMO3nGSihY1YHzdBNrDzHPtgy2ceqSIba5Z8bV86t4XNjSWXstVghJb98nn4Fn+sDNejzRyzlKO83SnugAmvMORid1FlfYWfJTQ9znz00/hYwZjU/vAbFQTl0n/+wUgnpD2il6Or1uIgwlUQ== 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=xyolPWjgzFxF5Ne4ELx4waxp81CD9zh7bT7r6noG/lE=; b=gqQSKvyPlOECqnVtxj0fTMU9Aoi4ohTPxZ8fZ4jovmNg1p5dERYNRcvsbf0Cy/XgvkzXqTGPjUgpbE2FpFp71/06z9rqufmJeLOh8SZF+jTOchCnUJpm+VN/SIXmhjmUJ203CWJs/VFnLWiXzX8YCoUC4fKipm5v2+D0Ff6hcjSbloinPSExMwC7hcbZpDcMNxvJXMSSFoRBOqtpIBTnCv32TaHYemAS2Kz3DYg/nipPsTuOCXdTqQdUZLCLC2ErYd/kS+8e8fMCrMA8siPMEzoZqQiFfxGAg/932/UeVB6Jt/nd9R9xYCiOMMfkw+tEg62+NeDqlTM/2knQV7FPRA== 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=xyolPWjgzFxF5Ne4ELx4waxp81CD9zh7bT7r6noG/lE=; b=h0OK82MX2Vfmu2AAnaw1Kyc8zbekL9B6lrxFwD+MWzWXjb4HxmwIwI6sNdDZuZprK4IHRHcLmBwL99PPvMuAnro7H8f3uqWLzVE8vGRg+7It5Ccq+dy1XEb9O4ACJ2yqMVP/G9LeYXFJRHgqDpcGSS05TD67ocC+doqrrX65D9wo4KoC3FC1kUsL25A0DBo7oPBwKQOJDvh3zcBHL2nbSWh+JpYL9f4uNTzlVbOKuR87OP/LxkppYukNar0RY0gXhhsE5KKTb06LQUXQIVjq/Qf1J1XUnIqySpdldN784BU+gjFnFdPiMFt6270OSPmmuR8mFaoc7o1ajrSHHc+J1Q== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Steve Sistare Subject: [PATCH v2 09/29] vfio: return mr from vfio_get_xlat_addr Date: Tue, 20 May 2025 16:03:58 +0100 Message-ID: <20250520150419.2172078-10-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: d6dc8f96-4c86-4670-0a88-08dd97afa8ec x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yRklIHx1wyQmAvzihNrEgu8VdRwBH2Lq2GnnPmdW/BpFFgAlTKAwRKU6fg4U?= =?us-ascii?Q?SdEQ0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SCXsSgNLcDk6qYu?= =?us-ascii?Q?EX+2cZDH72pI/v0uL/lmTQJAbKS3Yl4D45R72IPiakGsMGeTLxMegyAMvUTv?= =?us-ascii?Q?JmYIfKuZMSVFSBSlm1OqrwFjGcagOg2+xtETvqgkh/9nBgrL0yA8GhtBXGTs?= =?us-ascii?Q?Feax+9GIJnUWPWDisY3yNIdAZ+UOEjpc1TrrWOd0fe+J8KybhwEqZ8rsPNPi?= =?us-ascii?Q?qPkoCXwyPa2SELqWldTNv9ry5ttqcy2IMWtlnEujUOo5wW06cziECfXDV20x?= =?us-ascii?Q?hyG7TSbPLpFn2qHhvGbwIorwNioHaE5EUFEy6Ts4Km0PhOAzDleZ6galoZKm?= =?us-ascii?Q?PWfOL436EZCC+Lpt5jemoW1PpY+zNB7u28BLsJPXKp3H21YdpHnIRJPE4uQY?= =?us-ascii?Q?ssULpGmdg4dTtx2bNjSkjkUs4C73s1y2k2ky/2+Tk18Uvw3WOj1z4bNX457h?= =?us-ascii?Q?wSgq+XK1eoW/wLSO2vOypTn0yuQaW6DKBWEZPzuEslikVlIBcDeB9LbZb6G5?= =?us-ascii?Q?Bp+2lDyjMUs=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?WI0Ijcj6kAlZZ0hgvRODUIjjNnSupArujttylGhyixWHZa81q6QOSI8kZey7?= =?us-ascii?Q?sDv5BTD7L/IFxNaEjjerG4Z3U4jXdytoAvmAsaSYlKREX6yxtbcPcinq5YBv?= =?us-ascii?Q?JRoPZM+nAU7YseyhQR1K6z1QFy8M1x2TW8MB9q+GE3wnLQM7l2en1ReR5Zb+?= =?us-ascii?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/fgqHH4qN+RDSDj8KQ?= =?us-ascii?Q?9UgqNYCYLPolq0PjlxHYMRCUsbZHwBBv6wAToHwviTquDg/9yVoP0jBegNLL?= =?us-ascii?Q?bulDl8JrbQF+4Igh5IS3blAyH5/2q+kGEhYmT8vNulUQerbN4uR0I70hzqqe?= =?us-ascii?Q?ZgtUg2qPPchy1s3BrhqG3+umXqNAKrzSfeWhdlKzO62USHopnHr0Xe1Pg5y3?= =?us-ascii?Q?eQJRwabA08dJUGUFWvQRxlU1r0ahx5Juaj43sGVmiHMTEdk4/TN31rlLpCJZ?= =?us-ascii?Q?XUOMOqLeCq9nJOlgodOWmREOmlOFnpSamEm5d31xuKnVvK8Vk8BM550imRDB?= =?us-ascii?Q?Y6t3ekMH0fTaFlWoiECo3u6gC61OIGIK5/M/hHqdz1GgQ6Z1Y4Aab+/tNH+u?= =?us-ascii?Q?jzjYrvIrNqB6BJGKuKQTcbunChOiwZlSFbMWoJkZcuUCOQDRJfK24N249Tul?= =?us-ascii?Q?WWDhXPf6DW0JLvPNc26sl2NpcaAygAmmhd9Rb63GTVCl2kR5wJVtTRiv76r8?= =?us-ascii?Q?Zrl45vE1XtiJb4HzbgFG1Z+pf8vLvB9IJiAvL8MZ?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6dc8f96-4c86-4670-0a88-08dd97afa8ec X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:46.7207 (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: WHfvgs31ACDVDWb1WwuN2gFAZAxXcK+RX7nUDQ6UnKhohLtmp3MioRaoQJ0hGQWPtgC12hm3VuF90UJLuj+q+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfXy1/PJZ5sECBt nNNxZwaFu7+jBdpRSNu9/JYijmvJmsHvqrLkfxj1dch+TF+gEZP1/bfl7sIGsWpg+T3jS4XYZXg KKHFHNsaU/SpIZp25SmzNDxfeo464MlM8r8ojL2QIh07wXgEGOKBicP+To2f+s3BczhK2BKOWDa XTvQwoE+aqiDuGCukMqo0trcyx0Q4zKGghKyCdV3DSJPHODTCdreftbZ/laMSRFqnaDoJxcm7Mi Ks59x5A8N3he70+9yz/JvpIvh0GJPPEd2SwkiKGF2DCgDpi3Suef5IeE4SZqlS9Y8JoAME+Z/0Y i+vvWCALt0+kTrqUPlDpGHrUjVS3+Sk5X/xSwFIRUgK35Y7U6sqPDi+IXZlUDCOG2Vx8yyxOgFp TTeljNzlorUMoAVgK8pmRWMrDdg84ex8JZQO6dOJG/sECT6atB6D4N50FOgPRoW3p1VY87cf X-Proofpoint-ORIG-GUID: 7y6fAZkm2S8b84-DpJx7HLS7pKDcFfiH X-Authority-Analysis: v=2.4 cv=KINaDEFo c=1 sm=1 tr=0 ts=682c9a11 cx=c_pps a=XlWNgFwcAB8XWrBhwjv7Vg==: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=20KFwNOVAAAA:8 a=QNV_3Zso053vk46vt-IA:9 X-Proofpoint-GUID: 7y6fAZkm2S8b84-DpJx7HLS7pKDcFfiH 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753566996116600 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. Lastly, rename the functions to to memory_translate_iotlb() and vfio_translate_iotlb(). Signed-off-by: Steve Sistare Acked-by: David Hildenbrand --- include/system/memory.h | 19 +++++++++---------- hw/vfio/listener.c | 33 ++++++++++++++++++++++----------- hw/virtio/vhost-vdpa.c | 9 +++++++-- system/memory.c | 32 +++++++------------------------- 4 files changed, 45 insertions(+), 48 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index fbbf4cf911..13416d79b9 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -738,21 +738,20 @@ void ram_discard_manager_unregister_listener(RamDisca= rdManager *rdm, RamDiscardListener *rdl); =20 /** - * memory_get_xlat_addr: Extract addresses from a TLB entry + * memory_translate_iotlb: 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 + * @xlat_p: return the offset of the entry from the start of the returned + * MemoryRegion. * @errp: pointer to Error*, to store an error if it happens. * - * Return: true on success, else false setting @errp with error. + * Return: On success, return the MemoryRegion containing the @iotlb trans= lated + * addr. The MemoryRegion must not be accessed after rcu_read_unl= ock. + * On failure, return NULL, 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); +MemoryRegion *memory_translate_iotlb(IOMMUTLBEntry *iotlb, 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..0afafe3464 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 MemoryRegion *vfio_translate_iotlb(IOMMUTLBEntry *iotlb, hwaddr *xl= at_p, + Error **errp) { - bool ret, mr_has_discard_manager; + MemoryRegion *mr; =20 - ret =3D memory_get_xlat_addr(iotlb, vaddr, ram_addr, read_only, - &mr_has_discard_manager, errp); - if (ret && mr_has_discard_manager) { + mr =3D memory_translate_iotlb(iotlb, xlat_p, errp); + if (mr && memory_region_has_ram_discard_manager(mr)) { /* * Malicious VMs might trigger discarding of IOMMU-mapped memory. = The * pages will remain pinned inside vfio until unmapped, resulting = in a @@ -118,7 +119,7 @@ static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, vo= id **vaddr, " intended via an IOMMU. It's possible to mitigat= e " " by setting/adjusting RLIMIT_MEMLOCK."); } - return ret; + return mr; } =20 static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) @@ -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,14 @@ 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)) { + mr =3D vfio_translate_iotlb(iotlb, &xlat, &local_err); + if (!mr) { 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 +1017,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 +1030,11 @@ 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)) { + mr =3D vfio_translate_iotlb(iotlb, &xlat, &local_err); + if (!mr) { 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..a1dd9e17a6 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,14 @@ 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)) { + mr =3D memory_translate_iotlb(iotlb, &xlat, &local_err); + if (!mr) { 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..306e9ff9eb 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) +MemoryRegion *memory_translate_iotlb(IOMMUTLBEntry *iotlb, 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 @@ -2195,7 +2191,7 @@ bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, void = **vaddr, &xlat, &len, writable, MEMTXATTRS_UNSPECI= FIED); if (!memory_region_is_ram(mr)) { error_setg(errp, "iommu map to non memory area %" HWADDR_PRIx "", = xlat); - return false; + return NULL; } else if (memory_region_has_ram_discard_manager(mr)) { RamDiscardManager *rdm =3D memory_region_get_ram_discard_manager(m= r); MemoryRegionSection tmp =3D { @@ -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. @@ -2216,7 +2209,7 @@ bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, void = **vaddr, error_setg(errp, "iommu map to discarded memory (e.g., unplugg= ed" " via virtio-mem): %" HWADDR_PRIx "", iotlb->translated_addr); - return false; + return NULL; } } =20 @@ -2226,22 +2219,11 @@ bool memory_get_xlat_addr(IOMMUTLBEntry *iotlb, voi= d **vaddr, */ if (len & iotlb->addr_mask) { error_setg(errp, "iommu has granularity incompatible with target A= S"); - return false; - } - - 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; + return NULL; } =20 - return true; + *xlat_p =3D xlat; + return mr; } =20 void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client) --=20 2.43.0 From nobody Sat Nov 15 20:52:47 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=1747753814; cv=pass; d=zohomail.com; s=zohoarc; b=VCoFAjKHKkqIrfEnVh7SxrGmxYFRjVaQtWu+z0EO9/Jh04SGuUVQf1Fvluv4jGM3ZQZrYjBfNR2+Z9j2ylv4pod0DLSxc04KoZpwMEM1eh8RaiGWqZZ+oxB816nJSH6LWL0cXCkd4JsEZmwE+tqKqc2k7Pot8LmCWRb5tbxR5EE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753814; 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=h1VvT9mJEdTWrDe+HTk4I3vCUVrW9NWxE22+aAmMoIY=; b=MW7T6pBuQ1a0jYiz/NBGgBAws0rd9RxvysKSx8RSSMGOTjKyJklrtr+2/P/8y/aITHEWQ02kg5G7ImJad4/1XmO09+7NCla4NDxHcMCHOaMANKD7uhRaRnMsuWsSTmbYCHThpouqV1zy/48TAJ8NkxKk+QGoSC6RpINyKpalUwU= 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 1747753814916797.2178337885629; Tue, 20 May 2025 08:10:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWb-0003DY-Ay; Tue, 20 May 2025 11:05:01 -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 1uHOWZ-0003D1-8m for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:59 -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 1uHOWS-0002RE-N3 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:04:58 -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 54K7TJcb016599; Tue, 20 May 2025 08:04:51 -0700 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheacm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:51 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04: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.8769.016; Tue, 20 May 2025 15:04:49 +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=h1VvT9mJEdTWrDe+HTk4I3vCUVrW9NWxE22+aAmMo IY=; b=119PORhFyA4LipAJZtwS1iMW5jiIAlFfV+i6xgJSULXZY57SwHaAYKSMQ p+641zQeIjC3dQ0UG0/9kYwS6RNcgOUkilR2QCFImMrfy2RfbVtsyhXUuV5QgLuS IuaREqvR3hP6Bb3ykUAr2acmyKS2qxj6a3oViQj70dQVCQwnmIlqV4vrvmiLuujR i7fkd1yKAb+4URxQKxFuzNfIxcNutxLcAC4014lU7FLK3vhrs9nOIt32GRt5MS8m jUOEbdfAiny9OkayHBMx7Umn5pWsidFg4GVXTWIiR2AMXjTg7y+hTTfiiZZQa6j+ D0VHZDCpu3kQcPgftC2loXi4QwluA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EzWYVV4i2GJ4cpXOAjqVaA9iA8xhUpE4EQHzGBCDe0NKcD+dXtRX+4YHqcg/VNIZhR8i7Jsms0OOUzlq1nEUJL5+B7lEkNi+Oy0doPge+x27r1R5t2x2mgqxV2//yUVMokLt7b5PGVkLOeuB1FPZy0NIaieA3swqnKENwTMi6LBA+DWGCGLHMVqVIO9ndovn4T/UPDOqkg5XjLMmzVtlCN1ZJfn9R70UzlpynvplTKZSFtpSnNyfcp7EprkNJBI9yhZ593mgebOPuEtiu+PEsR7aNNWWxwrClsx6q1TfXVoM84hs+pECVPa1ChfTXtolRriD5Wg58+x+lwc7rWs1DQ== 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=h1VvT9mJEdTWrDe+HTk4I3vCUVrW9NWxE22+aAmMoIY=; b=sQbCGfZSMcW1/13H5yC57U4CXfYG7n3Adarr1RBByUVwG9fxMfX13CmUB3z+rIdH9vWCDlmXlCkPfG/rhLh5l14wcxlsklHuP6c+wLlhKhUxCSDJuBQktKK6H6wg3IoYsHPJq6DP4ztqP9pI+t7g0ZXGqlr8mU/18o6kS4v+YqBh2CwQxzwqtHONl6TjJF2zdpmHeT1Ff2HCI285qnRs3rhhINb0maNs9Lr5MD6x3NOanfjkbKGQrUif4AxlyXYOlap5ah0AunxeshByEbHXR6BCS/M1NzTTnObNjDJWccEWTgPOIWSwZhTzeImnAXkAsiPUy6IPhraNQKQyXy/LIQ== 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=h1VvT9mJEdTWrDe+HTk4I3vCUVrW9NWxE22+aAmMoIY=; b=D7IhC4WTgyfSDWYb8kwVHPkn6WFLaJM2aQEseNm5Wxuc89jJfEncWhBlE+ObG/QQMX7R1oI/g/YEzSbXogLAnSdMxEz9jqrN3nRNoCqnpQhtZdIB476MZAikncm49l+C6HxrnaDkJ76twLhaURvAYqtmKjq947BAowlmUtR9FEThz3XysUHVJx8U+nIQrrMXJeqsZDWXBjoEA2AIw3EeOy5FR8SwC0wkmuE6w5KPHavFkK5zieyJEDqq5Q7Y+Hyp03wTTe7uTLVZ7//KVyaTS8C6euyVlBQiCgMq085A2T6F4m8mfVlcMU2blk4gLIlf8mHjvFHyz59FD4VjNcpbSg== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Jagannathan Raman , Elena Ufimtseva Subject: [PATCH v2 10/29] vfio/container: pass MemoryRegion to DMA operations Date: Tue, 20 May 2025 16:03:59 +0100 Message-ID: <20250520150419.2172078-11-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: d8af3fa4-d2d2-4d88-748f-08dd97afaa75 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?da6RNqSHp899DrR7YqjSupEHhaY211TlvaxNA3jE/PK2qNa+4k81gPkLVK8c?= =?us-ascii?Q?3WhFEXhmp6oUQLnr3PMNtzl+hrfx6LeSVb3PkiSwq2yZajMMBYAxC3oyZyEQ?= =?us-ascii?Q?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0GnmkC01Cqn5Vr/MGntHsw6WK8pTy2s7+Vb/k?= =?us-ascii?Q?y85a93WB+xp0LIBMi/PNyJWE4gyHQgaa9qCXxgHnLXAzDx69j0eqZp+93NyA?= =?us-ascii?Q?pHumPrFzj32xGlxYvE/45L+NRZNJ7WHUG7LUj9vQjplHHvH5yhTMIFyrW2zh?= =?us-ascii?Q?fnuscOzzkk1goQ9QqGaoFzcvEvZxJdfCMcEKi0ejAF6QEGEpD0uU7Xu+81D4?= =?us-ascii?Q?TW57XE7E1t4nLt76OTlD9hdGgTZxa6NU5UmBFzdPSSayoi9gcs87GEH1wwHz?= =?us-ascii?Q?3P50exWoeoZQ1gxnH3nGQeqHXpUY35RjcuRnkmk4Y78EfHBvjMRsWZ8MJyPW?= =?us-ascii?Q?GmkyNBN41VjX3OsXOI2p+8ld0ENDnbReGPpOmD3GAAtljJ5og1rKCsUKaQEs?= =?us-ascii?Q?H/dozpBSM0Qz/zmRL2AefmCf9EtPAYeEOddXUpMC1FAZfE3wrHS5oB7swJnf?= =?us-ascii?Q?+n8Ab1UFtE4=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?3LxjHLTFJhPAkbcfBTZPl+XLM3LU21T4n1Q6VP9t2FJyb1obtHaQTI9wH5Zh?= =?us-ascii?Q?gDEjPCXXmX4hKfKXvR7NwNNcgaaCwBxlW/sVXs+hYnr/QxUN3epTAC1i9d3I?= =?us-ascii?Q?ARS03z8/UVsJMGzZJ9Vat15nOH2sCqWG3UDPD57rnUj+G/KSOFaHvOVBknUt?= =?us-ascii?Q?laHXZLp+3LaliA2rJJe0GqrTwMu8gJAfkhzCENjt9G/gIQ0yElaNaohlnlmO?= =?us-ascii?Q?K7Gaws27zgVpVs3o/YjSDYIT2iF57wkskqOvtiPbz2XTO74pkryv8DUIEUQp?= =?us-ascii?Q?KrK1txS8pHy9jkPwcyQHtYcyx7tVplaPREpoyXSrACjC1JJlofh5UixH9Hbq?= =?us-ascii?Q?Ul0KWwbxGETKV/ov/CPMFzOd0kqBjlXeszcDUO+8i3blA55AxPjvN800uaLl?= =?us-ascii?Q?DaeU0OPO17EfErikS+fe31CovI8SRiiGkmlYTNhrp0qu/tdei29O+R4oJiUC?= =?us-ascii?Q?u2OghXWBUknlrHNT9H0hgI7oLhyEMDIsafMI/Vr8RTvz1nETCHypGOCHiZeW?= =?us-ascii?Q?dJl3o90uQBkVEGg2A9sScU3qe0e6QyMG/sHINDCtry+oyak1zAaHwmtJuwzj?= =?us-ascii?Q?a3zhPNmVlvCWgxnRvMujT4jk+ZY/plY12gPKmLy6z6kVfwTnkfzZF06UoIqN?= =?us-ascii?Q?MEc/gySawXSzG2ppdukYqRVTYfAvQIN6gOKshSmm9F0qOMj8+b7wrpd+3DNC?= =?us-ascii?Q?Q6EtOmh4sD0bcts8pxN+pnH3F2bSC1cQG41r7l08uOpLyrBEyouphOeiKjqf?= =?us-ascii?Q?s+H3TZgLGdJCRFSoVzoey/KjHO2Cc4mBUlMkZ+vZnmz0LnQP4taaOzNGmFxz?= =?us-ascii?Q?4D7iJBVJtX0dZheYZN8DQmt1rGUXhQCYy6Hj2CmCATlrNfAZRKn6IvCb5Blp?= =?us-ascii?Q?23UlAULZQJTF/W1jhuHIHypSfzd6xunNSgsysMTJASlXgec+yvCZJBXeNNxX?= =?us-ascii?Q?HI6X1ukrZYhL/h07HHWSByO3+9XmzR7mjbToHUaR9G6gzSGX6D1xJ1iJJeRe?= =?us-ascii?Q?Xnh3rafnU7ewDYLr5wHTCfcMg1sqFEA39RpJ+K/YPbwV2GljuyqmllYy0ena?= =?us-ascii?Q?qJSk3q74ACh44gUHq+ZzzmGeGBBjNeaFSz1teCJD3/XwRcP1t7ENwHLMmvK8?= =?us-ascii?Q?vt2wkYXDnuKJiTcQygZ16qOIrUVdBXhk97C0XrG61FnAY298lKCmu09EhhF9?= =?us-ascii?Q?tM8VHQbflT2/s5MWhhc4vNciioGeakfCa6J8C436Ob+zR2F65h70EW66n5kl?= =?us-ascii?Q?1NkCis6rrj9wuHGO8XVztrxd4hv7Rg61eQ3eCra+rszZY5w6HH4+e+DfcZZh?= =?us-ascii?Q?7qjmtRcyVqnulXpO8Ii+VJ6lD9YodbKbZWYtwKBOdY9cteQriyD92xQUQos0?= =?us-ascii?Q?2Mw/OxaAY4iEveYKYAbC7kShAVhp+RunAkIYbdS3RoAKqQ4kVYLYVbLSDry9?= =?us-ascii?Q?7mStmpNsHTpjr+qw4j+8R0cZn4mawh70i6Sp4F7ASBoV4QB4qi6hewoLqh83?= =?us-ascii?Q?6VSaTCZvBymsmczqWn6mLEfprq79aXYWf+jZkGRGj6mnmmJluSSftRMF5Laa?= =?us-ascii?Q?LfQqPvNbaC1xSQW4MwlUUiqN+Py+dp8l3cV7+q3b?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8af3fa4-d2d2-4d88-748f-08dd97afaa75 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:49.3030 (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: 0Myamf75/lwTiRAkjqiCs/ePSIWJ6ccgGd3LwVx1CVCTfFp9xAWUK80fEQxA7rwVoXeWUEiLWSoWP/87i3kjww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX851Fzl+EceWw t0I497hP7suNhyZxAN4Ssr7cAqn9xXGHJ4lKefCTYflzBmzPRZsegmBg4c1ezoeS6/WznDC+ums U6z6l9bZGeN9rGit0vjpEDWRxnnLIY4ahXD6mkgv7Cex25FlXYPW0fbgn6Avbw5siLVLHeevVZd 7wcdGGRkC+XKvgXnGAe9KeG6i3WIRtenAvwYP/CSWk5P0ekOFQCUlHeES91fAtw5sKaCotFvCR8 jn9YPuhWm5gmd53J6c7aCmx7HXGE3cVUX91hERfjw7OQk1qJ93vLaCVRYl+i/y4JuWNwzcRsYAK CcptTOXbGxteYLxXVSP9L0L8HSjVLMuVgGrw/fspelgM7qIP5fzLH81cPQwp0jPVzCzDdSBO14u CN9L8iejX4WDmXtnO5pSs5zN39So0e52jERQoDm3U1iAvwmHYAbZi2Wv8I/YvRikXKbc+6Es X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a13 cx=c_pps a=gIIqiywzzXYl0XjYY6oQCA==: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-GUID: 4Vgnio4vbSGX42BGI4iOl2dKcWn3zO_A X-Proofpoint-ORIG-GUID: 4Vgnio4vbSGX42BGI4iOl2dKcWn3zO_A 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753815719116600 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 | 9 +++++---- hw/vfio/container-base.c | 4 ++-- hw/vfio/container.c | 3 ++- hw/vfio/iommufd.c | 3 ++- hw/vfio/listener.c | 6 +++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index 41c49b2aa5..c18986a621 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); @@ -149,18 +149,19 @@ struct VFIOIOMMUClass { /** * @dma_map * - * Map an address range into the container. + * Map an address range into the container. Note that @mrp will within= an + * RCU read lock region across this call. * * @bcontainer: #VFIOContainerBase to use * @iova: start address to map * @size: size of the range to map * @vaddr: process virtual address of mapping * @readonly: true if mapping should be readonly + * @mrp: the memory region for this mapping */ 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 0afafe3464..a1d2d2561d 100644 --- a/hw/vfio/listener.c +++ b/hw/vfio/listener.c @@ -170,7 +170,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)", @@ -240,7 +240,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); @@ -564,7 +564,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 Sat Nov 15 20:52:47 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=1747753657; cv=pass; d=zohomail.com; s=zohoarc; b=MOh7s0Yk0Z/ocM7pLHdqM4yVxTUYm6sHybkLCWwoyQR1KTA+y4mzTDuK5Eu6rrgN7DCEhWbHjQPs+MMbTSYOcZXvZZ779vO0kosCRrpCHwdcSLnT1bBB1LoJwREsd3FETqS5yf0NIjq2yZzZVMM/WdgRKoTzS0ODKRuticX+9Ag= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753657; 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=dw65c6AFMhdfrsGeyXKV9qg3jxPLALrDD7qpIgfTYOVoCtSLTiRKgX5PdqqmFm4VxsxnxLVy++UFuJA9gNMzqcaTC/Q/I8H2AFOldr4vZyLXEwH9RcxC11mtJvI70yDn3Fhjqe+Rgjm8XOSD4+ce9o9BnOt28ZVOjs7WAX0ZJ5E= 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 1747753657532152.42111436404184; Tue, 20 May 2025 08:07:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWf-0003GB-Hd; Tue, 20 May 2025 11:05:05 -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 1uHOWc-0003Dl-Co for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:02 -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 1uHOWX-0002S3-5D for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:02 -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 54K9bbXb010210; Tue, 20 May 2025 08:04:54 -0700 Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46rcm2hydj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:53 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04: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.8769.016; Tue, 20 May 2025 15:04: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=jgGxX7AAuov5EEMp/7WosYFWwTQx342BqvxK24VXy wc=; b=NA6YtBBmuZ/r/qzBxeNtIA1Bqa+iYY++GGQIBHgSroEzx12EJ+PyZseMR rMpvcc56KsH2+Wple7yCZMQvDYOudUXjPEAPFsZQ7nveyQ+icQbNsXoz5y0+9ysQ JrL1/XVfBhTZ6S6cQ+X1UM9VIe5PbfWc84IMFmZ1vG2VUKb1WWIP8YAYyi5dmcXr bn+HPmBh9dn+p19Z/t+T/6TouP3HBX9cHhXw/58Ii96vzB1Sy3arbHi3ZzGiQORB 4NsdjuiknBUdIpgJc1+tkCCT5BcFIoG6jG1AENipAuKN78PaCIjrt+SSD2POq14I J97RwcwUIfdP8He3eAP+1BakbCFAA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DSycUOCenuA6ScQp6+Ch6DGr+1NpSsCsV6q4e1lA2xL23RDwf4UvRqojcnY1aPs4BpgnM4/C2SwFAVhh18cxy8X1wFvFzzDRFR0dHsTmaxyyAJzaFtNwXS4EnV0eiX0GehKeHiruyrOoXjUvqurJQmZQf/V2bU2hzY2blk1Hq8+WADlfyiPW6nAYAKTZEEFh5zZaleDmxDMYpLgJndcg6OdK/avc2PCDJJk9+mgovWQTf0t4Qp3JGj/lYFdTgt0rFwqJapgP70WQdo+QN+p1j7+MAsyz9QFb6vzXxqWH25bgN7KCXrxlxVNyCgcCmRoIIufPKqZCD3CyYvlUnZRuFg== 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=A7OlqsvsmyXsTsLSSxd1cJvXA6GwTdzlJPoNsaV100eDZqyQ0Ms0N+LI5aDCpGmK8pIkpZgaKFsqSo+g5K+iKcMoqhGuneia9OCQyAle+TIz+B3+V6HlCRnGGQsKxG4m8IXMRSU8HbBKpfwKDMzCFOQ8bOf+Pf8u36O14jjM9BlHSopV15G6zRTpM0n+5sBWra5I0UGLIVjnHoMXy17fjusKOw+pJSxRKhOR8Yov8rhd4CQukSRcm6Jzurn61AL5KlBUlSW2Vp0WG8IBHEEbj3fKGKf/gHuwtvD1lzVnr014rLrWoEzrxYmuglc0vz+EKEcdX9mNaT2wRVmGUKyhYg== 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=D3DAylex7Zr7tDv49NOgrSY/o58NNhw1L4+dEjI+d1mzIFK+Pihu2w4+Pd44qBzOMF+O1MnsLVd3azVgrOZpt8mM3ErDwRnqAwphsYfRxAg6/+/Ox/1dzGvODrjL1HBlMIv0F6EBtiwlQgmGKqpX3e793E4dDRjX/W4poUn5djpeJbR8RX6qNEkLRU5r7fZm00v1W1y8cHdEQhSKGaEXSmxWE3km2hiKNr1Q0bCzxwfZa92BO+flcS2bsVBigQv+lsFYIZ3GgVC9/q5MWwGEj7u66hCVqKwLEWR/Yc8qLgRhmy9Lk0vjw527j04AxdngXvRvDdJEeFtUJB6efWs+zw== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 11/29] vfio-user: introduce vfio-user protocol specification Date: Tue, 20 May 2025 16:04:00 +0100 Message-ID: <20250520150419.2172078-12-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e4c500f-6c85-49b3-83b2-08dd97afabc3 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GYkYPH/bPO554SW1sislgTammlApHGXPw5fHBJ0NzkEIO77QBNRiVh1qXPtt?= =?us-ascii?Q?y7QPzOkmZpy6zaY4yiNSQvudjsaBnsFSMEbWvzIWJvuTPiSSa+AZuOpX0LSf?= =?us-ascii?Q?Y5EnwgVN8LsqXof2b7g49OWhZMgxBHfGbXSIKVkqpcy505Qb7Jd2dvuA7Ins?= =?us-ascii?Q?nis7x6+mOQxoS0WY0Umo+VO4BlzN+/ShISMx9QfsFv/0SjKGzJx/3nQBhpZl?= =?us-ascii?Q?J6shY/2sWIPQeLdeRnzSb024og7BTseP9XIBC26gWeCga9lB3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VtTkWl34ATYcTFFxXsBuh6UdCxpy?= =?us-ascii?Q?yhS1xE554ZendAubokQAqb3r081U1koFW6XGCEtZOingpPNPmyu3x7ZcVzQj?= =?us-ascii?Q?Mb9+cUEP683CJPqQdIn5jDwpzP0HAGGjGep1D4c91LP8KCvHOLU9V4Vk653V?= =?us-ascii?Q?5HemmQ9IZbDaUFqyUzQTctyqQI5pBoB+u00QyV28StEY70N01H27Mc0TWH4z?= =?us-ascii?Q?NksQFtY=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?a5p7sS/gzPeYz8XNQ19Cyo9PZ5MRd00husE2vyh63CJMo43h57fgj5qg9x/6?= =?us-ascii?Q?nvEU2QTQPrBuPOe5fDv5Q2rs2xwRNhDTjB1v0EdOuuMfjTRs270bS2vcibgJ?= =?us-ascii?Q?EPBY08yWthYV+25fUj9wjyh1zFYGYoxa8n3KCxvBrN121ZCY8N9YttFTcm6G?= =?us-ascii?Q?0iqMyYtjExTfISNagzTh3AkEYOzDJtfOHHtx8y5Vv7rfjEDlKQaiOGOPlYwO?= =?us-ascii?Q?t9GI10m7yt7Fh1NWg3KjKmQzhB6jBn5DuMQ2y5Cst/Tpl4Hx+nvO1FoVD9vj?= =?us-ascii?Q?jaQeGUQRQ578MiJQbDUoi4TT3xNYhiQb5I9ngKOOosY2asCRHRF5dWwRlXhj?= =?us-ascii?Q?BFqQkueEHBXR8H2Kc4Pa9VCh628O/PmEA3D8pqmfAyShsXJ+6Xol5sQVgmHA?= =?us-ascii?Q?yXExlMU6TMM6rDwZGXjh/RbYCB+YEDLuFv93O6I67KKgzDd51QtF60eqMiZO?= =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8dSqSNCeOV78G1ZmFyJNc4B5F64VEsyt2fCq?= =?us-ascii?Q?GNzPY6fBTzq1SRWVmfyb84a8xQZyFzK0E/TQj9D2fGIkFeohPP3zdrPky95h?= =?us-ascii?Q?eYRBgZgcbHGGRCHQE0m9rBhSR+elfRa+QVgFj8hY0UdjwC80EKU+3JXtIQFc?= =?us-ascii?Q?I2X0GsyZ7fmkL9e9gaElZSyG+meo83dLIeLgZFuj/B+Et6eZwA089u66a3QW?= =?us-ascii?Q?TreWueyG/VnM2SU4OQOejShU8LPJP82IGwT8ajXI?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e4c500f-6c85-49b3-83b2-08dd97afabc3 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:51.5787 (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: Q9OmEcyL3+xynw6PoN96+eR/cWN1FJPuY5Yd+FSFdpqTN+HJMf1TRW054Dtuj76qiKpCpjJHRRGPauZuxpUj5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Authority-Analysis: v=2.4 cv=HZoUTjE8 c=1 sm=1 tr=0 ts=682c9a16 cx=c_pps a=PdgAl9AEy1hEU2ikvxmBtw==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX9olQmo523psj 2ur9JceaHB46DX4fM/fnoDQN5+4tLOA2wCdqZ5775TdaOYx9m7c6JXJTaO7H5VZrQuqoxV0BIBG P053ZdaPPmtWXd1uUNnwu/OoXx2xnZea9k/zZsK7bLn/44drw9Cg3zT5yYCUJ4KmUwKjQVDTzFK +v8qnu4HKBiLt5npItt7IzHxIBoaB40HPrekKEwBbIkQTGGoMS/F9QGBFmM5TMk0rwQWBVj3LqV BF7imUuZ08ytsTVBV96EAanxVwkALwQEWMk+/g3IkvQsLMzm7VDcAc8ZGM53YDN3rn6d7E132ZX IJPb8LTr9ady93Too6bJt9V8mJFJcToNrBlc6frapdly+Wpm+xFpbj5UZhvAMrnizErtXZvAE9p co5MRhSj5nCcBBiARWXqsNrJvSxyGt7vn2KP+OweOGlWwwKFr/NIpmFGgnAsJeXoCjOodOFK X-Proofpoint-GUID: HiKbmhZ6Bs3SSVtPVSJipHCgnBIgtXXt X-Proofpoint-ORIG-GUID: HiKbmhZ6Bs3SSVtPVSJipHCgnBIgtXXt 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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, 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: 1747753661672116600 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 Sat Nov 15 20:52:47 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=1747753896; cv=pass; d=zohomail.com; s=zohoarc; b=ljCvGdV1E/nuT/dxxCiyMEAXmcembF0UabrzMms5cjmfeHuUbzs4KHrgERvW5uz5EqCaBLeE02da0iUKzY+WEWRR1CIl5WTHXrHhdXx8KvWnZdM//6Bvfh//GLcJt5fxgiRUBU9VmJ2ZXT3cHixWQiqv2bnjkuYzwNBfgpDizIA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753896; 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=jAwuoWw+9SzG2piLB93WarEaEC1vEoduf8gYAZHPFgc=; b=G0AjYfSXQjGzbuu95ShkC+Zh/kW4xwrYfsohr4PcBJasn9BmQZx7ob7HRwHPzFBG4PMxzaHea0TLQ9/MeBh3mryCIyv60DUdHp0Hn/LPEP7r4Xrwi+30zTs2JwIOXgWECFAJYLv8ntSAsiI1hE1xy021GBBQBxobJi2M58Q9kTc= 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 1747753895742475.5853679646733; Tue, 20 May 2025 08:11:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWe-0003Et-HU; Tue, 20 May 2025 11:05: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 1uHOWb-0003Dh-Vj for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:02 -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 1uHOWZ-0002Sd-3v for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:01 -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 54KCDUcx008785; Tue, 20 May 2025 08:04:56 -0700 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2176.outbound.protection.outlook.com [104.47.56.176]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46ppsuehgj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:56 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04: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.8769.016; Tue, 20 May 2025 15:04: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=jAwuoWw+9SzG2piLB93WarEaEC1vEoduf8gYAZHPF gc=; b=EXt9r22xjZaz7zBuIzEVsem0sjxS693qJvHhjE7BxkbSB9VyaoiBQvj+b SN4/y1D4zS3YcwX33WQakK2yLhkb+P262lHJIyi6Rh35dp4CY76nTy1bBzAo099q y6NLC9iw/JgWJ4gKz1JyvMs6l3o3sfVrKKTzi84+WEuG2Rcqm5bhf0LHROA4+Q+K cdNT9WJj7HZCGRTNoh18hJ8h2fnvHQyor7bMNy24JPh8O5JmdvCQeRpN1+MN57PS I6aY/LafGQzloPpkl/BYvoznD4geXLLQ0dtmb+oKdYQDKOlZmxTjy1xQ/Lr3HpPM OuSkX8XaO6sg05UYQfoo1OcG5VjQA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pgOveasY7U9ScSjb5+7jvz+h/TA/jfqSPtCybD+t3YF+5a/dIrusEEi/XFhrI2zmgFrxakUVfwbYeBPga/z8y5JnhoCCgPRO157VEziy9yQTvS5O0HgKPdoQdZbfwueJhdaz8TfGQZvC9fWmlsF97t2HV8BM/xfVRwX5xtKywZaSNVlcDmveamZnxdmyJc1ER1pqJpy/dc7ZZz7MgnL9bnxCbHrbKTxHpuZkCDOmKGWwpAB9bNc8hiKal6T5IjMv1UB8SKC5BVkokJVwURXU4cot+GHA4OC6Wue0luqlz/DilrO9R1Y+8jVv6z7Hf2QQ+96YoUii3vMVB73BVhSabw== 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=jAwuoWw+9SzG2piLB93WarEaEC1vEoduf8gYAZHPFgc=; b=jVkozMBSEWwAfKV8DgcsVyXvLRBHRwNZYiXjjzapppDx/H2RCf1OdLGib8tAVyqppm6JVgx+flKU2VTf3BpRZdw1e2rZg8jFYeumCr3gLU32TNgZP94G1O98hnjix45jBlmcYXE4rbGkSyYtQDGJv4mEI+tzaIRLUA5e3cTSVim0Uij1nVIbKj9Om0uXNRpv8pkdkIS72G3UDTtV7QnbDgqQRNGcP3IB+v5nl+0dcg6tmVdnB9D0ebazBmKbLrz6Hs/+4O5W/c4SnOZxH97AiAusoqtE70qk7QElKfasYgDGbjpPMY2jwSH4WLBcihZlxDZUiep9CLA3fWbc5NHiaA== 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=jAwuoWw+9SzG2piLB93WarEaEC1vEoduf8gYAZHPFgc=; b=O9srAsu9DGiBw37JG7chrOOiRh0LxXFAP4mtLt2i/Tb0xJ9nLMaE9tKkHeo2Qif/txvOosW8RJzHHZxQFgvkmXIzcmPRQxmKUFwHeiQSh3edNYeshHUTgn+aURMeNJni1Sb/ickqcN5tfuURYYwDEMMfHZ8cGxG2oj6si5+McvEIlvSOW7ag7BohDwWYF9Y0ySD/KHkAPlpN+mIenVyNPP3arEsBSG9Ja3+CYc6dI4mZ4h4s9wlFv6N11m93Pqe0hjE/OAqO+1rQZ0vDUSADHQO1bkLfz3VfIRaZi39sDGLsWNV9lyq3wPODo5klOiFUQ5QpcWmavSJGsgdoyY4OgQ== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 12/29] vfio-user: add vfio-user class and container Date: Tue, 20 May 2025 16:04:01 +0100 Message-ID: <20250520150419.2172078-13-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: f4e5fae5-65e7-4e97-6f8a-08dd97afad57 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL: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Tk5dXJ5?= =?utf-8?B?MzJpSmJXODdadkdNQTg0dHhiY09WYlp6VEtkaHExZkp1OUoyVlV4c3AxaS95?= =?utf-8?B?bFV4WFJMVXhyMHM2RENWLzE1bXRZYzhSUm5ubUZ3bktoeFpuZzNpc3hNYzJx?= =?utf-8?B?akNpN2U4WjJ4bDdRcEtrcmZZc0crRHRmTmlzeXVnQ1AxL1NxcFI2NkpwN3Vi?= =?utf-8?Q?ialH5WvX/iE=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eDlaZmRGdGN3ZXhYdjlZSDdZTGVuT2dXRGdPRFRkajRvTnJaaEIwUmo0dis1?= =?utf-8?B?ZHBXalhlMmFzUEVWOXBpcHY3WkxJdkwvT05heU5XRUFqNThMVVRYYlBpQ1lR?= =?utf-8?B?blZQeEwvbEdxMHJmak9icUpWQ3RWMU5XUGJrQ1MwQklnK3U4RDRJQlRoUGJH?= =?utf-8?B?YmJtNEY4d05FSW9ZK2oxa2U0N2V2VzNLU1M1ckpxT1laWjNydVRnc0ViZHd6?= =?utf-8?B?NlRJVHFiYnAxSVpqODE5UVExOUdMT1d4OUIvSFZoNUdNWXBDY2FWUTlvNnJW?= =?utf-8?B?UW1DdGczL09rbEUwSUpleTlPRUVnekQ2K3RjZWU4TzFRUnZ3enBGM2VtVXZX?= =?utf-8?B?M0Q5NHRZWGwzQWNOUko4WHI0ZFNIcGIvS1JTZU9McGdFeS81V3crcGgxQmlD?= =?utf-8?B?ODRnY015Skp6ZnpmZ0tzOGhNYkJyZVNrZFhwQTgrU2cxOVJpQk9uT2c0UVdu?= =?utf-8?B?Wnd2QmF0MTN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tnUStYbGRZZGhncDlKWTJPMlo5bVdZZmNvSWFqMkZSeW1abnppN2RTK25x?= =?utf-8?B?UHY1cDJ4cU1YRTZWLy9XdXpwQy9sdDBQMFIrcW0yOENFNi9UNjdkOGpKVTJE?= =?utf-8?B?b0ZBL2hMOGo0WGhWaEpBdWR3Q0tueTZFdnpUajI3VHhHcG9CN1daUlFMYVp1?= =?utf-8?B?UnYvbmVmR1NnVDlsdG0vYnVkZm5FcmNxYmdEejY5RUZ6OGtBUy9JL1lxOGxw?= =?utf-8?B?Z2VOQmJHTUI0SmppZERIZU5RTzNneklNL1FvMEpWM1ozWXIvTEttbXZYMERS?= =?utf-8?B?bG1oaWpTMFpOb0ZnY3hEc3VqemcyZHZmQ2JNZ1pjQTNrY1JDNFhlTXhlejI3?= =?utf-8?B?eWdxc1hnQVc5M2UyN1k3anJXcmM0dVZhUFY5clhRRW5WRGY1Qy9EaU55dG1o?= =?utf-8?B?TXEyZk9jZmdQelNIRHMrVXlVVEI0QnZlZEtFSjJvUytnNUJYbnp0MEc3Mmoy?= =?utf-8?B?ZmVyTm5VQnVDbmlJSWN3eUszUjc1bG9MZ21SMi9MTWpsMzVmSlArN1drTGlp?= =?utf-8?B?M3VkNTEzOHB4bjhObmVrN3ZUYVYrcGR1L3NKMDFtdHpNdjArYzRuRnJXWU5o?= =?utf-8?B?WGhzQmU2bjhnQjIyZFVENXN0QVdnblRIUStKdHZHMUlZWkNCOTgwVHhkQnpR?= =?utf-8?B?TVUzaDlhWS9VUHdMSmcyUEtmRkw5ZG52MmMvdnk4cERXZGJnTXpvM0w4dVk1?= =?utf-8?Q?PfzcZlKkvwfPrN7kmGV7JfS4y?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4e5fae5-65e7-4e97-6f8a-08dd97afad57 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:54.1757 (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: E/xBoYshoJ0+MJxZkkIDF7QbvEL924Np/dfb1HmHKKQIbvY+tc1fBngy7QYQ0Hrvt88EVKl61tcWMGyADutcXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-ORIG-GUID: J9ib4PbxqzgFb9rrtIuxkUR1SOC1TgSz X-Authority-Analysis: v=2.4 cv=Y9v4sgeN c=1 sm=1 tr=0 ts=682c9a18 cx=c_pps a=/1KN1z/xraQh0Fnb7pnMZA==: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=Zlyvcu6OI-jkaoIL6xgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: J9ib4PbxqzgFb9rrtIuxkUR1SOC1TgSz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX3rr8vOm79pEa x+gmRF9oNfEy73zaT6GyIwwwxmW70oEP4m4XG2xB2FUOkPyNbRxChW72eBdciw/i8EkBmTpEzgn e+X1RbThyySDbS0DVjuZNi+/dUGmloTTAAqQ9l6dis1Kl2f3T7rWVXJo4izYvURM4vrbMw8q2S4 ZzfQCrm+J6qbuNjg1HCAM/G4BWyOuG+aIKEb5U8qhQG29uINIZ497HbA0G/knt+bHeVdtoQxt0b 5PbTE1ctyZ/WQx+xcJbOgfIdMrOYmQOtYLjDySTuilueuYaXCKPb9FnBKwV8KaYwTAkiXpy8pQA wiFF8tVubo4Q2BX2Nxs9uRp2pAay8UfShdBLLHW1tqgjDhx+Y/9HfmlMZEKj7CjfUvQM3Yi/RuN a+me7E1PI5yY6G4DAgXa0Xf7+FS/9P6U9psPPz3NourdedeoNX7Tr8ZxlKb2MsZ9AFfRf3uX 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753896828116600 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 +++ include/hw/vfio/vfio-container-base.h | 1 + hw/vfio-user/container.c | 212 ++++++++++++++++++++++++++ hw/vfio-user/pci.c | 146 ++++++++++++++++++ hw/meson.build | 1 + hw/vfio-user/meson.build | 9 ++ meson_options.txt | 2 + scripts/meson-buildoptions.sh | 4 + 9 files changed, 402 insertions(+) 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/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-c= ontainer-base.h index c18986a621..c854f902ed 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..181fe0f02e --- /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_pci_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/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 Sat Nov 15 20:52:47 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=1747753564; cv=pass; d=zohomail.com; s=zohoarc; b=LiaeKM5/IAvxVNIsfzjAiMJKIN88ceCd9ILbXkByAIppKmfyDg4wKdrNP/x91t3TwDmVkqFDSFm5Rv6eRFZqFX9Ddh5EpK/QJEpBSolgR2Cq7cfuLmcX+26lWPPeVljQzR5WdwgygCu0OMkFnDXGlOr2zJBsiYUzyZasSXRGFjQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753564; 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=32+Qwyy4PKCdAlU1XbkR2tPxH1dX91rBCeR80BoBBkI=; b=PAf2ydLSI05EHR5bTIS4Lcd9Qc7aPJTaEyy1MpElVu0Nn5nxetS9IeIphVF8Kk9AhS5qLeKafO7hvjcyz6oS1pADm8J5QG8lpEzhTa4Dp5PyA0jHm3iVbY1Hs/Xnmf4d1nKO0BN8G1T2NZHxa2iR4ksASgcRWTy2X9N3t3Ew7H8= 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 1747753564356503.9239525053913; Tue, 20 May 2025 08:06:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWf-0003GJ-Sq; Tue, 20 May 2025 11:05:05 -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 1uHOWe-0003Fi-Gl for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:04 -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 1uHOWb-0002TA-ST for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:04 -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 54K9twWJ009877; Tue, 20 May 2025 08:04:59 -0700 Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2040.outbound.protection.outlook.com [104.47.51.40]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46rcm2hydv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:04:59 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:04: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.8769.016; Tue, 20 May 2025 15:04: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=32+Qwyy4PKCdAlU1XbkR2tPxH1dX91rBCeR80BoBB kI=; b=c3Ky8YZE8toL/MV65d/c5dBNf9d6UiMwFCbc/cmXlLWrD7ZJ0TWV0/smZ Io3WV0C6VYUvpAtz1u5hxbp5okxEW/V+uLg6NGaU4LWgTakWrqHWzAQQIBqMVLpU 8npGtRuM4H/5NDpR0pyEuNnPXS+r2QbcsRB98C46pJsNnIFYqU/TiYTqnaFUcmav rNUGYZVtYAoZtf/mVWMGT/Yhx3+8OTgj3Td6+EsOWzaWaE4eAsI40XtRQC7kEL7P GELI+LCyRaGQ/OcOtFWrGnBz9Tiy6PxIC4alx62yeE6ZaI/uXSUDqddEqqI4nm2A 37iRGwtPIYAnLQl0x/f2ekXH22hLw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AE1toe9joHa0PQWMCEwATSK5kyBWzzcXD7tMXxoj+oTiyIfqiCeoK3wL8bvL5CVz1twuh36/xmiZsulMHXkGJ+AjwGxmVJvzKjlQtyTIxDiRVjlMGj7wImrb8xAb/FU6gAnE2kl77UCaKQZJY5tz0/p9sasHgBGl+mohdF4f/ysSZq85leLC7c/wA42U/8l/69qPDU9cTX6aVy2iLq0zdEbJiwFYSp0M4lNSlx/OP2ljUCJlclMB3iatykUBVXqD47kTI07P2qeuCnHQyOrzKR+PaZ659JenHiaU/1Lq8iicG74gNNRvFg3Y5tv99iBV3LjXXrFDHwWuA/GDVCv3DA== 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=32+Qwyy4PKCdAlU1XbkR2tPxH1dX91rBCeR80BoBBkI=; b=KI9sLIlH4DNQg5Ll9ZUdJWt/HXdDmHrSpe5bZfdNeLYBltnbh8CPCD3EmkP0CoyN6Z+svKJHmjEU8VstBMSJDoHqZKJ5yKLH2CYNwFIJWUcKgqAuSto1q5X1bB3zvaKuYM7YDSSKwEcsJyRb6FuvaG2Ui6WvuiPOqk/0QMHnmkCJPBQBpx6Jnzo1W/NzKyvd6TPNiwjb8dGZNXs0ZtxrcxsWYG24vAwMsk+WhXB6PPXHe7CIvRxNmkAxl8e2sJprUF7IJG+VgFy/P5BnoRI8b1ZvQljZkZ9E/GEzT+FB7a0f/Jf7qsqg2q6S6UIX75Y2ytSl1kVifFEP6n972rpPMw== 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=32+Qwyy4PKCdAlU1XbkR2tPxH1dX91rBCeR80BoBBkI=; b=U6GLXb219zhgPk4zW4H+GYe0VBKyfbRT56ABGVsZ2Vh4u+kEY4jtxU6ALOmTig3ZZm3HXIWOMJW+P0yAGyrtZpcw2eOt3UQGG0fL0Du9PCTXLMvCbX6wKvlopexoky1kF7VxxTI8BjLhpPTwb5xs00OV9r7orhsjBYTIjAPkUX/n45GTbTB3nq39Ood1KvCctCu6vT2iEV3u63Y7ueAESdhZfrxLfMujhAAE1DZI64JJijh6hzy07hlmpVnnkHYMFo4C9XM917tSmUexX/ktAbIPd5hIvUmzlI7uA2+VHJHmVfKiMyeoqCutrF6wWrq66oQr1ibaOMMo5Sdt1zwL4A== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 13/29] vfio-user: connect vfio proxy to remote server Date: Tue, 20 May 2025 16:04:02 +0100 Message-ID: <20250520150419.2172078-14-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: f1ae6d28-0ba7-416c-5a28-08dd97afaef1 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?L1RuM0xJTDhPdDBjUVBubGJ1SUNnUnd4UmhwOHpTd3NlUVlmV1Foa1ROZHRX?= =?utf-8?B?NlJZckpZRGw4S2lGT3lJSHg0eUpRNFN0ZlExZ3ZDRE1mOC82dk1tbXBRS1R0?= =?utf-8?B?WDUvVzBFeW50MGZUd1BWR1ptVksvQUExWUFjT2wzL1BNbFdPSW9iMEdjSlg5?= =?utf-8?B?eWFzUHlPcVA0Zi9WLzkxOEloRXloSWJFZmYyc09CN0k3dXd4NlFJZTEvT25p?= =?utf-8?B?bWdQMVY2Njg5alNLZGNaVGVldWxqZGhxalJBdnRKL29wVW5YWk10WFUwQnJJ?= =?utf-8?B?Mk51YTBjMUxEK2Q2NmliTC9IK0E2Wko4aWNLTERyU3NtWGh0YUdwZmRoT2Zl?= =?utf-8?B?OU1EalNoTC9BK3ROb1ZGd0svNE5uc3V5ekZPQmdGTm0vanJHb0xjTE5Ycnhk?= =?utf-8?B?Tk9Va2tGclp6T0tGbnU3cGwxdVd3ZFIrOHRwNm8ybkM1Rmg5SzhYa3BQNmFY?= =?utf-8?B?K0FWS1Q5UFNxbkxZalZMMm04YXVpUURzUTFSanpqTWQzWXl2eU1pSmdxejgw?= =?utf-8?B?MVdOS09wOXhMbm1lWDlYbndLYWExTEVWcUtjUVAxTHlvaW4zT3o3YzZIYkth?= =?utf-8?B?TDhHcU9oYjAyWnppTXJXdFRXZk9DSkg3TkNwKzdLZjk0ZHVVTk5TWkhpdFdR?= =?utf-8?B?M3B6bFoyc29OR2RoQmhHUWwycm45UEF4Smhid09ISldFUWhNUmNlYlNqL0My?= =?utf-8?B?U2llTHhaMVU0UGhEYkN6bFdIaVBKOVBLdTdyNTE1MkVHNEhpRGFOZHd0c2hm?= =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ZVTkpHb09sdmdK?= =?utf-8?B?SGdHUjRtL3BkeGJtM00zOUk0SXZlWTN3ZE5jbnN4dHF3Y2pFNEpFY1RIdnFC?= =?utf-8?B?ZlAyWHdnelVVL3ozbmlPWE1TQlJxWmlsaFRpRmF3N2lIaTBYcmZGaWx0Y2Zv?= =?utf-8?B?YkkzWThDNWVTSUdnY3VxUitOcE1oRWcybEwyVEFjc2dGd09QT2F3Z2F5WGxm?= =?utf-8?B?TEhhQ1d4V3J3VmdQbmx6SS9PNmwyYVloUjdvbUduSWlFQlp5dVpBWGlkcEVD?= =?utf-8?Q?19tZebXJSh4=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ejk4K1JLbDR2T1VBM2RGNExBOU1JNkxHT1hlVFV6SmJyVERuVUdVRWU2OTRK?= =?utf-8?B?ZEdRT1pQQUFPQmtHckcvcWd0MVMyMDQyVmJQZllvVXcwd0h5Mlh0ZVlmdjZh?= =?utf-8?B?L29GQk1WekxhdTlGb3J6NXJFZEY0SzFiVnNpaTJ5cWlOODVKT3lCbFl6Q25U?= =?utf-8?B?Q0UxdUxBbkp4Sk1XVm14ZU54U3dTSmRIQVoxVHpyZEpJSnZ1QjM2eFdESmJl?= =?utf-8?B?dWIwUDV6MFY5NGw4R3pLSFVZNzRERU1FYUkwaFA5R21BUFVsREtvRDhQeFFB?= =?utf-8?B?UVMvdkR1b2RlaG0xRUdQMzdyZW5LVXZMNko4RzZjb0FNRXM3UEVPam04RFoy?= =?utf-8?B?djlodWtKOXhvVGh0NzJ4eGJqL2FXbHk3TURMblhIaDQ1R040ZGlCdkU3Zkxx?= =?utf-8?B?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ange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:56.8222 (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: Vi2COFyQv5gwpTv448kbl/ysJZv1j+CYqF6qyfZOrf1MK2cjs8LCwkmFOR25ytY9Wg4Q8pi4XjNaI7ZptRrs5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Authority-Analysis: v=2.4 cv=HZoUTjE8 c=1 sm=1 tr=0 ts=682c9a1b cx=c_pps a=UtaLnOzkojfj4BVWksq/2g==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX2hLcMUho6yAW LvlbI1b8WL806UnrbyIN09tZQtzwB7DrJBRxBLOc8gOWgIgAk86fN3chAollfIgTMK7uIdHP351 6lD5Jrj3UsIsJNGIxPNr4fPxoHkRAbxzymGjmf3T2ww1WvHs/gMnlWGD1bzX+WOtSIlzkkyBun/ oOmAIpv2Fj2EAmCKkp3BbwnyAgEDOFJTVj58eDymR0GreFzOFGYFhHk+9iGjrt4uyjJg6A5pxHM ICk1rE78suG+eSXPc4VWmtdSBSslAIJfTXtghnlYLrJzP1ku1Oo8TMQ/zzdxIMWl/vDE74Tw6+e 0lvd+e6oVQvurn/AUMWj0XzQel/P4ZSpViNpc/etW7lsaK1Fj3FbYn4sGoZCC8Nnk8ocjsASZo2 HJNEq4khpNlon0W5QUBlGXSkhc+hkEzSO8X/lmeQVxDfSVmOOFmrsxAhZpJC6BsPwZk6SQYC X-Proofpoint-GUID: Gj_DUGR89tg30x0TW2qG8e7aPYaEfxgB X-Proofpoint-ORIG-GUID: Gj_DUGR89tg30x0TW2qG8e7aPYaEfxgB 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753566965116600 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 181fe0f02e..f77d0e497d 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 Sat Nov 15 20:52:47 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=1747753791; cv=pass; d=zohomail.com; s=zohoarc; b=PbPLKFdeNUBGit0+WS2+j7Q/LuGt27zwvH1Cb9Da6imWRInZ8qXJ92TBKRDkLgMud5VZ99OUOrbzLS3x9QxUZK0V1K/DJI78OI7RDRJV9JSykw67fMjupHNoMU0bdwBFgsRYGrtMwykqAs7nsRcngPQ6IlYrzMWqIl+MAuXU78I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753791; 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=x1RAiF5oWjlW3doYblZCC83ximlzoogokIoaTE5L9zo=; b=edzPzInzVKZfMKFMSOX6juJve/Wo4hTzKxyECWQ5F+Esp02CsyjHrCMfK2c2WUqvRAzhL6qa60u9RxW5r8aOFJ55uxpsSn737xsY5NiLpixEVcOcIS7G12X6RddRKsueXdueYwQn0nOAnhW3aDOQ6f+Ornja1YbgmdBYrg4QeX8= 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 1747753791296755.8770151204467; Tue, 20 May 2025 08:09:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWj-0003Jh-BX; Tue, 20 May 2025 11:05:09 -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 1uHOWi-0003JQ-Mj for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:08 -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 1uHOWf-0002eq-Kt for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:08 -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 54K7UjtJ019012; Tue, 20 May 2025 08:05:03 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhebwy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:02 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:00 +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.8769.016; Tue, 20 May 2025 15:04: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=x1RAiF5oWjlW3doYblZCC83ximlzoogokIoaTE5L9 zo=; b=vVPgISheB2qsYQIMEDzdEkH7VlBCgZruRgFCpTl/YsxTP92J33wD4cHRo s1g4SxS/E3oUk5dV12jmbQjGUF9dur7djaQCwpZeSnOuml0qVyQF+9RcrYOwJyNw fqBXQ+FWh/Iy5z4XFy3V+HuAwHDZQU9APQvnY498AtAASzGA9DAWFN8KYGBrfTgZ SITkasQGNQbaLyeSuiijn0SCg7YBlUVfBSvpdRUeNdJJ9ETiTAkqw57c9XZhLTjw KDB6OgkqoQ+wBoS9CQH+WUApont3Pen9/ei0kxvUn1KPDzrxquoLBss5B/eDpYOr zk+PPEDKd+aeKvE56Je/93zJdyoHg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rInFvmYfAKHt5bS3ztQbdn9rQDr4fXyPJ9ZVmBBsJayKLtmfXwFpS0eYYRVxGxXVIpyCFRc/+dvWk3cOYEnB/cesd5MP1/7RWt39dnz+YlrwxF+GNCSoBLIxgNpBdY6dS+gnyBofAbbq0mlaIFGOf7SgfGp540T8kRyUa4NP+C4ogf91KpB0l8/x5KUO7NgNCUEl4RbhOl5NzETySKr4nYKIkGMTSPL625sPzzqkNNrStAYHE9CAEqwJ2f316EqGZOsX6fMXl927RjhbLhXDCaMuF7rhXXGGu2bZmPj24hH1x1DAptcRQTEVfnqs8CVbBsB2C+dXPoIoncDROJDyrA== 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=x1RAiF5oWjlW3doYblZCC83ximlzoogokIoaTE5L9zo=; b=ozLISRPguzYFYISv9/ArI+UjbcmNwODG5Srt7PSml549HkrOujM430VkyU4hIcAZaRyyZatQVJwKeskrNywfhb6ij+Z0kxfUAriwVaRIGY9r47cNRFaVJE2l1oajH9RluQ6jD0pGwLxXG167knHLhZCyOMUdBa1gAJnij4RwpCwXljkrJ02JCcr6v7bwokcgoJe+uZKTS5zgU1ipc3K8ht65EQsTXM7g8fkcRU7p77ksWuzPWm2tQlzpAGRAdJgsMN/aeCgB7iJw/r0oCne+coOEJUPaCkJ4IH0+UOjxASrkDdVWEaLJv4Qf4AQ1QCCP/yGQhVrf5mj3sryPFMQEJA== 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=x1RAiF5oWjlW3doYblZCC83ximlzoogokIoaTE5L9zo=; b=PxraEfNeH1F9SYQ1YehE7/ixznfNQHi7WTiCcpCPPdPenjupa+IDUKJPzX1bwOzeKS4xdvmIMzrkDwtTWmAC84fg/BVG2151IfhJEQIDb4Z4gbpnaf6q+hH7Bu/58zAyg6UOmv1E8orLEcTEofPKF1T7g9nrQlxrZzm3KZI5FoDlOWZfTidAbCHDAIobttHM+SDSJm3BvHbi7Ls0joIG5qBb9aHODH2cEe2qltPGAohBqcgJQ+ms4QAVWj/+xqcAolIoZhVoIDl5DgvQQ74Ox46oN+n9wLzdM8AFwO90Fo1RL7T88hYeJtncjtlWqPexaN9k7GyOia4POBmGNvicXA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 14/29] vfio-user: implement message receive infrastructure Date: Tue, 20 May 2025 16:04:03 +0100 Message-ID: <20250520150419.2172078-15-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 991c8e53-8ff9-4107-7f9d-08dd97afb07b x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?TjdQYjBVS0J5S3Nmc2dhaCs0bHRaRWozRUxzWW5TMmh0ZmNBUEpPek00QkpT?= =?utf-8?B?QTBlV093cXVvaGIwQjFLRzVaSmsxanFCUVAwNWdYY2ZCdVZTNEptQ3JvSktz?= =?utf-8?B?VGlIZDNzSkdWOTFTTkVZaTNN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IzbnNkTHc9PQ==?= 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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OSt3OUhDUFNDOXd3dU8wbVN0dm81N2txeSt3RlV2QjhFQVA0VkgrT01qRGxU?= =?utf-8?B?VmhnalVkSHp4a1dCaXgwbVhVZlpTMFAra05OVVF2amFzOW9nblJkdGJNWEg4?= =?utf-8?B?dkZCd3NXSExHZDhpVGd3ZjVKcjFhVEJIcTZpcW5qV0dJNEs1NVc3eGkzVkJh?= =?utf-8?B?R3NLR1hPUkltclZoM3ZRRGZsOU94SVNZYlpJOHZ5T2o1K2NPK3FweHJzc1BW?= =?utf-8?B?R0MvVEprT0hSU2c1L2dDbExVYytYR00wZEFXUGpjSWZuSFIwRGNXajlXbkJa?= =?utf-8?B?NjhCN2lkeUdMZDIwc2pqTm9aZFJlOGVBVXRISVRVQ2JOR1NTVGVLK25RemNE?= =?utf-8?B?VUJ4bzQ0UVJmQStYWndaT2U5Q2o3MlVBU1NKRzdjRFNtUUdIVG9SVE5FN1px?= =?utf-8?B?eEJUUUgxQXNZVWZxSlg1MGZUSEdnZ1lvSXczbkU0Y0s2amc0WERnbTV5WERn?= =?utf-8?B?VjVYWkVzV2IybEw5cWIxaHQ2aVdWOHZucUZlQjJCZ0h2YkJwRUNwTGU4bUwy?= =?utf-8?B?OC80SlBVcnhKQXNnaVBNcVRJM1V1ZlhEeWxGa3BKWkdEOGI1amRoaWFTaTRO?= =?utf-8?B?QU9QU2ZzN1JjY2JGY01pNmhON0FQVjJTczNLR3Bic0JRVUdQRzRqbGU3M3FQ?= =?utf-8?B?TU9SMWx2WWE3d3c2TTU2Q0Z3YjJaVll5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xwaVlVNWhOVFFST0ZiazNBNVpOdFgxNGpCZ0ZVWXRxRWdR?= =?utf-8?B?MHBqK1FZQlRRNlFVUDlwcU1SN2VES0J4SEd1a0ladEtBRjA4Sy9BaTBNTmFi?= =?utf-8?B?STMvUXV4L0xrTFZVWDhaUUltNUtNMUdHQkJVZGx5eXpCdHF1UWhJYUdJVUJ3?= =?utf-8?B?R2ZzMXc0djFTcDM2cVBMMVdNREJtRkhoNTNyUFQxblBWc1Zadmdwd3ZxWi9K?= =?utf-8?B?RlBzY2lVajNyVU1lYVJCdndUTXVLQ2F3cGtuQ0FDU21INDc4VGRkaGxkK1hn?= =?utf-8?B?WFUyMy84SzFvSFB2RGdTdlRHUjRFVCt0VmN5VjVWZTlOY2pPbUlCOFlrT0ps?= =?utf-8?B?V3VSNENXaTY3emRHMFlhWFZNMFpjRVRGRnJSb2dYRDNNRnZ0TFkyQ2x4OFNl?= =?utf-8?B?NlpKaE1FYVgzNnlzYy8zcXhkd05SMEczVDZvdVdnb1kzWUQrV041ODN1bDdu?= =?utf-8?B?UHFMV3YweGRKRC9peVJKL1M5ZkNUanBUSUcwUTJFY0N0bE8rUVVCUS9pVTFU?= =?utf-8?Q?1Bfrv76ZoEtkC8BsjwbJRW9XT?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 991c8e53-8ff9-4107-7f9d-08dd97afb07b X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:04:59.4937 (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: vpbceVfIEGG8x9fiLYlxtVWSdmfjUMv13fhZ0GS1dCvtV5f5OFqnmW1rf/00VLnqotC5oZ0mbeMpe2Qj6qoXpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-GUID: l6Bpcq6HfDbXOCXMx-FQETqz7nKob-o6 X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a1f cx=c_pps a=qvBKVd3KFl3zkoLf5jvq7Q==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX/LihosZmbePh fjKv0Xn7OUESah+s+l16BO0Pf6eLU03JpCVC1lVkHopnEkDeRTkaMV1KDW7BZ+52+00FKT1Oeia 1owZ07CiraVcfXp0JmXhkbDzhGxUyLMrCPpVVZVXzkrax5kWImA6JALi6cA39z86zuZPeam74fj VV6wlzycEP7Ccb5XswosHmWX7gS+KwP7gZDBOK3WhBMeN+4h15d2Cg6uHrzpv1u4GQ6ovvgFYd+ xZbsso/SvZ8HIsuz6LjH4M++F/o6Ixk2Lwg0065uvBvcpMzL+A5AATllkagds5qIoE0ZKcnJxsa Qa/wBw47f11ce1cF3Me4jlpNUZyLXSRJ8Gxjzh4Lk9lqB8JfsWxucJhMnSxt2SO82C23UP2LzwZ b0wA7yM5v8BS58d8p33zUf+IZVbd7uinWQNkrXfmXTOS8uBBvSA61KpgaGKSfyuvFBIoEnz1 X-Proofpoint-ORIG-GUID: l6Bpcq6HfDbXOCXMx-FQETqz7nKob-o6 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753793233116600 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 f77d0e497d..894130b575 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 Sat Nov 15 20:52:47 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=1747753805; cv=pass; d=zohomail.com; s=zohoarc; b=esAugXyQq5J1ARbffJ+9bJVIUc6T/29yTzQFAZnKPJTfSrCvnoOQ+RhOrcEk8X4waH9CxoIqgSHGDQcimLK8M7btZqTChwl5hpmxXPAxH7Jxw0aoVset0j7CIrjuUX74W2HT7/grzMkVps/i1YoMaBuFCZkRDbWQDpPUlSKWnzw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753805; 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=/6thz8mv5WudgYGT/kAXdl+hYA4wu+ATfm2j8D4Vxlo=; b=lTRDAIeBSJ9qzpRVkDTnao4VG189m3uvLkpXZfkOjzMJBUJt6M01St7g46ia4LpuKrkUmWXL3WEcwczfxgLgfP4AV7lTsLlj3JthVUYuJlZKx0ueMAvCdwx95azth9Pdjoq1ES71669ECVnn/awZntZgM3/TcEkm17XPxgu0W/4= 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 1747753805617490.62646067693106; Tue, 20 May 2025 08:10:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWl-0003LE-Tc; Tue, 20 May 2025 11:05:11 -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 1uHOWk-0003KM-49 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:10 -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 1uHOWg-0002fI-Gf for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:09 -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 54K7UjtK019012; Tue, 20 May 2025 08:05:04 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhebwy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:03 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:02 +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.8769.016; Tue, 20 May 2025 15:05:02 +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=/6thz8mv5WudgYGT/kAXdl+hYA4wu+ATfm2j8D4Vx lo=; b=ziiqXKxEBmgOhtp2nUydGZZ/Btp99co5CID6gYwK5o3Ua4H+TPu9Fvo59 1VQa7pvzrAw6TgeGsaqsw8j16FjWhbpJz/7cczIFEjPG5PPzWvsryl3FWSp11DY1 HziwXKVY9u4p3tY5O3PRJpxrNoo9YzCEaWkbn0hXmhdeJHoNwUksgHWyBW28wRTm ch12yqm3+8/vR8B1JnJT3JGCoVHXlbqa3Trz+E3SxQOhjN2wzSjAGHqp/oh9ZxBk pmwMtsIfbcpfzOKTCwNOYUOwbHyZwEY/XlPgBEaWwE7u9PwzKtR6VjP/GWgORbaO r+lMiEsdIRvtJD6qQUb1CQT7W5e4g== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YFqu3j0+xte3+fN9N1X0ZH0J3iQjYqHlfM2ULRORxHXunH8dk3oxPml0zfHt2sMbscsLR1XkuGsbkErWoidPnaSOpOTidhqUKav6xZbXuNNzDaCj8Ph6qJGpTpIfFgE/UbHjWlYBTT3zNNleexa9C2CD8dLeVzqnb8GYsJD9TYLCIVOeb+vpAnCqMUxOJNjXIumMyA6XmlG4q1y3UdOUwwQRft3p0aB8wD7tKhKdFK65TpBAP3VQ3RvjSBRKnawdE7zJaqTEayTKDpv+d4fXhDqpE2pHu/rgYQnU3XefTVQhIzB5kKQalqbKoNw5v0vjwIO5JmE/cU/TmsMHb6dFFQ== 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=/6thz8mv5WudgYGT/kAXdl+hYA4wu+ATfm2j8D4Vxlo=; b=YpOQymsf4BMNhOFBOVy5k7XIrdzXg13zsDPPjD0usjfhH2JqxlXOvNygsZysgHMQ/Eo5YIhVx37Y7NktRn2mUEQpnwdGfX19rDdMtngI534AAcfjOrZMo6N+BcsBfPSh85avhjgXKN1Oc/SZoMuZair/OwXBhssHw2dvx0MmcBDtCKzLcphQ95NTPiDIt0wt4ksyX1uOP4Y5fGF8tKo0AOx2T4s3mobck0wFjMHNZVBiLpVpPCzSgtn+nRlDtPw9s9QzULwVBzlwdsvB0lWy0iKnSwU27G/NHDQ8pkhEtHtv16viqGgxGtYOlMwS1j53Uh6JwQEgVaVU33Q12GG3oA== 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=/6thz8mv5WudgYGT/kAXdl+hYA4wu+ATfm2j8D4Vxlo=; b=yzff6775TIdJbcX5QUsKIa+cPW4McqMQmiiz7zLie4ExMuOIuDan4QpU/MLSDLJwgRjODjSLMUUDHzlD8WD8c79t8wFuN3hGRhb4Xo/qjYdFRsCMJWNAR1d/Y9P/ELaZ71P4md2U3WHLCvItj2rB62tIU1fO8LwmvxFWi6Ngj+5wD1QxCyScHeBLYxV6BoKEbneXVKhrIynt4jqjWdGSZwUd9zfxxfzNjHd1yQnC1Df/IJd1RGns5APClvfsQBwc9mEJHsbRZI7UK1JGekJTRNlSyzqf/hNHeyUSirseoOcdlXl3D71smi+TtwhFNnd8NUtccbU8IkSjtPet/hjhQA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Jagannathan Raman , Elena Ufimtseva Subject: [PATCH v2 15/29] vfio-user: implement message send infrastructure Date: Tue, 20 May 2025 16:04:04 +0100 Message-ID: <20250520150419.2172078-16-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d0833f7-85ff-4101-d355-08dd97afb211 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mHC4y3JlJHAJGwIj4qsqYPchPLotH7snnw0LpP+4Z47+gSBEHK7JXtekqSKS?= =?us-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QF/piOzkAJa0/Yy43OjxipKatxLpQcgQR?= =?us-ascii?Q?Ba3bbzablO+cTIO/OBSlTdRHdpRaIo3+ao7EiF8kuChn/T4BNAa/hdrRoKw0?= =?us-ascii?Q?knrGiab5pmQRWwKepz798o0Kw4V+70WdkUSJ6dVw+tmSx0aNLgGuHRNDjOGC?= =?us-ascii?Q?v5oSsqd7dKzouWpsigBeRZ9GdeM6XNv/UK7Dx4NFflgbstzZ0u+dCzpmmwxK?= =?us-ascii?Q?LeihsD7hhZzBXbM9Quf0Wswvap0uNQjfUlCzQSzrOcLA1bJ2ouHQcn61myRL?= =?us-ascii?Q?SFxLOht/QGFi5lqWPxUPVt8Rb4vPd5Zk/CHKzPaK1i47lOplPY0pDxpzGN5v?= =?us-ascii?Q?pLHcARp8fn5CQdhIn+J3sZ9n1lr9Btp5gdOLl25nPRY0cgfjC9iSl+5JnQJM?= =?us-ascii?Q?G0fCkwzXfPd0ILBG4pI3+BZ/QkBrESlwcBr0pxJphshl4aiI0XxZ580CtWrZ?= =?us-ascii?Q?h1P8ECrlhn3w0+ODqdGZp6HfLzPrx/d299mnGbERSZ1lRxB3jpr27JbJW1hG?= =?us-ascii?Q?//2x/brmyoc=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Q09kOhqqQjITyWL5hDQfJ50+VOiUzXqclChXBdjjR4FHiChA+joDq4IAG2kJ?= =?us-ascii?Q?2pq/svmn/o+m7PGBgu7558khqYzedxhIAfNpqWPtlJQ2kvdOGLFp7MMugysK?= =?us-ascii?Q?dLTWT/NyIcnOyiriOPFi62g4xoLKEEo/pG6V+YfXrOwxFsi/7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vMLB0IM92pbtGJ0L+k3pgYnLhKIvaSeHO8hDxNEfV88FY5G7Ev?= =?us-ascii?Q?LQ7c6oPleC2L/QyZrsBzbNYpdvz77LC018SaBO788Lbx9omklBZ77RaKomCi?= =?us-ascii?Q?6sLTLClzLg4/MykWGl8fWhZ+OuSxNWsT1JBOminvzLY/bluUdF4YpQCRiNGt?= =?us-ascii?Q?EXzRnF6uURZviD7+a7N7q3s+cnPfbRTAkjsMqfh6j4GYZlxSocBqgy5hgR7N?= =?us-ascii?Q?m5Wv5Jhfp1v4rKIqQBzqgI4oSX05fxMXXYqqjwi3ovooXgughL1P6Slzcnhy?= =?us-ascii?Q?M8Nx7LkdUzOTJFiy0p5nsgGqlH3t0+pvwuUJrj683kS6z98VOqS0A+MPjvUT?= =?us-ascii?Q?mPBWX1XOWlhE8c8uiZLZAPti8GboTckfRR4Jc6ODl1FA/7eYsDZDEZEM7B1V?= =?us-ascii?Q?ZxmATgstP4QK2TivXvKHRP2U2k2moYXRugSwBvotML7ugb/7+NCwIQWa8lUk?= =?us-ascii?Q?QezJ/YgkkqfB9lHbzN57IDq84JXxFmjci/5LbNMuvQJBFdS1cKeFRfjGByoa?= =?us-ascii?Q?pTCBBPh5XLeOkz7LSj6tuLH5foOcbahTG45d4xnM?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d0833f7-85ff-4101-d355-08dd97afb211 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:02.1984 (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: sdHSBA83RHp2hGPtdLiV8RSYYVM20lHaK/Bj7f8GJhLBmE6LInZ1BPU9f4IwYA62tAJMvUjDAyODT29U1OosTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-GUID: MJcSBucSAXwF9ySeQCGHJuIgDmytng0K X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a1f cx=c_pps a=qvBKVd3KFl3zkoLf5jvq7Q==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX9zg61XqQmIPq ftjBTnfScROibV94G8s45k/4WH1Y4OszeTCyY8bhGymKoBXpgYMXVB4YKE7joQaVGsybXn9I0DM WXXGT+jIRE9UjqmIDWqS8x2WCLTd3B1Hl3k5zW7w3vxZCR+sYrdtYKemjXVleeSXeh4ZbOo8hBe BEW5oESr+IVpcY3d3FEb8NG8TgYO9nHyWeeX46dRoaIWEdgfiuFqHMFBBek1m5VuyFrbKBniLiJ PDPk9NEQJ3D/efl9Q5rjX++9KOPejbSzZ+tCDzxrIB/0nHhZxoqC6w7ALtL2ulTIb4D96z/nd50 969HRXv3Dwzn8OeL3JbXx3VRnimbXbh629PZ9R0oSZ8O3ISbeGHpVnN3s8i3TGJMfGYq0vuVCa5 bZzRXUTi4yLBey16PbgbCyvTbzSTkS86DCtxngDzVTT/vTu5qLCLU5iJe0sMBT1qnUcTQj7z X-Proofpoint-ORIG-GUID: MJcSBucSAXwF9ySeQCGHJuIgDmytng0K 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753807639116600 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 894130b575..391864412c 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 Sat Nov 15 20:52:47 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=1747753880; cv=pass; d=zohomail.com; s=zohoarc; b=PBRJa32+AeTZPfYAuSJuV4ZPllw/9PzvZzzpnDD6xssmZZ93GBNiRWwI5FaG52I6Wk9nPNhnXhubM0ZfbUzjadQOERHBDtxlyM8z7ddWwCZJqQYcJMLJi9i8hXtJVq3G91LyN/6GJZAauZGjdFCHQ4byw7Hsysz5tcsCLxB8Et8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753880; 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=k3/tSm5Bj0J5ZcvRnZJp9DhXHKPMmN4CwqW/lTDrbEPrJIJTnJkS5VZ5yhUvQLlFC28p0FdCLRlIt7m0IsbpgJW6+ZzfjdrNBtTAGyx3wTwF/J1oLwVwGh58/iDQ2yJ6Id+5rGkABZX4N78agLBtCsfozx0N1EulxI/uwWQWLv8= 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 1747753880261264.0519914652921; Tue, 20 May 2025 08:11:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWp-0003NW-Bb; Tue, 20 May 2025 11:05: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 1uHOWn-0003MZ-7b for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:13 -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 1uHOWk-0002gu-Rt for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:12 -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 54K7TJcd016599; Tue, 20 May 2025 08:05:09 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheadj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:06 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=UH6f2tmI7ATg3KzwM9TyWxj1523guBD6/z5O7cFLN GY=; b=ufYSsFigOMdP57yhWK+Jw1WxDSqGsetZcqLupUgQ96oEUT6eKufnpxucz Ojb/56uor8bntystEKTn9sYk5xHIKoELHcpoJLRKA7XBoJfkV0LgkHiU/eGpR+Bn hdjgBXC08aWGkX8tbQuRhXt5Xn+u6IB1SXAGqim04iYeTxDFdIwN64GSrVlfeOd0 tgGFFvLImlxw5XJGKnXDJpzrJ2gnA9dpBaaCqjfclrYdhAiIWJATpJ5B/YNv9Haf mH0ObPRFu3j/PNzKn6EciU3t4Y8+vTjNlQqq724Q9fRlFJqNT0Gtjav1YwZgjlQh ovyZJNltYEl37Ce7w+vaI3FV4O6Ng== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ho5zKlMSoVyqJW15JAcWzglVZiZJBnWeQ3AQ5dmPnFtw+wykqvCOLpVEOJiZrd/vTua94nXEj4fA+iLWjbs+WpLnLpWVAUCtVG5nhVYbB3vRUQq7Q0e/0o4m7z7qQxufp4Y57xK7pZwqxASZp3SlQu7BrTgKsAKlVcJgtq+ChxA2cYy8Dme8h2VXGKLZr5qrHwCOcodFZooLxdU7EbSPRKTazkU3bPndst3sHUp5WVfqu4+WQFffrQg7IzxjAZPcck9r9M2epd7XWZMhEzD6ptxEXzhPqp7Q9bTPr8zSGhDioAY32rSCRxpMYPRMzy72IcLB9MqZUfMxXNomhz97qw== 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=Hmzvl/qiTxsQBWZRUICNvV3NzRH4lcoRucYKUdXh0bCZCYlgrcU9TsApNfChcAiHtFbzGxayN5DoaMO9o4JzT9pEhH2i7C/k6UWUBR+/SJWAWZQavX8zhxZFoghQvAc+8ok2vaza+GFOJLoJHw4dtQAlCgywlWbV6sPlL03cOtfSSzIe4mzLKAlYnXGwHS4hLDUNbN08PNayWM+faEYRp8L9FDiwN2TvBDRW/ABmYQL8S2j8allYaiYjdsOGDDf0ZDp18yyLXhAd0SwfBDzl4iVcw6fbcH1Xa3n6hYQMbfwLvI+RNx3MnAV7looOolqlkMT84P8q2NNUqHeezw3wzA== 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=QJhoyvLytTeGfcbD/JHva1uftpd8/Seh/slWI4eq1tFP6BkO2rb1jQQnqCSYGO0PnJlEfAq3AFANACtYOvDY1UXBsKpdV0T9bpkSapeJBRyvrYBK6pAXNxakQqjJhDmSqzpEf0UDMVG5yxxnxE/xEqZKu9JdSWDbe48CnSQWbmd2m8VoqLBfnndpXIajw015Yi1wlh54l9JnBuh9vNeaj7BF7MFDnqWWhVyjVRTFmAD7hSktPj9Nfuatgmf0PaB7CzLHoF6Pu62LH8K2dHiDdXrP1qWeHLtdfEwqeLmQwrBw5yYZhZp0C9/5sK9Fu9xFvNY48KSCV0PSSRNl+5IVzA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 16/29] vfio-user: implement VFIO_USER_DEVICE_GET_INFO Date: Tue, 20 May 2025 16:04:05 +0100 Message-ID: <20250520150419.2172078-17-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: d2d93259-3e56-4f01-9444-08dd97afb3b9 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?OWdsdkl0U21IcTNXS3IrMXJoZDYrYVhBbk1QUVozeTVEQmR4TlFYdjY3eW5M?= =?utf-8?B?N2p4a2V6WVJHY3IvYURWYTJ2WGtUdGtVOEZpbFQ2RithNFRmYjVndHBRcVdw?= =?utf-8?B?RXZFbUZidkR4TVg4d2pTMjN0MGxCVXJCRXo3YklydmU2bzRRUURWcWo1dURG?= =?utf-8?B?ZU55N241L0FUVDR3bWpBSWlYOUIxRVhJMjJJUzg4Y1JxVXhEeTFRZ0UzSyt2?= =?utf-8?B?TnN0QXN5VlhPUmZpWFErcFlhd0d3N0V6Z0RQUUpGWkJraHZ0K1MzWlJXSjhP?= =?utf-8?B?ZFExRldqNXYrTVRmSUN5SE1ROW5ESHk2RGwwUGFUVVZEb05kOEZkVHZlNzFJ?= =?utf-8?B?MisvbXRSbnVRTURVbFdaVy8xZFY5VC8rM3EyV1hpT0xsWERLOEVmOGF2aGlB?= =?utf-8?B?VHl5bGI0Vm05TldpSURZYjVJcmxWdzJvOGlrVFNFSXdvcD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K1ZaazFQVDdxTVlDMFZx?= =?utf-8?B?OXdyY0xtTXN2WHMrKzR4OGZvOHRtalk3VW9ZU3d6STRBQjV0ZStzNGpTcjBt?= =?utf-8?B?SE9tYm54Y0hBeGlZc0ZUZlA2VFBnM1RsaW9RSml6dUhIQnIwVWtOYlhnMmla?= =?utf-8?B?N3ZlNkM3RWtRZnVaNERIQ0xIS0ZvSjJMeXYzL0Fwd1NJZHVEWng5bDVtYS9T?= =?utf-8?B?ZGxJcEhHdHp2VTdXa2VMSTY5U2xrdDZiS244a0ExMnN5RzdJeTNWejIwanlF?= =?utf-8?B?Ym91aDRUd3BQRFJQM01XY0cwN2x3VkUwaDVmM3QxU3g1QnhCVjJNTmdLNmpN?= =?utf-8?B?QkZVS0NlUm9kcUFLT21KWmtDU2xIcWhMaEhTUFhFZURkeENEMDBWS1dTcXFj?= =?utf-8?B?MC9sVUFHcWpHUzJGQXZmWUdyS0IyRTlHV1VMZmpobFZrNUd3WHNmUUxPMWxr?= =?utf-8?B?V2YwZURZMFlkVWRVcUgrYzludUVRT2dIcVloS0YwdUZsZ1lmd0pJZ2dQK0dO?= =?utf-8?B?Uk5MaGxhUFNYcVhHRWd2cUg4M1AwclNNQkhxOVNEUW04V1YvVjNyVUdtVCt1?= =?utf-8?Q?HB5rNlpv16k=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UGllTkhvM0tDR25Ta2tud2VUK3didVV2TDg4UFJGZ2tkbmh6WnYzR2hxcm9N?= =?utf-8?B?bDhaaTBMUm5IZ3JZekRHQjdwaWdWV3FLbHRwdmpBZ0ZVTTdNd1pRRENKMFpG?= =?ut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NaaUdIekxwMllOTlNCVk8zb0hJTjQ0bkJwSzdBMmlEMVhV?= =?utf-8?B?dXUyZlRQTmRyYWMvMTRqOGE1c3pGTXkzaC9UQVl5TFNFbVZIVjE3eTVvRytF?= =?utf-8?B?Zk1hOHg4N2JmeGRNQmUwcFJQQW9OeFpUVEE4Z21sc3Z3cnFiSi9nZ2xzY244?= =?utf-8?B?SERnQ1BZUHZ1ZWxJblNnWktZVXV3enFxRkdaWkorUEhBa201WVdDd1JGWHVa?= =?utf-8?Q?uyS4DjXR/K5wFD3uRW4cCljlg?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2d93259-3e56-4f01-9444-08dd97afb3b9 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:04.8205 (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: zWHkvQ5eD3vMvtfInPLTuydw+PdL/9Qvi27LywEbMtk9BpO/uk8OKWLKwZQCBmOrD8+Z0beR/1DEiW6es1pT8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfXwu1Ury6ye3AZ 57UJfQg7NrDSxxeIhFqHm29myJMT/I4YJT7hnWIeDbZGyrvpXVoJyWYRQPh5OrimCUikaS6iYnB 4ai+2TXCoT58Y81QyehKay3vHLYGzHprTRxP/HqW+bfDV+HzgCGM1edYj9JXkyvdYolwkxRB7ZR 6LL7yMFn+CmUPIUQemLGC90ho9AMpCMBlBJWiUBoQnanp/OkARTH1pD+SaXOxaY66XiXjkI3GTv 1cL3L1J1g8BNIhQuoRtksZxT6fbH3INelN64JtQUTBs/QKE0ZZDP5L0rHkcTHtMIIbzOjSxEcUY mQzyLwGFDZ1SV9I6duWckwvF7FtlyordUaHup5PyVOb04w22STwcmYZX9xpd6JoBZjyZdOc3iYB BisniFJEfBT/EJhDD1GECRh6UAmY+PSn8JXZF2dZ0KVJS3EmWdBUZd5DtrJwYyRGXnihzUQR X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a22 cx=c_pps a=6L7f6dt9FWfToKUQdDsCmg==: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-GUID: NZmconDRMKRa3dBSC8rma82KxkOp_ja3 X-Proofpoint-ORIG-GUID: NZmconDRMKRa3dBSC8rma82KxkOp_ja3 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753882731116600 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 Sat Nov 15 20:52:47 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=1747753803; cv=pass; d=zohomail.com; s=zohoarc; b=mdzWOTpd04z/c9lUUxkZAkAY34Y6ftn5E3MH6n990Tjjc0i3vloYjgpPIfKGLYtrB9Yk3tTv8utnWQNIBQuftD09lIVl0eD8oiqJIFypeXDCD6+4Q/LmOiXbKbiDigPp7KHdDC2txAzUXJMJ7vZ9WpGL2u0z89fyTqY+72Obj7Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753803; 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=qVmeUiR5OGlh/Pj2aaqY2wnRJ1E4eTbe1pR0nXs8xfs=; b=QYmX0EE2RXPC3xyh3SIvFTvbinM1udE+F0pZirA1AzK8Jpuu2uTlKy4kcKw6V8N/WOS2H4sYq0iNnR9AKvm/QJRyu+KCmUyBCDglGyApAotn5UX/enOUcKqLTM2PcCYBXnY08zIcfav9zonuEIYhU53sf0B66bJGuKAv1UHycp8= 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 1747753803564975.8904157271579; Tue, 20 May 2025 08:10:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWp-0003OJ-Vp; Tue, 20 May 2025 11:05:16 -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 1uHOWn-0003Mr-SQ for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:13 -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 1uHOWl-0002hC-J8 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:13 -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 54K7TJce016599; Tue, 20 May 2025 08:05:10 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheadj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:09 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:07 +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.8769.016; Tue, 20 May 2025 15:05:07 +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=qVmeUiR5OGlh/Pj2aaqY2wnRJ1E4eTbe1pR0nXs8x fs=; b=fwlljWC7j3uUzDS6sVKnEgof0+Qbj19RZ/oH/zvnBdSF5LDta2I38/48y pjxAG3fwEjBJgIQN46xhATPGkXJitINr7vB3Yao53C8yvBKlLWHbg/wQ0MHKGg8a ywxR89O9TjVYHgppg2E72NFOZ44lv5A2fSoOLnoNTLJIqTBWJDcwjw2qithGtofq HSn51nLWodhlXeEZdJ2XbSHHnFGzBxZHBDvJh0A9woOJRVBrve+etSP4G7RnRS/O BiU4AxVdAEZZGelToo5KYitZaA9nEuCWwp0wVocem+nkogXNf8pLdP70kpL6cWvh 0raT6GevTfxOa+2xMFp9CqRTH/JzQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iZ/NqIjGL40+XWzav3Dqd3Wur9WnezA2IM/EqOzdQc4Uw/xDnCvwlbUzlr3klQdNfO8knMWfN4LIcpKHE+u7lbm/M8WjCglBZ3benJVTEnVwqCtF2AUQr1nhmpVSser6XIDpHG9FGHh3z8FHsl/FZdilHg+MIiKdOWxQLPURAiTlASIwWatMsgQC7yEPIbK+FfL2ErWYzFI7AqCwyaHgtiyBI52flmUZNDSGtRyWVCUehdFDPbvfbm3VGUNXKnbnTysNw+NdJ7de3zO3niZeoLFPdcGBm4pS+w0frPi6v3pMtiQNnnI5CELIwfMUZAWnf6CAWyoyD6/1v9Tnx1tdeA== 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=qVmeUiR5OGlh/Pj2aaqY2wnRJ1E4eTbe1pR0nXs8xfs=; b=XKeFVsTZLWBNi/SSKSwWJKSalLPCMmLasdNosZJd9ej0DJQM6hL2c1afXmJragGLRI+BWQPnpx4dgysZzonieKv0QnsWfSRTamkVf0klRzGD3vHxwT0ALMHzJK/+4qnVkARCch1tNshdqyM3jpBiMcx40AgPJFGH+aNvw34TmEZg/ieRAV0AqwlxoOqKstpTm4WgzPWkm+nMT7uJvJIXmvnPrplOg+CQkCB9fwfOz+Og7tkluT1YJvP4tqcLIn4QhkExG238V3aUWK69v4eu7UcPZCopGkNreo69Ti8XwOCeRFn1BOyL91DwwafqnKAi/q86/i2MxEWwRg+wSO1TdA== 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=qVmeUiR5OGlh/Pj2aaqY2wnRJ1E4eTbe1pR0nXs8xfs=; b=n462GP0djX540HIqquxcsywqWK37pS7gKPih30QNUFJO9ddwyVZNT1eppiTDU20cXdb0/Yxg49MCzvdAylEnM8zB7/3icAkns7S9m9p0SwPuNp4iUd75kDOAGIGhMbBVF9SKJNS4sESKcuw4ZzcHxGct29RVWUZRBvk0bQ5xtVoDDFq5XwToxQxi9JcUtfJfyF4GNo6Ez6mNUo4gt3Nzh2sAG9S04TeXdsHH98oLdBLIN9wmoOYrLxEzJvQ36h9P7ZYfcevlMDPPLkOGtvPymgidR17x2TVHBXLZh8V7XHzgD4rrBYX4FpLEDHZm6fe10Q0D7t6RCQ7IGbi2zhLigQ== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 17/29] vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO Date: Tue, 20 May 2025 16:04:06 +0100 Message-ID: <20250520150419.2172078-18-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 00cb70dd-71b7-4272-1205-08dd97afb55e x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uGYHX+c4NhK76TSfpXSbj+ymAM9fOdSeNVnisb6f2XihI7lPsVkMUTsq89RE?= =?us-ascii?Q?Wu7uByjPIgGe2TSemXTbmp63KoNbm5NeTMwQvAsFax36aX/oDCytE4MMCoo8?= =?us-ascii?Q?antzPAiISPWN4MzEzJukeE+TlQo7I7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-ascii?Q?n0Brh/ivlQ6GIr/F/j97TQt/7KnbHgW970WF2QM51jQJ6Jv+rK+R/FkYubC6?= =?us-ascii?Q?SzoEl1s++2pZf10mY2ppa+Cwlf7baT6Gycv+4IFGwjxO5YLXmDsGPBIKXFOX?= =?us-ascii?Q?A9/N7jbfSxnZ/+xWYp/VYzv998aAe2bVgQ+8DqRlCI388ivB6a9BtgfyrULO?= =?us-ascii?Q?OqUBY8pgPHw0BwmcQxkjEgrlSgdM7H/3kyW/3GVxbRwAvxbaaJKxqrvzhzrR?= =?us-ascii?Q?CXjcYybGEr8e0mqH7KhB1MxSp0d1yGIg+56I/kz8oN9qhTDQpNTZZCYKCUlH?= =?us-ascii?Q?jEaw2A/CKuCt97oNkDGMugrNXFBwleD/SufTrhR8JiE4SMmwb4zL5guR9f2G?= =?us-ascii?Q?dneQWHOLZPfQlwGzhZQrmbX4x16XSBS5lM5XZE85V4kTd2T2Jw=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?DmuG6y71rgQiHLoy8pC2Ng1oZxlGp5V9pD91raQp74T7CFlrUY+i785Alntd?= =?us-ascii?Q?DdGQo2sS3rxjgpY65HXWOf9rd8+aaGwj+zbzy+6E/RTFhVzGnCmiSTUqqaBk?= =?us-ascii?Q?cijvhZjzWT138FZZdMePpBjsqmss3tQMa/9XVUrKT4mQsSBGWdV8mr+k58Tq?= =?us-ascii?Q?1aPHRiGylEJi0tEC8oitEdwfTFVZ/W5EQj6tiR4ohaSZlL/BN9mxVflSFPH4?= =?us-ascii?Q?mzEMldHQtUf5q5YYgk0AnSH8bLRxw7q0AzAJaST0OdX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sjB947LzB/pU7rxOUf7RrWgF75giQJJNfdi6r0Zrd6vBxaRWWZ?= =?us-ascii?Q?S4ANUvofN2kVDOX8Sruq6eRvXdFQQxMQWZ7o0+LUm00wC2gMJoZeLPK9gKJ9?= =?us-ascii?Q?AB5TvduX+OuzmVJDlJMXOCETaK1xm50PKUdgNe6QyRnMdYzli9kUw4ygMFHw?= =?us-ascii?Q?Gc0PW62jJdJFKGNCudQYJrYjf45AzggZT4q9srrq/F1KtNff5nKvg+4ZxeEm?= =?us-ascii?Q?lNLmvrlKimqqt7ih8LKwDC0Zil1Qb1HnIhwJWiyYsghUCfiSeVkmClJmMMMg?= =?us-ascii?Q?mXl6j9ZaW+Jh8v/kzd40Ib7IsyC+vBjcowMfERbonUo89FaFjPBc5YRQFTAD?= =?us-ascii?Q?41cQRezr/HpdbkIPmKneWOgeQslrt2eFHHFTN2gTpHcmGpKqRPD2zwF3V/G2?= =?us-ascii?Q?QyV4JmOIvbjGo/G5v3c2hCZoLD3dR2EZwX75LlmK?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00cb70dd-71b7-4272-1205-08dd97afb55e X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:07.6208 (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: ohCzm6ExgTyuEfYX0Nn6Lw3bHAMD0e0jZRi0x+lWYuO6hRMgapb6bzNJT4ShQXeHhG04biJuHrk+6I0F/Fn+hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX2fAyHOlgp/p+ tjJr1cNzs3jNaQyPiCNKTNOJe6cC/04C+R9P2gc2fT2qpYM/Czjn3kl2x8kRF9ap+fOHlzJni+T 4r2hJQyXwRyPFJaUI+3DzgVOnj0iyGbSbRv6c4ujSqK0yjA1Zn3KJzvUFvccnDN5hvxrSofvpQv snHHsx+bp/ilR2J+F3vdVC9Xk/peAV2+3ZOVvM49BHq8FEx9ea0l5CV9/STFkRb0ejoO0so8Kfa L+sjgzC6YCI8MynQk4Dc10SXTcuBfz6PRs7kR1WEARHF3fUXDdasZ920V/qxt4BClFHUkV2IZpE TOAyP/O2paR8VsV/9U9Nb0CpU3W5FIqMLa7A11+NhvurRi06Vz08+mnuI90oi9jnCkR3z7ic5Kl qSt842u501T/B0UvQ47+OEth1gTRstWUQwDjCnnNZXC774ZM9399rkZDHP91mF/JLbP49AGQ X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a25 cx=c_pps a=6L7f6dt9FWfToKUQdDsCmg==: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-GUID: nbUbChhwrvkW1Rm1jWVfHpVLW84Pobfe X-Proofpoint-ORIG-GUID: nbUbChhwrvkW1Rm1jWVfHpVLW84Pobfe 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753805276116600 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 391864412c..3dfbc33c52 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 Sat Nov 15 20:52:47 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=1747753890; cv=pass; d=zohomail.com; s=zohoarc; b=DMygroEm7Sjr6tkrSwEtLD5+RdXVk3um6KhUMFBcUOSP1eA73NQbr4yMG5EpVOMrP+VdsaR5QXh6kasqSyE8BgpnC1sYOCjZCP958FPqlhoO7vLg4Pj7M7q+4lpdJ/zbixUeOTuq3oziveGX2b6hANAcZTtLbXlRyfgdG6lhfGU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753890; 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=h+WDk9DABRezLSAqRZgaGWT9mx7IvcgCi84oGu6kTXkvPNgdBzT+zd5qCqMTwMbTpGRAxLGKSQDqNgN7phl6EqLfbKJhQXc0NQkhWyaAYluFmq6h0kP3FcbvjkuJKPGeUhfhANbfrsjo4RIS9NRQdUA5a8s/BXctPFN3CPe9oc4= 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 1747753890813593.6504656827738; Tue, 20 May 2025 08:11:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWt-0003Oq-EM; Tue, 20 May 2025 11:05:19 -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 1uHOWr-0003Oc-On for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:17 -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 1uHOWp-0002iA-SI for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:17 -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 54KDvnuU022299; Tue, 20 May 2025 08:05:14 -0700 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46r0e2ursv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:14 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:10 +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.8769.016; Tue, 20 May 2025 15:05:10 +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=kb/FeNoo1CcotQp57T0MvGvySwM+CqdA3EZTS+5Qz2g+Ke/egtV3o+l+F hPfksQsEXefwXf8zr0PdO/737j31MIkgD3/q7+Ff+uBIQHQePtoCg1F5nkyGp0Z5 /ZtSokT1s5yafMDNkuofctEVuzexB8Mk66BP1z9bnUNwZvmZ7FiYuGD25wJaAwKB K3TepFupVxbZ1HFGvPNxIJDm9oJdewEjsYUYfWgGxFDxQaN19rVcA6uQzW5gjcP3 OgYIT2JxL4H+jo8FUVGTGYGrWWJBM/wtFmRCroM8JgnQpeubqyRQblHEOe9mXQMz Ab5HUCGm1QvZ986ItavboMWeSxtUQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NUE98L2nt3H7jQdpiK+x8IGUoDj2CJSpOK4RbqbcEMHEULIStHB0TiMNVA6Wlky7rr2OSdOkkW0By81bAHjdnhkNg9XfS8nGioOFP0y0oAJcP17lvCL/3b14GxOxDCxdS6euqe81BLcgiHoJNtwvgnhcSViTptBeR/ClMEA4A7K11D/l4rlFcQxf3riIsu0tmqZwEqd0ZtGywd31K8d7PGPGM0xk6r2f38ophxIkuLbBew5IYJaE8zHUAS8+vjfivwOiuRWzrVEXG7ND0dS+x0j1Rld6/hzBFJrFEH7QcheauGUByYQ0B+hckS/Vz/KCHeKtL8UTO0OOWPx0yKF6MQ== 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=moAqZTMswJ/O7Q2a9Jvs4p0SyjcWWly8E+OANqFyve4/eSaiXiesHq0BN5rYiC4UKoUfSeHqjek7yxWSmPgz6EDm0dNUxF+dmT9M21JCRwN/QAn9i3zfY6OZqJBvkLJ8KlobkpdB12NYzlG4/m0tb+ppjxYMWUGEkWzzmEnD4lXtbTjimd8ApgFwZj2asVBTwOCOhgxQG/NVvPK8vhG9yrt7gwmNkX5PUdfsIEzP4Lzy/jVN/gy2ZoF9AiaVfpluE3BVI2KfeyBnuOxytYl/OC5YCXrYx0wFbEeJNVi9yDj0jXVZK+XIIhMemScyO3OQvvXThqaZMiPYKzQ4kO8nPw== 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=yBW9R0uWxIHkvM2NDVr+sEQVW8i7yg1opq06lYcex5cncMIoDzlglEi5Xe9bhcCjTSIPtzQnlEg5vPFW/NcPdgchTTRro9/txCbBdGpu5bPJJh8/gb8c5eqXCRhBAj5y5+geMeIi6mAVYKPPgWU+t5BfpOw3N/BlmJfA6tesMgyv2DQhRWoK4oLKfBDNv9SlmhJP5OWM0ral4EfZYF9AoieprRRdVausvlkjMb2RPZjCRKWtWwaS4aupyMLLqcYY73+niNs2gBGiEzVpwroaXytO8cW5IRpMGYHUjXKNqz0+4ss3EgXINs06GcnMOpALZPEplr+lUUUZilkaeQeZHQ== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 18/29] vfio-user: implement VFIO_USER_REGION_READ/WRITE Date: Tue, 20 May 2025 16:04:07 +0100 Message-ID: <20250520150419.2172078-19-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 77cf9e9a-3ad0-4225-555d-08dd97afb6e8 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Micros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bv1ZVd0rXjqn8Vwrg2YvRBYCgtIIiRqJfR2UIL9x8TTRAzaMO+ntc?= =?us-ascii?Q?Jq9hPGaoizy+7C6Y6R4F0JzWci5H0rNVAmcv3dyZuprsQKskbjvs2FhKhtpX?= =?us-ascii?Q?gbhxgVpozkgMjRbjIzCAGaIeRpSq7SF040JFaUEzrxufvumdm8XgLoemhYwA?= =?us-ascii?Q?1o5x+TuKO0vuXrqatj7C+DzKeM8I7DJrDLcUUNMeybxicg0i4hxrlLS1g4V6?= =?us-ascii?Q?n6S1PmANJVEttWY93b3HBzXciy5gS+ToPhICZ9XZQHhXoHdFINlc6tJyuUhF?= =?us-ascii?Q?brptdiiDQs+CtO6K2zrGY9FlXS9GcWXHn2FSlUBhZyDWrEJAhT/cHzLF9LNN?= =?us-ascii?Q?o2rOEY5gwb/ZB1/VMTQ+ZIkmOu3mAbGi7Ys1d/C8WmQrKaknlhoSfh/BOouU?= =?us-ascii?Q?azVgz8lJFjdbFbXpOHJKqdHFZjYIP6nB+Zjo5FNtPSRTgBxPFFE386SV/hmN?= =?us-ascii?Q?1bVYrGs2foEgiBJaPLt1xQDfoMAPpNiMaThK9ULDXGhdSscyb4jg36zmB7Z1?= =?us-ascii?Q?Vy0d59l/9AzUCX6kNqt8a2hzJ5OIQ21dQfVlqdzVqnnLhDVUDcgGn9N3cUe6?= =?us-ascii?Q?2wsGE6xMwRw=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bR7r/o3znMrjTVJMF7lJ9m2p1QZ+ps9Qx8NPN2q9fZEAbcic3VOWTM2uARLU?= =?us-ascii?Q?fn5/2cFZI/2wef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m7u?= =?us-ascii?Q?vbjR6zvXiRwG6Q4Gu/a0+vHQerLGRZVP0Drm1k6MXQbA24V2xf7+DFAekiEx?= =?us-ascii?Q?cHtcJHT2bAbYyPaX9rbV4rGDzH65wwbZ41Bj9yzD216EpuaHQX1nUHBNugAR?= =?us-ascii?Q?PGeA+wRwZejoy6po87wyToRo9M6HjobE594uqMoPzGqg4UYRhmg4SzXKDb09?= =?us-ascii?Q?bQDYx0CIGHoa7AldbL6/lUH2xKpi3w7F9gS//Q0y7SxN5jbnQWs6DmDQ03RZ?= =?us-ascii?Q?IiL/TcnBcSG5n5Tk0z71npaMqTK8CrEYCH7m82n+Yg08HO5lvTntnDSB6er7?= =?us-ascii?Q?wReDX40cm9Y6GvEwVitqAXM66QOU70qWav4oXgRmvsxmMeXFgVEvEDR+S7z5?= =?us-ascii?Q?ned/85os0fbjQo3iXpp2CNQeHv5Ymm4Q7MDsRuHSzzp889ke0kD6ws7ugNhJ?= =?us-ascii?Q?Fb6jgymcuyQZB/cQqmKP0V0Qb0SQqjj1Qcu874OMBkL6ZeWKRP1i0ENqch4r?= =?us-ascii?Q?WvFrqhTX+33vJd4rzWwbNqOgA77opO63qto0+sMqZvHMLyiMp9rRI+pKKpPF?= =?us-ascii?Q?xUg6iYO314YCMKakPkq8Q/w+kCUpCt1ehqPLjK18qhBOWfVlHXUywHs49Nr2?= =?us-ascii?Q?Wrtp72qukU6QIAr8HHsVW+SJK25i2BpYXKuozxM+?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77cf9e9a-3ad0-4225-555d-08dd97afb6e8 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:10.1560 (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: leI4muhZehWUV5N421VsvwG36RE2mNWAiVHPRf3jjlqcpxv/9wODXZTkK9jxcPF+suyrRVm2iNdV6CKSobeRrw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-ORIG-GUID: HGij1N11dFG6mgs2LBdvOzzUiyju557Q X-Authority-Analysis: v=2.4 cv=deyA3WXe c=1 sm=1 tr=0 ts=682c9a2a cx=c_pps a=AuG0SFjpmAmqNFFXyzUckA==: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-GUID: HGij1N11dFG6mgs2LBdvOzzUiyju557Q X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX73ymiUdL7l9n qeqw78yvjKkIaTICIfeeldjeN372uM3g8d2hHm4+uYf0gybzPoe6N6Ng2Awl5G0jmAg/oS/XJX8 QaYlQWt4BUPIGbpMcII0XVfT5GHSKoucoxokwHOGLzczSQnOkYQwaUkdalRexZ9GK86oweB1wtu 2+N8buXldlQKN0tpBVNi4b/Yv+pviAh9GLk6V+5UKHsdU3J9qtRpnfCafb98LPw1PCvgQOefrYc 2s7nACEwdkd0pA/G6jKYdxQevgKUGfyZeThXlIi8MG9a4f713nfSaArMrZGCslFlqXkm2zp2BFi cVX9UbPB9CGHEyb4/xyPcTVsJiuUva2lGBmzksG/o4I/qYKNjZ/lEeFiDrpgiNqrLsOOxhOSfRX mv9e9uOewrf+9LDkXouNrIdSQEpc8IpjOve/cXVdBuVk3xg8FL1Ot1g/69lhoWRAzO58HcLz 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753892718116600 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 Sat Nov 15 20:52:47 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=1747753576; cv=pass; d=zohomail.com; s=zohoarc; b=lRp3ljFZC37M6N+itCWwnk1MDRsDWAiqGm+OxDKfOWIvrgDxuCGGyJwpAagSBAydX09hFeUHKHIUA7bHzt6X8COf0PbOG5A5niFVkT3Nd3wGtTbpzDurm2Uf5FXpLRJZ9y3ZooPSzRxu77AlX4bHHx6rIIOL7FxXg6rrzZdEqfQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753576; 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=D2KfDXoz36GvTozb9uD8eLJAsTvhv+Uhiu8xE+c6DQY=; b=W9DwUzbNFw1gP1u4Akn6ktDaqwHvBDXUvtYF/6R90WV2wBCf/fiqU/DTybP9LTMwr8XedgCVnMqAv8/TvvE8dmEFx5upNj4XPSNHtuxiaLiqic/F9wS6lWFfaUMb+1DRcsn44t05kd9wRWTRUnLo35lKr6ykOUevKXFyjZl+zlI= 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 1747753576372785.11958767648; Tue, 20 May 2025 08:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWv-0003Po-N7; Tue, 20 May 2025 11:05:21 -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 1uHOWt-0003PH-Vt for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:20 -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 1uHOWs-0002ic-9E for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:19 -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 54K7HZOD032326; Tue, 20 May 2025 08:05:16 -0700 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheae9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:16 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:14 +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.8769.016; Tue, 20 May 2025 15:05: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=D2KfDXoz36GvTozb9uD8eLJAsTvhv+Uhiu8xE+c6D QY=; b=go2ZSbJXB66Ysaesh7WnmbLLxGn+WZ3EOk9GhRRlgoT45qKuxxBeRexK/ d+QbkDsehxy52gUZjnR2cMmzbFt8uUrEwGV3T0m7NlxvbLbR8P0hgifD2b8d0jXm dZUzDSZzFJCrKfiq3PrBRv1V0Ay9u2514J1ImZWAeEHXK+MpPWGJQkjuUWgoF6GN Y5x4jLyDLLtTImhZRBYDCTTH9ghQ9QsYrOw/ac2z6Fkjbml+5DRuGL1x3iKF4zIF T7Hj+gQs0sxzBfj4Fb1TPUFKPbuCW67XSu1m0QEZhAotCZvOo2lQZS1iYjsSP/TX qyktYOKpp4qk0dbv0qgBqrzyWJ9YQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B5mXx13EjeagT7NiLpT1SyOKviLZX2FMGhv5jtHd+9daRqoimU0edz8F5xZzZyszLL8lH6kgGlCLgqh/Sr9BoJHgSaLQbXZ6zodil7NYs9Rki/xHEa0rzw+aj3BnUz3xCpuw8lurl30vg4hIfZAGqTSyFTIq1Cau8rZvPKwsFQ/mcHIyQ+88CqBpUIOWtKsgSKJNKdW0pGcjIGAjZTFp4QziEZ4IJujLeD9tsjF96B/cUYhX2DKlpZRNv2D36A0cEeZ/ddlf69mGKyt6T4SHWh4tghBvFOwnUeiE/UEdHiZqyzvUF4qFiP3jXY4Ag3ZK/QcatTulboL7i4FGLRiT0g== 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=D2KfDXoz36GvTozb9uD8eLJAsTvhv+Uhiu8xE+c6DQY=; b=SdMLRxIWabSajgffl5KWCfT5lkY+UHi2vqP70xH2z+WroXPo7BXyyX+B9DtYcZ1gITGm7ucmCHh8yYe7qpnQlB5h69Icdpleab1oQTAIHgitGGqogEez7IzkjRK6Zw9DQval10YNx0B6nxBcWQGpdo7el3BR8wKHPqc2fR75Zw3+KbJdb4QYiWc+TIJW2ZVzgEfohwJ14kJ7ZIUfuEIH8KVMsVRZYEm8gfEB5dqjmVS8uSg8DxyMvBU7gj4BgQuPcxWjuu6P2d9iszZbS6fTQlAtSzmRyB5LPBrbBqnd1IYm2wsUjkLF03435fnGQ6ms/2sOXV+GOx9yeyMf3/HvfQ== 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=D2KfDXoz36GvTozb9uD8eLJAsTvhv+Uhiu8xE+c6DQY=; b=XOYJSI6C0y4Zll19m0KWIV2lKZwPTReumfShEe7jVzAYEdq39GRV9xp5znhSsRZACAznZPBHZFCwukWrXW7xxaB8z6ypFT3NIeaoDKVZf368lWvgdD6mS42YxmHSlzY1aGqd0ekxvZ3C7ZMOAbCm94y7uZXgzyn7ywQbXMszz25SVfjYKPMo485K/blphiotijSyIAnnduTTKqXBTqZ9pguJWrRZ4whxMmbAS1dGZPiUzSVFrtlynmmJonogbp1flcZksKullEmqI2WIMCtU8BKMnkshv/Sp2gmVl//kioGCOKPMzg/jE0IL2WP1rNxqGVrrMZ7Jdxtl5qIL9ssSPA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 19/29] vfio-user: set up PCI in vfio_user_pci_realize() Date: Tue, 20 May 2025 16:04:08 +0100 Message-ID: <20250520150419.2172078-20-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 09e2dd07-821f-45f5-f948-08dd97afb86b x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?J1abW10EYGjGw6f+hEGn8X/BGe3ho5yNAvI+USV6x2CIw/UqAOxuD8an8l77?= =?us-ascii?Q?A63um+IxPsExUdK6W9E0cvYJHLgXvA5aKFDhEWGiSxTA0tLBLS2VHYE7+sf+?= =?us-ascii?Q?U4BZUiUPMvhHFL0wlJwW73YhtI8b58PuxA/l4kCa8TPQowNPRrza8DqyT+ip?= =?us-ascii?Q?D46AnA7PbpQrJVIDCnL2xr6FRr4S55ejX7IrloZfO57hkaIhik+lFWsRXhE+?= =?us-ascii?Q?/faXp8KfrlzZz8WWW5y2jSsvaSZvXwFgejeMVJzjqsseiABBTlDom8ENKQz/?= =?us-ascii?Q?lyL4Qgk4woO3dtjZyUW3awYojYu/uX4023fIFZHLfsQnQqEiekR368HfgAMD?= =?us-ascii?Q?GAo5bgoza+a9TV4tOdkiWLxAP2etMYlvBqQSUnJfMBvI1Fq/6AiPSuNhmjKo?= =?us-ascii?Q?wXKuLwMd4OncuTMPK3JYD36oKqWuqaXofMA9/I1ApRscPspYMM8tNpqPXe04?= =?us-ascii?Q?2O8jI1pYQ5nOx3gKNqDvmiyac7tseDFoX4QjWbf5+F3cEMtexQTjUZBBCHM6?= =?us-ascii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vYl+zgR?= =?us-ascii?Q?JD4+C1smvjU=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GQMR4kvyTLgfWSHAmZx0MCXJKf7EGMj0LIhclI31tDAjBTuqnX8GmJ6u/+rF?= =?us-ascii?Q?dOMrEf6LNdEFKoh7ACXCm2kolTMhUZirbkvqlmZ7hqK+syeFLyoRlHo7j9eH?= =?us-ascii?Q?NWeFXkglm0KzGm/wOsEL5y467kQQrolcRjmwaKnheQ25tg+gTh+aMKsaXOcJ?= =?us-ascii?Q?Zx2iF3ul3a6M/+uMyP7Db18kWUcwYrhEOAs9f2HkljtNagcFbyvKljd+Rgk9?= =?us-ascii?Q?6eJh/rTd6zKP43ctDSVVas9qTMRIBZDl17ijwfI2tWyIiTvHvP5FG9Q0cFnf?= =?us-ascii?Q?5fvT9d5g8bN9JbzxQ0xm9bnyPtgph9UvJ04GlpQiQ7HzqzCjX0ZQoJq59mO+?= =?us-ascii?Q?qyqpMKQzWhskuStGY9HdaCtAG14cB4NytWw/nkqzzPIzI1vUaAPqJU+NAV4J?= =?us-ascii?Q?xxiyjAxPP8Z4zi19Zw00PWtzStY2KxvV/LNMBhdyoAFKYh0n+jy5SjwKeReT?= =?us-ascii?Q?Hiw1mqoulOrF0oD7usdRIG2TCdjlP7imK1Q8v6NPaYRwOdeWrukPoPiGF+Ft?= =?us-ascii?Q?8nw+I5YF9gnDkUZqIoXxEUIZyzRt5MXAJEH7Zx/cydsA3BHmeO7SaVRzvT//?= =?us-ascii?Q?sscRu2GqT9tMwS5U4K0oqW/cqE1P9/qBtvcGXGuYwzZqHPq/iz9vFQ3MNdkE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x0tnBAfRKkrbU4GamNpZzQ0aILI?= =?us-ascii?Q?E9G5j3MvmS9k360EWuIIjDmJ15en3XdBYdfq0jds?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09e2dd07-821f-45f5-f948-08dd97afb86b X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:12.6894 (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: OkncICB7EfNFWRrXmjdzyohdSQxdY+BYkIrnncTqeYvzHEqqP1eSxyaL3VBO21ZCXDtojyj1sq2+ezuT16acQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX/+E70JjwwciH hJlvsD+cS4Lss+gsNuF9NQQrJPqcaC9BIo+iQy0rumtMPUbyA5AYt6WIxCu1WB1AVA4VlR5exRi 8wJ7dl5HzEdHn+GtGAAt3ax9+C4sv5tPG76yiZkdb8na3Bq+qFv2zd3ckw7Qw5hrriELLlp70vk /BpBuWSnWm3I7RHTrecbWZHa/ewjChHk4BKeATDX29XmsUDd7Pw6wRGlq1nwY+3k/9C2k3eEsM8 azG52eMIVrTNgAj+ATlHw/6hHKvFE6CMzoN2VXue0X0dwGCBAkQ2yqwWOpdLgSX1rbW+KH+9rWD 58GdzPf84gdMCMRd6vebQACmfpPTyrkxhD8GpotEgTGIquVcDJSitMvhOuLjIb9I5wExykXL9F8 +4o8/i7sJwRtrcXUmLRbmSCRmF9JbDZjb6LXgY250Q8rXI1UC81wSko6EJfZSZ1oBGYZES2s X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a2c cx=c_pps a=hHPfuxNGWHHq0fQgDGst2w==: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=uN1uQ0dK97G9gywtELIA:9 X-Proofpoint-GUID: jC-gMajbju0LevC2RVRTRuVUBLhE7He4 X-Proofpoint-ORIG-GUID: jC-gMajbju0LevC2RVRTRuVUBLhE7He4 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753576889116600 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-user/pci.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/vfio-user/pci.c b/hw/vfio-user/pci.c index 3dfbc33c52..481c6cdef7 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_pci_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_pci_add_capabilities(vdev, errp)) { + goto out_teardown; + } + + if (!vfio_pci_interrupt_setup(vdev, errp)) { + goto out_teardown; + } + + vfio_pci_register_err_notifier(vdev); + vfio_pci_register_req_notifier(vdev); + return; =20 +out_teardown: + vfio_pci_teardown_msi(vdev); + vfio_pci_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); } --=20 2.43.0 From nobody Sat Nov 15 20:52:47 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=1747753798; cv=pass; d=zohomail.com; s=zohoarc; b=HpTxW201iL9lOZfF4q2qmvkDtrWyWutiEK7jbc5DEtEOgioPh3JaIv6ukEMIPJ5MeoFLOVeKdlaYCiSeYdPbVc+HR2rzLNcf2kWBARuySPo6WAVc0g24sdRnqiFJ2f19fyDG177Z+tGx9XAfs33HBKn2aELp7yu3YWQyGwmzwyI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753798; 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=VsYuIx+11ZxUf5B6M42OJOCO7Ge6ncnQa2d/JYJayZ/jYEzkL1zbjYT5BggqrdQz2oTKvzT0VsiaPFFDFLSm4mIcgWx6qWwxyxcBodfduAF/w8cP4dyDlE3TghDwsbXwXjNR4iGoYoGhq376xquCdxG7N9/ew2hFEtCe7sq2/lw= 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 1747753798899351.93027192590625; Tue, 20 May 2025 08:09:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOWw-0003Pq-EJ; Tue, 20 May 2025 11:05:22 -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 1uHOWv-0003Pc-1D for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:21 -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 1uHOWt-0002iq-0F for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:20 -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 54K7HZOE032326; Tue, 20 May 2025 08:05:17 -0700 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2177.outbound.protection.outlook.com [104.47.56.177]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46prjheae9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:17 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=gLSKAir9CownbVZp50Jw3pkCn369NuhHnd0TmbNav zo=; b=B4HgyPbk8HfkIG1PFpT3vX3zaVv5X12b/VhPQObOpe5JTA/3KlbQave5v Z4neIElMC5uba+t7vEHk/RBH181LDCoIVyyCx3YzqeteGxRbEbzs4zbz2UAqKQlY puLcU8mhwOHfjJ5w3Tl3Dq3xCgGWAp2P/Y/uFXrFADVoDq9y4U72p1ViyHqr7O1B xp7E+qi+bYizgReLN3QhzfmontvxWlz0HfZqZdvb58i5gDlaGep2kRZK9u5crRNH mjXkfBW25iiFbZ3XoSMrtfcbYsY/3axiDdR7JCD9h82XKkNEqPko3js9sdfuQXUU RyWg8E67rFh0eKcKqjJ3ZJHjTwo+w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZUMOzksa4iYcZiG2QPeUzztAW2JWcA+VuAjo0Y55x/IyzBqvLxu/Uerc1dtY4JuVNavVIYvUk2iyiY1iGVywfbAiZI78xFUrse07ekKImA0JYwbcwZTmt+TR/z8Gwaholv9wM7UkoQfseBjPbqSXzedmcDcJznwNjyt3Z0WH+cQYMP6oM0521nddBJ5gJpThAe4/YjlY5Os0heBz9BIuew7M9pOBA44EbALPtt0kHeycuMYUPv8O0/xPm5K4WFn9Uf1AiP50K2/TQkVDabI9ThTrRp4mEB4chUfYDNLh+NjKd5awXmjF06c5bmC9ydMWPe60DcSsrZVM3qV0CTSW5w== 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=VYeCafx6srkqIcXjMO5u44q8tGTJ0D9/3uyDmLLsnbcubO9Vxzgu3ov7hpT7iaTOd0nkVxcOcGgGBVNcHdXXvn2pcegCF0hNqK13lrzcsIEjQ6o3Wzfdz6VjNf9BhYGV90JR2URCgKXZLXTFWAZiB5GLku5XO7lSR2vSANLFBrgwDW5SQt9A7sEKQRQ9LUIbvhXzLDIQBesJNo2eMN+CDlNms7/J7rpLzz2vzpmQcJwpJ2uuBNNyElA1n88ucNoV1Bo8jNECeqLtcflGa+aRIhfBEVQ6x+W78Hk7YlMA6OqHyLww0olojhUimi7aRFey5RZzVTAQZL0u1Wr+3XoKdw== 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=xXjQwDbspKU8fHpzj3i3aFqlRyB6POoXVLW5H1X1Uc94wXn5dNYOPv559lYjTxmNDI12ZAPedwV12R8fCyXL4XO4FwXcqmsIsvEcQzYSPQBo5McH5BPjCwA0V5dyFfyee9+Xs2zV+iNskZdU3p+ixtVVzXxxdzvTP6wwpdlps+1t2MjKMndPFkwwm/RJzsiOk8myYRw1IaW2hZQ7VZ5ARrOFN/9rPxKEhcynBVebiRjTkbOhpw/K9k5n3LSvbsvGk0/kkcypAOc/aA1t5lNChPfLGNq2U/bGRhiTL7Z2n1103TCRwONGTossL6XFKhcMovC0xOYIxYEGpGl8PRzsEw== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 20/29] vfio-user: implement VFIO_USER_DEVICE_GET/SET_IRQ* Date: Tue, 20 May 2025 16:04:09 +0100 Message-ID: <20250520150419.2172078-21-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e35ed78-0905-4b09-ada0-08dd97afb9f3 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?aWYdFvedFeik3V8ysjqJYMe11F2wd82i3oe07WdJIlQh09jQVuGtUsZB33Dd?= =?us-ascii?Q?BUfZ8HnJJ+wVM+D8PqQVCDUssONJiOU40ka8GUhm26XlzwagYI1T3VfBNUsz?= =?us-ascii?Q?fQ7YqzQU4aI+C+vaKov0H6UKVeqEHzJSH3K2BrZdA5YedIoDsyz4OzKMzbR7?= =?us-ascii?Q?XyvDZBqmM5oQrmFmxNiANBTtbn3+hpNGH3Zo8PAqHl8SxGZ7ufxLqBuD8+Cy?= =?us-ascii?Q?vjzAVUQemC6GZQyg8gga6rqPju/1ulraWFUJ4LmJtqCnFRqGmOm5Cgyzg50x?= =?us-ascii?Q?8vMvxSlarJ2myb9I/6Own0diUxtEP51OXpmO05mhfNWoDXAXmy2xSW9Hc4l0?= =?us-ascii?Q?4tepo1Mgy2IFyZU6y0M+qhzz1jPHIdU+SIWcXBm/Yt93FCZ3BWuBhqftjRW8?= =?us-ascii?Q?NYy7KJ6FG0aAe3CNiTpPX3UAT7UC/mcDcePnsrx6O1giaDZiDzkAlN6orpp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jZOhHSgzCwTm/KM5XM0GpmDvBolh?= =?us-ascii?Q?OP18Tav9Qfq0qmLRb4qgACo+9Rly6dwZOZ4Ii0NpJ1iW/ZYDYA=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EV5J6iyJkjJ8junbpnhGYIsi8Mp7QwhRZzpEQOwk0VuokF2w/SBulNn+GQMC?= =?us-ascii?Q?Dhi+3H18A/0dpc3sGKP/Aqw6AWfMf5dL3GAMakHdunoDuhFHUsERxc3j9+ZQ?= =?us-ascii?Q?EHgFeOLAQjZy74784boZnf9jNbVsJK+bV6hcjOmbiv9R5qlO846yBGTJJuNZ?= =?us-ascii?Q?ZoXR8uDE7wjC+vjLW+OPH/2ZWKMnVCoXK2Xr5KVP1IdxwIeDsW/lyB2rqfgK?= =?us-ascii?Q?lC+LmdK4hvj0dWJwy2NOxpnIJoJS7dWMxLFEbxq0UNqo/IfXBQAF1KsQA2ZA?= =?us-ascii?Q?VwxS1cQzyn4uTxS73xOOEMir8XPwS5XwKaZLLHGG545p0beImgZy+HcCyl0n?= =?us-ascii?Q?KKtHk+0UDio/TAyGevs8PJ3V7FcycEnBgRmDRx3TgHfJT/nLsJft/jMCUnl4?= =?us-ascii?Q?7xAgWdYIC6kASrmw+RivzetGgBnfZh6WYpl1sLuadwqTMWKoHEt6dSRW20iz?= =?us-ascii?Q?G+I2bLKH89Uy2jpn6emW+8HajNlTQJXM9pK8xwlxPVYM9byHwBZoTOoaPb1U?= =?us-ascii?Q?5Umvn/mtz1/z0OMomuxcp/hquZMJ8XsPWhj17IPwuuPIOIGONZwtcg5s7NYh?= =?us-ascii?Q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IVzhJ7v1ohBG6P?= =?us-ascii?Q?0LAq5ktuPrmInwumLZNs8Z/KEpWIpeHJWdmOvASMA10/qymDuBg8H7hKYATI?= =?us-ascii?Q?dzcIjZwRIej20F6BKTyY4uWdwkxWHByuNINhsaSZ?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e35ed78-0905-4b09-ada0-08dd97afb9f3 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:15.2696 (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: 4YpEYF4s9J3zIXa1WPLaKSjTnlwleL1kis3WsRuy2QtczgIw2fgd6b+YrKh5lcY+Pkjry+SmhL21THPvKy2+pA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfXyCu6N87th1+v 2UwoemayosMyF/uTqfrmaR/huA0BZYfZo39yfdE1fv8bp4GOt1JeAMS+lt4cR3ZyUi1sMkataHv 2ES2nAxO925ZbNy4BsqWx2aIWbVFxB9W4dA21Wqp8J0sY3In1vLFwS6EA+8GkVm8zFy6cLMY1If kGsALiWm5F1+pgqdd15+MOzWa6vE9eDSRHbfEIfx3ZYMSaskj0Wx73vA9d/qPhT+qGer5YV/9iA fn7wEj1E44yRQAdmoi4kAOo7RP21G9qiUfHc76WZ91I8W5wt2h4cgIHnRoXVay4z/Y3rHDclHoY 5KPh2EgR3L0vhcrGWkMb9YBcJGxJ1SQ9lAc1LJqW2bUQiXKJhyvyREfEcp50qD7O0nvGqbOYPIh +HZp1r6/juLQ9iYBPt69Srwnx5osMPUrpO+nWetgMfgmy87UIMbXaUiEwjea9Coc3PdHWjdm X-Authority-Analysis: v=2.4 cv=T+SMT+KQ c=1 sm=1 tr=0 ts=682c9a2d cx=c_pps a=hHPfuxNGWHHq0fQgDGst2w==: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-GUID: IPcewKgFqqnHELYkyd2sIXWmCcncNSHm X-Proofpoint-ORIG-GUID: IPcewKgFqqnHELYkyd2sIXWmCcncNSHm 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753801330116600 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 Sat Nov 15 20:52:47 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=1747753879; cv=pass; d=zohomail.com; s=zohoarc; b=bJzSzTAdWHKGk4XmBUGuqMFw/0YIaMV7ZpzdKZ/6K+CuZ91FhIp9VEsjdwFkwSJug1BKvDu58irytcLkRxqLdYhrIKE+0rFhF/gqawMUM3MBvKnFux/ad0g7kWibZdf3U9MDf1XSbasMcy+js8KERc3/AsSSXIOCcyKxCXL0Kf0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753879; 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=lGV+Q473x/KSUpOMLlAkqadRsVA0gvMfbeDG2gYo0Ag=; b=lUbewM6scTlfVRaOXPNTJLvj2VtijhwTB7Yn8EvRgT/VNHo7LJXbUN1twwTFJ4gWW2v03ZYd3BfjXuMeozpwmTMEwdVw7606ZpALcn2Vh4XZq2jsIg+7ziD0WKMPpdxU43A9R4FWGnEUABj6iz1kcE3Dtkl4haSledSZXHLJYko= 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 1747753879086282.54064089973383; Tue, 20 May 2025 08:11:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOX1-0003R6-Cl; Tue, 20 May 2025 11:05:27 -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 1uHOWz-0003QJ-47 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:25 -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 1uHOWw-0002jR-SL for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:24 -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 54K6iN79005330; Tue, 20 May 2025 08:05:20 -0700 Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2172.outbound.protection.outlook.com [104.47.58.172]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 46qhuncujw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:20 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by SA1PR02MB8462.namprd02.prod.outlook.com (2603:10b6:806:1f6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:18 +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.8769.016; Tue, 20 May 2025 15:05: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=lGV+Q473x/KSUpOMLlAkqadRsVA0gvMfbeDG2gYo0 Ag=; b=2Do6t88jAwU3AFI3x8ierAQB4UedxvYayhdtJJwqnAL2Kv8lWyOpu185E u8M4EKi3Mp9OJ9BJOcPXlW+/Jt4thTI5poXFM3RpP1F6ejEaOJF2r7oEZfYCZQhk 8lwMZMpO86kcLT/V6NgW80JnFiNMdNa6fzLbK56lBap8C3Y24m1MHqKvGOvmjVTg kWYQFHFPtDXcnaxGEtQJ8sPDfVj0tAuW0n3cNOymdNlFqe9RjBp/xpjnV75Ozvoc 0QMCzdzJCdvFdjpM4ewxgQ7jbTQqIcz23UwOC0Xia/e+qnwoYDyvthoZ4BbOu2bw 39hJ+zSWt4IWySxyyPeAZ0KNXzTFg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TpnFVt0toegI1fEJLoD1ccd5r5L4fyg6MFB5R31Xccf9EDW2Fk1cEunFyBd46mPEwOtWng0l1DJgVeVF/YaslPrqtU5dCxNLLvSeOgFdYnRMKHyYNqrkyQmoJIlCUijMlU4Y3T2Mm7hYJibKHWqDDtIacAI/bqq4IHnN4EchIn/2/6RbK+gZ+cDbkBt8IPlwoeguzTnJei22mrndJ0zYBFMq+rslk17zuj+hBfLJWH+LPcGPiXkEqQGRlbZ3sI1izfTJz+DckGrzXmPGlPSvlCHa3bVUvYoEHo6RFSU/zU45MzigPoDEjDWqvxuCzNxj1TvHOt55jVU7zzOS/jZmSw== 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=lGV+Q473x/KSUpOMLlAkqadRsVA0gvMfbeDG2gYo0Ag=; b=g9Do0GWqVCL+pH3PkDmV1A1v4vJa+NI1qVfOlRPDdbYat0bD0E83IcNnI7vsSaESHW1YNkWCc74WcPATNsub6PjtcfVbHyamIlVhlvtmqO0AWiOJBW491b04/cL0J+onTl6lXIMoOhOSq5KkLCw0OHFb+j1q6Y7SBylWqiN6sTdidKxMl4manMOTGSE1pbGY1XaQfSN6yQafj8CIz4jK/POhbpBLxRanzJQTgUyYD8v+iaj29ccAgM5fqodnm832ukvdNCnYx+iFP7ANsNdYbaJ1rl/44rUOPX1OoZ+XS83/PTte44S0pWmk8LBCWJP2wiomivkmsHRgYvveIxfrlA== 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=lGV+Q473x/KSUpOMLlAkqadRsVA0gvMfbeDG2gYo0Ag=; b=eGzZRe8H7DZTkq6fNmbqZR6+VmpoLcmD6FTeRGc4zrMZtEO1tTvxlZjTLWMitRFUcjy15cIfMv5DvIR97BtA9rcjx/b9z9eLzvEevxGNPCwTnXS764HOgtgUCJL3eiekXTCEpIoeACRcn2+3fTFBPgwrdXQNZr1bRnOrjpDwHQZXRUcFjIFBKHXwCVsHQMcmT8dyl0G4QJTkgVQEriaOQyJ45Hdnm1MMGI4wbGEHXcOgstMoKXaCjgEi4pRkw5XUXwerec/lzCL0p+5sHEeGUDSsG2IBIpQu+3/GdJRXvRylH2UsQzpyAFQ5pjqJ6Cx+hAvDFwf2XUgBP54YspJo7Q== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 21/29] vfio-user: forward MSI-X PBA BAR accesses to server Date: Tue, 20 May 2025 16:04:10 +0100 Message-ID: <20250520150419.2172078-22-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|SA1PR02MB8462:EE_ X-MS-Office365-Filtering-Correlation-Id: b258a65a-96c0-4d02-f7cb-08dd97afbb79 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014; X-Microsoft-Antispam-Message-Info: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YYZVvJudfbk+sG3VoQwNJK?= =?us-ascii?Q?0FVs1ynKszNOmHv5xcfOTsXXp6mfsi48XIS8dJILQaW9IU7RY2jUXkMYUss0?= =?us-ascii?Q?dem+fa2QJGZlLKm1sy3yeX/ilMoKZl39opUZGsQprva1ixVfQKEu6loXefMK?= =?us-ascii?Q?8d4fAaHWyFue10GPUvKrCsKiGHctasbhBYBhH4QUJsbCgDxk8JjQ6uTE0/XQ?= =?us-ascii?Q?ZoUsjY2YdTRu2ufz21DEY2Q0UUZPtXUZ2g77atEpQcivOc4stCmOgxagKy8O?= =?us-ascii?Q?8dD2h1v9/zTV2UNFSVwOIb6n8BaBF93ox7mxd4Ozwm8LmVdCS4llISWMcpgo?= =?us-ascii?Q?QnlAykUwI7YcWjKXT/tSnjsXR/DWQlOSL+NXBQqR9JQ2XukfVWrVpYz+OpG7?= =?us-ascii?Q?SgaERKbBEhtRwXMFEfM4xabs11ewsKrHJOhy22a1EAsMxYM62MmUCRplRUE8?= =?us-ascii?Q?9JsDI7LfPqk/Vjk7tnB23w49j5ijSLkzNhleC/x/eDWasUnfvWzKOywrbNO6?= =?us-ascii?Q?mQy4L7X3QKpy/RXpuN5bK3w1dVKWYUvK2mySeA0am/Oox+VcQ225K/Bg9VDU?= =?us-ascii?Q?qfp/Y4sCTBE=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)(1800799024)(366016)(376014)(7416014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?tidUPTrleo0pB2bfeD8s82uvXsiOxChSi9XVztbLA/tofMSNNznAZfDzYXXv?= =?us-ascii?Q?iAmyzthZhnLPlhyVhaRYlW6bPYFDrz4R2+ee9Hw3skY1fCMaczqUmiAChiTF?= =?us-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CZMHIPUrFS4fs4KUh5OgdJc?= =?us-ascii?Q?otnyDZIeTAo2oOzXYO2JVknYLM0jw5yIM40ATnyCQRKIgqABFL7Xe7uW+gnQ?= =?us-ascii?Q?+gtO0GiIiE44ZsptdKZDyAOVYShob5vezsvqo+byZTvdis6j3rV17e9FqOvs?= =?us-ascii?Q?/FoYW4u894HWI0zZhaUTpcp/ejAQBdlZ2gXlMgrKIEZLCnIO/bEzYPDGO1Zx?= =?us-ascii?Q?QzCOJClRjxFjW37mknX6woWko6LtL8cMi4X9GsVMoTdi3/F5g3GSC2tE9/eR?= =?us-ascii?Q?zTy48Ko1XbWPQI8YKYVlF06M8l8e22xgjC9UwgKMvS+1Xa3QUSiyfNT6n3vc?= =?us-ascii?Q?xH6QR+Q/mPlAeOTAGsz933uE7J9b1ZKvtUQesijXyV45fdW+tbMiMCCLJdXl?= =?us-ascii?Q?4wpdyho78TNrJ8FDwnsKSGrE/JE+3Ma6jilNoii48hpyc51370RXPOBt/G4d?= =?us-ascii?Q?OV1zHqrfTjldLP5pOfQCXa6rn/wTbFlJT3obqGBtrlzZs+eaKWJCHRQdwKAf?= =?us-ascii?Q?4O5Qsv3tb7iR21TGragk3DYN1OE0IXboTkslFUIKJlwZTx6dnwflREJCS6MI?= =?us-ascii?Q?3qz6SMV2jL/oFqxUhg7cvDPv19RbK+7SznC9INzu?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b258a65a-96c0-4d02-f7cb-08dd97afbb79 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:17.8928 (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: fzOizcQd8r+5H4OY+EsJMGvgjhH5Qgu9GUQhH8woxxbAvF2U/XRJlTEHrk/IgTrovntgZguIYisqpcl3FufoTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR02MB8462 X-Proofpoint-ORIG-GUID: 0_5vI-ThSWwzb07u8wKPFdIZl4m6WJ-l X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX0SXQTcMR8rcK CPkM82RzrLKbG7CTloklVYBySbQbQRfbxVMfFOLhFnVZaqJ/fxHt0wA0s6lg10ReERtsaAwA2bK OpXb99H37aGxGzc0js3RGQQq5Nx226amQmvpehe1ARQyATtSaQPnu4FLJmTz5GHmaM+tNcoBBKo NNVGzxTT67Y93jsMrca+B6HfXNwwqWUKFvrsdGbfT9p/8HV9le0YNPG6KGueVirYmsvpGJDH/Re 9CCAfr9o0899+Fv/2eJuAmF+UYaIRsZ4vBrHeRODKP4tbW4+dzFdrVqBAyCnvFVU5voZlSVYaOf PJDdk/Q8yZjAivBySYcTemJOq5prXvaWd0ioGmzUArYDwC8xY9V2iMbQr0gJOWYd69IL3A8KUel XqAXMlkQbgT2r1jNp4sR9uOqZMyGKOUs9mZetrWdWWNm8m21ruBzIfCtJJ+sj5HIQnGUAaYk X-Authority-Analysis: v=2.4 cv=TqPmhCXh c=1 sm=1 tr=0 ts=682c9a30 cx=c_pps a=1OKfMEbEQU8cdntNuaz5dg==: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-GUID: 0_5vI-ThSWwzb07u8wKPFdIZl4m6WJ-l 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753880624116600 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 43c2d72b84..434d73a1ab 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 481c6cdef7..5904e7ebc5 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_pci_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 Sat Nov 15 20:52:47 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=1747753927; cv=pass; d=zohomail.com; s=zohoarc; b=d/S70WiEAtYhZZr9864vlZwTHjVLGyRvCstWhbyFsa3o3iLZeau0Q0cx78ggY6Fc/cRAr0BYHynwj2I2wHRUCEkU3LZrTp1MLBqSi6sgR78Rv7i+Nt0oP5W8riuYcjsGUObi3qF6Ggj0VnwkAYk2lUtv6IWzuXBFZdtbwNvy3g8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753927; 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=gGwP3KB22o0PDPTVDyFcrGdm2CX3dooHACQxwB5YmIG5niodat+diY92WoXlUzp5KE8AeAElty4qFOj4DAM++v6kL20WpdinKAO8r1N0sY/HJv2VyAPZBVFawnUSzKIXxqbhI74T23iw/Y0OYsqIf4kuKL+rGBu+G3MoWfNjcEY= 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 1747753927240628.3751032824741; Tue, 20 May 2025 08:12:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOX8-0003j0-DE; Tue, 20 May 2025 11:05: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 1uHOX5-0003bz-IS for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 1uHOX2-0002kf-Fp for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:30 -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 54KCUIcA006673; Tue, 20 May 2025 08:05:26 -0700 Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46ppsuehk1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:26 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=le0NKHZtXWjCySeTO7S61i/syVWzvme3vUpWwRiOy n4=; b=mZKftc2xhtgWsw0Y4KY/aFYU6p5z8govRbwFVcKavTY2occ1/Pi68dUqo /+ujAASLr7v7W00wpzur2zABBUpwJ+WazNaEI3YQfbKblIgaq1aNovm3X4L8UO0y X+ccRTAV3hs7z0OB3V4mryS144SSgLyLTM7RE31iU+yJZbOnPZPOlkTjvzOtD+IE RzU+zavli14VOgWB8VQOS3W4C6FnvAa030cniQ9BOCkKrCWvz5ZeHOMN/5VZglRg nSZJ15fqITZirzmD/ZJgYwYMUN1r+mBpMwKQjS94eoFec0aTY4tzTd1ZZiJdJRM/ 2NIwxWN2zRHBI81zayaO5vF5Y595w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GZ/6SvI60ABQWQ2po71vwgzfu7gLP9yhBNoV6+DoEuYOWbmeskD5EMbjE0ZJisuUtung6+7T9JdToXPF/6vIXltVl09p2pO4k3+9kl7cr3xbWf7+sH7fSoPyBdhFofbMMzItfm2F3Y7Vy52oKcBt5CK5skHxJZGa4/N9+4It5eIH2YddIq/DN4tmjYsxo3U4CimF2zS8GdoVwO3dRi11Sr5Z0oTfYKr2SqYwG9geg2rVsZlZvh2vrvOtW7gD6+wB03ZdD4uaOBCZC2cMvRWoZK9gRKkyB+jxdWf9qEtUVICKewMHddAZQtDPv9bqbcJRNqAoaEVPwGUL05bIOMxg5g== 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=Q2A4bQ9rj2Q6vS/FnjYs9use9L0D4fLvcnEURlPSEeonVvOaaCyWaCLE+4J8sCzczRj0TrhamOuGRMnNAZX0hD6g3Yq84y6vSYeshzZ3k4ENwKFK48oIgJw3yjEteGpsWzb741C0vP0Najw89ippXAlhN69q+VhUxsx7VwPEiOu7Tn3N3pZQMWJV2gt3qpcA8gRwrSwWELPK6qe7rZ2sM4HO8UbBaxHmwbs600olE5IJBd30YNICTwHIyUn9ITp0c91Eery5keLTMr+NkaBUO//DUcI5trXDzSvg0ULIjRn1HUdLhIYpwCL1clEZyGxMs5vXPSix1dlnjyu3Rq2Uzw== 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=nYl3pKWp7RBB92N8Mx15EKHxB/GFU5g+d2GkEwmLsx3XsYlS3ZlstLGviisWS9r9yqalyEoZo47y+3lhbEmDu9McWEUjP6S25o5Hu5/MheItdNActAG53N7Vi8bufQgVLcTI2vyIQeYgzbU+JBhxuojQ/+UNLbesEDj7JdrTuz8Szg9+VGgpF8PsU1NKkOOvfozWE/GS6/Hau31956nV1c84K7bOHSHurszbqAmnOn7x/fWNlVvohkhULzfJORj9YibaLPGJ5wSFkEmUboNoBA53FfjfqCFPdzxLXoieNZLNGbZp8T/T7bR5Z+EHEFS0STGCUx5ZW1AvnJ49x35uCA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 22/29] vfio-user: set up container access to the proxy Date: Tue, 20 May 2025 16:04:11 +0100 Message-ID: <20250520150419.2172078-23-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: b62c074e-4e02-4ea3-069f-08dd97afbd03 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014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GZ4vpb+kyMNcvKutjAc1/2OAUF+PwZ5YLLf1+LzP5qZJUfbKbZuocrUsO0g?= =?us-ascii?Q?Bia21iLq850aupQ3Tk6mFb9tKuOoMt0dgpS1KYgDugu846tSZmAYuZhQEuut?= =?us-ascii?Q?UpWICiJ8yjQbic2vz8kVyfvL49M4oQ+WlHzFAOkOHKuxUPhMhmCSzVgkRDG/?= =?us-ascii?Q?NViIgWU5fhcB0kQKKV1D89UAxz5vdcwuP/ljgCMJ4vYGvm4Ed7UMQtfYbEYa?= =?us-ascii?Q?QXQuRLUc+5mOIdSRaLJLrYFMyepO2NLdgtoJDPVcVw6tnBgcNqSA7lovk6OX?= =?us-ascii?Q?jpoQiJ9V3+51sTVC4F1TedWuS5o9H2DLzMjiEyFNc18b/suL7ltuuZEAF+eD?= =?us-ascii?Q?p4kqw/6rTuLyeUX4y1MBckr7gehY94SSfzoXZKC+9cGQIlzSJ7kJMd9wTqoL?= =?us-ascii?Q?i3jR9JVSkrhKLYjycuOduDgrULLKUeeVzVRyRdKBmgq0x8BkMx04eS+JwCB5?= =?us-ascii?Q?5SM6JJB1kDISVBkXTyhNRO4lUG9r1cQs9V9dGs7hnyV+I9kbMZ8+G+O3ffuh?= =?us-ascii?Q?xXDr98lCeeimkQHREd4JHVSyqHo3Xeq67Nf8pg+Mspw7/OtH32O0lG3bOpnU?= =?us-ascii?Q?T7OpaQ1CRyE=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?CLdplS3LNxpiBYpDmdMoAUrDEKyHZXbTSO8HITdLP/JhvYayHdG1SZJ35+xf?= =?us-ascii?Q?E/rg5UQCFzQ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IGVRl8wpUyfwH?= =?us-ascii?Q?dnE2kOmjx8RMyH33dU9dioU1gNTlhcsqhbBB9q+g1LDoz9c2qgRoGaTrwG32?= =?us-ascii?Q?H2YgrIJGUfwYMk9c5ie/kiEJzpeFF7ONUo5QT65GCmVBO/EielVhCgASA498?= =?us-ascii?Q?V+0fvqa3C8gHBj/a1+73Sf2f30Dj1yGtEpPlb0++q5333lfM7yBMj2bIXVdb?= =?us-ascii?Q?akdo3Ygx0micswrkmTPG64JEgr7yilFDrYE7ddxNn+JEqqbbZIh50S1ILXwf?= =?us-ascii?Q?kPzaMo2+a0gUMcUEYS1RVsB7BCDsPYt4C0P4W7D52+ODrNw2SDYMM+MtXeq8?= =?us-ascii?Q?6gf0ENABvu5YSMrQBcSCC4aP3Mg0AmROL1CXcmhUBe8JI1nO4YUV1eD60dNY?= =?us-ascii?Q?JbB0LS/ZKIpz2KO5uYxdNN5azX6T41JMTn4Dt1KHfpZwWb5CSnujoAWY89R+?= =?us-ascii?Q?uYdCx6rdyI+fHr5PYT2mXYU3eCuuGETRc+S9MLYvoBpqV8TcS+j2fQSjLgMS?= =?us-ascii?Q?8M9Kr1iT+TgAo+kiSngRMn8iR30mWdF5T5HoOMWqqWqxklaatfkMexaGhRxc?= =?us-ascii?Q?TsclaLhETrumO02OsC+ZVtSkdr8XD8RmCdXdnF6/XTDrO2DhZsSX+vh1Vn56?= =?us-ascii?Q?2GKyCxt7V8cH1OLSed8PZlGjJuC8gU7nCrV09lkj?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b62c074e-4e02-4ea3-069f-08dd97afbd03 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:20.4278 (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: 2Q+MYh36U/IZD3uBvYvHcHa+yygGqJxch/qwJ8oJg+9GYrcTvzQZQP8g+m9r5yvBsClcYK7abeqCUgg3nyyTEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-ORIG-GUID: ifS9hkD7UuY2xhehSrXTAd4xL40d6CLh X-Authority-Analysis: v=2.4 cv=Y9v4sgeN c=1 sm=1 tr=0 ts=682c9a36 cx=c_pps a=TJva2t+EO/r6NhP7QVz7tA==: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-GUID: ifS9hkD7UuY2xhehSrXTAd4xL40d6CLh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX/fr3GIHsAbXl mfBdqXoboA25gHQNQtw+V9cC8a+zJzegj630cXRLHa6NLhB8oKv6kseyYCkiKIeh2KZgwmKlFHQ mPxa5p5Q6Yb0dOCSm6Xjcaw7xhHXn6mVsWRYyychM7Sc1SxBRJi2M4ZAmiyTo7muLYsF+VEl/8O XhPPHWVXFwkYby8oDYuAt2JlfeMpgf0HWCvoDzaBl/APSWCvfvvI7virRYzONvtYJYJ3t/5015G q5kem4OHD5KvqFScgO/tYN6abZfm4uV9iwGR52h4ZuhPcPKWeKPffnl+d4mirG6sSI6EJwk3laF +dqcjSEFRrf8QPKwZruic6woBKk7CIxCQbhpceOJs62Feaqar4LZHDhNlIeyKY5ZMXwlHYJXruc L1fpIsnTd1keIKTxq/TNVe1CrBLHXa+lEueucuh6a56GTLJQpjBUNmvrUf3pDkPqvU2sVsw2 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753929180116600 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 Sat Nov 15 20:52:47 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=1747753569; cv=pass; d=zohomail.com; s=zohoarc; b=Wpp3BiMSJ/80oy2CqfMxbONW1+AA2nMf7DHh7o6KW9wYbnqZQ494PzpjXNrfnITDBYFxkPZYKf2P90OVmMHyxEZRx4yghsCiQ1Km0lEAjXBCMJfzuM9onBPe8gU9RAP3GGpk93TWBPn1mMRygmpjHARxLjB1Zt62CMzGb3yOkS8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753569; 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=IQLbshIKGGPj2z1Iv3e/LimoSuGnuEKgY1cekfKetWk=; b=Qq1qN5sXGGs1frkvNkpBaPGPVzoMQE2YQ0rajwa6uTybSrM76992kJcvVlrI2y+cWRfS1Elze7NM8a9LJ1kFVk68D4JGjXSexJwEDBR9Z44VjivbNRiC/XBIjlqgVlJKzJ+PYBL2GEDio17HIbLHdxNiMxhGZs5iinx9e7zAEgk= 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 1747753564676441.3948215707711; Tue, 20 May 2025 08:06:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOX9-0003ja-6W; Tue, 20 May 2025 11:05:35 -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 1uHOX7-0003fo-0m for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:33 -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 1uHOX3-0002kn-7y for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:32 -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 54KCUIcB006673; Tue, 20 May 2025 08:05:27 -0700 Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46ppsuehk1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:26 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05:23 +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=IQLbshIKGGPj2z1Iv3e/LimoSuGnuEKgY1cekfKet Wk=; b=tLC10Pd0+ZtgxD4TkYEFbkFDOhhzwL8uIP7DscsdgfZ4FXTpbImXUWGQX vr0EjdSjjJsgUvL4dasYLOqgi94uf8DiRfapb7EHmNFm7TBbVvoXBk57550U63NH VaeKEoVlKUBjPi/OUWfk9KSXGSkY+dSqm3kYS2d6XiPI9Km0CEfiIgc7YvSU8hLp xhuB9UwMdKJcM0ccEF56iCkDpEjQDVgNzvzCjOoPyHnK3Qo6Hpo1pAEhzcQbFuYz irR/+ZyNU0VvWwBwKFY1NzuQPsToAJq4yMdR8GjKCf3oQE3LjpO/aQtQ1LWfHQSd H2JEASx2lGLU+o3NKgsxWVnkP+Z+Q== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XVFslGAYBrCi0jZ9cSiB5UmOiIBwbCmUibuF0ULNz4JwvXziZWS9P9fdOVTMBb8OtvqLSam7nj/DI5xXgUAgkjBvdvUHpwh7cQiVZsaT+wWnIm2WzOO2frVgKEOk/J0akQ8iaUu6Tn08moMzYDuUR+IH0spVT1U237G/yn0vZWn0qL3KPrssw7rJWmlOg/HLdlGvm9kaOaZ6DEuUlkw8UvkRT60qrR+k/8KQ8KgzhsMtKzEDU3o2bIB/k8p0kU5Z+/5na4GbWDanPF34BFTogzFyDH1PwAet2qW3CVzOGO+fiMiDN6ekOObP1eRMvWeWoMNM761YvIBlSdS7phzhog== 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=IQLbshIKGGPj2z1Iv3e/LimoSuGnuEKgY1cekfKetWk=; b=Ox45uJtbZGJhHHGqY1GYCvygpB177JHV+zfvTVfmnPU0m6EDq38QJ/odefslOva/KHwcBX5YdyHrL3qdwrK9tb5AsZP8BtYTlU/AQeQw5De5nvp1lgleX7UNUQe2MC/2RITo2tFlbgN/GZYnU1UckJrNDsrkIuZuvbWRCym6NKKbP92dsrtKZU9VjSzAp7opRHucYt3P0Aj8Jr5nPys+ja2kKlax66by6SJPnG1tgnhhwRACivRFtQFlKzuhe/jltUoMHWhdbFSn3fsrfGcRXmLq8PCJpnsV/0JcsqbO+TDdthO9BYY0nJXrjLWmk9wsK7sYdtbvIXGEJ9929u8I/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=IQLbshIKGGPj2z1Iv3e/LimoSuGnuEKgY1cekfKetWk=; b=i00p3xWfLs8OXBK6+/CoHFY7Ez4b/659W4ASzs9FUTG685pKAdmBblhUnqTUCZblZLWBRNyFrYFYJRB8pSqkrbp8YCthGcjsrQezXLTHxmfSMQdht2r6nJ1THNh69fZ+sE5Cnjge48T+qjQdUMWtp/FPIJQnNgKhSfBXWAXQDt9z7GnneY+0JEjYmUwzH2xNVNNrNo4JbNtNEIM8/uwQSj8UW19VFwwGy+FjDJ4is16x9wdcwhBQJ6E4nTGAHQ3IEhMF4QS0onYVGOwjfShnRcGwbrHO7RPcCvA/ZfI41/LHtsUna0/1DJ5qQMhQJZFTHe2pqYk5saq1TKTzyqV1AA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 23/29] vfio-user: implement VFIO_USER_DEVICE_RESET Date: Tue, 20 May 2025 16:04:12 +0100 Message-ID: <20250520150419.2172078-24-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 666107d5-66a1-42de-c809-08dd97afbe90 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?pDyXyC2a7X+cLyvjr5bD/5AmOdLJ/xReuovO0BqCmgI5zC48n8Md1iQGRWCu?= =?us-ascii?Q?tKPRmsJec1bFnrvIRJrHNGe+VlGJ9cNPU3FbeiNJ3xQgCaWbj+Ld33E5J1oK?= =?us-ascii?Q?vHjJoViQCzd86m10sujla96sANNycpLcTGCB+c6b0crdS9n1AUkVrL92aa4r?= =?us-ascii?Q?R3epmvy1jlScKzkXuj6G0lxRdyqs4xQdSnnz1RmDsVIe0HJWpryzk9PhmKfD?= =?us-ascii?Q?IoBn1xckAfdIdVLBEiLvcEHsMbNiq7/Qrl1PKVIeFyW2pugP7LYcqsH6Vxn7?= =?us-ascii?Q?3H6/4RzS5vqo6Kpx6kSXdDBvTaNSOvFLWhL2HcxmRwLAPW9b11Cg0UHB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X0u5pVE4KyXvz2jRA9NYDUD?= =?us-ascii?Q?syEWMbGMyjqcxvUcc5sZjM8URb7DCM4/ZG3dTb7sFPOFOr3z15Tgru4XnSax?= =?us-ascii?Q?/b0Ye5BE495XAXKz3IU0aH/jQWhsHDjli8Eyx+npQxFslKhFGA4zzi4Iuk7/?= =?us-ascii?Q?/RHAIBGbsz5PC3ENGxNV/h6bNmuv8EjStnMmi+2hjNKSAFI0lq18F2OHlDVv?= =?us-ascii?Q?N0SI4ZckEqA=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?odRtdTIBGQdVRkw4GTh0kVOvlSoRysjTS6tn0Dslz5hZ8hVHDM5+djHP/OQh?= =?us-ascii?Q?E+Rfjit2MZF7MXupInm3hNUe3wX19Ls8n7T3/VDJQB1oXXUFxghlp6n+42ks?= =?us-ascii?Q?UzT4XUkSeNy2MlOyk8su5bIe5jRY4Km7Lrg0MS87H5/cTFp7mSyiSS6QFITs?= =?us-ascii?Q?VEMnb3cst3Akq3hDE0UNlkFoBo7x849b2EttBQ40Ic9M14WN8hg2Y3mx/P4c?= =?us-ascii?Q?XM+8c4qe7XA3w4ocHJpS9xbjqUMhrAq2snA0V5ty5q7KORyw7FYOCtHYt1Ly?= =?us-ascii?Q?qm0H8h1FanQGQtiyVTmAET2AKaCv3kMaARHBa14HP/yUnb8ecPPz/oShNWLi?= =?us-ascii?Q?d0qJj3ilcVizfVr6N5JxnxkUvhjPowLOGyt7aGeeVDa9MM3P0RcXwLjlsmHj?= =?us-ascii?Q?UcnoVLBxQEVvEuvjFf6W+JfiycWKSYpoBXK7DyWBVUz7bfK0iIZH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WEyfQ7prCad7zC+yrSI/7zk8SUOMnsm9OUUn4DK9Sno5WiGkifRSsRKN?= =?us-ascii?Q?C6SwwQrspL0QSXSx1YG8UJ/qNPag2ywYERYuWIIer+c1lHdam4f0LCVkL2+Q?= =?us-ascii?Q?en5EKY4LRUYlVX+C+PoSxeGUjoZpKFn0jEGZTpZFDfey3ek8ghlUw4gFAXsf?= =?us-ascii?Q?61ikHoLVoAwG2uOJ8sp1Wxe7nkphUuyJJccWyEkKsco4gMz4WITIB2NQoKhe?= =?us-ascii?Q?3eQYBVciMijmfIG+NtbNZ9svtrZteIPHQfklqsiL?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 666107d5-66a1-42de-c809-08dd97afbe90 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:23.0456 (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: UfwWhEVDZYCDBrWvEz8vrpf2JvFjZ/phY9pHvy2OfgCGTisvXwsJ7EzRuZRVuR/SMMDbN+hFu0JXkDTieMRt8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-ORIG-GUID: 1qoKds8WDyA_8QExJheVVetyO0pjxsKA X-Authority-Analysis: v=2.4 cv=Y9v4sgeN c=1 sm=1 tr=0 ts=682c9a36 cx=c_pps a=TJva2t+EO/r6NhP7QVz7tA==: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-GUID: 1qoKds8WDyA_8QExJheVVetyO0pjxsKA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX5MJ5+dDZk25J 6qgzfCQgC20oRa+/6Elsx0M45BYtjccWtr+7t64mCXAsuWVch7qSp2Iu7wOxf0IdIJeZIk4Dycz FA5acTdgee/NjGrGrBjl58cQAYAqDi2o3vTmRxe02T3Q+edkJp5t/4h6qTSq+dEanPTC6hyAegW ZLrw1i7/o1ZKP6PrkavUMv849gl7ahxukearhiqXKxjl57tl8gfFLCXcsMeqJpvSlbXReeR46py olNF8UHg2BNbTq+6JVX/uhSK2GDv/KD2qkoBF2Kr73q1kau6GORXf0iqTmbL8j2pLmRk/1lUHhW QUgpd+7BIa49J+ibjLbeFNGIh67yz9oVVnpw36wsOkqzkDORCUn7KCQ520Ygy5k5W1w8WLZIS3C VQtB9O4tneq5e1fP8aTNAmQ4GXBp6z3+etG8eRrQFVKjTrZ+0DgrSE/ej24QGgf60x02Mvlz 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753570877116600 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 5904e7ebc5..2c3edb7378 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 Sat Nov 15 20:52:47 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=1747753592; cv=pass; d=zohomail.com; s=zohoarc; b=XsqusGG6YF6mTta8NGDpcMeajR+cWI5v97DbV09KtXfrIniXaMRo2EZBmc7eofAPLWaihEkuyWp459DbpyGpwEbKAcYlr1PidaMPEyq4sKR22OSULY8CBOoqOsLfJiH92/K7lM5N9L7w5yXpFm9IY/zStbDUBSQ7d+NVEcoAWAU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753592; 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=Ef4bxyrFiS9zPSoY0srEGHfXWrEqXv7njHJ4lACZuSb50RkfJflAchetEk2gMDIoMxxltRJ4JZ5Yjg1Q53Py2AorQcrLCctEcOgbOYj7G4HTYVC4Lcc0X6b0T9kAHR8QmT/tGrH3iSt7lg9n/3ZGoG8ORoZz8bKeN4t7w3OmaEE= 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 1747753592445289.09322767138667; Tue, 20 May 2025 08:06:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOXB-0003lU-DK; Tue, 20 May 2025 11:05: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 1uHOX9-0003jt-D2 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 1uHOX6-0002lM-FT for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:35 -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 54KCUIcC006673; Tue, 20 May 2025 08:05:28 -0700 Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46ppsuehk1-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:27 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=9s8GGmvHd7YbLvsT1cNsRFjqwTXQbF/N8tWvGuRlB X4=; b=pG2k1Qbak6HPqkxYbo4AGGGkhN1wQAlHINUw1++8uwdvkHoZJovNVkWaq r4/NutUnwlTFBrHSPDjMcAJuwP6bFT24RsH9GqpPlNT4d7Xrlb/PjaYyNnxlJrV1 Zo3LNUJ778hn6oIB12uxe6J55SJGmRkD5bQxb1VSZtrxgcvSx83ihNH0gm1wvlqx YKhKdXRXkf1c3lrI/KmP0yP0zZ2vD7csORxHEy7eLmwVkRN92C0cqUQ7DKML54OX j4Dj+IGiAaX2UKQes8Pon6i97W5mMWbptMIg9fV8lB8ns+UxbDWBv4+7Z+Ybzecr FGFRDpU3k9SCCRW3vSHnZHqSXWwsQ== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i6upxt8rgE7V9BHWS+UqiSdAH1DIqnpP8MVcd5VmKMb/H+DT1kebKA2Z/8sCU2K8AxqWRpgD94nA3uGCKJz98ceGtcZUoBpTLDzPHYZ7SAr2fPM6CCAFWqshnaIIBH0YtXq3q0Eba9e5SQViCp6BWtHn3RtOIlsHsK2teptQB4Tmy0pSo37ZvgMI2gjBHPnq06fVeWh/X0EEmOUIsbbjSmExXCQzTgmS9VaFKENpbxLkkOV4m3uuRwSLy93opLAPPCPyQPqM9jMdLOjRYQpMt3KW1c2NvauKnAPlch0rtZw1Tpzmf4UnceMid4Bs1VUoaEFz2jDtutCah13iaeXx5w== 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=utCpDsAUS5fjtwJh/6D9ikh0aA7yviovUwjAMaD4evb+rMf+qfgxJn2p/lW3+ykwwSFOYYUYes4cP6yLn69BISk7bflitAgJdx7ZcmtySOmMK5qbyk3Xr2D0F7zTeEoz377nYE+uuU/vPfpVOjTVHuGcNdyQ10Uk4zLa+K6Ao3YvHjRy+q0gCqWiUgvosvg7+5icPQJMGozZAmiSxmzqXjYt90BiA71RAoqANSqaiJeqWio7VlBRF4hkfaMfsDOXJr5bG4+yYue6y0SF7Lbif72bx6dgNnGrkzaEq4E8fzqtTlUEvp+fcyturtQ50up8EOqRanA9qPqz1R7Sfc7GsQ== 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=afH7M4l+y9pfudABHCFAVBt+Nn8LE+8BLNNUJY8yienjKk6uSPEPQEoYt55/t7oZZSf5OdP+oUQscMQ2+J0xAY3elSsR79dfWQuG0RFsB6TCch9GJNKb85dvoISzFe0c9uPJZov271RVYFt56wRxM0L/Z8/hJ6jX+Q08NUBUF4v8wfaURaZ/HadeoaLHdN1RDa+imqq7FBkToWBddB0xEmjJh0SNHphU0uTH1LvAhk70N+ZFLFDPQYORUBCYbxshiSBdBUmpCR8nq/9Do5is1v1oO0qXsKK6yq+I0Dd5nSltP6+fsBh/cqg988f8QbFVDI7pzYEAqZbWkkdoyMefAg== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Levon , John Johnson , Jagannathan Raman , Elena Ufimtseva Subject: [PATCH v2 24/29] vfio-user: implement VFIO_USER_DMA_MAP/UNMAP Date: Tue, 20 May 2025 16:04:13 +0100 Message-ID: <20250520150419.2172078-25-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 057b64a8-cccf-46db-0951-08dd97afc033 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?x942UGVIlRSY70p39YGal4clujzdTXcfJZF9PpcDPo7KLuKtM54AJAq03qLD?= =?us-ascii?Q?Anh58ERK0KKoxGAtymPqp4l6BGSjVc0l0RNpKxl73HOMznYXNqrUp9zszvfC?= =?us-ascii?Q?qjOQ/qzN5iRrAyDy3bedshh58EDe1UjbbfDP6+jj/taIF4XH0Q0qoT6UH73f?= =?us-ascii?Q?dBNhGvPMlgfPDdlDJvzdJ80U7LQolSAR1gckPvdOMpc97soHJAmwUN6YMzoW?= =?us-ascii?Q?d+Qg3L1VXNQntE4OqojBs6miihOhgMvvVY7Px9dIH2vrgeEnY9StHt4hXXrw?= =?us-ascii?Q?ntwuiJK2rWGToWj04pvYtj5SB8q51Xq9EtI0hP8lWI9kiIj43XYUyAv5s0N2?= =?us-ascii?Q?fCnvhIklTRIvERbZhtnR77qCT1uxWlBi3jsgA66Xlfn6JJqqcDrXnrlDrALN?= =?us-ascii?Q?4He0LsxSArL1o8qj7F/3pdSBtdZMs8gbwLzKfB47BQ4KnPKeQjuAkdDmWbm3?= =?us-ascii?Q?muWi9DyUAPkHZ4EPbdvdmil2kFjFhZuvfUGIUSTLLS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CckFRUCHDNCT5lXZw13fTs8jK4iGcngZ7iJ85kazftKr5Jone?= =?us-ascii?Q?AyZyEYeDI/Q=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dDoArYtMPFbP1Mpbp0DnP90YH1rw4sAfLfAGTi4xRy2NmqnNmYtnBUlcV96k?= =?us-ascii?Q?ZqFjk3G3csLPhhSTIUBvlnrSYIpJjmBPFAvzwjsdHRLxkdXwJQ4mR6YHRkPk?= =?us-ascii?Q?JmVzQkQwNjron9dmIQDDxb4JOYragSskvR5j19yyAJ5Pd5p//XbTOz3K4SN4?= =?us-ascii?Q?wVww65ugvRjeUnxwciHR4wrc2h3GxThf1UxsCvfYOwsKhtZQqcsw/CWzjfYE?= =?us-ascii?Q?5FF1emxpSbBKkArRBdKueq3TrBY+iGTNeUT+d0G1rHKfPYTaYw3FNA8154In?= =?us-ascii?Q?cnGvnQ0GHZXGmzITqVFPoO4g7uTm0l6f7CoCRt2JrpKyYFGod1WLWV+pGhsZ?= =?us-ascii?Q?M1DJIcGbBFVbDJTIKWSNhc1Fj/IBeGWdPFGKco0/c/GMMT/mSdiY+FBboyqe?= =?us-ascii?Q?CHRe98s+TWrektErD6XIHnuh8k+2gaTs3LqV78l5SLbFqgJ5TYpk+iJBN+oQ?= =?us-ascii?Q?/hR0UlmFF+xjsTPVM16OEP5vg1QAKJS7PHOg24ZeOIINgkEmARTxPXXTDq4p?= =?us-ascii?Q?7r5yxGtV9yS/GfD+x3Tgh/GjohCUsCAPh0cCC1lx2qF7Uo42LL8CYG5GoPyX?= =?us-ascii?Q?V2jRcYgPbS0V7OjxY8WJxlOhMm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2/i8UpT3OTNTj7Wct?= =?us-ascii?Q?I/6MHh+p+w/RnQsQv5gGyFUyX5lAGLMRWILwpz1a685lBqou/2TzqR9P78iR?= =?us-ascii?Q?LUNAllZipNOeJIyiCwiG5mimRb8stLXTY6cl/iXP?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 057b64a8-cccf-46db-0951-08dd97afc033 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:25.7607 (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/HGIFYrcRcojpXnVNJliIFYSWqQX4AEZBE6cqj5QHA8+FhtE2CuAjoxy2K84bg9XV+wFECE3/5bE1PqMVec7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-ORIG-GUID: f2M9uXu0Kp9n0NLDmXydpyvVw8yC5KtC X-Authority-Analysis: v=2.4 cv=Y9v4sgeN c=1 sm=1 tr=0 ts=682c9a37 cx=c_pps a=TJva2t+EO/r6NhP7QVz7tA==: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-GUID: f2M9uXu0Kp9n0NLDmXydpyvVw8yC5KtC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX4VfrjvUYl/Fi nAI7vO+SRCqbHHMnknPUbanCcDTo7Zp+ldHFIX74On+9lbB8rlrVzfPIFmx31JLpQNpS87tevDp 9KQFWrmFiFqZMHFGsmxc/1tQuaxbGDVogdrxziqT7IECSAmPTfxrOOpEmLIRbf8/JnYeD7DS5YC 7IkNK+u05uJCclqO5WE9pa92MLSPROokC9mK6ya4PdLc81r7nxBF9kItL5aYsGwftY4DA4b5ja8 z+9h4IaTVqCLOhtav+ZF6eH97wEee61eIZcDLXQv0qv/Z3yubLMwxJaKQ69ey7M+EApJKhdZaqZ 2ybagKhWdl50KrHdEz4ubjxFgnJML4ZLnbbeIURy3YuBmFo78uWaI4QBIGZk5j19JpvdcBuVNw4 aK3iZRwhdb/hAmGNUXLQsDIFYIabGt4wvuxjRjFb5zRNJ6b+JyilTIU0geIBrTgRSMAgFGPR 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753593562116600 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 Sat Nov 15 20:52:47 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=1747753607; cv=pass; d=zohomail.com; s=zohoarc; b=AoZztxuMwNkHi8ZT1WS0eFTDtnl9tKNxVPIEB7y3SYAUWhxZ/QEv5fmnjW6nkJFw5j6EMozclz6q5tvjyMrTe4xQzctiD94590lgArZ6Yg7VPGc6BH6YTlf4HeQC7mXm5RR2NymNZKRriUYVrjUj279NuLK8gGhX98cOCUCkwzo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753607; 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=u9jJUSmXNJCCQeN/pGfq7Gl8NDX6hwBr2YbxQJ01njU=; b=SqaMT7AVmMrzjJdqllUj8VU+xGa7pG6JhWrQNdawBfltuaFkuvaDI3/8/zwQ5757WvczpPgRGZBAtPAaMP0OFjfo7L/hochELYBEXnHi4ejgJfnle06MU3ic6kskHy+y/DTIQBXsWbb2f1SXz08F4xx2OMa1RFIiYdWkwAGd/DY= 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 1747753607330237.45748076066025; Tue, 20 May 2025 08:06:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOXF-0003sg-6N; Tue, 20 May 2025 11:05:41 -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 1uHOXB-0003l9-71 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 1uHOX8-0002lt-SH for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 54K74Jhp000844; Tue, 20 May 2025 08:05:32 -0700 Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2042.outbound.protection.outlook.com [104.47.73.42]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhec0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:31 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:28 +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.8769.016; Tue, 20 May 2025 15:05:28 +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=u9jJUSmXNJCCQeN/pGfq7Gl8NDX6hwBr2YbxQJ01n jU=; b=KM6A8nVDFCGLDT3kIDJQb9Cf3gUfxC9XPeG2FIeD4+j+oDRD2rDIy7Cn9 0N5DGXtMiSuVPZBz0yuMPpWRm7nhid3CiHHWeFfUVMLxzsHwdEQwC35g15tn2m1g 3ct8cxOkeSyv+P/SgeWKUVfFSt3MLDZIl387iF6/hFOYU8NunrzssBllWiSqXU3a JlcmexVS2wrng5gy0hVU9VNjR2KdtnFI5BpYcDkMZdPyKf+MHBMcekMGuvhZT/GP aYs1fpLIXmGwuO5jD+Vzua4q8jFZEyRN4NHjhV2v18/p/gdeCFWI24iF+bWeBGzZ hD5VdQDbG79g5Wmm38Ay+SKxva9Zg== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MfjoX2vD89WLgkCERZUqP731UrV3aKbNomGyO+2Hnag8tvYvCdXBkiE3jOkTGh5t+mUNZdqWQoOxFYu4pYLCKr2Bot7XVmOwYDYmHPuaZywnrskXyGobxSyciihXdNg+5FSOuqrZTLa2/MEmmfstbnscd5ZJt1p/KN1NJasC8NT8JrO8bgrblnM/dt+3/rop2EMCdEZUipKTC+S27mOZuN7ABV3XJVHU1RPT6T6bUBdmGNowegLYRFN8nv9e4dtegNstU0jP+V67B4DfUBn88WUfha3Osnm0XC84uJTWIukxiDuACy/FD3mtvzaogIky6DrKrmPn06R/KQwmB12LaQ== 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=u9jJUSmXNJCCQeN/pGfq7Gl8NDX6hwBr2YbxQJ01njU=; b=q7lurkawzrsbO8h16uZ83OC9pWGV/osrJUUxQio0GPCHb9ybddBQGro4fEcONal5d9IQ4qYDTCW1pjKE7G/2lSIs89wd7pgKnS/Sc3vd6i9QJH0iNROlSrINJ7mY4VgX//lq0/Yq6HxhKyKO0pr63KTSSFzKjlKK3AJe4KxCMWVf/QnIXdNhHcb1Y4zBF2pe1HWeGRMyRVjnS/a4uXMf3TaDsTA7GECkWnfAbqGm8q8yX/Il25C16KLjKyDP8FNaxWO5wnMK/YN6jxSvzZewtfshPuCA/aPJCq9K7vq69gf4GkW1RVJb92v92LGyPY0zVS8IqrFox/O7cP0z5ufAwg== 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=u9jJUSmXNJCCQeN/pGfq7Gl8NDX6hwBr2YbxQJ01njU=; b=J/7DPtOCZM3w5y14jrmaqhFw2837uTvGMfe7YrczbMMTlLkAeHpXI5J9vmqry6d/ZBl65Um+Rq02aWm/VITTLIqU/O/fPJzSenFYKetGdc3H4EspLNvZhXynCGEhHHC6naSR4HgsJ5oho21cmtrRmQ3ZIFcSPTlGJsdg+M2c/SqMqjbj7ZFYAu0ozaYMTCq3qhzEVzq6uqn5/NPU+uqzs5mt1y1DNS/K5vmGwSIsc7UYZ7JnHYBvtaWlNerjTv5sltgjbT2lP2IVHv549t0ZYUSNs0smCSx4vlPSwna2KyZjULh1O0ZYm1RY4qsTkNt47/lOQKS2Rj49kE64hzIMlQ== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 25/29] vfio-user: implement VFIO_USER_DMA_READ/WRITE Date: Tue, 20 May 2025 16:04:14 +0100 Message-ID: <20250520150419.2172078-26-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: cc899166-b703-4667-46c6-08dd97afc1b8 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?56WSe6YyoLjzwdY02AtgLwI9RVgVZTIIcATK5RyJILygiymsJGi6xyYDPW4p?= =?us-ascii?Q?tm2HZYUpZMWHfX2qTUGpDoDCS1eSOeOchBYstgxypIpGR01Rk4m7+c44wGg7?= =?us-ascii?Q?9rF7eD70+LfhAM6td69MsHDbo3znOdnVG3XScQaOZfWiyXlsA7S+92/54wPc?= =?us-ascii?Q?5AYFC/mIr9j8W6tBLVqVkq5pcSx3V9lKwNRx6X22gIa2W8EYAXYTFqiC67W0?= =?us-ascii?Q?O6IqTE/rusP8yE4ZqQMEUcxTjpN6vhvhkZAEggD1xrYy9PAM/qFL9TwnEEE/?= =?us-ascii?Q?lGFYHzhz1l/oCmQHq8l9jiwmkSxOB0DWSBNF2fFCqCXY/q56cd+lCd6b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vsZH6YJt7k3zFgSRq/l3g3X5nKs30q?= =?us-ascii?Q?1v6/smMrbT8lYb3DAy9zc4z5MLgZGE7rvU7/UymHyto+vBH4vluKHSPqP5Za?= =?us-ascii?Q?T3UGrriq+O2T1sB44PXuEo1RQnnGUOZOCuUGiVshg8vhrBMD0r4yXTr8GhLd?= =?us-ascii?Q?8ay4MKVgC1csqmeIN6XqKjzXaPwnnnKSucMG/4Uu3rFydODtJA=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LlgyFQVU1A4m3czpdsNsHiG3A0dZER1lJgB1xLekEe8BnQYdBxfSs4MZpICK?= =?us-ascii?Q?KmEPnn0pvoBYguGeZ/dH22aej35cAYbdie0yZmarAn/Es88V+JbR10baNyS4?= =?us-ascii?Q?OJRmuMAHCDtJkECUbaXLW2FkcfM3sW059vVgEuI/udbO7IkqFXqCVu57azsI?= =?us-ascii?Q?T+dgLYlUIAEnWYH64iA1LFz5bP6OaRHAKDmqpSjNROkv29+Qfe+qDNbEKm0G?= =?us-ascii?Q?72MDtkCXoXtaW4x0I/VO5IIcF8186L1j+pe4wak8W/TIHU6eObKRi5qjEAWD?= =?us-ascii?Q?Ku9kC/pPjWw+0T7GOkBf/dxQG7ZeW3Mc7seaS6+2bcLwZhIrD4xjlXu1TIlG?= =?us-ascii?Q?pXUuTzQbE3Rmwjlei6T7R9wsQLk22Qn996wQ2Q+U/33zaZ8bVRbbFCen1ic4?= =?us-ascii?Q?NbT2GF1MZvQQ1HHY6vnlKp2mXQY6JlkyABOlpudPM1l/m6a1e13/IgeUZLrr?= =?us-ascii?Q?KmZV1FRlJgEMc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=?us-ascii?Q?vRjynP791Eb4hoT3f58yO7Y5Q6Tcfl3prBW4RuiwXqCWLnoNb8ZVkMue/r3R?= =?us-ascii?Q?o/EcphcQAyAXrWc11FBaYaYwqekhG/R5qUOtau7wD9AteCnBvb81I4b7ea1q?= =?us-ascii?Q?MCgCcPQBc2lcWmRGbdlaNFEd1L7mjRtBn/aoE8o5UeiO5zvVsH/kBOMRAdnl?= =?us-ascii?Q?UKrfq7QNIjwf3x1CHX+xvifAGqJ8+xKpX+WPl6Yw?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc899166-b703-4667-46c6-08dd97afc1b8 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:28.3119 (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: gu3W248VZ1Q9rVjY/8TrEZztK1vx81GwRWWHoDnhTCXAng7p06SS6BTXyxMYUpbyC4hvE7ZY+vGmQ8XpM0mhJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-GUID: rgflKR5Sjdqdfbyia0_bRqJrZW5uh5k9 X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a3b cx=c_pps a=WxcSnoYPg5jl6yrDmkeCeg==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX1XNG2AZOAHRW ktARYNw41C1tMvo1fKJWAHX0tbv5Jsu7Ymfo8UGt0gzcc4OQO4eoicjW+6DjZE0m6Aae6G/KSSi ME+n2wrXyBRuES56U7oj4UPotoiDU6PK6jZ/Mn/LuNRvoG/n+2vLfznZiUWU02/Komas2oQ3TpS G+WOwGYOhnQ+d6Ernza0pPSigi3yVVBS2TnKTb/K3W1KR591XpdgErjNpGPQQFVblB6sqfOraiH 5UsTUqu80IXQ0Ou8KZUj7OhSBQ1R3pZjVQvPj9R3GNKQ3fhsZmSSRWiV1i7Hpu0BtuTTz6plish t5zFFpQ5QgGx6d5uq5mWrmzawoQp+ZfyoYn+Ua5K+aduZtynvHaH8SVNEqzw2OV/Eyec5/O2evF Fl4GcKLiKSdZQCoMB/DyVpG/dWGCDTGbopawzq4ROu4l514FUntbxvHt3j0EyjZiZyxwPIcB X-Proofpoint-ORIG-GUID: rgflKR5Sjdqdfbyia0_bRqJrZW5uh5k9 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753609790116600 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 2c3edb7378..dff6efaaac 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 Sat Nov 15 20:52:47 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=1747753888; cv=pass; d=zohomail.com; s=zohoarc; b=Mbu0A5JVsILGkK2JJEv++Z5uGXrAmTVL2HshRzR8MvTLl9lZk7yeEaZtJKvv2973oxQUrIKXGXaYUXlIOZMYDW5HZ8aJWJwlCYOkXwocLVHfmClzjMK0x5LUvXTkDE4A47xUGPqhDlKIkssi81cDDSOo17nIOYGx+Xp9JhUvJ/I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753888; 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=3nMmWr81L5jTkiobhbr8tnbtIlHsHImQiRCLOufsec8=; b=WRHyVgXwbE48uD1Y+5CiG7Fl/LSZ5FrICpn8PqrtIh8c02/4G5VRD2JO7LxJxX5PIL/CQefrMrzVmufKHmDfaQu5MwLhUnlxA8kbyCfWEGXFphEF5RWbn0RZQ9b4qTQcaeaDURUrhzGfEcA43StUVsCKrW/UCSsDd+O13YfOYnY= 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 1747753888651364.2118650141804; Tue, 20 May 2025 08:11:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOXC-0003pG-LF; Tue, 20 May 2025 11:05: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 1uHOXA-0003kj-Py for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 1uHOX8-0002m8-T7 for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 54K74Jhq000844; Tue, 20 May 2025 08:05:32 -0700 Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2042.outbound.protection.outlook.com [104.47.73.42]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhec0g-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:32 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=3nMmWr81L5jTkiobhbr8tnbtIlHsHImQiRCLOufse c8=; b=pqSxQK8cVlo1icL3bGl6oeARPm/0GytBaIoyqWLmWbed/Uu9BYXjLonRR W9YsKm4abEgVys9e2urWmWKtvPTt9atTIBUUCq+WCHiHJHAsmQSsGNmqzqEmVMiK UODe+m0UYYL5oCN6sOGqxUhibeX0A0Csnx46ZTsS69sGKNNw/nxqyj8411YMEUdd 0czGYle5WqMdXlBjvodZkdKG0wmzE142FUdVCHtce01H8iClzCvp5ZTor3gScRIz bmOw5oyxVHIkf6RTf0qvZJnAW/mDoXYmoioKteeNgV3AUc6QOCuBY6rnJBV8Dxxz VDXq29C5nmB8PopKLsgG6kn/VSpkA== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hr8Gx6Hsk8ewTrpnyCG7IgsyUkSHdd03kJYVILqgA9ggpYGf+vdtTsnMZyENkxECGQNkIVBrRjtHpLNj7gk8GDHD8etjIxn2Qjn4GSK0eyB8sQWr178tYmtec1QPUG4sOI+sFECqcAJE0dbBKgIG7Z5OgiPxWiMj/d6wRZx+yuhFdljoABbTAq3otK/5lO6So9NQ+54JTFM6sqCsWaGznmdkxx4dCiewdxAniX92OyqWfR5l8FMmWHxDYu4hBq3AXkNWWNcnqJ/jhEXdc/85DmhBdklK3kMNIJemJbVXjdS+ajNl+bxazFG5RuOwcfw+c5Dz9BSEVuPey21QSrCO1w== 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=3nMmWr81L5jTkiobhbr8tnbtIlHsHImQiRCLOufsec8=; b=ccXUdXRG6pKzqiRN83/q55sK9R6aCE64yXxv/bAveRQ0Tvz1CP4VRUSCEv7mzAnDTrIIydeGPMKZHOMTnn8EOx693u0USUP3Ld1y+TxUAhEsq9LSY834i1q35t0BuDfyAJpT/AI/vLxigOG/o1KMbcwJWz3SZxg1gOy2ouQ67YsXmgsqNq2yaHxiT4jOLL0iYyqfRVOyoLCjyxLnFG5mr6IbdWC5dgiVlwWp/QxeHaNtZUd4F5SC1x1Y96sFHrlEvL0CysTBZIie8fU2P21VsD5Od3tRIFrB9ZcsbtJMVKNBF4pwuKNApLlP9jofJ0FSZEs3+UHH7GA3B7KrRIXUkA== 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=3nMmWr81L5jTkiobhbr8tnbtIlHsHImQiRCLOufsec8=; b=pfacO47QejQ27sjhyTiod+8hgk5jm6UZmjpK4aMkI5OdpTLKVsjL8sbdoD6XAm58jMuE18Rc0PtpVy27irh4/If6XQNiQylM83ATfqjv05VsXfmgQzpah5GFhPkEHmLvivM3ckU6Zu3dizvgiKEGMjD0HEWbBNPXRcnhgCX1/oVs68CaSC/kAqugKYscUc3vCzLbdAw4Z3sS2qhgPPT5nxHFuRPWDTj5nxxTHRD6M/WrGig53IDtAQPCVVbhiq5KWVmr0bD3LZh+ip/CLxL++zTyeYG0KgVVZGMKkV7nvhzT1ZlSD9M4GHItseOWmQsqi5gpoSVc1XXyLq5h0S5aDA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 26/29] vfio-user: add 'x-msg-timeout' option Date: Tue, 20 May 2025 16:04:15 +0100 Message-ID: <20250520150419.2172078-27-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 0ffccbec-ea0d-4080-10de-08dd97afc342 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yFAVnB0zHR/BdhnmuHc6JFVNnV4DaxiGPzpL1L3eMWLSKKf1IDzgLkBxGV8E?= =?us-ascii?Q?LADXWtlgSKqyOl3PcIHvId86HguV4ZSMfhyT6UqyBjyKHpYFlnjmK+iUJtSB?= =?us-ascii?Q?3pOxz1ZSzFIGiD4ye/lvpKll1FWN8Fws79putHoH8qC9vfLkBIiqPCb1GBFK?= =?us-ascii?Q?j3JC80aKo3QhfT6VX2r505MXz7H2UGmS4WmTU3NVb9+Sypswa9ob7y44SXpJ?= =?us-ascii?Q?RMSZDVV/atBhnM1Ae68Ty1362NpzfBCLw+V5p+6unV6aPDxq2i7nlczfxTRo?= =?us-ascii?Q?SZ7ZeUxX8MiV9KyKt/roVeK+qI4VMlJnYg73+y/aZFlal2/kNQ/ia4sAzh+Y?= =?us-ascii?Q?mahODIg+fQ1uZiufzYLbe0OiT2WGVyUa3JeU5+a9re/U9er5LPP5Nyfh3v6T?= =?us-ascii?Q?vZz6GeUFnBfnkSuiVhBr5p5nRDN0MEWN6ajqVyEYJoIF3SNjHlr2Cw6X+en3?= =?us-ascii?Q?YVIfdTMH5pT4Uh3SI5EiaxLquDjPMUfWAjzoVyO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95FUoe3lEJ79ypd21Ow1Xfi4v99DBc1s4XeGZtmJdYW8mo0g=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?FrW3+lVAdUUsdsj+CM61ZmcP3C2v7SIMpH4xM35ZBMsFoQk6gCKfUX08hkHw?= =?us-ascii?Q?/Fvlp3KHoG74mNVDJsGXM4Kq5hzTX2KKljYIu0JzNld/KCM3iAiXkY7b8KRC?= =?us-ascii?Q?e9lRoM8lre0+DoX8rX2I7VDqksdF/+ejqlRQ5N80p4sMJMAyot+ZtnpFJVf1?= =?us-ascii?Q?FS9FRghhxLeoeyg9GgDe9UyIw2fFe1CnA6e33+/3mm8XR93raPvRjYyQn3Dh?= =?us-ascii?Q?WEI2TLAVq1fiirt6fld1TbTMEw29QoHWlcLbdpzKrKspryrBH27Ps+7oLY3f?= =?us-ascii?Q?Ch8BClG6BdZGDNU5Jt0TWYZm7HLodDISjBnk95Xb1+f4sJ3IE6qc31+BiorJ?= =?us-ascii?Q?NcHaCde/puBUFrdHeladOZOpcD3eqezmElFXosNKC1Ut2iCwhsFCmWwrPsdk?= =?us-ascii?Q?o+SK+i9vJU6KEeuC+SXdpTM9YkEFAO8E2mnFjErSUXDeLgDip/LVESCI35/4?= =?us-ascii?Q?C3wLpDkqRdmzFyomsDXd19mM7XF4muhG8qH6i4BafFMFB63+oGakhnJYL6gq?= =?us-ascii?Q?HfLm//akodgre6tWrZP4/zJd33NnViyiSU9EaCb5RSNqmtRCjM6OItvuSoVH?= =?us-ascii?Q?WWfmdzfUAQGmCj5LkadrasET95ntGMsJSi8o5WYAFuMVxJeMOkKEbkzdnae7?= =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nGtUkS0QWtVQZL6U1hWvOCOYTUlk9NEz19KpA3EF?= =?us-ascii?Q?qIkE2pCOo3j/gE8DDxyAhKGoJN4dIUx46A+NpYzu?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ffccbec-ea0d-4080-10de-08dd97afc342 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:30.9896 (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: S/UPv8XjhS/ntHapQZ+v3gqfW5usb1m0/LT6ZkFkpYblWMeHKMfSUiW0an3GJH47bNaPmzSNuxW2kHZ1ubJGfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-GUID: VPy4D6OAPiCxJJZn5b2hftSUk-jvD7pT X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a3c cx=c_pps a=WxcSnoYPg5jl6yrDmkeCeg==: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: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX4v+TVh1Qzc4E dqZ0+clwnq0LHf4+d8Y6atERmIbvehgmfyrxppaHWd/tpkc2SQxROH6pEQAUVU013uD2suO96cO 9C/fipUoKr9MFsQj23d043Fke0vQpUcC3o16mwPRvaFegT0AzUThlJwNe6fz5SV/dC0wP+2AcsE qh386epXZr3rCLFpXAYhWfnXeS7TBSMHLLze92We/NQsErVlKe59wwjWL/etHYr96ueggobd5FB XJc8OsO/8oXj8JDaJyCDUfxXGoTm88fdExz3h3lPU4xZ2y7Ozs6Fl2QfARb/AD37sAHLYZdQYzZ uLIDHdhuRL7uCTtqiz/OVHtweeNLAwJl+ZZjgHYzEl6Lfla43cZ3dECGht8pQjXRxOI8viV7BmL NvT0xT9/RVsfZzBbrfDy7+bQ2e4hkJpwI8dxEIdFgTErBuKJg/O+ZngC7CC5kuTvlV4y1Afg X-Proofpoint-ORIG-GUID: VPy4D6OAPiCxJJZn5b2hftSUk-jvD7pT 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753890875116600 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 dff6efaaac..e89400ba03 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 Sat Nov 15 20:52:47 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=1747753731; cv=pass; d=zohomail.com; s=zohoarc; b=CWItVRoenqv1p3evR3I/D25nOHV7WQgxaMb70p1uxEdXh/QJv1fhYOnfAq6WioQOH4BBU0PQ+0CtU7XraDafTltnEtPMaru3AHI/t0qQB3bKpa6oKiM6SW9QTU2iqOQXXZKcmKCwWRYlL72hxJB7p7bAX6B3xjESYaAaCY3WX+w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753731; 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=qQNvbELn+CJURy6I7NZxDvnMXKaa5p+lqDaQN9JIFeY=; b=Ht5YMmeeuCn0Byx5xWWURJzKfoemvVZ/CyLORDozWWMP6xU4Nfsx1Ec4J2ZudK1VfL8Xrq2zsbzBBh6qsFueQGSD1LoccmM9RR96mCbsmoJ9eAdfIeZ/BHFEt5SIEgZzYFIA2avGLLV6IUwV8uWPxxCxyArBtClyz3CubkQSJv8= 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 1747753731680303.9386685798463; Tue, 20 May 2025 08:08:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOXS-0004XA-Jx; Tue, 20 May 2025 11:05:54 -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 1uHOXO-0004Ns-Rn for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:51 -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 1uHOXL-0002n0-Oa for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:49 -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 54K7UjtW019012; Tue, 20 May 2025 08:05:35 -0700 Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhec0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:35 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05:33 +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.8769.016; Tue, 20 May 2025 15:05:33 +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=qQNvbELn+CJURy6I7NZxDvnMXKaa5p+lqDaQN9JIF eY=; b=VecJQbiEx1cDy458bi/ZJHDfcJUuIYjGmSeL7P8LK202Qj3K5Ar7tqYFI dm/aUWmhgBbpqjIyxMutGozDX68MPzGvSVt9HByZx8Q3WYqKEMTRBU/18SWAaXpx ZJzG5n+nWFitVj3cub8kdUslZVcmjCWpOfRdLXxbnN++8fN4VxskSpiaX6ZO9WW0 rBe4B8VkJPAFR5CDsSvPbsWNqlYK0PJ096lvRwdyUyVbf0UqXXiL3vOcpttRjvn3 BdTO924zAgEDs4MYKRM7Ff0jhYdx1j7so94ToGk+KZ2Buz265uUq2Bp5atvT9ZRg uYQztMNPdT3YiJncqNSdrDExP7s3w== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YpiH2Fo82aTUT3CBYy7ulxpkDf8JESQsUpuFZKlAUJQcDbTPxEL7oJvgk9ttPJZ5zHZ8dV+BzTRomBXVjSWQs0Hg+hluzG5EM95RfBXf8vnXjgeYJrVIM4srkEz1/MdDZWI62c24i3ULwd5ONr57//Yig3fjX6L8/xJqxHbPmIN7SScSTxyBOt3dClIne6CTiJVJiOAUYpgdnoiFcQaiYN+bAzNSmlWo4FmZtzZPLvJgx1gsAKYlYIPly1p9cGJKyWYKacX46Ffm5Bv1ireaCkW7cgmCUmWITDMPSkxS6KNkcWPI3ELIETuMuCBtr5L9DI1knCFEQCnkJS4VFzYJ5A== 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=qQNvbELn+CJURy6I7NZxDvnMXKaa5p+lqDaQN9JIFeY=; b=y9krikUHtKyIdlAneZObZXfYbBFOvR+Vm2h5SvEoeri66TLEOJyxO5wf9N0wNh41jFZpXnLHAsSA3tb7cqhydLuhOvkUnfvULibuxoXaERWofVfkw2Czglw0l1153QJpOkpJBhqtT1poEYnca8vCp7jRMKr1kZRd5Y15wF5OedGiw5dAsZNu684Pz+VdL51pBDZlabMZJZ2bdG6Rgr2notQibWqQ2ufRv5V7KhP06XFe4rHJppiWO2oMFEGOcHQP70fV+eRgAUA4Cxrgrp/Iju5LmbBZcjlfm0G5cnAfjSJSdIsqP1/eh4UfPObGoVm9d5H/GectjhtlvHSmUvLR5A== 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=qQNvbELn+CJURy6I7NZxDvnMXKaa5p+lqDaQN9JIFeY=; b=RKGnPYa4DaiI2AHtgeMbOqUVxitJRsRNrM066o/+gh+cPBTdecI1mnqH55ZLBZUM4zvL6wMy3lx5VnDPx6BatLtzQ508SMjOMuS0ZZgvio7DrJqKC4lvxqZJuB8oM6ClWq5XNMKNDoBVxKu1o7hIxN9OiuyARhxHLqCQ7ilWUCERA5P+bQTWVbCiE1VT1Q49M+rGVYlV0lLI6mB28dURkNqrnmZc0G7/qbspnIzX2Whm6FmzyKS5UidDJwdj8bu5ukbUMm3czrblVyyUaVnyGRf7a/KmVPMge3KZryK/FlV1Li5STsnYQVG6iYGP7iGGctmppJGABVhxyG8EnYzSiA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 27/29] vfio-user: support posted writes Date: Tue, 20 May 2025 16:04:16 +0100 Message-ID: <20250520150419.2172078-28-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 90f855b4-bd67-48e4-c9e4-08dd97afc4a3 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DVI4TS0XNf5W+1pjvJjyNvlrMs2RIo0dwDlyv5ed4UnrOr6sT3V+gYYW4XPC?= =?us-ascii?Q?VGMXBrnUGkhliJPdPz+ElpAQGLA/TB9f4vxIoojE6lplgliEWa1CNU4Xb42l?= =?us-ascii?Q?0GJSNg+Adgj4rfR2+G/9OPtIYu1vHbuVBoY2GguVVwarwk1MtTBBywobjyfx?= =?us-ascii?Q?QvqXKH+oj4sRg5vDUwoxHYTWsK5sJ7t3O8LWkUvS9gWdpf8n5FVCGZKHyiCC?= =?us-ascii?Q?DUT6QHrqSh0NqDVWN7rAHuQY9E9QWnBpIOatlym+YUd6g7t9MAcw1w2ZpuJp?= =?us-ascii?Q?A7ijqw1fOScL84ZTdJhlVwtwqv2BP+H8We1Ni8fbpB0cwx4IMZshzBKbyUwz?= =?us-ascii?Q?gQ+W1UYJjoZeB+m0/v55PdargN/tA6MAI3yzu+rXRNsngy7r1DR6SKdmO2nX?= =?us-ascii?Q?Wa9fhhyRO+wb9JH/kSSABE7Vv8WYh1id+LIhVQRoxlPUacncU0bTaDXlz/kU?= =?us-ascii?Q?/OUAiTtaRVS1WaOccYFqbUmRsUBf0LpwB1aIv1tcwycjw5Nk2FcJ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XSVDhQV6AwQ8zlBHJNq6cXHLDfeawtsZgOLhZAW?= =?us-ascii?Q?0vKM2Bqt4cw=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?LsHNkJriTRLLfqL3JGWwHk7p5bMbDgOVUuRCetEd6nC3VOa0eiFuQUncr7Vj?= =?us-ascii?Q?K7Zj6IS9Kjrqp0qGQaU/sKv+PIzUqnbhKFi1cLlzaltnFkvLfj6Tr8BGA4AI?= =?us-ascii?Q?S3JCdDyaqEwzI2RxRe9FSw2XQq00de4ZPymdS/sPYRYLOfHDgCBjSU+nyJuP?= =?us-ascii?Q?mx+hOX4ijPh92PfFyS4OxvYyge8qkuzJ/+AdnLRSkqacndN/wqIDv3hkpM2m?= =?us-ascii?Q?DcR7Z6v57wil0LA3Ab1biDfjzG4OIH+3M+q6TJ1cTBBbP0vcdHmmqw40gHR5?= =?us-ascii?Q?0Akk8nBr51JgtwkOcmvn3HjRUUpV5HZR5v1gKqOmB2IuRVbNN4QrvZfAbKzF?= =?us-ascii?Q?HlPwoQc0kyDIsqouge7Io3U70oXZnW0U4IyPJO0cdOqSUMhOqUfF33A+XRVR?= =?us-ascii?Q?VWq4TmFeXakMNH8Z1Hmjm/RclIfKa3K2dlbenhYuCE4WT+f0XjdsMBn4JQZn?= =?us-ascii?Q?HUMAiZUkr5dz7Zjnwu/nn/KmSzrEdMeBfEd0So1vOomz8z5rhluxLELUsjOe?= =?us-ascii?Q?S9URw8b5tivaHQPg/dDOz17CV7BF50t/F8XK5ZS0/P60omONC0XpgTfB8Ueq?= =?us-ascii?Q?h/sqS9AQpyDUmitTSUNyUIhPZ1S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KC/2?= =?us-ascii?Q?GMsM3+0ehbMhNZEeVrIJbKMYWsTdlRKfc5WrVHorjdBrGuBw7O49qPPcnbRE?= =?us-ascii?Q?YE17UxQbPpROrr/Ik4gBdN7Uwc498Cz5x+FQ1dep?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90f855b4-bd67-48e4-c9e4-08dd97afc4a3 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:33.2115 (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: ODDvHuGm0MXejgU9JDHQWqX2YWZSqsXbPyl+Y8tIPUP+BYSkvX39JlHWxQmeUB0JDzA8E3YqWOpdK51nqCmKdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-GUID: qPbMGcG4-G-aReh04KIuTELHi_Ui8iYV X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a3f cx=c_pps a=MHkl0I0wjNeC5ak5fNlPUA==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfXxjyy2sQOvhxM INRYaCDpJJSSyzJrlhxdSwVjg6r8of658RG64MSo5lSfc8hKMcPU1uXqJPEqIwHKflOlSAgo5Z1 ZsH8KzuohxfQOsfrZtJM8Q1YB5zggLAQq/0nWair7L18DUGKsx2Ur640t413VCATKjXU++JPTu3 lryo/T7G5VIESUsaAk0LWbODxP/XdfeiPh9UQ7lLZnf0AJNE+QGsh62o4K9l3deBnWg7cSjjAM9 QKHQtulj0UBk6bHvBTFc3AGgz/LJGI1KewE/0u1G62RXw8aCdZvC+RHkqEAO2XKMjrU4eaucK1M RsL1kxeYPdmO851CsZPbFoP8TkXzF6NUJCN76fJZpQfm6dhuPO+WpCe9EYdzxHJsaigPuGELn1C 5Yq4KtLkgOQMMffWkz9Y2umx/3e0WZyqYucQZ97OhyuBUPhj0hR9OHn6EeMIiOo0dSGe+5Vw X-Proofpoint-ORIG-GUID: qPbMGcG4-G-aReh04KIuTELHi_Ui8iYV 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753732284116600 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 e89400ba03..07fa340c17 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 Sat Nov 15 20:52:47 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=1747753615; cv=pass; d=zohomail.com; s=zohoarc; b=O4komj/yqNHv7Vb4a4vWHK9h2nukcKCaL91TfwAE1YN6dFc2dsdaKStN49PXjlLZrzWtZS+7AqS/XBIUv4YEaOTvhJTRfpcqebB60JXhx/prEf/0j1jy5Wlq8kgpUsGJpTGNCbjA/OaTCZWJXu3oktMjEDmJy3Q0vZoJQZ+YlKA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753615; 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=bgUuQdWR7zwmYYMxUYffOXXm+2j70J8wIfRJdmtlmB7NVySfvsKqOSc2jIf2Mii68wadixzfde4A3wIz8oKBz88anK2qk0fRXzksn3xyVRFKjQqAdV3sLxdvX2yOOkVjIsFbI6VhiuZvNEhPo4GXsEHBpxhDszLmZPGYQSue1xc= 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 1747753615504610.8194355750254; Tue, 20 May 2025 08:06:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOXl-00058v-Bi; Tue, 20 May 2025 11:06: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 1uHOXS-0004XP-1V for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:54 -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 1uHOXP-0002nf-6B for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05: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 54KBaTfg018814; Tue, 20 May 2025 08:05:39 -0700 Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2045.outbound.protection.outlook.com [104.47.73.45]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46rcm2hygu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:38 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=CXd2NeK/ET6uD8gmkhbk2vh4nYzQVltKbqv/Wx4cy uA=; b=ptsdOFMBAZTS0NsjR/rah3CbI7VRqVPaNufgn3fYttvN6YppL/11tH2Nz ThknssiB9rDjPeIiqCvPW1cmUq1n4jH/qKhIKaFcI++FQky+hdRIORW1yB+B9N2g Qq91p9zNjwyAGORJUBjTJnt3lQyf3ajCmbHZH4hTK8SALvdr6+abAN5xEpEftolg SqHR8z950EGuJqsYL+K7tg4qzE4rv+/4F+nAeAtkIZULhER8izHp8WfxuBynaqU5 LO22O4sDiKv7ewnWIQYa6McWufztd/XT09WbnfObMT3maacIBa4IUoWQ714u1qRB L7HsHiwduLrfdl6eBNJ80wesqsWyw== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xy50z93GvxBkmisWdtGUUDmLCTCZz0UitFbx965xLL3wdNr5UwlLLtvF/i+UVOWb359YgVC3xtcs7e3fQkD935Vrr8V8gy892NuITjpIozgZKvkMhYNFYPIWcIytgQvPAEQJhqEhFWZTUbylzYz2xyETZRAmMDpf5t6cY2sN7s3GUteqcz2+pmW/ef0HEoO0+4171nCS+lfUQPBj8PTr/pOlhmgiMJirdln77sh23pSWRD69ry1JiW1/RDVE7lX1VvxZ8hkClyYonYQHnHy+OfN7iJIOnlE+j8IgaZnXcAIy9Ac6n9zHbGeJV7wKG+OkBljz21b9X3l7IVVBiUzFew== 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=Fvl7g/ciZ96K/1sCMrGMkM8DlV48tLapbw0qzfB0Ql65Kda2EMr20go03wuM9P1jNd8uyoInEj5ha2V9lFiUbhdHZqaL7GW3luIqhouVZAyG6aReChrJF1GLbJgeW+Ach2EqtuPYHlWOjmEGZ1jZRZz9cUktlkI1XbLcRuWjXsAQfn9c55sRK+GfQ9pbEuFwOM8TPEMK4H/O+w3S8NSWyz+LmL1P7dngqo0FyrZ2i5Pxx1gMHJUgETufeVRdFz5Nq7HwCSiWHZLFdHsKoN920THe0mwATmThVKg6j1WiSHaDqQ1JMPr4ix0rHFXQ5QFic60pgenSnPfzk2JF5EDpyA== 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=p61tleRs14gutYRODXNeaxWO2dGaS3l0U32qoKwRroK/eiojq+8lUlzNb48FuXobr9V0+tKhamEyVPNdYB2iMuYSyp1lCWEl7ydtnSdZqMKnzp0OCv2vpjVnzKLxhQb8ILLgm6nf+8BIFQlCpyppV+C1GBjBzp9+9Lei6eOJnvub1TjRB2Vh7BYxee2YIIrDY6fvwHfkOV6qxE39/VqDn/WAo1aJIOz880tm3HzVtC07GFZ7fcJRXt1BmkyOGde4+YnTHGMfwX84FDLoY3mP/zo/T1+FzqxRK4x5jKdXnw1Ggn5nHVCufB8lGUSgzkU/t5vTe7rlzIGvr3q/hF/SVA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , John Johnson , Elena Ufimtseva , Jagannathan Raman Subject: [PATCH v2 28/29] vfio-user: add coalesced posted writes Date: Tue, 20 May 2025 16:04:17 +0100 Message-ID: <20250520150419.2172078-29-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ec7456e-32bf-40d2-ff5f-08dd97afc64d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lWmohK0NhlF5psuiWK2vSAy1xcNT+V5vrtXhTatxJWwnzM3/81vJIGWDR7vQ?= =?us-ascii?Q?dPX3nGXVTAPMq9cf4V5gkyKJPkCIT12NQ4s0RVlMnf+rHVZKjoBtbmbtOgjA?= =?us-ascii?Q?Y4eidSh+BSJa+OgGHRffVA+cMS5Gk6gAcoEpcb8c0Yyf9a2giScO5bmrijVn?= =?us-ascii?Q?xN7c3uk9PVNwm1EZN9YAlQO4i74OlSmakjnaPVWuORha0vhlcW9P+wDeZcnl?= =?us-ascii?Q?nzUA/Izlk2w2TE4m7CFuOXY8Bm+2FDBQ1tVlU72noauwyuVL0Rk9eZ/g4J0R?= =?us-ascii?Q?7pCBgIZ/ZlbzDDbvGibts7tk+RKQCDq+BCXmhdSlH5aFilSRbjQLBC8J8z/o?= =?us-ascii?Q?ipdDiCrXZUZIHcKDKd61/U/uW8W5yspVqnWY2AiR0QPxbjJOqYx/DdzU/tdi?= =?us-ascii?Q?PQj+cSONsz8Cx5GtCG1Ww1mfXDlA5GKePyXiPGOGlAcOUYv40iL7wWl4+o+6?= =?us-ascii?Q?WHdnirzC3NsX32nuzdhr51vOMZgoVYUCe4/qmm4EHyPd+Zryg+sgn3KrHYi7?= =?us-ascii?Q?z4rF5ajDv9v2nwzA3XCUunZEzVY8D/2VkB6M2DJq1KZMml8zA2p0zt1bO6Ot?= =?us-ascii?Q?kCsyY+D/hbaC1D2l/LSTtRdYf8XqYzgMV6jjLAEDuNsX5ugLko2G+6QkTXzk?= =?us-ascii?Q?kQl2qO9BoAvCacRyNpcxXS90SYQ19C2MR1KgtYKSAMznaQ64N1+CLsUmQBIE?= =?us-ascii?Q?P/9KYyOlqMVe2r4XRSBoqY/CgQa8e/RQNrQhtIfqVB7HfC9RxhAlnF362MLp?= =?us-ascii?Q?/hPlQ+SK8tl/CzfOzJMkpLfFvneMmN2E4VzSTFxiwbJMb1E5kLd3OxG6RXAe?= =?us-ascii?Q?zkhLizV+7IZtXGSrFGvSWSPXNSCG6BQF/jKvZip69Q+8ln7iHAfKoisMUd0s?= =?us-ascii?Q?8CUX25VSqqkMnpNH6UZjwJURTD1BAHeqFB2Ke+AcOoMsCjuWpACdta2GzpMU?= =?us-ascii?Q?3gXLRlwQ+xeQbwgAn24smuM84eYq2Y/ByGFf5HE5pl/QvQLZvG45kkda3NR2?= =?us-ascii?Q?Z3ToooHsuVVnC/NLuoZKNCE68kftRxQFuPPh1O4EiGgaNU1Pj94jrlXcMVta?= =?us-ascii?Q?asZwzjdiXIPw7MmA8incZ4U8fPwQy5XyJKaBXzcDHzSiylkN32Jvzk7bWXxg?= =?us-ascii?Q?akEM1cKrMLe1D8zqMylA/3olX64FnhQ3APabpTndaYbTCxMBZ4YvvntZtT0e?= =?us-ascii?Q?A7ZqdGyp/sTPytwqT0etZgAX6D6+lkLmV4lL6v4LHpgCEqtOk6QcHDaa/Ecd?= =?us-ascii?Q?a62OVf1tjd5S5F5XQiu3uoZaBa+OJqN5dbYvJZZDNumzf34XdLFO4JrpRmyC?= =?us-ascii?Q?y1q4x61+01z/2TRncnr5N1Sj1g79ItMHx4Rqx9UNfQObJ7j9n6Y1OvVZgJC2?= =?us-ascii?Q?wkLMO3tLOvkdh8LDTgpTHFXUABYD/hGx6OKNnkXCY99FcZQvyg=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?sWeFPF6jzOqZ44Grq5Ox2dCK7MqPV5KlHaxCwYajXK5Z01dxAlyHLDTy5UTo?= =?us-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Ry5tCNV7A2X2gDyhihU?= =?us-ascii?Q?QUpX/kJ1XN0asexcEgsfAXEyqTvwnkMfxPVKtcSoDbC/RLstFlqM0R4JjZvs?= =?us-ascii?Q?BN7p0HxnO1ckkH1oZyplk55kbREG2K8nx1wi92JoriHYGzgtrVpTetVyZuRL?= =?us-ascii?Q?z6GN7E/9u62TZ6vtSExgcgFDNeVUiKC84nXkvd9Y5iQ2YkZjNiKuanPcIhB/?= =?us-ascii?Q?LPXL67OOhBPXcjbPb8BQkKBYIaxz4eeoy2q4MDjSTt8/IaENMjkl2n1AsnvS?= =?us-ascii?Q?9Y00WyWyR5xUBz9JkK2CPX+NoUX5aBmjIrQhVYDKcOkbOmws2q4fFJancXw0?= =?us-ascii?Q?QCxKCELrzaUZQx4VnWJNJJpplhfIejyN1Yr+qrXcnQAt0z7GNYPojr8zMjr5?= =?us-ascii?Q?UMvPUCnQUwD4CZwIwgLf5uAqMShZYoULa8QIm334s7BoiDLti4IAiS1y8YxO?= =?us-ascii?Q?TN/SitfvkjJQcg4ZvNYkdGXXUEDN6rUO6zQ2I9UXP9ihft0BY9zLUxmEF8cU?= =?us-ascii?Q?qe+E9dHgc7QfsjZYophqjmP1Ic2Shr3FeMelCfsmufeIwHYqVXH/Vw6QAJ9V?= =?us-ascii?Q?lBSoTccAJIPgVEbtRLqvBsU18gpYc9es9AichAKV4rYWqfwvKLgnGTctIKJJ?= =?us-ascii?Q?B+vrFbj1Tmc+d9Nx2fCtqQtblFETKt0YgFiAFK40?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ec7456e-32bf-40d2-ff5f-08dd97afc64d X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:35.9848 (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: CdleM4H+zBAQKrKlLkpBSZictGqYckTCbGSVTVvZ/b9nlGskgWHD7TGE/3hXQ06wjezUOUJMLMiYE3yYryB1DQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Authority-Analysis: v=2.4 cv=HZoUTjE8 c=1 sm=1 tr=0 ts=682c9a42 cx=c_pps a=o99l/OlIsmxthp48M8gYaQ==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfX5rlIErOpNZAX dRsSidGtlc/Id5wu7hctkUt6cjbbR/W85EtXF4ilEMnGH7mT7wAGIaK+d1b3vTGMVj1hkd+c7jN GmK00WxwYvaV1jdPupRlV7zRu75AtyrdLYlNvrBsj8zX8ZvfmULSxazJSVHOnqJq2zCO4PJ7DV/ McsimWgQaGCrBjs59in30GmXrAaU3EHfqSY2+SElkAA45Vjm38iO/+E+2q3IulplFwIWBQKZn4L Asj8ubz+4YrZ1LOj70mZ5krQiEFM/J7+JzytQ3gdFj3l5gHqbOh8nqRGQ5vNR+r2z9X5xp3ywJ4 ix7NoknQDCy/nuugYyWuUOwHv8AKb2e0dP1qgP0bhNd+X9JAVxhEp2v4M/8C80XVC1MATVuxLbt bdQxs5NWnQEirt8P9XGvRB9agq33K5DDaJZUGMllDr/bBSVFiAtg9Ko5Q1kW+dI9pucCS242 X-Proofpoint-GUID: RR_TpwbaYi9KW0zvTRsDokR5WMPCbGS7 X-Proofpoint-ORIG-GUID: RR_TpwbaYi9KW0zvTRsDokR5WMPCbGS7 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753618246116600 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 Sat Nov 15 20:52:47 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=1747753786; cv=pass; d=zohomail.com; s=zohoarc; b=UsLO6sDPqIPAY3JVv2zZGBzoHhempNc2iHukj1YnE0rtIvfDkVqTzKYjQYa3t94tTNaLIsyWSnLpBghaZtj2PR2GlLNbIer9GetQBp03mPWj746w0zAMWiRPj7XLftCAW1lsEjKzW9ITCB+fO981P9m51suOu3wRQTD7g7IBaXw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747753786; 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=cSjlaD61CXs2fyz3fztscxTd2NGujqQhK7BQ6fyPcaGQwCd7OWrLB9wFC/24oHQdBGs6seoqhHAfdrMf0wAaSuFmaFRqUyMVh95SH7UhFbhs2j3LcY2xfyNlo4q3vUASulxxybI5U9NLH4SXcFrR8SRveLeQpAVyHQudQeG61Bo= 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 1747753786530336.4036739459101; Tue, 20 May 2025 08:09:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHOXl-000570-7W; Tue, 20 May 2025 11:06: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 1uHOXT-0004bG-IG for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:59 -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 1uHOXQ-0002nx-SH for qemu-devel@nongnu.org; Tue, 20 May 2025 11:05:54 -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 54KEqgNb027716; Tue, 20 May 2025 08:05:40 -0700 Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2046.outbound.protection.outlook.com [104.47.73.46]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 46pshhec1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 May 2025 08:05:40 -0700 (PDT) Received: from CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) by PH0PR02MB8582.namprd02.prod.outlook.com (2603:10b6:510:104::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.23; Tue, 20 May 2025 15:05: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.8769.016; Tue, 20 May 2025 15:05: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=NYHfEYolJYtB7ztdkTtSBJXJfFu8OJVZtPxqxjVBU gw=; b=Dat0Gmjnno3WqePPiuucR29OvKp/N+egOSsZIBr4Fr8N6m6hGbh1Lbqua oit9utHmAXuYwq92WtN46/r77xu2DJTPvXZAvntL6jqv3LK1X1QATdZe70JPMwxB Fhl5NhTc5Cht0kBgBNJyHDAH1aZaMVHLn6rrLylI01NOhQFeO5oyfsvojDV+Q9d0 XapsUJaeDaGEwOHvdoy/F6kBtTElEcVN7t9eAm4iEEmRJcCqEfadwMaWTdHrQM4c ERfISw+sUHnT5qZJaCRBc4La6f9mJk/zHibBAi4vpE86JDZPwRc8EzqAbfwaMqEL Vtu1R0hUoYHxrZzEMvOAJQxzxelww== ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JlzlOX04m/c5n6NtOO5csETChK8p3NvVTpm2IkgCjslZPGfU+/JeDlxT9cFCKQSXq9jY5ZX256s3yyUMBk0I1h26b7pSReMqL10IeCGOVJGp5Y0qyJtHRBpKwBZWATXVXO+UvBhWP1zrFtsW9raI0BYZXygqxohN+KjaZOlNFr4izHlWmgEZnE4ZHgSUGkyjl01iskLptO2Sa032o2/GBVst4t9pTWnsCmaghdIO5HBi6xooAQ5IAMB6AIGeh0hrh4geS5a+ysRsMVP3aDAPcrYHC9y+yptnz9ypzDWbkGxiu+AZYh+E0uahKFYzc91KuPnngaAVEx7ohuxMDYNa4Q== 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=NltH22GIxkKs4KNmNHgBEaEmp6pBK/vNEOeWfRY1ZNjfRtGB7IJdnQSUenNlc+8GR9ZDs6lkixuo1Wz9dcJXnGXZTgUweT6R77sv+4JEW4c1YYAFngQCQ5JLIAIwk0VQQLKeDez7E7hcleSmV9y/brGrOWL4yAHKziC492fpwo2G3rL9Xc8KYAhpklSaKGoQsxx3su4WIHhry07JAyJRb7UFObJB8+w3qtDKwAblYxPleHLZIPdfXIw1agiDLtMs5lDcLiXsGoP0owjX2h+DSCJF1oxXaNBkkJBuprYoHxaq9DZ6Xc1pmrvQ2wbWtrUQ7JgLDP2cQX76WyAFx6Ju9g== 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=p+qXTHMIatEbDANOvRZqDY0X8e0otEi+htcdKOSu6vMTfpSC9Pfn8wHkRhxcLcpxJs/1+DIUi81ohQYLcLbjAt73I0z1MbPY9TKPTFvirSSjWvHuNxbdlauDFiDwNBDxh5VetxDdxgSc9tzvdjJxYB1NifqN1D8qROvv/b/sePgRt0Gr4Eb5QjO4vctr5n9ojeieHi7TOjW1jSm9tzCckRHJbUPnavuLtEgA0hrdPI4SPCn9getYs2v5bJ73zAEVPDS7U5sJdu1x1NzzgukIeMYvwUqRC4nqM7bNDZin8/4suDU/h/hQ+8YWEDwaP2pqeddCaluD8fvRBFmvPkg9lA== From: John Levon To: qemu-devel@nongnu.org Cc: Alex Williamson , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Xu , David Hildenbrand , Stefano Garzarella , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Levon , "Michael S. Tsirkin" , Thanos Makatos , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v2 29/29] docs: add vfio-user documentation Date: Tue, 20 May 2025 16:04:18 +0100 Message-ID: <20250520150419.2172078-30-john.levon@nutanix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250520150419.2172078-1-john.levon@nutanix.com> References: <20250520150419.2172078-1-john.levon@nutanix.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To CH2PR02MB6760.namprd02.prod.outlook.com (2603:10b6:610:7f::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR02MB6760:EE_|PH0PR02MB8582:EE_ X-MS-Office365-Filtering-Correlation-Id: 9821a76b-a70b-4b91-d6ed-08dd97afc799 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?6iQfReRzTh6zMYgOGFlUOyB1IPrh1i79lw/W9t3CDgpTDwtGFT89KlKymfoc?= =?us-ascii?Q?38v2Io1jXJ9D+NhGQoFksHYdv3CPxeNlVkQQUtPqlSLknzvmAqHMfCnj1iK1?= =?us-ascii?Q?8y0kAR+2PClJcHmjPdZjCLjoA14BH8M5MdaesGIKzMX+f1sGYL8l6Es6h0A+?= =?us-ascii?Q?/7J1oPRtimgIJ90VgFLxisD58XnfyJic7oyaZjaJHemp4oFow4zkROt72xr+?= =?us-ascii?Q?Px/B4OLYa+iJQOKATObj0rHMR17c3oJlmXVBMa6kGca6QJytr3Ik40fvIS9u?= =?us-ascii?Q?x3V/Y44nf/E63zg8bvyeWPGVNXWNxKzpdvd9TvbGPijsjK1SHbYchw6udWyK?= =?us-ascii?Q?DYqh08TGy7oy3tXHvZQhYg6QhJzJIj0YA6gP6fX++JJ+9eKCDlHUw9EqbR3S?= =?us-ascii?Q?r6T3Kuid++YWv6UW1tGJ3fzifsF9Jmz+PEJtLMPYcTjZ04EKu63fDUe37v58?= =?us-ascii?Q?5T/4NHN1lR8aDjH1DUjRW2ClK9n9UCqsPU9f/5vlhKDOXXt+HY+03gvFoqxh?= =?us-ascii?Q?5V+np6sg5qorwzcu7JYrJy31tYPmxhW4p6uudyhibpGA8Q6fKURsUqvoHezu?= =?us-ascii?Q?umpKQDe+zwCmcYlM2Xc/JqOsggMW/M44Q9yQX5LkkkCjpbzERwcWyeJBa1ZG?= =?us-ascii?Q?90StrVuIEWQ6jXyqikPsaKEs1ODzjl3RqAzFJC3IHssjFM1qM7nxZ9oz37St?= =?us-ascii?Q?KYSaafGUoW1PERhDDXY1HPwcoUeMHtmjlceKCpt4crYIRoyX+cG3pFQIyJzm?= =?us-ascii?Q?ueTJmUOFHm2yhYK7X2LC4/0Tx/wOHpN4LqbaisUR2clupedbN4u9lSLcno3j?= =?us-ascii?Q?KnD6nzlFZYo4wA7ZHvDofBEOVhfiB/c3w6lIs662cffbhBjFw/bk2lW07GtW?= =?us-ascii?Q?iyhV9AeS6NkLfy2eLyqPeDIV0mA1osavrc14fGoOAwTzER+bmqGttLjaQ3Ye?= =?us-ascii?Q?N6Ro9Q+CbofI2gB7ePnnrAAD+WwGKutAuk+QHJbOZQZYxmjdREp7mVUn1DBa?= =?us-ascii?Q?MYeTXg0CSF4qCQ3siTXsN2E/DbnpIinKSPlMVhNmNBuvKiuPsTo23+RtTCOe?= =?us-ascii?Q?WQtU+X/wt1eARMedSCJH5lg6DFvkJoEzMlwpzwj6DtbeP8GJptlvBSQ2cgvj?= =?us-ascii?Q?2QNoW8dMOrRj87OU3sih+ECLixggepNrCiGsRNp/SBsQU7EwOw90f4UDsaCV?= =?us-ascii?Q?v9i+df+UMes8lQ66pLc3SskkrvciXfx9bCoamzpJUwGPGzv6ikM6n1CwyC3O?= =?us-ascii?Q?DWaAU7Z4SYcy/6QS3b4F3wEDLPaLzptpJRqNokCVRVSDQAooP0O9lpUqsqdK?= =?us-ascii?Q?cGt+7aiH0KY8MZSXbpN6LAv0vlW70zu0+dYtHZVJuzZ3zVI66gzkSqxYqbPx?= =?us-ascii?Q?rYB2cOv5+x25Q81NBWr3BN5hTK0Xct0JG2WEZAPpqoqxNwBEoXuIK4XT6gHm?= =?us-ascii?Q?fIhNnDQpApU=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)(7416014)(1800799024)(376014)(366016); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?3y4I5ccDHYpIZK7Ktmvs02GogIvtylTpHelOo3vD4V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q?yGzw+eHaOlK4nSzHH9BT1qMieVvO0elgbNhSMjXNCBpPyhtOCjYEYf+uKrne?= =?us-ascii?Q?4uzmno2wyKEq0geXfE/5kLqaaYsKk3T0vdrz6cWjtQR6lM3jbm5QfAeyHuq9?= =?us-ascii?Q?T+l4rTJ9rhxv8M5/f+oXi9VfNiW3fvjfPMK0jWmTysqZpw1YgqyvC9epOWym?= =?us-ascii?Q?EPX3BovHL05HHyHTnl8T/GOvxA1YM+fOu4gWLY4hWu54eW2XgvBj0nbZxcV1?= =?us-ascii?Q?+TNPAdVWH9aUHsu8/jFS15QGfOGMNaP9+aBODwSoJz+hnv/EL17ejl4EXrGl?= =?us-ascii?Q?RGoOlZI60jTPGOeRXrt23Ib/xZPz4UTjI4eNTsLRyKZ5YBrniPuHvdEJTwC8?= =?us-ascii?Q?lxZBg4QDA0NOwfBJA0GA3WmziriuT6JMXxRltTRfvlzK1Y1A59sUfQp8U9bM?= =?us-ascii?Q?MKep7FtcdmbQja2+f6K3adMvTsxTkDXJJcQIpYwWp22qpPBp2sKp4q9vjOcd?= =?us-ascii?Q?r3xVKuQR7wT0vk9Tj1khVjYkbAjyOPc9Nsj9VJJAav0hq9MCKvvf0KoMr9JT?= =?us-ascii?Q?FbxorvplRumTi6Su08UcADSWKmvrIMIoSs4rGacDHRFKqsIN6312g411fTW+?= =?us-ascii?Q?LZM9qXAvUg5I+7AlJ3o/6Qss42ssfsD7ASmSFQRHIwgpJVc3ufZOQw8/uY6d?= =?us-ascii?Q?f50yaxSAG/i6D+OXiIjKesG6kpOUjKcd9WHUDx5D?= X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9821a76b-a70b-4b91-d6ed-08dd97afc799 X-MS-Exchange-CrossTenant-AuthSource: CH2PR02MB6760.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2025 15:05:38.2057 (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: k4BUY142ZZKjwtPvXJXcPDcPxFE959dstBffQLLa3HnYoUBB2hnrzW5B7FPaHTdPY4JZxK39BeUzYVfw4wP0Sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8582 X-Proofpoint-GUID: Jsg35I8VSrZ0lmDsUugOPZUzmNRNZSG3 X-Authority-Analysis: v=2.4 cv=SoaQ6OO0 c=1 sm=1 tr=0 ts=682c9a44 cx=c_pps a=wXDgSYWbwZencpnnUUTq5g==: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-Spam-Details-Enc: AW1haW4tMjUwNTIwMDEyMiBTYWx0ZWRfXwTJ/p3iefjKQ ToMI2Mi0C5tD/5DspkOa2rTxvo7dT7YDgGdH7BFvBjlWTlOM+5TTT9Yh0Kso/MpLIhCLMyZ+2ZF Ix36hnJ0S/9gS8ffylWnV0XYh7n/cK1ON16dLRBkiXbA8guCHbL6qge9pxY9hTL6nt67IL5Ud68 BwMTM2eu8PUtgnnjSASXZ1jHp09jZO8UfV04px32jBC42WIqsdgMlBSpwj7NQ+s4eoyDLE//gEc jPLpcoqqrmETeuhdHFAhg1t8wDndyOuSFKiIUavcs9l7eJ/xUH7HVtFeX1r7otLqJfNsRZRc80H +ar3XTjBzC1dK5tppjpmkwiPpAL8XuTZluU9/FMW3FEaYJ551igVAYyVS992K5vPb2N3Gt19VKP ADzEBwToGdlh8UtizKuTJG2GxVgUrLlBfyVqI9naxzAnm2cLmmLig0z1waaOowJ60sm8uLab X-Proofpoint-ORIG-GUID: Jsg35I8VSrZ0lmDsUugOPZUzmNRNZSG3 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-20_06,2025-05-20_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: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.487, 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: 1747753788992116600 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