From patchwork Fri Oct 25 23:49:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13851930 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2068.outbound.protection.outlook.com [40.107.94.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AB6F21315D; Fri, 25 Oct 2024 23:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729900226; cv=fail; b=PHh6lcuNKY4gQ7rYfC/3UQjzopttOccBt4gjEqSRjfnMnCbRtY3uqaZdhK0vHGePeWc8RcSE2dS9lj3Oh2bjUjYk54dEOVPSRhEGGSqRvVWqNLQENWpOinSqQzPwQWQiNG/iCj9GycT3ZcbdMq8RPiLzanNQuAAtvSDrLaDf5/A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729900226; c=relaxed/simple; bh=2LNF5OU0OVSNIig7gZL8BZEJt/GjtGXT4X+oFiIa3Jg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eWhVtAKfO4slwy2TV7ViikNrXpYnPqYRcDFfN8tEHyxhzJs8qiySPovpkRoy12OFS8hmO7HBa5zj7jhfvM2mCjtBv+v0CqngVQQ05scv8HagcwRj7qOQSUucAB2qFxX8zMMSgFNIJVkweTE7UMGUymnMQdzcrIsf38Iif2pGnh8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ZhRoVPTm; arc=fail smtp.client-ip=40.107.94.68 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) header.d=Nvidia.com header.i=@Nvidia.com header.b="ZhRoVPTm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OdGhwXSVUI7upYGP5UIsBfWw96RiGoNmwx+kg5LuMXHSLOnRJrnU0ys/LOUialDBYhEwJwHcROAQaM/vaG23/3sgq0obyHjB3PI7f74ekhufYpsbunkhlMEGzV+kF3ceEkjaiTdOIdv8zEuKgsIhSM3npVUNF1Rv4vGF6qVTqq0db6OKqoXNd82VqaH7wm8b99PgvvoeMsz8SX29G+O/EGCkoEAehYSs2aieZsyrKCDvRQK+nxvVZGXnlB+lQKe15tTVkDkjeL7pVUN7oLQUVQhXZtuBdeb0u9c92v3cYCTVu6/rstypMSfkpveG35fM29jt13Osqt10nUMoN/tXIQ== 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=nlxFZtXbv8TUgrDYmzDIRMchZkPrluvgK/V/ik4gZ/A=; b=EzygujGvOUGuvaa4Mqy8zOZ4bYzBagVticSi+3ZpjKol/qpeSORehLAibQ42rqYLpDWqovjouJBZRFHPNCp2C8Zb75KegryzpaGbIZ/IowMkgQshb+44HRA6j9+HKyW1Lcn8kWWLOlAOp2H0xRWqS31yWtU8wHib9TpV/3IWFoIlI4psLlUWAi2g96izlmuAwmxGZcpw21jsxb6+cfw6pruziSiPhNJF25HsTZ4Wk8txW/0ZgbYdABnfSmwe9WU0U6ledP2WuS+HUg3kiMXvtrVsM8AQaBOuViKYQNXd/5qSljNqXsnJgjFrDdrTzUdKJ9jZIOwClNZa2zsK316XzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=nlxFZtXbv8TUgrDYmzDIRMchZkPrluvgK/V/ik4gZ/A=; b=ZhRoVPTmAfgjSGlK0QCD0hlTlWLK+bmpynOQr0kbD5EeSNuUW8940adeb7RNHcw+ARU5LAGiEf5wcVgBanMbx0+AIpK+Cw8JFUkP2cHL0rVBHJvfroQvkqQ15mzfrsu8hnXxc0TYz2NEm3wgGHlXum3vWdsapMuG+PYpvupqKSV/i0RHsVZjfdTSsbVfzaMf80LdOJPjZrchZgvWFEPXo5rGmc7YtAiYGAGzdoCoFA0N5b9zQLgCHtoh4lOpo1BXhVzfVqKT5nebezQnRS/ITUMXvjOydZb6fKG7VqOCure1PcGdCLWY4/138fqdG+9kivSR86Us9flhraY/H8p97A== Received: from MW4PR03CA0230.namprd03.prod.outlook.com (2603:10b6:303:b9::25) by CH2PR12MB4215.namprd12.prod.outlook.com (2603:10b6:610:ab::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Fri, 25 Oct 2024 23:50:19 +0000 Received: from CO1PEPF000075F0.namprd03.prod.outlook.com (2603:10b6:303:b9:cafe::1f) by MW4PR03CA0230.outlook.office365.com (2603:10b6:303:b9::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20 via Frontend Transport; Fri, 25 Oct 2024 23:50:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CO1PEPF000075F0.mail.protection.outlook.com (10.167.249.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Fri, 25 Oct 2024 23:50:19 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 16:50:09 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 25 Oct 2024 16:50:09 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 25 Oct 2024 16:50:08 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 05/13] iommufd: Add alloc_domain_nested op to iommufd_viommu_ops Date: Fri, 25 Oct 2024 16:49:45 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F0:EE_|CH2PR12MB4215:EE_ X-MS-Office365-Filtering-Correlation-Id: 65acd73d-5f08-4c7b-4e24-08dcf54fc894 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: NsrxnRwaw/vMJ2Hs2l1oWDKK6u8T1JSwvuuuG10Hug1ftutpcgH8yG16I7NnU1zKKKMYC9zWYHUFIoMD3VZ7MhDbFBdTcVMB1SWx1rKjeSqVEuoiycZ3qOgcTkdPr4xzaqBl17RovTFBKYBfDOji591y8+KIBdKNCpT0x+jSybmIgxznjw/mV4qDtnTQaoFR4CWa5AvuK7eP22/Eh1QulcWWxvyAivyQyPfAYjpmaUPuTd1hVL3l9MfG70y6lKG7vhqfDkytkROO3u/Q2cFYh/diom2l5+t9t3zZbQ7DS9oWyVfgDPKAcqLEqWX8NDaxGXwOXPjPwiqDCz9vO/LHRZE3Z7hiXInNk6rnXif1v+PIbZl2V5ttZZ7qAUZ5Lk2lYbUCck6PNLXuAS7wNwAHJZJsF3DMEgNx6Dp8eTq21b8UIbXgtfH2cnfMU/SZ3vosGEtOoIZWu0dnREwhUUwoyxG0jvrKy3KoEQ0GpJgn+0JzWt8jmSftzQTAXKa+lBy6J6UQOAxmJ8US9DyRvJp25vrhdXD/eWrCgCk6wNJIeFS3ScPVVs7sVMqNGmM1OrQ3a1qO2/qYWvPQVhh0+xBTpCBGcA2oLWhwXUctk10fI+G8AQVB3EiENtTdzw8x7+XgHouuXunMD3ioipILLGKgkusIhFLcuIwNf8CYffYd1yvb+kab59fHcyvpKnlPfob+oPQC42vt1pLt/IqVVQ2wVSr3TKMtQtmiNGg+kTWs01dTWMvdtccBT18VEI4iix0hYY6baJnqQB/JIoEg2j5I4J6ZGFYeNkTq6QdncJafVNzkotUSlF/rtuTwANaE+9Vmd2L2CUZFt5qn0+GBIPaBQ1NZF8/2YuUfC7++bOobmE16IcgwwGX7PzDltg2IjXdHxIZYQLTuI11nyro56dEzu4ZlzABV2F9Jm8XxuZIPlLyU+RawOOqTnVMUq8AVc7yx7lCIrlJtWex6sEe3a0NsmMNN1k80Vqzq5LejpkgCgwQUsk7pOaYoN8bRJpNzNP2ick4zXjMt/DExcyMd9r2DXznGUlNsN4/Hu96zc87qqLMvW2gLJYvy7wP9Bbf27+Hje0OTm6DfxcexVDeOsxIMcGF3AKYrH5w5GQetF20v0AP1nCPd6y8ja7DZRmLYAhcSaphHFHH+T1+Htn6rS1rVT6+u84B8JlHlSJR4i9eqrxuhP91tpQs8ubbqfvql6h7fQqMvsl8m2P0/gZV02BIVJJ2iywVd3OzHzGEbWwSy9cU8fbt579g7f9vPpU6lKLUEZ3G6X2gqHiJwoMoyJ1e4yFrUI/f/+rUOA/ib6FPkTzuijzkY9Dkhx8u5rLSqhLi8DJ7fJMLbc4flY481t+o1xYEquQFMeqrdRK+w0P1Wp7NWennm/A2OlCFO88E2hZ/bWNjfhXxxbHzlklZks0YIlw== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 23:50:19.5214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65acd73d-5f08-4c7b-4e24-08dcf54fc894 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.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075F0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4215 Allow IOMMU driver to use a vIOMMU object that holds a nesting parent hwpt/domain to allocate a nested domain. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Reviewed-by: Jason Gunthorpe --- include/linux/iommufd.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 4435f21bd833..083ceb209704 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. + * @alloc_domain_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 *(*alloc_domain_nested)( + struct iommufd_viommu *viommu, + const struct iommu_user_data *user_data); }; #if IS_ENABLED(CONFIG_IOMMUFD)