From patchwork Tue Aug 6 23:41:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13755512 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 D162CC52D6F for ; Tue, 6 Aug 2024 23:45:54 +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=tOSPp3mKTqEcr4jZdc9I3lgbRYxHrlJiJCYECRK7t78=; b=PNZM0nLc9PVOHliaCB5vCd/YcU 036d1CxaLyXRReQflDlfGpv5GUhLWNALfEjWGcKp7NVZqv0SFKM1c/PQdlXbkyOkG4ctaMXzLdk/z Gn4iJF5l5zxvsqTX6u+515Fk1YwoJy0KXxyVjkSnO3BjeP5geAfd0FXt2+oXHlqkWRpxPphVqkQFf 8mKRxf1NW2ngsvR/WttQ2/553QVFLr3extfX8D9nzwEJgMSmmIT5KhwvFHDRMbtvGN2hs6qo0qE2q J2KiZk+8KB6hDtWZufNewf+wcVjaXcC0rjo9dHZ/5Nc74ZN70tJQvVNDpnX8WMZYLLquv68lX3BQI 7tppZUKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbTs5-00000003MaV-3fUM; Tue, 06 Aug 2024 23:45:41 +0000 Received: from mail-mw2nam10on2062d.outbound.protection.outlook.com ([2a01:111:f403:2412::62d] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbToA-00000003Li5-0A7N for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2024 23:41:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KQjthcM/JhRJ5oIgzb+vRaKtTzvpxy9kLhyevK5KqScfvPDhhCDiczd4JnNzz6JmaIWb3ZYjPtsK9qJeuq5SExpWWMYw948nS5QCdIALnSgGSPuC1I/1/jZVIIJyfucYlnXlbIslaNq0TUOpVICLEZspmIsSjAlnMUQuTbrfUHZIQEsf9wcjC5/xCudSCjBhSclKbz1m5SSOvWqWGawsw+kwDSjdx7tnFLlgjZr0H7qV3fAQ1N2N32pLVn1yrshq2FO9bxdeAFMDQWwtDPd+VHOysRawEyqG9Ql8Ej8OP6rxZUj3TgolTPoEHR+Uow+QZ/KWBcr9WN3NP34XdyykZQ== 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=tOSPp3mKTqEcr4jZdc9I3lgbRYxHrlJiJCYECRK7t78=; b=DmyLroBVzNRYY1GNsrSX0J8qveyD5GV31siIWIe02cgy5D24e7yBxCY4lGl4rdnOCL7NLfGGHKp0/Hr9s0JnoN+Um5Mbj0RSz0EOs13ard9djR9E29faDMIiJvL/v6p217jPx5QXMVCk03xG/gV8wagjO2wWM8j4/T98/qOA1IcWhE065JzzkP5wcVnmNoL8VGoWuetGYqt2OEeR32bHyMTFITJiZZxyUV7g2ZX1RJopiwpmIE5H/Wmj7rm2fOeETxj46iEb1HktAtXJ2DGFZJyGdi/EsJnQVUCgt+Y4HxNOg3TSJUQgVUbbFWkxshlONbCyxUz2bcrBoma6TmvwrA== 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=tOSPp3mKTqEcr4jZdc9I3lgbRYxHrlJiJCYECRK7t78=; b=r5p4OlWa0hisvvB6VeZbUscDHFEZOcezdXiu2qF2NBr2SLYAv7umBmlixpmsX61Xk0jjaZ/zlVh9f0FfBW0koR/ssbMnqx3L4l8yYIG1m9DpsWZRyDDv0xjtEZrNavaIqL0t48YgHF5pUxazEra/pVf3HuTZVQQy4dB1AQB72BnLURpAMHlqyzstGoRms349lwr7eRxOhzkgmR/4hhguGfowgY9JHcmPs2fkAL6v8jv2fJvTK0Q2zohL81yng8u3lXUnDb7QA2kzoVW/BpyZ79faeLsBb0HKgBVO3JAlIgB212smCVIjVJkBYSgaJLdWPc5EyDmN3Ryy+d3GmzkmOA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) by DS0PR12MB9422.namprd12.prod.outlook.com (2603:10b6:8:1bb::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.27; Tue, 6 Aug 2024 23:41:27 +0000 Received: from CH3PR12MB7763.namprd12.prod.outlook.com ([fe80::8b63:dd80:c182:4ce8]) by CH3PR12MB7763.namprd12.prod.outlook.com ([fe80::8b63:dd80:c182:4ce8%3]) with mapi id 15.20.7849.008; Tue, 6 Aug 2024 23:41:27 +0000 From: Jason Gunthorpe To: acpica-devel@lists.linux.dev, Alex Williamson , Hanjun Guo , 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: Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi Subject: [PATCH 6/8] iommu/arm-smmu-v3: Implement IOMMU_HWPT_ALLOC_NEST_PARENT Date: Tue, 6 Aug 2024 20:41:19 -0300 Message-ID: <6-v1-54e734311a7f+14f72-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v1-54e734311a7f+14f72-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN7PR06CA0066.namprd06.prod.outlook.com (2603:10b6:408:34::43) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|DS0PR12MB9422:EE_ X-MS-Office365-Filtering-Correlation-Id: 895b3b7a-9661-45de-6b38-08dcb6714948 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info: +bfqhu0Ru+DKW2L7uLiKkn/LfVtDT81Ctfo1cy1Nd2H3vX1wLDxCK4o8yMTdqwYhdiL2/ueyWitIQ75kwcperPNh40veOxXC4fgz5dlHPtF8sFgl2XVusJNvdRTQ4LgFJu3+pNPyCFdgLshyZQn74J+w/KQrTiHU9m22vCQkVpuccf9NxwzYshe4GtuFnuJLq2FJALVvGXaIBn0B6WwJCeOZNJyoD5Mw5XoTvFJtyz4qnjV5S+uHqRG4zx5mI8rYiFhtvxAZGjZhy980s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Knfa8M3gcPWB+nsgR3ALDiJf0MB5tt5p35G2VhZtxcz/psLP2sksaYM3+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH3PR12MB7763.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tscg6Yvnz9wXcTMkQuIcubgAY8AywkhtCmOp5VTjx/r92PDXmyLT3Dg7377AijqkoNrZeKt3IkCKlyeCAyxId1d4KQweCgPupJZcfhFXw1UrzgC3KPaUP3kQjdAxDaxjV18s5H0tkerM99x/jgiQwhP0Woai+hzPbs2n+hgsr16/2K6t1nBt7OZq6i9QLUUukwly8rP6B/fzT1jl0gjOLNFoddJRtXMx6O4lD/YaDUo+bNPhdmPW7Qcduq9xsTVBCeP/BvymqX/ZHOxCKmDQt6+mBk6oEo/PGmvgmlYRpcS/vCHI9AGw/AirwZ21xp+16gJ/ezq47WhR4eduboftup2YJsmzgOlgRiZS00l5swdrYyMFp3FFdeyTQLX+aSMqPw2Yxn0R/ee1eRxSSgxuthI18oJoxXGzXojEtgyuD6PEFD7zNiXVxVwx+WEJJcrNQDCHfNuSysY7+XbQP3Z6SZ1E/xf7kvOS83IJK7/iK7eEXyjBSojyGjBhhRLehtQp/uETWoNAfjVXmbr0PicBrK5/ZCvozBPlHV24EbGWdkpRPr/G2kkAoy1xyt2e/ykag0bfshvst5szsp4ooEIkEk1JyzWAnbogSBN7iY6BRlTuq2BNjgGEksFSEyz+wr4MQas90+MHM9m1/ub3FIdTY/Boeg24hR8OJctktODskebZMzNvTkIG5wmDXIyd4QfeJcVzXLq2lWk2w/w7uLudpk2Ph3+CQYNrVeO/z0eXQ4nv4nac/DAHtn0MSGdSctwmAMLfDVktZcOWnq6o3X8YKimV0iiurX5O00skPCaLHGYbm4PWkFsHo8GRaHYPrgu+3w1j96iIYwIy4apJ6hPox5fjPLuko0XrIbe2HT6bZTeh1TJLEhjd83pGTPOt0GSOUX1SgKNyZaHT224XXhWChJgPXnsoZ/gyGN7u5duMRHwcMNPWKDFPOtdVBOtwAhRvOnx5ub7GGZOqGXJrFfARUtGGc4z2fLvk9otWmR2TWwI/z2yBX554K+Ep1JiZo9gswSKqY6U9/KkPxH9WOBoX1rxXwcCAn94/NyBOCoU0PpTbFbsfacFhZ60GUcPaD1sIaBT4YJddJDfa3NDxflx4Uw2KaZoNGEuSby77n3c8J/OKP2UckAv4i5isivXI0ZdYISfa4RCa1XeBiGrZ3xmvkVmuiZzXl7EzDC3rFohc+ocN+V1fHZFXxVQvfQjhENnHyK5N1HhuBgncW7CAS0W4s67VINnpJbgv3BgtSna4AC4g9l4+nRnufVB4QtGc0h5fcvA7FwuPM5n83Vzhrfyg10inx4eYbetlDbhr9sbaJmQE1SAPuriJYhQ13f1SWaGieng6OaD7fy9z3wq6qznp7d8jUbAZNQ4xOxLXVfp6/6NASKcadotJoqnaq07xsYPp7KS9DZ98v5GFwFXgCD6QKLRxmJ8Hq9cDYv7YBU1RhFAz9kfBnKzWsiKme+I00XW41LXwZc5uv597OypUPheYLhnZ5zS4XkfBjAMmH7iOinY5jsnzNUy6+AL+uJ70jF+rI7i9YLXqf6A+QCkfKfihoLAyrdRu79giCIO5jLJTl+Y= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 895b3b7a-9661-45de-6b38-08dcb6714948 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB7763.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2024 23:41:25.7838 (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: Jf4mLIfxqtuRGTpG9gIGgzBPwuaZQit+rBx5h8uQddgIVb7qj0BzeFx/uFm88Ax0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9422 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240806_164138_169254_A776D2AB X-CRM114-Status: GOOD ( 10.05 ) 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. 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 6bbe4aa7b9511c..5faaccef707ef1 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3103,7 +3103,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; @@ -3116,6 +3117,14 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags, if (!smmu_domain) return ERR_PTR(-ENOMEM); + if (flags & IOMMU_HWPT_ALLOC_NEST_PARENT) { + if (!(master->smmu->features & ARM_SMMU_FEAT_TRANS_S2)) { + 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);