From patchwork Tue Oct 22 00:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13844920 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 EF42AD1714F for ; Tue, 22 Oct 2024 00:31:33 +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=GDOVpruPVHaeXX/yLPhF82POkqZ88LWPXhGzJ+rlYmE=; b=KuADT5xVQjUethMs7xzx5nvlCK Qbus0OwrRUqiXt6C3ZpeGfzkxgh9DDqaPdML8wbXaMAzydtwOzo4LwA6Ko8ldpinNcKdHS7/ck33C j6Mon1tyVsVenyOy9CfhmyD3QHn1XOtv054JjqTOH/IiVbympx5AU4fEHMaRivhl9cFfoUjcVbs7L vUNctzt3PeTdiv3Mjw0V4YjqWdm0U0YyGcf+rFthpjmOdsJgUwAUh/qZO4d/JF3LLerhFs1jU39Ao Xl7XtY4VwiccNTYWDEuOT3NculqrbVRATcFvj2rWyYvgfcUqrRycpuBpEOfFVNiudaqzRr4MwGwjL 02BcimzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t32o0-000000094w6-1H5w; Tue, 22 Oct 2024 00:31:24 +0000 Received: from mail-dm6nam04on2061e.outbound.protection.outlook.com ([2a01:111:f403:2409::61e] helo=NAM04-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t32dS-000000092DY-3ce2 for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 00:20:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AUxPb7KgR0RyLdtjKD4ejGUe1NVcNaS3Z9AKyig9OFUTvWe7m0hm2P0VHJEsSGd0GhmQ7+PrGQEaYnxG5PZtzL0nU6wN5ccMx++qT9nvtheJwLHzfTp/3mbn8enpHInUuRfpBHlbiguMA4PT8wKOKpej+sl0B+rSDWlGmopqt539uE1W9ItIs6rkmRIRe+ySfNPaagp889kDg6S++pYSZJLWsXA5raQrwsZsvkXyUQXWR/ixb9aI7+b5tjoMgOHp7ZLmzC3jtWCt006yXU+7ydZoADBn2fD+dBxYPGrD7EsHdzNaCNYpmdUpssH6Iy/5YbI+lOsPzXNW3Cjmj29AjA== 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=GDOVpruPVHaeXX/yLPhF82POkqZ88LWPXhGzJ+rlYmE=; b=LJuGxXMxWLm3MbVXKzhmAWEGYUUITCo+4gNQtgythCWtT18XISfYIAB88TiHpd4K2MUIDwNXp3GmgRdGU+nXZ0J5BPWNU3clV9vh4WO87UB9icx3uzedY5VpFuEcxfUMYBrSPgkO+fGShNjWIr7hqNkfKGWOQJhmkiEUVv7aS6v579kZ7TKZha9clj8ikNc/sEwnmP+EeCG3Uwdp1vOcOrX9Pb0fKnhLiEoEk2bDCYGJU9HjN1yP/QmYXijbYhECoMaxItSKpOoqsxOI8gJRz1VuSvrnBU/ND1JeKX+ey8rppeNykLpsYeWNVjDqYqrdAxrxp6rebnzaYif8D6+wEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=GDOVpruPVHaeXX/yLPhF82POkqZ88LWPXhGzJ+rlYmE=; b=XAEG8GDQ9+iwgz5QYBnxgNSUH3oM2sF8DzOQshaET8uir9lmjT68JtpbtZHzTVFUWYwurCAFZnxgN8cXdnkPQQDjv6I+eGXLNJXP70PNEgdDSidaCiYRNGhk5M0RkZfy3AVoPjtjeHcf7ww31EN++Ar7K6oZDEStxeKiXAA5Ej7ZwHl3lq00M8/E4RadX5DvTePFY/+CYPsETi2BtWGKNjVPI6rvnNfFXgNdO7F0rZGizsQTEK7N3t7Llui3UDdqAlpoDGSn9HU4ip6/CXa28hWxt4Tv99zrTBbErDw6wDOF5dXblO0MyV6J4ID/zYwye/XInAmm9vygaE7xIgZ4sg== Received: from MN2PR03CA0015.namprd03.prod.outlook.com (2603:10b6:208:23a::20) by IA1PR12MB6628.namprd12.prod.outlook.com (2603:10b6:208:3a0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 00:20:24 +0000 Received: from BL02EPF0001A107.namprd05.prod.outlook.com (2603:10b6:208:23a:cafe::90) by MN2PR03CA0015.outlook.office365.com (2603:10b6:208:23a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 00:20:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF0001A107.mail.protection.outlook.com (10.167.241.136) 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:24 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) 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:07 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) 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:07 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 21 Oct 2024 17:20:05 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 05/11] iommufd: Add domain_alloc_nested op to iommufd_viommu_ops Date: Mon, 21 Oct 2024 17:19:27 -0700 Message-ID: <1314e12b76edd84a8c9d0f14a6598538c8eeb50e.1729553811.git.nicolinc@nvidia.com> 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: BL02EPF0001A107:EE_|IA1PR12MB6628:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b40a788-fb50-44e1-d181-08dcf22f52f3 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: JR1dMC1sNuD2TLCQbudjDLiT0eN10ofKJzXldxfMRfN6CdAtACMnK8URBambAgJU/cnGhzN2le1hS4JVzFdmOkn6mNZAH9X58LYh99PyO961PhahkbJTCGWhcxmlj7GtYd2n+X4LoStpU41mn99xccqO+2kte5JklDY1AP25YBsjjgvw8zmjGq/6IqexII23T8Dde+et9wDYivCCl3yiDzlxfogH++rdahAE/wdXpo8omD38KKTfna+ZbVQGisjN7SXk5Bf6RuUN4Gg4+SlFyvmgd/Mm9Q1Uqa/sw3kJ4tJxw1Q2fDTYctym+dCNQQQxxE+12aMgzTWDWOsH2YloGe6hA7T/0wwJJpRcXkISY/bGPDyHFpPKgjtlvAq/TkZETRPNRbg+OiiXaSJwsrkJb8kz2tez1oaVXTGFU/L0O4+y52zSG8VuCqalCOLJwVtux/aeTxfLueXESDZdCibMHJD2aREUW8Lm7Y/QJhEfJQwZD+RazwjQ5G4Dub7KV+nmpN6QG+6MbSEDXfAjEJt9gwa0EO72Mdh0ZOCLESyeg0gSaYnUds17LiVf1JeAaLDSV0KT+eeIgPO256utBsl77kisAkz+6AvA45BAop4iYUM7nq/a4/tCPS8XJIFB5tMoKlbphicaSaJ3oQDaf6ZMwF/7kW6o0z1gLTU2EvywCPQHRQTRYHxV2amn/JTV3itrSUXs5/A4zIsGFtZoNw1nCA5bHqU7ShOtBwygDK3Sx+SbFdH4ylLVTXokitRVEGnL00nF8dCnZVO2pY5tBZhzyJwMilxt4IQ43Z7bYo69eoCHd0u7DaWgIV3nXyPjLO9H2V+2ChhDY4def0FG0vqgH9QkXMrOylzhnN2rl5UGLgu420S2OLqFmNg6/wvsFcLeumnEBT+V7nsjgsCWq7+p3BGad4kFwIvTt85pu2XAwtkqYA1g5JCl09796sPPVRyz2Q36sLFG5bPzM3sBDDkIV79SB7YN6X5x5YdpAqLCASWRDg5x+i6tu321FODHiffZcaEtafKP9CQCFjpJvpwuY1QOM3v9Sk9iYMMVh2kWyWujPLL/7Wd8dDgy8uPDx1ih3tdkwlISGw3/ajvSN4u5PqAxPADHBvSePvcVKup71h1Pkwau2VX407clh5l7LhkoCMbhZWSoibfgPquXjEozJNFTq+Mq8hr4+P9thxAFOdZWqD940hRdoAbk0LiQXZDiERIQhQTAXXARSjiSGioaE9V0u4XLZQG2rsBThyfCNVoSFHhcqvrCpvQNZbX6voLm6JS1kaPLVpZE8NE1Zms6TZ7QA3D72j0VO6yOuj0vmK9wke1AnewyPWYxezHbEGQol7Jji1kLIkijVo00Nrdz33CACDt1ZZ2TeYYCzSW8fswRRA93lMtkp/fD5+9jn+mQvNQFLO+7mRNdyKQf4rBQVg== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.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:24.6988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b40a788-fb50-44e1-d181-08dcf22f52f3 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A107.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6628 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_172030_973856_9590D07E X-CRM114-Status: GOOD ( 10.65 ) 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 Allow IOMMU driver to use a vIOMMU object that holds a nesting parent hwpt/domain to allocate a nested domain. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen Reviewed-by: Kevin Tian --- include/linux/iommufd.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 55054fbc793c..5c13c35952d8 100644 --- a/include/linux/iommufd.h +++ b/include/linux/iommufd.h @@ -14,6 +14,7 @@ struct device; struct file; struct iommu_group; +struct iommu_user_data; struct iommufd_access; struct iommufd_ctx; struct iommufd_device; @@ -95,9 +96,17 @@ struct iommufd_viommu { * struct iommufd_viommu_ops - vIOMMU specific operations * @free: Free all driver-specific parts of an iommufd_viommu. The memory of the * vIOMMU will be free-ed by iommufd core after calling this free op. + * @domain_alloc_nested: Allocate a IOMMU_DOMAIN_NESTED on a vIOMMU that holds a + * nesting parent domain (IOMMU_DOMAIN_PAGING). @user_data + * must be defined in include/uapi/linux/iommufd.h. + * It must fully initialize the new iommu_domain before + * returning. Upon failure, ERR_PTR must be returned. */ struct iommufd_viommu_ops { void (*free)(struct iommufd_viommu *viommu); + struct iommu_domain *(*domain_alloc_nested)( + struct iommufd_viommu *viommu, + const struct iommu_user_data *user_data); }; #if IS_ENABLED(CONFIG_IOMMUFD)