From patchwork Thu Oct 31 00:20:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13857365 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 CC0B8E68946 for ; Thu, 31 Oct 2024 00:45:04 +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:MIME-Version:Content-Type: Content-Transfer-Encoding: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=AfXCICcjx/gPooceCH2idpyPNlo530cMDJUtAU51n+g=; b=fiJyHqMyy+JRG06dF314iD2Tla TXR3JVf8nEnc5EMed/Nmc1QkoOR4JEg0Sk08aYzZhkSE+eu9XK6dRjOk9PnDCKsSCZ8Szs6Y9qMcy UwYjlML/kDxbPE4zEoXDuOqRZFWbXZlL7Hzgm0XayYdOOm/0sgSGDvd9GLWSDYgZJfcFDFHcSHlp7 Hu0Wj6fBFPF7not9GMuASKh9GUBSKTpT1vLtksg1ybQbFKhRtF8OcXU1AdI6DrcXwCjQxZmLD9vte rZiiFZDipf7iFiXXhPGgyKaxY6ykh8d7J36gjki2UemN2vvF2RpeqR2w2aXCy/sGxQUrydjDGPg2E uHXkwp8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6JIw-00000002Axw-36P5; Thu, 31 Oct 2024 00:44:50 +0000 Received: from mail-dm3nam02on2060b.outbound.protection.outlook.com ([2a01:111:f403:2405::60b] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6Iw9-000000028U2-2xRz for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2024 00:21:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zT1PajWwCdhzPFFx/fmKaOUXf2CIM5xxQYlLjsOrJSjtmP3qEOverjffeSv6Z8hyMcCd4PXgDLJg9qds6ztvPynhTOYFKIfxW1wnciYD/y5cwp3Xn32Gp0DGLgwwWF9N7fa79vndSQDvzt3llEnCDVj78+6Jm4zJU65g+ee7Ugfxzm9Lk7WOefpmr707DlrdKXnxIl3pfeVttlayJgLAlCPcS8OlWKet7DWXbJW/RPJTeetJcXhqN66ORirKbCvHTE40L4rchlbhZy+2TwNNOPFOAuqmD4ODdO5fu9eWOzrf8UbPKVnzIUil/OjO/upZpBOevvqsAypV7A8UgQ28rA== 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=AfXCICcjx/gPooceCH2idpyPNlo530cMDJUtAU51n+g=; b=wfUIEcOc9cWUEwqW4/6+ti0srA3cBtwa9OLYEtTdlQMpRZUDCFXmLVm/NAnZ2s5XWCQYWNJMBwaDIKzQWLl2TmqWDe1Nr2VlRXJBe/XLnIDEHDJVY4hEbALh7prThuyDha9JT2zwYZmwm59dW8DqzcPQZ73qV8EegsKeF/gBjQX8U8Yfe2sP9b5hUqmgXTC35c8JmPogU8k2kgpUBcLEOvnaBTGq/PLKf7Ap6vy9xfe7G8vDMgwZ8PfAvskLjHjgYB6IlbuKkk9bEA/E9TVFf8gUIHD61zQcjSKZoeRpDD2AkcwUW5LXc4nW9e7vvRk5LHR3Jc6DvxcdBqKKr+30IA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none 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=AfXCICcjx/gPooceCH2idpyPNlo530cMDJUtAU51n+g=; b=ckKPjqVA5Cec7L0OVzDaQY2t5gPe23r5X7iLul+s33hQFbU0dcgcEEyBMfXRpxktsg5svW8cLzKKnEYO8exTfyO2/wjIHVLM6K23oQ1LmHVI5ThxROoaD0dDnzM+7KR1NtfG6aKEXAC6zdAMoHiUKxK9B7EjHoWGcPn+/2dywW+0LthnUYB1whQkAAfvlAn/7FyIbfx3puXd8JzPPCFJj537WbKayjO2anF1gOL6HN3DsIOjKqy0594RN1UN8swoT6GIbUvvfBKcI/jRcdtA46itjBHKgIvqgovvaMp9/D3HTHK6E15QPAawQddv78ptkZs9iDdU+3aSoUW6EXSowg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) by DM4PR12MB7573.namprd12.prod.outlook.com (2603:10b6:8:10f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 00:21:01 +0000 Received: from CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732]) by CH3PR12MB8659.namprd12.prod.outlook.com ([fe80::6eb6:7d37:7b4b:1732%4]) with mapi id 15.20.8093.018; Thu, 31 Oct 2024 00:21:01 +0000 From: Jason Gunthorpe To: acpica-devel@lists.linux.dev, iommu@lists.linux.dev, Joerg Roedel , Kevin Tian , kvm@vger.kernel.org, Len Brown , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lorenzo Pieralisi , "Rafael J. Wysocki" , Robert Moore , Robin Murphy , Sudeep Holla , Will Deacon Cc: Alex Williamson , Donald Dutile , Eric Auger , Hanjun Guo , Jean-Philippe Brucker , Jerry Snitselaar , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, "Rafael J. Wysocki" , Shameerali Kolothum Thodi , Mostafa Saleh Subject: [PATCH v4 06/12] iommu/arm-smmu-v3: Implement IOMMU_HWPT_ALLOC_NEST_PARENT Date: Wed, 30 Oct 2024 21:20:50 -0300 Message-ID: <6-v4-9e99b76f3518+3a8-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v4-9e99b76f3518+3a8-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR03CA0018.namprd03.prod.outlook.com (2603:10b6:208:23a::23) To CH3PR12MB8659.namprd12.prod.outlook.com (2603:10b6:610:17c::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8659:EE_|DM4PR12MB7573:EE_ X-MS-Office365-Filtering-Correlation-Id: e917b365-bd5a-4ce3-1272-08dcf941e495 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024|921020; X-Microsoft-Antispam-Message-Info: 7wLGnVtWm5E8MJPNSBBpnUipcRnbmkO81d4obyOch6oravTyAlsZ4OlUTamt3RpxvZCgZQJqBfc/w70IchPQEg7MQTh2wtFzPxwCLJ7ISa4f1dNxQx58uSe5zkl2+BKxMXPuRUZS0xz1ZxSWB/nA5xVaskLRUj8gVI8duLeR8WZdtaII7Ze46A5RgyF41R1liFDOvx53dE8u+YRVegmml3Mam8IuiPU7Rarm/VMvzD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RUpKFhe8Lff+dxmDEklmu4OCrSyJoCSulond26jw/yFR21qrnFdlmzsU7P59wsICOHIKtc7LUmwpgzNo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB8659.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +1EZl7QyU5rPlD4u/gzBUHBxLyRmUrZc7kUMvkOnFW+QWnTlFDWIG9SfNOhrfXPHVdDpfeI/PcWHmjSv15ZQqAsjPzGFL28r6r4tJOOKDn1zmrt0F7ThrK3BRkw74f1FpVO6F0NUsxkY1gL9DOmwWPL3nJuYvS+qRRXYa+iOcLiw23TbgIGBuWfJ11V5vW6Tab4hqHFEk0NmcsaKFoKgen4LI4U83ywJI3EUEPfT5BZTbxEXNJP5wzBrXd8CQnlGX3cRXTg1iDcfUGENeU2V/PnHRm8B/oMecfXvXjenF+K/U3qIKvS69FH6UbC44P6URl/7A09UIFerdg8P+oHJs4H+aXVU1mrfyWoL4biTSklF7wmdVEl6sb4EoqVKWWWOSHMsUKQnFdLsAQQTyBG5iShZeuvJrWyZOEf3lUIzVyw/lTzC1ffPhlUSEMAs1z21EC52ygAOvdlQv4SEEY6vMjNmiHI5jO524F76N1eFMepQwHyamdwgC4on/dg6RYMPfg7PVFX4yV3kR79GbZitBv7dcCmla1ueeICuNeSZ/sxsmK9Ce5On0lGzeOqYba7zsAZoYzpGpIWoslDGwlE8gWpEoBBIuV5aBIvjzrRvUlurCIhE0wc9J5h9QEe9vu+st5w/U0/UHBqCT/qIB8bVXsbluap4FMAKT52jOAyVvfww/nZeT4rlzJU2Spdabe24FwpObqcjXwS7B5KjFhps6ax0a+pnuh9yxSnIN1Wx0oDQi6H1QJo8B0CE8yFk8Vg0I7Uzz/XKarBsrKI60lNmgM6L7wdkVt4Rqw8c90ICwh3Yuy+hapHpd3AZC6qfHq4wPiF44A8q2rYOSfRBM2HPjBVOeu2fKZOexJTaHjl1xLStrEixF9Z9NHGBMV9kHkzBcPwpuCrvzOsTIbXOaQ9a31W+DY4rTTsP0J+PqSqAOaTJgIzuvMhxi1TE0/0o6FNFLoXw40JenDBhzchHf9yuorNilhx0auazNEFmx2zgovV+ztZ/DXIkL3TT262LbjH5EwD/N2kWaiz4p3krMYURnb8L2pLone8UtYG5eB1TBpUWTwNyPAOD/pyzbmzecxr74+mrAehOwEHLPgpIplfskF1sHfIg+7v06OwspguwVYOnZWQb3eacrDgEuKplmJJiAjTgduTEz+vFFNpKL8IF5qHK+3BNO9j3dxaN3uLyx19Bzu6XvpH3RfzZ++FLodNUapkyS+E1n06XPD750KVuwMUvWYIst+LcPT4lk1+8+0k/tGJdk5ZWOmy3GW6KDAS3fCcUsIenzGmMY9SJLsbTJv5bnvrGJEsNmmwsC1ubn1GPJJTNu8hJbbV7sns3pZP2bXtXqmdN8t6/i6q/pHrh7LTwdwhwKhgxS2NQvVCg/mKO5Td6E0VsJWLIsZ1WEEQrRo/TjeDGcKW//GWcfIZYBy+GHwUZuGtSafMDuQTTwy7gxyaOW0yTlVz272fWoI126wPdlV4/r5rxuDa/xAxOiw8Y0uLusd4I2qjlr0SnGfMoir8J4funsBmYRo6mVy0h5eaBXWJ3cUkVKDq4uoEzUoAwqGcpDWoZk6blorpF+kI= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e917b365-bd5a-4ce3-1272-08dcf941e495 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8659.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 00:20:58.4214 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UpayNvBePLtLGRhcOn2XMQkiH5cMQHoDI/pX2qImo9UUFf6X7iKcQSSIPfUNF3Q3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7573 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241030_172117_855990_7C27773A X-CRM114-Status: GOOD ( 10.28 ) 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 For SMMUv3 the parent must be a S2 domain, which can be composed into a IOMMU_DOMAIN_NESTED. In future the S2 parent will also need a VMID linked to the VIOMMU and even to KVM. Reviewed-by: Nicolin Chen Tested-by: Nicolin Chen Reviewed-by: Kevin Tian Reviewed-by: Jerry Snitselaar Reviewed-by: Mostafa Saleh Reviewed-by: Donald Dutile Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 996774d461aea2..80847fa386fcd2 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3114,7 +3114,8 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags, const struct iommu_user_data *user_data) { struct arm_smmu_master *master = dev_iommu_priv_get(dev); - const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING; + const u32 PAGING_FLAGS = IOMMU_HWPT_ALLOC_DIRTY_TRACKING | + IOMMU_HWPT_ALLOC_NEST_PARENT; struct arm_smmu_domain *smmu_domain; int ret; @@ -3127,6 +3128,14 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags, if (IS_ERR(smmu_domain)) return ERR_CAST(smmu_domain); + if (flags & IOMMU_HWPT_ALLOC_NEST_PARENT) { + if (!(master->smmu->features & ARM_SMMU_FEAT_NESTING)) { + ret = -EOPNOTSUPP; + goto err_free; + } + smmu_domain->stage = ARM_SMMU_DOMAIN_S2; + } + smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED; smmu_domain->domain.ops = arm_smmu_ops.default_domain_ops; ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, flags);