From patchwork Wed Oct 9 16:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13828861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4D1FCEE332 for ; Wed, 9 Oct 2024 17:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OodBFEyxwxkpxrU3O1vgTk+R9PWLfXORshgxazPXvZ4=; b=dcqpYGlfPzb73wt6Nji9/NcCE2 tiZ6Jqruq225iLu0XVnklHBrN5M2oPqEhdZwhItSqAlEHJd5w9LsG9pVGjDt+JeNf5Q4PxNUeojZV n7LqqvsVqMohwykhULzfK4re4ibdcl4bGSnNdKFxtmdX654TZgvGx4hVz4zDRKnqPuGIVXt6Sg6SM aZbOwOKZm7qqlXq0vGXdjkDtB2oOHtm+6+EryXBelCf9AM/Oj9soXQcbNOWqFa3gIvN05c+W/JP5f Z9MrjmJ5Bsoc93kNQsw8UsqdVtaMTAyeNVPX3CHVAhTPmztpl+6kcelM1aTkMuPswTNCzG9wAwJtW YZ1+KVFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syaPL-0000000AAE2-01WF; Wed, 09 Oct 2024 17:23:31 +0000 Received: from mail-mw2nam12on2060a.outbound.protection.outlook.com ([2a01:111:f403:200a::60a] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syZil-0000000A0ha-3fgl for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 16:39:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yRvFDZ/0TyEaagc6SIJMHgniMDEiuxE6vbHWaKw19bKXMMTyhFQgpuwgfGj38vESn8q2Sk+KZbAel64Tx51bt/M3Q25g1ZznjQf6zBbl3wJHURIG3OE0WNizHWXcG2SZ+i+8bLQLGsQ2TLCj1iiKp012fxF9e8JKe8xHsM3Ae1lNhkvBVCMOe7Bzb6TE6PF7lvq6RrvBkZK9np/rFcU2tCD5TeSsxpRN+VWYHQu6RDGrL5AMzEysmS0xK2msaaBNiHE748znV94MSIeLJA1YVSne+f5D1s46pw9CxB9h3iT7XBLuNxLQwueJdEwDbeZ3gzelKT8PKBQiK1VRVPLsMg== 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=OodBFEyxwxkpxrU3O1vgTk+R9PWLfXORshgxazPXvZ4=; b=JPA5TzOT54r4NyXMTiBEZdKRVcs15DPMSGYEje92zsgKix3q80FOIm6jErxhzUEghucRAuEwPLQHzVd7FSfpgYvcgtJBsxwQJlg33PbWWYIlpfQHf8QVEmaj2Mu6AUUm1A7J3N1XxXXUsugo77035Zfte3rUtw5I5C3x/0JmZw5VKLg3jIybXZipfX/WYWsVsH6oCLiLH3Wc3rd1AIf0YECikY6i3C76QNhWAASpYKn1bBB9zTK2hra2FwM/Zt41oFK6JxomeSjtPKxNnZztLrLQro+VDCCeqyhOElzMpZW3dE056jZFeUtLnt7KcJLW6o7w/1Z269k77rSS54WRng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=intel.com 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=OodBFEyxwxkpxrU3O1vgTk+R9PWLfXORshgxazPXvZ4=; b=mcNDv7s+Px+D3C6FBcux3JBQntKe1RirC4Xy6M6ZBznU5iQ246cEnZmvEToz9/Gp3sMBFEemWyPzRSNAbw2tN8uA2nSAyTCo+kHSDEubhpLcgOv+wTkXQ+oJMoI6RkIK3KmOjM+Pw7nAm9Gjzw8/NqPZX46vTCj2oauRzXyuz3TEqdW6p/nC49LAftSOeUSNsKitVSqEXgQ0UgbLyk+NZLZ6Pb9iUxMUy1GCaXspP8gJS84EhnRdUTenWyZBYXyg82WOSZHy7zfMg+2XuRaqL/rinTxPTkSCGwW6Oce6Q8zhmup6SBixtkCpUqUy7vts3MhFnFzmtNMhTT3GhlE1zg== Received: from SA1P222CA0121.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c5::9) by IA1PR12MB7543.namprd12.prod.outlook.com (2603:10b6:208:42d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.25; Wed, 9 Oct 2024 16:39:24 +0000 Received: from SA2PEPF00003F63.namprd04.prod.outlook.com (2603:10b6:806:3c5:cafe::9) by SA1P222CA0121.outlook.office365.com (2603:10b6:806:3c5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 16:39:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF00003F63.mail.protection.outlook.com (10.167.248.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 16:39:24 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 9 Oct 2024 09:39:13 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 9 Oct 2024 09:39:13 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 9 Oct 2024 09:39:12 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 13/16] Documentation: userspace-api: iommufd: Update vDEVICE Date: Wed, 9 Oct 2024 09:38:25 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F63:EE_|IA1PR12MB7543:EE_ X-MS-Office365-Filtering-Correlation-Id: b9d69071-26c0-4b60-b679-08dce880eeff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: 0ept51ItioDuIg4wBzv79WSFxk5016dRRfCeIcdHt0XM/NMrWer0hBP2GgboW268npaAFHZykiK0d4MLkmaxaYHzTtU4IhiopPUKk+608lMZJZeNR0jiCjfvp4x6HzH6ndwkCy0QXCK7zFcDaA4+6JwDXvDWEAoL4SxOk7w9ZQye8eVD7IuqyUJxShZPz/HxYcMe2DgJ0mhuiqT9qmQM70oPZsAoC5IP9+EJlSsdMrEKHR147CnbSUaGwyQ8h+H+LfLGuxRaWX1a562r46eR50xEPIhuRs4A3ZNZFe0AVCuUNXIXidi6o524Kz9ULYpjhYqqJaRMRlF5bskm03wX8PMGFeS+sApXCfcTglDiyzNvhoC1KG4sB+ffK4iDxx4Y5STErVvFua6PTG1tv1WATvKE/26kDMjeYLGUUsTWH6zD0ErLYxHUYVCL5mq89bVm3CX0WsA0UCfwY4IGACZDpXUOowCgpzQBN0DW+h5AJjR/iqJyu05DuJYpekpVK02/r9UJ7m68fP/xdtKXpKVMANhIJo1eDiYpwUTgWR82zo3TKl0WQGCJddmFoVXOUNLAZK6F4ug2tGjWtj3Qr1vcRnPUBnafptw7ztU7INw5btfKi3xDJR9ulWsZhWUiYyniz8BI3i7aGhQgYasi/Kdtuc8VMd4mk+5oF5iI4dgVEsN7eIVLPW1vBh4NtR+3mZ5Ked3vnw29TK8vN55HrxE6z27ozMYzV5C2ipCwi7ikD6eaDhsGkPuFdmVGlZabo4QjKiVf4DJ46CDk16eAtz8RxOd/DdbFFCLW28LIIn0+R7PJyJvnlZG6gqYV1PV0Ep56GKRlYEfPYwWYDFDFCzSz7rEEeeLrwGTlpAIEPAh5be3tdIKxoaojGrUOm5WeII2yFNmGvZY4EqGIyiL7P0trcacmQAbtM+SgAmHYJyf9U6uEy2Udgpq01v9Xub7iLFgaANZ6S7V+Qmn7xvKegF8L997rIpVMPB2IWCNkeFOGarveRZDMf7GLkN8k2Aw8pgNlTLd5vx8l0xirvtMwP/0s2ClS2xt6VfmjWUUyUlWkk+mgGoQXgGrsKDqCL/vP5RCYc2cL3Nl0oXYzZFW6zGGtGCGKnaaEsKxLn64NnQ+SZ3DHdUuv/atYtEJrIKCRXffuwshdotfFHJDmBm+5+LjmPkAfiqg6NBRYzbao9Bm+U2GEeZ/uICmd2LDG+YRUb33BZ/E337EoYhDYWyKbY+bYwCw8mgWv+nVu9yO42K4dyxpv/xzRTgfoGVoZo3wNSn7lMs/x9hYTUVox1f8YGvLjjtHE1S1bE0BmP5x45q6sPC8zEmUEJi58fAMPllKY48/679KWxQ37Z7VrpCAs0rxPZVFMRH8r0h7eCFc7/UjLgPF5ln+GqeRHaO+yt9iCTQIF X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 16:39:24.2023 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9d69071-26c0-4b60-b679-08dce880eeff X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F63.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7543 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_093931_958156_ADC30A01 X-CRM114-Status: GOOD ( 17.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With the introduction of the new object and its infrastructure, update the doc and the vIOMMU graph to reflect that. Signed-off-by: Nicolin Chen Reviewed-by: Jason Gunthorpe --- Documentation/userspace-api/iommufd.rst | 58 ++++++++++++++++++------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api/iommufd.rst index 37eb1adda57b..3c27cc92c2cb 100644 --- a/Documentation/userspace-api/iommufd.rst +++ b/Documentation/userspace-api/iommufd.rst @@ -94,6 +94,19 @@ Following IOMMUFD objects are exposed to userspace: backed by corresponding vIOMMU objects, in which case a guest OS would do the "dispatch" naturally instead of VMM trappings. + - IOMMUFD_OBJ_VDEVICE, representing a virtual device for an IOMMUFD_OBJ_DEVICE + against an IOMMUFD_OBJ_VIOMMU. This virtual device holds the device's virtual + information or attributes (related to the vIOMMU) in a VM. An immediate vDATA + example can be the virtual ID of the device on a vIOMMU, which is a unique ID + that VMM assigns to the device for a translation channel/port of the vIOMMU, + e.g. vSID of ARM SMMUv3, vDeviceID of AMD IOMMU, and vID of Intel VT-d to a + Context Table. Potential use cases of some advanced security information can + be forwarded via this object too, such as security level or realm information + in a Confidential Compute Architecture. A VMM should create a vDEVICE object + to forward all the device information in a VM, when it connects a device to a + vIOMMU, which is a separate ioctl call from attaching the same device to an + HWPT_PAGING that the vIOMMU holds. + All user-visible objects are destroyed via the IOMMU_DESTROY uAPI. The diagrams below show relationships between user-visible objects and kernel @@ -133,23 +146,26 @@ creating the objects and links:: |____________| |____________| |______| _______________________________________________________________________ - | iommufd (with vIOMMU) | + | iommufd (with vIOMMU/vDEVICE) | | | - | [5] | - | _____________ | - | | | | - | [1] | vIOMMU | [4] [2] | - | ________________ | | _____________ ________ | - | | | | [3] | | | | | | - | | IOAS |<---|(HWPT_PAGING)|<---| HWPT_NESTED |<--| DEVICE | | - | |________________| |_____________| |_____________| |________| | - | | | | | | - |_________|____________________|__________________|_______________|_____| - | | | | - | ______v_____ ______v_____ ___v__ - | PFN storage | (paging) | | (nested) | |struct| - |------------>|iommu_domain|<----|iommu_domain|<----|device| - |____________| |____________| |______| + | [5] [6] | + | _____________ _____________ | + | | | | | | + | |----------------| vIOMMU |<---| vDEVICE |<----| | + | | | | |_____________| | | + | | | | | | + | | [1] | | [4] | [2] | + | | ______ | | _____________ _|______ | + | | | | | [3] | | | | | | + | | | IOAS |<---|(HWPT_PAGING)|<---| HWPT_NESTED |<--| DEVICE | | + | | |______| |_____________| |_____________| |________| | + | | | | | | | + |______|________|______________|__________________|_______________|_____| + | | | | | + ______v_____ | ______v_____ ______v_____ ___v__ + | struct | | PFN | (paging) | | (nested) | |struct| + |iommu_device| |------>|iommu_domain|<----|iommu_domain|<----|device| + |____________| storage|____________| |____________| |______| 1. IOMMUFD_OBJ_IOAS is created via the IOMMU_IOAS_ALLOC uAPI. An iommufd can hold multiple IOAS objects. IOAS is the most generic object and does not @@ -212,6 +228,15 @@ creating the objects and links:: the vIOMMU object and the HWPT_PAGING, then this vIOMMU object can be used as a nesting parent object to allocate an HWPT_NESTED object described above. +6. IOMMUFD_OBJ_VDEVICE can be only manually created via the IOMMU_VDEVICE_ALLOC + uAPI, provided a viommu_id for an iommufd_viommu object and a dev_id for an + iommufd_device object. The vDEVICE object will be the binding between these + two parent objects. Another @virt_id will be also set via the uAPI providing + the iommufd core an index to store the vDEVICE object to a vDEVICE array per + vIOMMU. If necessary, the IOMMU driver may choose to implement a vdevce_alloc + op to init its HW for virtualization feature related to a vDEVICE. Successful + completion of this operation sets up the linkages between vIOMMU and device. + A device can only bind to an iommufd due to DMA ownership claim and attach to at most one IOAS object (no support of PASID yet). @@ -225,6 +250,7 @@ User visible objects are backed by following datastructures: - iommufd_hwpt_paging for IOMMUFD_OBJ_HWPT_PAGING. - iommufd_hwpt_nested for IOMMUFD_OBJ_HWPT_NESTED. - iommufd_viommu for IOMMUFD_OBJ_VIOMMU. +- iommufd_vdevice for IOMMUFD_OBJ_VDEVICE Several terminologies when looking at these datastructures: