From patchwork Tue Oct 22 00:20:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13844942 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 89305D17151 for ; Tue, 22 Oct 2024 00:57:14 +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=ZiC5SOn5wx3+AyofS3XSFjYoRsquGrqqghEx28hfyWA=; b=mED4Z5KpzX1XEW74JBwdpARSD0 VzfX2w4H/pPl82s//FA221/cWq5SYp/gDx282Jsn66IEthSFm844ABmSOwjPUABUx/C1TEI4ASHWe ERM8lmPpY8uQFT6yF9tFKaQebQtXc4wbRdq37jj0eUezsJm8Yox9Ded2gTF1W61ctlKfdI7ksI2Vh Itnh1+wzhLtcVII7sdw/sU/eXXC/BmCoCpLmDuQhyAgN9GpJC0lAQk2a6TQe7HM/fuiyWhXaDI0Y4 kLOWinBBym7wdG7DH13NGqDDgejQelLCpr9puelk8M/qlDR6VHrLDi8I9mUsajB4DQOKXcrfrft9X J+SwSI4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t33Co-000000098Jd-2LOa; Tue, 22 Oct 2024 00:57:02 +0000 Received: from mail-dm6nam11on20630.outbound.protection.outlook.com ([2a01:111:f403:2415::630] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t32e3-000000092Yq-0NMk for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 00:21:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zj7S3bdVQlLbmVXHJa3mf1xLhpVnlIAAIl39U9C96+2R/dXdjtLkjz5Yv6NEbQyc26YE50WTUtHOUk/lMd48Te4M2iWRnPRilKJm9JLVnwpjlkAuuHW2+EwiD6Fw4TOuNJiTZYMmxF5hk20tcn2E3WDcieuYD4BHMLYyLaJSilCA9gN14xCiuLdmSnCnGZAcM35r5jccjF+5DQqAVlmCnbNYd1LLvygQ7zx3dK/1TrmoFDSW/YOMaKNQdDzlT1hGEZe5FV50lM2cpO7icYy9kf/h8GTy+on1K4J0oZ7+vXOoGEEbLAmF9oRuqbdfYP7emY7tsc6bVBNz7T/ux/D6ZA== 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=ZiC5SOn5wx3+AyofS3XSFjYoRsquGrqqghEx28hfyWA=; b=m8ql4LxQRFa5O56oT4Qweobf5zbjo/aL6UJlDJxKQSmAdoIHWMR06FC90Z6nxtmSihZXT70VIyXY/CC53K5/IhLCKGE2/nqdfudiarYivcPfOj/NzdEghZEOgJFqV2YJXAKvup84ExPp6EcGt9RvWX5k3j1F3iUKAK9fCsB3dWDWoFyDvJZNnmWWYkyKvtDkB6X+kVtXVVwgPdWow/6mE27SQq6IFy808jBblSTalUuU/DidwpVtfXNx2XmgWJ903kjLsU9EH2cuOg93EH/B82Eki1tooyZ7z/+zk8jZEFRarAk2t99nW1rpFsRjM9nEg8d44ktcGCtuIkXwBlvB0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=amd.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=ZiC5SOn5wx3+AyofS3XSFjYoRsquGrqqghEx28hfyWA=; b=lQCTvXHaTt54/4HsQ21wGVDmVIcMf9CBdkm/9rSzZehUSYxwulLPI4tzJw8AQn9wFRmEBYv6VqHindiSTuMF+hhNkUwG1gm6AL3fTAvzcEkeVYlR6F8W6QRGCh/plGMHsHsJiOjPUtcrQbHzGl3c6X1u2cDG52KGavTJzOKCHBQcw3FZcRWCLAj3QtTQnxUjMQvhkikM4/SGMxzbFAvdp6dkVqTUEZK+Em1CW6yD5eBuy8WGA9E1yybdX7pKcDD4htr38utcDYfaRe1qmu74StbyZUOl+Wmwj+M4oa8YIWui9MrQBcPF+n+Lh87MKWwc9WWkkSjc/zR/xLHur+hr2w== Received: from CH0PR03CA0016.namprd03.prod.outlook.com (2603:10b6:610:b0::21) by BY5PR12MB4100.namprd12.prod.outlook.com (2603:10b6:a03:200::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Tue, 22 Oct 2024 00:20:59 +0000 Received: from CH2PEPF00000149.namprd02.prod.outlook.com (2603:10b6:610:b0::4) by CH0PR03CA0016.outlook.office365.com (2603:10b6:610:b0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28 via Frontend Transport; Tue, 22 Oct 2024 00:20:58 +0000 X-MS-Exchange-Authentication-Results: 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 CH2PEPF00000149.mail.protection.outlook.com (10.167.244.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 00:20:58 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1544.4; Mon, 21 Oct 2024 17:20:45 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 21 Oct 2024 17:20:44 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 21 Oct 2024 17:20:43 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 12/14] Documentation: userspace-api: iommufd: Update vDEVICE Date: Mon, 21 Oct 2024 17:20:21 -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: CH2PEPF00000149:EE_|BY5PR12MB4100:EE_ X-MS-Office365-Filtering-Correlation-Id: a8071401-7851-46f8-2ad6-08dcf22f6717 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: PBfzJHcddq0cpfJdzKaBtBT/5zlt11VOvr8gVX9SloQdnnmxWQgptcMug9Dv7UwJEdff5gKjn8zv54H0AOPfHsmHnJqEsGQWm84Ad2ku00nn+wd6t4NOvdzN1dcq6R5VpX3fNRhou8mXndxDlPV8FmCv8OUlVD17pKK/u6u0gocBDmp0SDkyyHUV5nj1moTRoYN+oTep3uYYqBl42vn+V8M9zkduBI6d3zBveM2RG78i6cLNOoWc1kpdvxV/xPS0s6fSsjpDGxkKNfnd+zOqbX1Ub1jsxDHC8omgIri+FC/yDFHWHkQnQyI/tsQV6RhQOgvFhivfbCoZe26yTgBr0OzUJYLztCYI03hF/uAUz3m0qulc7BquiAdQeWz4qEiV39CIKSD+E7+cVazaB4klFl0MqBJ6Mst35KJ2FxB0+7/dW68FbfuZBsaEPXp1eqHQ6eSz+kgjY8YzahW1Q0zO44h1BFTKlO2AIoRZJ5yIdy7yTdCZbGBbolaD628FqjNtknAv0EkjVZMb8byQt3Je/vm+EhvS8KBShXVXKx2KX1OUSUorCO7FuZPdRvuTb9MngGrwHETkEp7ZTAZvLXuMvKVEQudKvxfwN4hy/QYO3kafM4KfC4dv9wYk9bUFBytt9FLQtbE5MVXR6EkL7aPy97x/mfVS0QQD+tkg+kI2vrhdFJwc+S26piFHORN7zam4Fi0uAMeyKMVC4/RREQ4vwO1G3cKOYEQgYfJW+sAW6pGR8/D96dL7GIbFR5TL13OC8WS4VIKO9DgZOnhF6VihUX63QcRCCVwdQiSntOyzmXqVj540wOy9uoYPE5545rrNn1BGko4otnWvHTb5GPQptjNfx8HKZKof8ogIrXWT3xb5u8fsf4kf+f8Q2CLgOxTOdvVfrdd9TDclrh6EcmIRDCmHvb8lE8YqAyKO14jJQ1LZkyKKu0Z20bQdfpmbdffCTzHv2/O7zadG+IZyTZw0Rsxpo/ip4ahCKuBZHyRPPFWtMWOOXAodyNRY2v133J4gdZ+1rJIA6ezj+cP5shOC0Cz794c0xc+9S//HzeJxo079/yV0HFP1gc4DOfyc6ajESzrC6ZmBuMpfk0hCYWBYBYMbWlkOv5YLSi4lPD5ajtCO8mYXCc6Jer1VnXIzd2oXSP95MZBw+/4/jYlxWcZf9gVVgxppto8WSTMTXJqYGfmRSzSV4KoqPj/7Nanu8dp6GqmfbMQDb5dYHQlgmgGFfNTiNStuLbMz8slY1wVe9YS7Qty05zuP4VFyivrZ4BYP3NCxoBnQHIgxB9QUaLn7WSFl3hRCl2xQRQRS2+DUOi/IaLSkhwk29WO99X85lUHCeYuXnnnTYolJwDEsJUO4KnhVMiT4Seq3CrjEtsEM+aL0N4h28iX4RrC3Ob+xyWZpFyVoTEX8f8qBgpADVx0K/A== 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)(376014)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 00:20:58.4536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8071401-7851-46f8-2ad6-08dcf22f6717 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: CH2PEPF00000149.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_172107_168711_2D1A9A3B X-CRM114-Status: GOOD ( 16.32 ) 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 41 +++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api/iommufd.rst index 92d16efad5b0..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,16 +146,16 @@ creating the objects and links:: |____________| |____________| |______| _______________________________________________________________________ - | iommufd (with vIOMMU) | + | iommufd (with vIOMMU/vDEVICE) | | | - | [5] | - | _____________ | - | | | | - | |----------------| vIOMMU | | - | | | | | - | | | | | - | | [1] | | [4] [2] | - | | ______ | | _____________ ________ | + | [5] [6] | + | _____________ _____________ | + | | | | | | + | |----------------| vIOMMU |<---| vDEVICE |<----| | + | | | | |_____________| | | + | | | | | | + | | [1] | | [4] | [2] | + | | ______ | | _____________ _|______ | | | | | | [3] | | | | | | | | | IOAS |<---|(HWPT_PAGING)|<---| HWPT_NESTED |<--| DEVICE | | | | |______| |_____________| |_____________| |________| | @@ -215,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). @@ -228,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: