From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.8 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796357931; b=ER3KmUQ9vSqEKiYW8eNJUn7Dz7Z3vRL4hJqs9ia7xyQcGSJA67eZh+SeexjD8Hr5rw1H yG3HSFOAZvG1uIAegW1DO4gxbEsVBFfjNVhTHkmKzf9611hpbpZurqLpl9g8J7hf9SDE7 sbFKi6Kj2kMI4LVDVR6iIaT0k1GPdzCkgOakimyZTOSFpitVK/s6UBS7Os4QfakW6FyCx QEECWJL94sXPGe0UWsCkI//Q1mXOQrdF5RLcJ8SJsEM/q97Q2lbVQfkJ7iXV3fbDJ+euo SWtM29UjYcvyYALa+S9Cys3pQrJwO4U8Mvp7i5mRaqJGhKiOiP7Z97YViecvMdZ2PAQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796357931; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=PqjGd2N3AbZAfLGvN0y/UDcRvPILgGDwvr52AGLS2a4=; b=EIogRGhpDegnC2GM1QpwLBfDoz3qRkwjIce3I6Cmql6tV7YccXs3PgkAMCr4FlHDJLR0 DlGgSNJJ9Vi6VdEPKMHhY6xUTDWvx03nibrImVWUCkqx+liJfuOX6uCFvLi4Dt7G9Ntw0 MunixR02iGgz+lQDouYJi5dTjiQkSk5+vc/JQZQBxXIpyYnX4McW4C6nIXjxozQ1basqN pT7fVWW2uqzQbnsWLGlMroWIxpa6bxPXeV+wdZX2eMY+CPlhROInMUnek1tY+lnoqhoiw 9oboWYnGHD+2shD9wobBie70nm+vP4YKRaIyoSO9luOuD6G10AxRYV3f3Gg+VUCNzUA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=lNwc4CiD; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.8 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013008.outbound.protection.outlook.com [40.107.201.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2F8460A2625; Fri, 4 Dec 2026 04:18:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B2F8460A2625 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=lNwc4CiD ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dks59Am46j5EdAa1X5cIsmFpc0f58fIakeRB5y5k3ilDTEEIFiaRgHsX8+PYatrJMPDuhc6Kb9u1U/gjE7jqD+8OdSb71IHt10k5r2vk42Raz91o85zPpiYO65sGNK/uTcjix6Pgu7B6zt28Ns4AVCqK3+L7ng9H1gXMln3yTiVSFC9ttEBVQBPsrSthmoDzn/WKKsOYChVe2M8+HNS5zoWZe6t7WE12M+7jnEp9dAg4NxkaO0h8X9Bn6GSnuEPZW0K/mFlvzfaJ5uaWCPqYNq5sm3kKJJq62scP30mc9wB0VNfodkCYuYKfAfzamsL2btycDjkW0Yyi3KlbNQjokQ== 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=PqjGd2N3AbZAfLGvN0y/UDcRvPILgGDwvr52AGLS2a4=; b=GrPxgTfTg8Xyv5fz3bjIQQdOXtGqrj0mXYOZAl8Ygq7a/ovWXrK4ZtyiaZknkhwxpUPbMUTWkr9AAvqIyKks7vmhLflSA62AhSOzBm4TUzxuncnoPSpO81dCJU6HWQxkn878BltnaRZLZbSJKIWkRvyrbHokNgZpdadNhiZDqrfdCpSwCft389kbaNQ1apXb1o+28PP8UwwGe0j3PaXF/NgrIznj/WcbWzdQXlV0Ors0H1jRT4t8Ps5rRbGFSIw+TLesbPDyRJ83PbXJ+AWjJDkisWTfkFX2hBzxudL5j949ckJrDDo5DMNwNJlfhRYv+s1/9GS6NuVwx3gZ3D6vww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PqjGd2N3AbZAfLGvN0y/UDcRvPILgGDwvr52AGLS2a4=; b=lNwc4CiDYZzhqaHDseW4AbL1Nr5vKIwK8mTJM1TYzPa43VqS2p2zvYJFDd9mP16AEBlmpfZ4SJe7P6Qhzln1qVYM+fEwrFnyLf9fWWWuYeZFqZW7cVo8cW5jbTBjtowe/LpTCXtNetDli+BeCLbTp6rNiN78MkTpyhaxgM6Vr2PcHSZQjXaGj1qLDmxZbkr/xcGWs89viWtMJx+cKFpiL5AiYQrLf9fvqiUNbx1K9CAHHYYxWoUvFIosKxMb+2He5zJY3F5LkU3IlTJuJ1SCuhtTzb4qkc6+zWcF0qwfPrDiy4IuRzQyb1GYYIXKhz4NmSYg0Jg2r1Xoq6pGHhCcdw== Received: from BN9PR03CA0048.namprd03.prod.outlook.com (2603:10b6:408:fb::23) by SJ0PR12MB7036.namprd12.prod.outlook.com (2603:10b6:a03:483::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Fri, 4 Dec 2026 04:18:43 +0000 Received: from BL6PEPF0006C3DE.namprd02.prod.outlook.com (2603:10b6:408:fb:cafe::2c) by BN9PR03CA0048.outlook.office365.com (2603:10b6:408:fb::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Fri, 4 Dec 2026 04:18:43 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0006C3DE.mail.protection.outlook.com (10.167.249.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 04:18:43 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 20:18:20 -0800 Received: from xinmengs-dev-vm-linux.nvidia.com (10.126.231.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 20:18:19 -0800 From: Simon Song To: , , , , , CC: Simon Song , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , "Liam R. Howlett" , , Lorenzo Stoakes Subject: [PATCH v5 0/4] Rust VFIO PCI support Date: Thu, 3 Dec 2026 20:17:20 -0800 Message-ID: <20261204041727.4021092-1-xinmengs@nvidia.com> X-Mailer: git-send-email 2.43.7 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0006C3DE:EE_|SJ0PR12MB7036:EE_ X-MS-Office365-Filtering-Correlation-Id: c6297211-0d98-4574-c2e5-08df51bdaebd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|7416014|376014|1800799024|5023799004|11063799006|261009223027099003|18002099003|13003099007|260925021911599003|260925022911599003|261028144727099003|56012099006|260925021311599003|261102123227099003|261022105027099003|261026121527099003|261021123027099003|261026140227099003|10067099003|261022075727099003|261021121427099003; X-Microsoft-Antispam-Message-Info: T7C7LhG9t9aH2IHnAlHaPelsGQJXHgR4IW7yYA3Qc51krtDlyI3BU43P759iN8TDLdyqM75wi6cklGQHvIrvekis6PuJU/bpon0uBMNC1Eq2Ub7nke3Z3bETPPVcLPMV01Uqwg4DdpNHQsWSLSErHkB69bFuFIEd2nEbcKEC5cUHRhWFMhPfnUda6oTj/sbZ6DlsrlZd9dwvBnrIiZCJE5LuxOnuwrsYx1UL8bDw6EdG4OCgo9LkX57QDlEyGGVbCcA6GodBhaR9YRDZikQIPfuMM+QR1EfeBhGqQwxHJfyuJ0qD2SjZ/miHkja6gWjvMGJWSk9WFt4cKQZJHzo7XUXNHTz3iFcnSd8a5waIOSaj0cIP3O8U/1LnNiSrHySMoYBnn+iMtke9eDHS2Bc/jGUxI5OED+F74AxtD+IrAWNN23UjvvpVuA/IsrDIpM6bvwWaQqHJCkleI/hL9LECh8Ogjxv57y+tefYndcPE+UUJ9RhLMWOszt8uvr6QX7kIS11CdfXM2oF0CBMTVF9aKhGMmxU6cZJWQJDxax9XQYWLlD3MsakZk2JZCGb6eomGGUpZIvRyV9zj3hhzxztyu2kKrWkp15TaHLbmM/HTTAbcGlIsZ4AZMa+qB3C/vFeoKTeewz8HBqcSBYuMthMUpE6nVfDB6i5Du2YB2AFUysHgRm5hHcVnviZnILNghh0gK+FDwgMdRSWQ8ps90sHAZA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(7416014)(376014)(1800799024)(5023799004)(11063799006)(261009223027099003)(18002099003)(13003099007)(260925021911599003)(260925022911599003)(261028144727099003)(56012099006)(260925021311599003)(261102123227099003)(261022105027099003)(261026121527099003)(261021123027099003)(261026140227099003)(10067099003)(261022075727099003)(261021121427099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xOQirSkbZlrKUHkGjBjLqbB1+e1tEdgKmCCG2l/dfQst0KfElGoXHPb1WGz1zGUfU2sTjuQPaYtlObxVJKO1Z9V58FGOwdmzXcHunmnijzVN09T9EQl7MsIlXJQX/J9/FbNYCzLPdxuMBpF+43TwRtj6kIDO/0S8z2v1D+ZpIM4iKO1l094gh4zX3+OaiAEOV/E6CVyGog9ZIKNNf3nW61E4ov3ct6DwYihtGINhUegUKCqq2dWz3/miHbLq4mvLHT3vSjzu9nIjBItXtOULcLJ86qakkI0znaS0sbM1ocy3geiaa5UDuRelI1ghjSJKrW+N4KOs11rOH/tPiJ3C/wDJGCXP5TIHTXO2nUrWGy3JzFRd66JelJi04SFCRsm3ZBECKKi0xZDduoarQevil0nwMdi/4+QcS4h6ps/6DKMk+oYfClyFXriJzJh6aX1O X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 04:18:43.0868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6297211-0d98-4574-c2e5-08df51bdaebd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0006C3DE.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7036 This is v5 of the Rust VFIO PCI abstractions. v4 was posted as "Rust VFIO PCI support and NVIDIA vGPU driver" [1]. Up to v4 this series also carried the nova-core SR-IOV PF interface and the NVIDIA VFIO variant driver. Those two patches depend on Alok's vGPU manager series [2], so the series did not apply to a public tree and Sashiko could not review it. They will now be posted as a separate series on top of this one. The four patches here have no external dependencies and are based on drm-rust-next. Patch 1 adds UserSlice helpers for bounded forward traversal. Patch 2 adds the VFIO device handling common to all buses. Patch 3 adds two VmaRef accessors for patch 4, the VFIO PCI abstractions. Runtime PM is still not part of this series. It will follow once the generic Rust runtime PM support [3] and the PCI bus handling for it are available. Until then, vfio::pci::Registration keeps the device runtime active while it is registered. Changes since v4 [1]: - Move the nova-core and nova-vgpu patches (v4 patches 4 and 5) to a separate series (Gary, Danilo). - New patch 1: add UserSlice helpers for bounded forward traversal (Danilo). - Patch 2 (v4 patch 1): - Remove UserBuf. The callbacks use UserSlice (Gary, Danilo). - Make InfoCap a transparent wrapper of struct vfio_info_cap (Gary). - Use 'res for the resource lifetime and 'reg for the registration lifetime (Gary, Danilo). - Do not name the hidden DeviceBase in the public documentation (Gary). - Use one module-level dead_code expectation (Gary). - Add #[inline] to the small DeviceBase accessors. - Patch 3 (v4 patch 2): add Alice's Acked-by. - Patch 4 (v4 patch 3): - Let Registration::new() allocate the VFIO device, and remove the public allocator (Gary, Danilo). - Give the Open context of open_device() its own lifetime, so that the open data cannot retain it (Gary). - Pass a UserSlice to read() and write() (Gary, Danilo). - Wrap struct vfio_region_info in RegionInfo (Gary). - Remove the unused DEVICE_PCI_HOT_RESET (Gary). - Assert that the device alignment fits the vmalloc fallback of kvzalloc() (Gary). - Check the bound driver at runtime in Registration::new() instead of the const assertions on the driver type, and add pci::Device::driver_has_managed_dma() and pci::Device::driver_has_sriov_configure() for that (Gary, Danilo). - Add #[inline] to the small Position, Mapping and Device helpers. v4 patches 1, 2 and 3 are now patches 2, 3 and 4. [1] https://lore.kernel.org/r/20261127224928.1511382-1-xinmengs@nvidia.com [2] https://lore.kernel.org/all/cover.1796191007.git.alkumar@nvidia.com/ [3] https://lore.kernel.org/r/20261124113555.2480381-1-beata.michalska@arm.com Danilo Krummrich (1): rust: vfio: add PCI variant driver abstractions Simon Song (2): rust: uaccess: support bounded forward buffer traversal rust: mm: add VmaRef::size() and VmaRef::pgoff() Zhi Wang (1): rust: vfio: add common VFIO device handling rust/bindings/bindings_helper.h | 3 + rust/kernel/lib.rs | 2 + rust/kernel/mm/virt.rs | 14 + rust/kernel/pci.rs | 39 ++ rust/kernel/uaccess.rs | 44 +- rust/kernel/vfio.rs | 366 +++++++++++++ rust/kernel/vfio/pci.rs | 880 ++++++++++++++++++++++++++++++++ 7 files changed, 1346 insertions(+), 2 deletions(-) create mode 100644 rust/kernel/vfio.rs create mode 100644 rust/kernel/vfio/pci.rs base-commit: d9da44362d77bcbf1f5bfd2ba1c514e776fdb07c -- 2.43.7