From patchwork Tue Aug 27 15:51:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779760 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 74EFEC5472F for ; Tue, 27 Aug 2024 15:53:43 +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=fQsBYTfbTzgP5tc+uQ6gXvXO4gbMNJkCJzT1F8PXnvg=; b=mH0z0WtQMh74sBkMIFcvNJLoLM 3za2xPol/vUaoJZPSJ2pERhzTGRiL2YRwaV/5JAqTZzpH3eU8Ik+Jn/oxgr08DOVo92QcKgVMUzpt YYDAt/KIZ4ZbSAnHoDnx9zBXLAZP3EMjMX/A1qqkoujl6jMnI3w/JlB48Ll0YUmOp2Kln59CpEUe6 22vhWUd5Epw7q9oaRLZEEzfENemb+A4c1h4K0PbZQiO51MjF78OmcRgP+EhCT+uQFiuGU9k9Mr0bE 3dYXF+XvGB8U7jpEovrG4BXI3MhveX3GFsaGMjqtPGmUI+cLP+xcw2m2GU9xSqVZ5V05CxcE4t69g oaasREjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siyVg-0000000By32-0f9U; Tue, 27 Aug 2024 15:53:32 +0000 Received: from mail-bn7nam10on2062b.outbound.protection.outlook.com ([2a01:111:f403:2009::62b] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siyU2-0000000BxTb-36cS for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 15:51:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jC0C4sUwpsZZeoAZ1xMmGOsmgfo7RvKX2eRtMfr25HZeSWx3DIGvxBs4WHj1ZbSl5WUbQBkjktTddAkAiz0K0HLdSsYOndub77UGkrejsd6LpDvQIf5VJKAoRtto7CwQqgEgU/MckH/xXwyLPwWTuqlyZHgD/otePuVZ6DxYOP2RbmZUhrvDziJuebMNInpTUbQQV+FRCBJ4R6q6ghZ02QHZeYZ/lzudl6lO0Xm8vM0rgrrCa5Jn4bdt5OSB1OgyXG/8HOB22yDmm34LQqi8pohHKsSbSFYFP6X8Osky9uVkVyYB9kpbYKFNKK3uYSxeuNxucQHbZACGuPG80Mh6BQ== 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=fQsBYTfbTzgP5tc+uQ6gXvXO4gbMNJkCJzT1F8PXnvg=; b=JwTYNRCU+rT+7/XTdd3zLfUMWtMQpbDQkm61lORlQQQXAIF2YfFydBKu7AT1CGkkAGQKarviH3zEQS5KMkkzRwvzTMVcFDs1jJNHZfQCCvAfH+itrwGAEqt+Nuv5FpjE8xjqN98oVwWKIYTM91lgBM13HhW91JURgPSDQ2mMgRi0lCJi3zWtogzd66SiyYQminYyuERAGXFT3k3yQ/ip/ha3PP+CpMc+Wa8PFMZuPyybDVRiVVoW5KgHms8CTRFsok5UUXOWt6n8bQHjosZ0z2x0tQPacBjpNhaIB4BOJmsAGYNHHtr7/QBhdu3ZFiMJ3kQV9X2rAfPKRsLLqOZfQA== 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=fQsBYTfbTzgP5tc+uQ6gXvXO4gbMNJkCJzT1F8PXnvg=; b=XyzU+9anBbYRFnvAlM4U5S4P11Q69yUAzaJyHA9magQMScPlsFRczHAzXJox8IIO3plvB1+mwdYxxZlLkZzzP1i9kHpojB0mpyp2q+/E/wbrypRAIR50ZQiDQ/0pBaCvlO8iru+fi7qXIWRtt7hTkztJEX0jCCogr83GhUH7zonbNNlK7+8E60zDFPqKfKJurqN+OFsOC0fkEZYxDXnSgLxs2Ys17kqZhy4G1mZ11GxX06jHGt3yBux424cX17B5OH+1RcPejL2XuOcu0XoUlU5KaFA4w1X/yanB+tgGuxltvUY+qerYqDbkSz+VHNT+TZWWjXM7SrsLGZOZb9x7DQ== 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 SN7PR12MB6790.namprd12.prod.outlook.com (2603:10b6:806:269::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Tue, 27 Aug 2024 15:51:41 +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.7897.021; Tue, 27 Aug 2024 15:51:41 +0000 From: Jason Gunthorpe To: acpica-devel@lists.linux.dev, 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: Alex Williamson , Eric Auger , Jean-Philippe Brucker , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi , Mostafa Saleh Subject: [PATCH v2 7/8] iommu/arm-smmu-v3: Implement IOMMU_HWPT_ALLOC_NEST_PARENT Date: Tue, 27 Aug 2024 12:51:37 -0300 Message-ID: <7-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9PR03CA0888.namprd03.prod.outlook.com (2603:10b6:408:13c::23) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 09329889-9003-47f7-446f-08dcc6b023e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: wtAQ6Z+JN+1bCd3bfriAbp9sltZiyeNmfnA/rUQb3Bw5lsU9S2mliDgFIVFvgOTaQIf56GX2dVsEFVDtdBCnAu0dUQgYqVtvR7Vq9EvYD6IO1AiVQs8qpcS486LUHJTLLtSDNI7Ch+/PjZifUrGUH9vC+OLAzV7y9Ha6YhJEemBhKYnjSbaiEwO+ySCnJy+niog5Bga4tVXGzUalAmkAx38RPWNDPMpxzTipRvxt9Ihv5QZfEz+VJ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ID6NTtQ+aGMUn2q6P06y4WMisOtGj6NTQnd7ljtD73xRiheiD2LrRQVq9JsB8L+H1+XBAm8LwE13jzq0s3 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)(366016)(1800799024)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IRlHOA2E8slUl27ginqIgFBAcDsW7Y6Pkw4WLWVBTd0fI7ksRqcAGiYDjGdYFhxzc5V8UXwqSwUGel78OzmAKHdOiM3rkNU3YRbIYD91LgrrJ157FpCmzrWaFCXHzQIWBtuYLeZ5JymQE4YR1tznuCFXTxHJ9vx+JmWf6CZYAPPP2DarYrrvAXkSM3Dailu84YQeYRjec1TgjWl1H6gFbEZwR55nMTJNbIldCOUgfMfbBxBKi09iTuZ7lZjvdlKauIoIkxZQEQGaI4YWdQT0oO3lEEbzFAzG4moQVEqelaSu86Nzs4KoyVilx5fmfw3grnbLCIC2wgDVheFClNM8Gwwk1lojcOCEq9At3JhNY0WDcUCVbKMIfekGUlI5iXPgRQnfRXsyPm6o+9SapbyXopIRbrA7lmGBblqDRvSw2NZmnQDvzt6N3Sr/13PBN3GG5BkKmk8c4x4a6yT4O8AiPgeTLEkVLpk9Q65Zj8PuFfpjw4Gb0Dg9FU+uMd4R90DVSvC4Ze7CqG3rrP5WmdEvd/x2GoIcLXFS0V3gjfasvTISDRGG6eDU3TpTBWykiiYvViTeSk04Umj0sWt9J1U1g3GxUxBCwKYOIuu5ElCRXQp1Z+GbuumcAmlBWDEboXDj2b0ItRMGhzDOimy1FRQHlXdT7dn/FUn+RVY9U7c5+bFaDYX2Zn2Grr2xisWVD8o9kPbWoTdrNMUwJfDye6gEI0M5E+utmh2jMNrAjh1mkYD0GuFec79l/nKs5MEEry4feW1iCludQfwR70DdSYwLBjpQdTSvh3qy03NllPntKOaCIUalsxyj41l7j/BBEO1zHT5k/fH5Q+QlebkB727Og6FAH6qyV5tyEieCyYZZN+1SZ8sKUE7S1XOi+39AnqE/Oqqe+EdaCLqhU5ClLHgxNYnSNdSGUtPpwzB/+X1jJ0cy5lbOiN16iPinH38pCt2DbftacCFbFCSdqkRnbeVq88GlvpqqzGz7st1ffz7Uv/ADahjdNO5uwJRNC2O5C8nUU7pofAy5RTnGA0+EFAk4nXPp0DqvgaMgWW71fovMOtlhLKOXY/NRRwkqrDz54kB+LpsvyVgy97lmW3/atCXdjfJ98AohRdQXg5pLRxEucSM2zj6fUtb0c7LxdIJff0gGZTSIT4bX6jW/Vvj3SrbvwPLpRhT+Gd0t6WMxFiXfxWUHjHUcCyM1Ks/9DRvuvEO1TSGo6o48ivaWebikaRysbsrNIetw3dsqH3+exYDtchgTmtJ54V2r0L6HvwMfCPotrn7TcCUlW8HukNOs6Fkdz/bXnQJJfydSpWnhQrAllRgkYndjgu8PiYUXKOWgIW46SODUlMPNk9j6Y8wIRqJd84wMntwYshumZOIGz+NWwncKJXYpLb1Yb7LS7ZA/YG5Do1SbqbQ7I6PzA8ELLqGWlib7ILNEMm1xUkCWCVAishnJjGeDHSmHoW32m8Sl1sCrkLJaVJdu5YLhTxN23/5RgkWuWv0fp95gy8kx3SuWV6C57kvavlQt0SeB6tbbH2CUD0pKiS5Fs2QXPiEO8xc5Li9VHAghOJpDI37hw9xeznBjFwg1szeoVqX1qF1jFOfn X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09329889-9003-47f7-446f-08dcc6b023e8 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB7763.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 15:51:39.9955 (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: NwGPE53k12quGEwp1q3/7xUicXbySrJQMq7eaplN1HmQsDWBep/q8kHyJwf/QwJ7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_085150_804460_CD7A59E5 X-CRM114-Status: GOOD ( 10.58 ) 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 Reviewed-by: Nicolin Chen Reviewed-by: Kevin Tian , with a nit: --- 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 ec2fcdd4523a26..8db3db6328f8b7 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_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);