From patchwork Tue Aug 27 15:51:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779741 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2048.outbound.protection.outlook.com [40.107.96.48]) (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 71DEE1CCB28; Tue, 27 Aug 2024 15:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773913; cv=fail; b=jgVcGdpOBR3IaZpgyTEKmh237L9hslFVs8/xh/9HJ01/OlUNh6v2g30XQPnQ2LRgzZTTioIgu+BUf9habdNQntU1AuDIWIBQFYMcxHhY0EqFwM6SajvriQ2yAR36ergom+kgH7wfXRb1HWigPmMFXZgsuMDTXO9fMMAv+pzd8qs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773913; c=relaxed/simple; bh=5noAFabF0IKrb4pvhNpD3/eTe7kM5BT4EGJhRdcl7aY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IHd2klpEBgFTjK5ppGkZHob3fKtkV7iClGdO2oWafdj/Cqq30K7a+KIGJQUzO4i9Smqvv39i05c8ExgDB43hR8MzKHHcKrEj67V3yVq3j5Pq/4mF9pDQqlAhYpEsNcuNPFosvXmZdXrDWfyuXk/9NRjY7vZsEetmWjdmWcCWnAk= 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=MpSylOTx; arc=fail smtp.client-ip=40.107.96.48 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="MpSylOTx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EpPIqFhZPkNw86Wo6A+4UssQ0h9NCFG/H5vvA24BCcdsh85ZYrRDMd+OesYnSJDNOxBwaWVAVC8sckMGq0JTW2gsKnyQBAXjB7GjtLZ+J00eMlK/ZOssKIqqJU8U+q7Qp5HFrzoJFKnNzYy4PBjHozZznovTA88CScJtdAtQv28/n1onR0HjqoBdBT5GjtrjNcb8lbyJ/Lq1st4jA801RqXxzcK9SUBFWfmn8pVhYzeanuPDcEk7RztnmSDhebBbV9L++5bApqHv8c8vlS8HYlRNTpfKuLc1bnNvCHAMp6X9RfNX6ysgvB2WaIrJYdTrRUA7C3RmdAxzzdrBO9+5cw== 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=fiXx3NnphBzoqdte6K0mFD90uWB2VU1T0YNUeosSIbo=; b=kIcaHEtqkRRRaOBC4Dpd3sZv6IhY4K7ChJt65Ar6NNDyYjF0LdkfgXbGOl35ESlllhWADphRAKqmlTpCA5h7H+D6crQZrap2Oq1ca9mvDQK82SCmMQcN/hNG/5VCI5RQGe6s9XU5tQgIxQi4eZN/STs9Sas7jN7adt8c9RycakvO1M1JN5fL3/bP3cerQx7vc/7Xzophex64W6DjR9xzF/lAXVZtDM9J2kwz2xOIYlb2mJCf7IJ+jOaz2Y7uGXdmsxxpwQ1aO4qPuy/Uss/l++9+UJxwRpzgL3IDZj9+g3+5JMoG9yVLGBCepUQtC032oSztCcwC1HCF+/YZwgXnTA== 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=fiXx3NnphBzoqdte6K0mFD90uWB2VU1T0YNUeosSIbo=; b=MpSylOTx+UiZst6Mhb5cuUGvrYoYN2If6747YQljkqGkhTS/1o0G3sheFiPpESxbyKNek4xK8L+RisxsWJJ3Z1ztCO3beNIDr3rgYFBhCFnkU3j6tNLP88NzoQasm6syMKKi1AhsMOxfscPm0h4nlIJIsyp3NwE1PsWbu5IXCavukT/UlhFR0vuODU6Q8AJgL9GfJBy5kMJlf5ZXGlJO1HiZ+3br8urG6lRkLPihd9Xl/6Zcp7P7CPL8I9IW3/Y3qHZzk8wk04v9wTzbqxGtJ1hQRWQwi4FzmxOi8XuFoTHfTbz3M2Vi+gmv+45fVMedCr7b+vSpFU/UTsZA/62klA== 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 PH7PR12MB6658.namprd12.prod.outlook.com (2603:10b6:510:211::14) 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:46 +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:46 +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 1/8] vfio: Remove VFIO_TYPE1_NESTING_IOMMU Date: Tue, 27 Aug 2024 12:51:31 -0300 Message-ID: <1-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9P222CA0028.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::33) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|PH7PR12MB6658:EE_ X-MS-Office365-Filtering-Correlation-Id: 30f628d6-40e5-45d8-2464-08dcc6b024bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: b96QOBPHUdK5m3oArrmmdO0TCIqetOVW21WvbAWZY3VOX+MzEWjia3nHnZifLfVf+B9UlAILEZ5NdgBf05KHaRi4lwnYufcMDhG/DTf5i7QJdET1x3t2LRgQ3vuFsCx4eEh94WiYglz9oQT+yhwxJRE3k/uQrmhsEKDvTOaZADeu9A7R/NeGRrj1CNCURWyNtb3JIM+3WNYfnFqulVAU3/EsxKMiAmuEapPSFA6aCosLGciKsvNNN1UiemaqO+7i0AURyDEn8ACR4tO/DgWqTM0reL3UprqLvcHvxEeK3rd5nU8p8RqX0hwTZU+6y9FdSf3rFBQi9N2fwcwXyjAWSTAg3+R6uSLK89oSZ8K+csaNl9pYkSWO4FHzxhhEGTrNZrmPES54z7cfaZ7QigySrEWOzi05Xd8ByGfvrVJljHnWmn7/Au+ISXKtXa5FGf9N+ietu6oWM/rlRj1HjkLhY/akisC1cMLaetjYk9Yx0n1EHXvWxbZ71K4CT5pHFtF+9HJI4tBJ240ZgXiKqucuMmIdQKYX5IPbIRJJLo/ggCeJEiZyzL6qDdBOsHAjjHOrMzeqpklja9gxmtUhkb6CMVlr0oBxlW8JwZLhul8d/qmnVTZ6TrYRQ0cR8r8p2aNyURc7mrB9/nlqLUB0KU/RKrifs30Oya6XjnXH7DXsiNKz4QvDr34asWyo4S7lbl4R9SSWJeVjZgXHc+BfaZXerGHs0TTj3leqTXR5VHPrdk1XdGWdgVHuE1/+Pr55C3ArMKE0iAqvpN265jYDsaf7RbX2p6VfotEXvZj1e8HAlQPo2Zd7a+Dxj+rzXsAbnVVgYX9tYnQKI86+8lTKfp9XPlEoDCtEPfjpBDGaIsP0iLbdqJ37iWMMrduMhFe80PN4aV2qsUv82ogQcmhWURZPgNqLtRs7QxO9Z+mEpvmN97iWg1/9hZy+Zn26zBmexybDWkIWwzWeSuvjGURE/Age9GUX6066XqhADrFChg3GGlrpzawomM1hYnKGP3ofBvNm45g651NuHLzhCvMvIqe0x2kn2eeJ4NSnzf5037wM8PWS2XZGBuVb5azkecKB0yKP1AjPE/kxXrs7zOJqu0V047OvFob50ZuyLrAW61Idht4P2ohGTu2j4ozNa58wgB4KA9pwh94ax7WTDFa9KJzhHZup6jYdl8t4Y6BWfr33fkUvvzABcCOt+u3PnDsg1TI67vxCQrGcpwp8yGHI8LKNaLlKgnjwrsBtwzNKJrzlNr7RpAxV8nTBbweUUAxsGTLAKUj5fwVQVl4ZkKZLfUtCEMHCJeTFuiDQyVRitl2TTThq4acJ6DYvSbkZfh8z++SEU4GAcGDtvrGsyqZo6n8T2sC59OtE8EN7SP72+xoaiwSdbjATIMXFWc0bgsTFt1BWy+l3L7SsEa96tnO0feHNDQ== 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)(1800799024)(366016)(7416014)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6S+0cW6i/jSiQShscNyeZztzSuP0sd/UCB5Qb6pZe3Bhesi8LbaFuL72SGrQYLRGE7SL83KIjs0uw0zp6i0tYUrkH2eIh9ujxyOgctmWtpYDs3R1Grc/n6WMPzRyHAs88viwLjY2Z4wWumTkIXr0cyT/G5haVCmOPdHyHo6RX6/PPhtJ9BHoufPZ+CQhLwTN4RLr0exiVoGlw45zhV+l5zu8+RV4HOZod5/Khe1FKzryN0IK7XeNqpFt2oOsaBalemnmlzDqGDFzSKSkYRHsHz4ntwd6zKvN6vKOUff3q1sKEAuUhPJvCc7ADJwnauV1S1OV5UV6tBp0QP/oig4TVtT7rpFNxuhK5l37cY7fc1pE32mCSUZXIZXD+vJMJYHybNB3NRiq10wpb7vCv7CRuLD977RkhD3SMoYZ54B7pKCFSPHYGk2Evc7ECEUkT47FOdiVA1yvPhNdX6aLMZXtqc4QNRbUKMgI7UQVjh8Tk/pmLyR0SXi1Dv5/0KdTpaT0yZAhoaWAgK5LflSx0nxylrXZEM5Hn0qzZuwDmiWA8Liq1SvZ652kU2VEg/r20iLvy+y4KUXp6tQubyzjSav4FYMK3D6GLzVlFwpXLJzWpoHK17PhzV7bD24NR/nOcHDjfKe9BpdrUV0r2yg0OTkf6WdaSIGxwUNkiFmcwlJRm4Wlv+w5zMweGrHD2DXX53WJCidgNgmbsdzw9/45euTai/f5QhzuDxSw8FtPP4bQKhNhF3c6WsXc+S7Hscgvaa+GVzcJNCUEcTHWycuEcUy5IBW66FziHDETwYI2X9Tl7vLS18X+JbHBTMD2YxGDo2HP2gxxke5BojTb0JXAlq9rq84QfbrbIZw9/x5Zh00YBrDLML1YROPB5QvAxtfd/PAhv6yqecNVGxBgWSsnMuQlCThHcfr/d4GNoEBNqhCukZQRcVVR4zH/i9Al873hZTkC8ya0zfOSN+BCXEIPUXT6idJVKDluxcTJh1ceTOcNiM/wPqITFKxvGm/WVU5BI/QNu7RrjeZnVjsJBJlkpsIxAt1WHbe8X/SNMGPPyy5f5Ah38wt9OAS7BU7n5fXr6WvE2Brvpv+Eo9Gc8K97yL5XKk/dJ/n7ZgfRBxu9FFMu9JEumSm6MOsB63fBKwcLSHy7zz3PBZr804hdcdO3h4DFcbSvvKYNJ940CfW3BVI7XiV8iCU0ZGwr5Lr7TbUZRBlfIPv8NujwPqIACq4W3VnCSfmJ36sbS0EJGjctV/Q/IKDRi/a3ppyyum31PqKHw0JfJsziTfYI4PMyEn92+imFeyFbqKDcfyZrAORPSMSOmxRnMTHKlhaEiv9t8G6vaudfyGK18U+TKI/opyD/hP70w2HOYu0LuIFllEX/zHCJKuGpFZcWnN2pCGTgf4+hOPMvc0FG6ihYNtUBrLXZ4//n/o1B7UtX0AmQQ0f8ztOK+5/4NLTcO8g+68TFcos2QAKpnsN8+2L8Lh3IvVCTlUZj0uC905rglj+KILzG6q+s7M/ftqT+PmBFEEcvbmAuU7PfkrVnaRBnyoKJOW8mfFcDEff46bu0zSFmrMyVoYpsQL7WBJh0wjZtVTEaRJH3pGNM X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30f628d6-40e5-45d8-2464-08dcc6b024bc 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:41.4341 (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: iFOL/61FrsISvprOz3eYLLw72RoRquCA8QnBNPC96JeCWClExOSRqw/W9Bv6Jkrt X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6658 This control causes the ARM SMMU drivers to choose a stage 2 implementation for the IO pagetable (vs the stage 1 usual default), however this choice has no significant visible impact to the VFIO user. Further qemu never implemented this and no other userspace user is known. The original description in commit f5c9ecebaf2a ("vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type") suggested this was to "provide SMMU translation services to the guest operating system" however the rest of the API to set the guest table pointer for the stage 1 and manage invalidation was never completed, or at least never upstreamed, rendering this part useless dead code. Upstream has now settled on iommufd as the uAPI for controlling nested translation. Choosing the stage 2 implementation should be done by through the IOMMU_HWPT_ALLOC_NEST_PARENT flag during domain allocation. Remove VFIO_TYPE1_NESTING_IOMMU and everything under it including the enable_nesting iommu_domain_op. Just in-case there is some userspace using this continue to treat requesting it as a NOP, but do not advertise support any more. Acked-by: Alex Williamson Reviewed-by: Mostafa Saleh Signed-off-by: Nicolin Chen Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 16 ---------------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 16 ---------------- drivers/iommu/iommu.c | 10 ---------- drivers/iommu/iommufd/vfio_compat.c | 7 +------ drivers/vfio/vfio_iommu_type1.c | 12 +----------- include/linux/iommu.h | 3 --- include/uapi/linux/vfio.h | 2 +- 7 files changed, 3 insertions(+), 63 deletions(-) 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 e5db5325f7eaed..531125f231b662 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3331,21 +3331,6 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev) return group; } -static int arm_smmu_enable_nesting(struct iommu_domain *domain) -{ - struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); - int ret = 0; - - mutex_lock(&smmu_domain->init_mutex); - if (smmu_domain->smmu) - ret = -EPERM; - else - smmu_domain->stage = ARM_SMMU_DOMAIN_S2; - mutex_unlock(&smmu_domain->init_mutex); - - return ret; -} - static int arm_smmu_of_xlate(struct device *dev, const struct of_phandle_args *args) { @@ -3467,7 +3452,6 @@ static struct iommu_ops arm_smmu_ops = { .flush_iotlb_all = arm_smmu_flush_iotlb_all, .iotlb_sync = arm_smmu_iotlb_sync, .iova_to_phys = arm_smmu_iova_to_phys, - .enable_nesting = arm_smmu_enable_nesting, .free = arm_smmu_domain_free_paging, } }; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 723273440c2118..38dad1fd53b80a 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1558,21 +1558,6 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev) return group; } -static int arm_smmu_enable_nesting(struct iommu_domain *domain) -{ - struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); - int ret = 0; - - mutex_lock(&smmu_domain->init_mutex); - if (smmu_domain->smmu) - ret = -EPERM; - else - smmu_domain->stage = ARM_SMMU_DOMAIN_NESTED; - mutex_unlock(&smmu_domain->init_mutex); - - return ret; -} - static int arm_smmu_set_pgtable_quirks(struct iommu_domain *domain, unsigned long quirks) { @@ -1656,7 +1641,6 @@ static struct iommu_ops arm_smmu_ops = { .flush_iotlb_all = arm_smmu_flush_iotlb_all, .iotlb_sync = arm_smmu_iotlb_sync, .iova_to_phys = arm_smmu_iova_to_phys, - .enable_nesting = arm_smmu_enable_nesting, .set_pgtable_quirks = arm_smmu_set_pgtable_quirks, .free = arm_smmu_domain_free, } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index ed6c5cb60c5aee..9da63d57a53cd7 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2723,16 +2723,6 @@ static int __init iommu_init(void) } core_initcall(iommu_init); -int iommu_enable_nesting(struct iommu_domain *domain) -{ - if (domain->type != IOMMU_DOMAIN_UNMANAGED) - return -EINVAL; - if (!domain->ops->enable_nesting) - return -EINVAL; - return domain->ops->enable_nesting(domain); -} -EXPORT_SYMBOL_GPL(iommu_enable_nesting); - int iommu_set_pgtable_quirks(struct iommu_domain *domain, unsigned long quirk) { diff --git a/drivers/iommu/iommufd/vfio_compat.c b/drivers/iommu/iommufd/vfio_compat.c index a3ad5f0b6c59dd..514aacd6400949 100644 --- a/drivers/iommu/iommufd/vfio_compat.c +++ b/drivers/iommu/iommufd/vfio_compat.c @@ -291,12 +291,7 @@ static int iommufd_vfio_check_extension(struct iommufd_ctx *ictx, case VFIO_DMA_CC_IOMMU: return iommufd_vfio_cc_iommu(ictx); - /* - * This is obsolete, and to be removed from VFIO. It was an incomplete - * idea that got merged. - * https://lore.kernel.org/kvm/0-v1-0093c9b0e345+19-vfio_no_nesting_jgg@nvidia.com/ - */ - case VFIO_TYPE1_NESTING_IOMMU: + case __VFIO_RESERVED_TYPE1_NESTING_IOMMU: return 0; /* diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 0960699e75543e..13cf6851cc2718 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -72,7 +72,6 @@ struct vfio_iommu { uint64_t pgsize_bitmap; uint64_t num_non_pinned_groups; bool v2; - bool nesting; bool dirty_page_tracking; struct list_head emulated_iommu_groups; }; @@ -2199,12 +2198,6 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, goto out_free_domain; } - if (iommu->nesting) { - ret = iommu_enable_nesting(domain->domain); - if (ret) - goto out_domain; - } - ret = iommu_attach_group(domain->domain, group->iommu_group); if (ret) goto out_domain; @@ -2545,9 +2538,7 @@ static void *vfio_iommu_type1_open(unsigned long arg) switch (arg) { case VFIO_TYPE1_IOMMU: break; - case VFIO_TYPE1_NESTING_IOMMU: - iommu->nesting = true; - fallthrough; + case __VFIO_RESERVED_TYPE1_NESTING_IOMMU: case VFIO_TYPE1v2_IOMMU: iommu->v2 = true; break; @@ -2642,7 +2633,6 @@ static int vfio_iommu_type1_check_extension(struct vfio_iommu *iommu, switch (arg) { case VFIO_TYPE1_IOMMU: case VFIO_TYPE1v2_IOMMU: - case VFIO_TYPE1_NESTING_IOMMU: case VFIO_UNMAP_ALL: return 1; case VFIO_UPDATE_VADDR: diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 4d47f2c3331185..15d7657509f662 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -635,7 +635,6 @@ struct iommu_ops { * @enforce_cache_coherency: Prevent any kind of DMA from bypassing IOMMU_CACHE, * including no-snoop TLPs on PCIe or other platform * specific mechanisms. - * @enable_nesting: Enable nesting * @set_pgtable_quirks: Set io page table quirks (IO_PGTABLE_QUIRK_*) * @free: Release the domain after use. */ @@ -663,7 +662,6 @@ struct iommu_domain_ops { dma_addr_t iova); bool (*enforce_cache_coherency)(struct iommu_domain *domain); - int (*enable_nesting)(struct iommu_domain *domain); int (*set_pgtable_quirks)(struct iommu_domain *domain, unsigned long quirks); @@ -846,7 +844,6 @@ extern void iommu_group_put(struct iommu_group *group); extern int iommu_group_id(struct iommu_group *group); extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *); -int iommu_enable_nesting(struct iommu_domain *domain); int iommu_set_pgtable_quirks(struct iommu_domain *domain, unsigned long quirks); diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 2b68e6cdf1902f..c8dbf8219c4fcb 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -35,7 +35,7 @@ #define VFIO_EEH 5 /* Two-stage IOMMU */ -#define VFIO_TYPE1_NESTING_IOMMU 6 /* Implies v2 */ +#define __VFIO_RESERVED_TYPE1_NESTING_IOMMU 6 /* Implies v2 */ #define VFIO_SPAPR_TCE_v2_IOMMU 7 From patchwork Tue Aug 27 15:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779747 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 5FEF71C9446; Tue, 27 Aug 2024 15:51:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773920; cv=fail; b=Rj5gIgFePmnrrkNOohxTsFs7W/ftKSR3cM0eLZ9t8N4++2IGroOrcWfDBVrMLmT1At6AM7dzFscuxNrWi76oaE1MQc/ZNJKYyUvLVtpXzPMWjXlNd477rzTi7LdlKlF5OZl6RzIOJEsE9Zxir41Yt7bWyqRxb3r9x1Z/WMWIBZ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773920; c=relaxed/simple; bh=MF/khwL0nYiPRs9CasA+VdkJRC8nWlv1Y3lZTBslSCk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=G8Ql2TA5zAXjTtibj7myGCdXapdrTh/1b73Up1s68Z0N0lahFBhOXsmp5/x6KCMgLnr1dezURsV88W2557pBjzuV+YIPIrvG3j+nBkw54k2DnBjFt1Ad2ZeizHsQ4bF6vhhKe2Z32YSGSlP1G28IBlUevrUtkFnLmwYArLn1dgk= 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=dGy3tQDc; arc=fail smtp.client-ip=40.107.93.48 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="dGy3tQDc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iWgbnSEfqf2ZlsTsoYQx4B129x5SGcXqbmZEAmKZZ/hwo0RCwwUDLBgovc3nAkyNWecpfT4FB4Kyw69QgswW6YahdcGKuaPqmtXefRKPFdlMPIv5SIKtqha0IMJUU6G0ajEaUoaarVdhYJeHexH40ycb/fPQydhGBld4RAn/mBU3IG8MfeMjTOxf/TGX5T4o1Pu7RgBxFZ3tV2FwpXbT2HJwJ9LSeGarQgQLwMOrI4AIhyUz4ki/9bAnGpPvvvPAaGQ3kI4ZefpAxm3eFgmwhjEUUGD5tMY3PoIhZ6l5tR0YiQ94U1fwE3LCIwX+qgZEyOgYrzayzL3zzSsnX8+YrQ== 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=rRUyuzV0hhDxGQJiQHZpwajgRGE/E6DK8zboc2gejXc=; b=gbeeVFh1a6sqCRi8tcQPFD94vJVpJI+Wb4/62xveVzz1EGVGLK/4zg8LFGLHTSoDdeFbE2CiYC3G5My5TD6uMNf3YP3Z7Imf2TsX7QnG25rIpuI70jYArZ1tcantTusOHaFLyr9O8tIl3U+c2KcobPmzs5B87e+mNgFZUdkfY+TqcuyHg+aamE5wWzsB31gXYB0lOA+ZmDIxG8vebcX/Bid5ICWbtQVBVConW6d552DEOxpx85fYw1XHi8jHiSggtPrHpgmInuw3vPU4IB84UgZTFkuBZxFj/cOWYqMlEQmuedWMjY4HGgIXmKGgKKi0dNubJJrg7mU/ijagM6Zd/g== 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=rRUyuzV0hhDxGQJiQHZpwajgRGE/E6DK8zboc2gejXc=; b=dGy3tQDcB1dskk3RkVxNeCIg87qbELzSCHn0x6R2FUoCxDXuGOc3Fa+PpeUfr/ER0F/J5uPSNu36YuV9d387l53wI893UeVBkx11hV7u7CA5cEE5VnLhKaHNEt2Dgniv1JxZ5OJb5K4AC3Pyg6IMeAl1fUOpSPdHtDnyFETGPkoCLwN4lntPhxBWPrLkLNmmcnwptqMXjWL+f6mu9W6DLLkQyc5tVP7XLxTnBUKOPt69L9tX3BV+HyiG0Niuv8NzWEMxeqJ4ELwwjx1pJDBp5sWnX88PcN4eArIIaWXsU4/x+7WruqEaMf9eOCVPXFCicAVR/VvtsiDctIhMLE+ZBA== 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:45 +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:45 +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 2/8] iommu/arm-smmu-v3: Use S2FWB when available Date: Tue, 27 Aug 2024 12:51:32 -0300 Message-ID: <2-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9P220CA0029.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::34) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: ff8b5b8f-d858-480e-e780-08dcc6b023fd 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: QUAwtOXYLjV0c1Uy525qzDqNwsshyPmPJDfxVoWRmhnbk6qeUoH24u9F4RCo8he/miUw78DNgQjB9c+ZLy3WbUi4t+xtIpSz2TJ3pK2QPITnmrjyliQ5ToXhANyGTSrHWkOmGgl6MUXZxUEJkn75qLLXYMVHx8PjNbsllysKnluHEMjxcumqvaNN9J6cgkusxlEoNXsD8H20DPzGHxTO4nYGjpUkKmxiEVqOxqXttdDnls9nR95ZsGpEc8jNUvy2lqrDjgkQyqOwq1S6agJe61XXalMON4/ZOd92HBRGKk8UHj7AmvP7olIcQiBTPazdz2BT9K/+Gkoy3GoBg57aQrTJWUjDgU5buYV+blmCHY6oLrFxH3GX80RO4r4d8X52GzgAgnBQzNYDfCs4qH/SL9lNRrPI7G/c24UpXgq3txXlgVf+Z/vDOFfYwgHZQ3ClhNplkKjvanpBtkAYo6c0Y7YVt00xuk50cwu5fMt3OxNq/5ajyPmta2ZY7yK0vdNpof4+0IjDcw4QZa3Yi48uqaIrWtECLm4zYXR7GV/l9ujrGKPA81Uus9w094AXQgtgo6GqXTH4w0u/A62ZAKIo5jN9E9g8OVF+T/49S5fR3QskxkESK71BD6ebJORUvb1hnVZCr0BTdcQgOzne814yQbuFaZXYHX0FqtAIxEP5lS05xY7D7cNYm/6kMDOVArWjVSddDSNefHD6zNAxj7ppsXIRg/5axWI34bEAKMmVvP8wt9tel8qGfykB5tM02K6PkCwjOW9sGKiw0MAMCPETQSstBUxj2rLszuJK9OuCWw+2wPl2AMTXdn5QcqQ14z/0DBliENUvb4k1uDdE6VEf+7yl1uK6Rs2QxtYuzh2Mz9sNYu8YDVXhuinJLb1c58xornSgNpaZpgndeWiAQbNkrZv6c9C4AR1yMZqd7y5kszu+5OLgCIfSZN8BlTe9Tn6zVNakC7pFmMliRTw79gEDrkmPQtOwGrvUYcUF4FHbKv3uLhzdjQrEnDyJ3iQmGH8m93b8rlZMvbHLbxT2JKbNyK4f7MQu20AITb84t8eqMp+1lkP8fPMDDC19SEd9bWE/yfV93gOGxQISrK3p+7dECVHGlrmvSsbRPQbpJdk6Ahs9rp+CfjrXyE+R6/qvWYjcbMscZXClm9u2tNscrp+PmofCcm+IfHo6DqjiVHB2oVjGez3ewnU5lzkRZ7KglRI+KZE71WXku/pjzH6CLfBQ7Pye9QzrpnShhohj40YIbsgvjta/bmWI564ijvxZZwWlHmGJKyQQYq56EqK/mPatAn1pfGPi2H1BrHsYTHs2RT1vJJ6iMHbOE8f0USSUMuxwrJHsV920OQRUvsTwbv5B17i1y5syZrZQFeKMufGTyBKUEbroXj3IYYrfQxQnM1yj 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: lN2bytnekIgEu3q8wDbRVBZQyUH5pfrfHn23qkOejmrUKe6ZlSCGPxgWI+0AcbClP8spkpDCoE5HDA1xgSU2QG0xij4/SDefPKMeHZzrtsva1uEsuGQeRkNLtiMExpGSej1E4mrqQ583XC3w2ABzS9rxcYHvInc11jvrdMK+q1pFeSaOor4JxyEi5Mfnb7eAsucXxekvEWVIQGxRczW+DUdKFtRS91evY3+TdTnpEHUeMQVAQ2SADUVrqHOvX2WrpjsY+CVpV/mWeCqv/WNAIoVDBg+vyXRhCDgkhTQTsOXbxaBNfSig3Wym197FNIfzbzx0TEfWYNB08X2DP/2zaBYIFXBNWEAMnJQQZhIP35lw+nSZeQJ3dqDE7uvNec/xRjOLCaU3DhcrJZnqdNuk1kHFSUi4I7mTziCb4SUzlwyn8EQ97hwJR7vonOnHtHh4pjGs51KQJBBwYoaCex047tGOBUCsF18qH+xPv8x5RjehnyUWCWsw7gxI4lEwEYth0aV7rnPMBa97EV5Becq8kxc/i8lJaU6TpzJDAl+WCCe4WtUxMrg7BiatZ5TRmbu0VUUiolBExmE5OcYNvGF4zztiTXv/R47xsaQOB00o3aX4JEWOaOci/M4x3XGLDhCgRYHwuCBEB29EXRor2Z8nos7lxdn0SEL8XvyqfDQSM6toG5kJNxi0r6gBxO/PC0TxfmZlgx9R1WsoxKDrNhuKGLd6X37FE5WOrIL0NMmFyc+axOyHrxWaSMp2/y+4K+s1ywOiVrpiQ8oGeNqimvZYb7KH5z7YMth3ZijngQn8l+9+hKbTz/+OTNhZN5uaSErtbdPCaSNhcRxdyKRO9UNwQQcOgfxpoDVPh6yQaqLfYVc9DBF6yWoPGgTL9BK5D1u3SqV8YC7zGsHq4ETtlzrORRbmSNPzz5KBWCc8K9vtI+olU7CWIin1AtQeB/IOhJ2mi7lQ5PdbAGsdVue24PyNZoV07GL5I673hQS/yYUY0yY10yWTEtpA8D0OZznxrpR8o7KN5Gumu5+phgMdehxp9pkVD7mNMy4psU+LPgip0n8QmBLm34lkZU1aSm0pSKcgQq2oVdE4cxh+sIdRr5hLSLrm0d3xXd1sTo8eXrHO/iSLdFhZUPSl/F1aUI+ccQvuTPp1NdFrEsNjEWie6JuWgdDeSCWk/Tw1q2GEWoA0kf6q6r+rEg1MVaRRvjkWockrMv1HdTrpyDLsNYjzudagdpcD1AXvHRjZYnVjVgFzUeBIxyJgGbHIw7cwoWwj4+mwRkEAULwcKCwJRkdSJ/o2/PnfwDtke6cnJRGTHDE0vGW4p3K/ZpoqRod5wuNnzbgawAHZCZZFh0OwO4/RMNQ0Zx4OcRI1Qf18p8Cj+vuf19+H69pKxubYKaOzpkkEbBi+AxcRBJysTBokwEDfVWIoIg2ZEIUbyGHeFkdJ9vZBaCr5w4iO1R6c3qlJQlPB2SWrLr/967RY5fnbBJV//FDTWurSjgEdbYUKR+pQqWOfEHIIvIgOe82l2bUJRoR6wcs4OcewntK+5XEwuYyeOKWlV8goUik3XdJP+AJURvolqmSGqMut4sA31aUciOwlTwOD X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff8b5b8f-d858-480e-e780-08dcc6b023fd 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:40.4587 (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: Y4fWn0Si0w994NAoYaDZ/S/IfMQfqmfY0+AHtSo12aTzl5Ft3dHDbFvK07ltpOVJ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 Force Write Back (FWB) changes how the S2 IOPTE's MemAttr field works. When S2FWB is supported and enabled the IOPTE will force cachable access to IOMMU_CACHE memory when nesting with a S1 and deny cachable access otherwise. When using a single stage of translation, a simple S2 domain, it doesn't change anything as it is just a different encoding for the exsting mapping of the IOMMU protection flags to cachability attributes. However, when used with a nested S1, FWB has the effect of preventing the guest from choosing a MemAttr in it's S1 that would cause ordinary DMA to bypass the cache. Consistent with KVM we wish to deny the guest the ability to become incoherent with cached memory the hypervisor believes is cachable so we don't have to flush it. Turn on S2FWB whenever the SMMU supports it and use it for all S2 mappings. Signed-off-by: Jason Gunthorpe Reviewed-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 +++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +++ drivers/iommu/io-pgtable-arm.c | 27 +++++++++++++++++---- include/linux/io-pgtable.h | 2 ++ 4 files changed, 38 insertions(+), 5 deletions(-) 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 531125f231b662..e2b97ad6d74b03 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1612,6 +1612,8 @@ void arm_smmu_make_s2_domain_ste(struct arm_smmu_ste *target, FIELD_PREP(STRTAB_STE_1_EATS, ats_enabled ? STRTAB_STE_1_EATS_TRANS : 0)); + if (smmu->features & ARM_SMMU_FEAT_S2FWB) + target->data[1] |= cpu_to_le64(STRTAB_STE_1_S2FWB); if (smmu->features & ARM_SMMU_FEAT_ATTR_TYPES_OVR) target->data[1] |= cpu_to_le64(FIELD_PREP(STRTAB_STE_1_SHCFG, STRTAB_STE_1_SHCFG_INCOMING)); @@ -2400,6 +2402,8 @@ static int arm_smmu_domain_finalise(struct arm_smmu_domain *smmu_domain, pgtbl_cfg.oas = smmu->oas; fmt = ARM_64_LPAE_S2; finalise_stage_fn = arm_smmu_domain_finalise_s2; + if (smmu->features & ARM_SMMU_FEAT_S2FWB) + pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_ARM_S2FWB; break; default: return -EINVAL; @@ -4189,6 +4193,13 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) /* IDR3 */ reg = readl_relaxed(smmu->base + ARM_SMMU_IDR3); + /* + * If for some reason the HW does not support DMA coherency then using + * S2FWB won't work. This will also disable nesting support. + */ + if (FIELD_GET(IDR3_FWB, reg) && + (smmu->features & ARM_SMMU_FEAT_COHERENCY)) + smmu->features |= ARM_SMMU_FEAT_S2FWB; if (FIELD_GET(IDR3_RIL, reg)) smmu->features |= ARM_SMMU_FEAT_RANGE_INV; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 8851a7abb5f0f3..7e8d2f36faebf3 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -55,6 +55,7 @@ #define IDR1_SIDSIZE GENMASK(5, 0) #define ARM_SMMU_IDR3 0xc +#define IDR3_FWB (1 << 8) #define IDR3_RIL (1 << 10) #define ARM_SMMU_IDR5 0x14 @@ -258,6 +259,7 @@ static inline u32 arm_smmu_strtab_l2_idx(u32 sid) #define STRTAB_STE_1_S1CSH GENMASK_ULL(7, 6) #define STRTAB_STE_1_S1STALLD (1UL << 27) +#define STRTAB_STE_1_S2FWB (1UL << 25) #define STRTAB_STE_1_EATS GENMASK_ULL(29, 28) #define STRTAB_STE_1_EATS_ABT 0UL @@ -700,6 +702,7 @@ struct arm_smmu_device { #define ARM_SMMU_FEAT_ATTR_TYPES_OVR (1 << 20) #define ARM_SMMU_FEAT_HA (1 << 21) #define ARM_SMMU_FEAT_HD (1 << 22) +#define ARM_SMMU_FEAT_S2FWB (1 << 23) u32 features; #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index f5d9fd1f45bf49..9b3658aae21005 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -106,6 +106,18 @@ #define ARM_LPAE_PTE_HAP_FAULT (((arm_lpae_iopte)0) << 6) #define ARM_LPAE_PTE_HAP_READ (((arm_lpae_iopte)1) << 6) #define ARM_LPAE_PTE_HAP_WRITE (((arm_lpae_iopte)2) << 6) +/* + * For !FWB these code to: + * 1111 = Normal outer write back cachable / Inner Write Back Cachable + * Permit S1 to override + * 0101 = Normal Non-cachable / Inner Non-cachable + * 0001 = Device / Device-nGnRE + * For S2FWB these code: + * 0110 Force Normal Write Back + * 0101 Normal* is forced Normal-NC, Device unchanged + * 0001 Force Device-nGnRE + */ +#define ARM_LPAE_PTE_MEMATTR_FWB_WB (((arm_lpae_iopte)0x6) << 2) #define ARM_LPAE_PTE_MEMATTR_OIWB (((arm_lpae_iopte)0xf) << 2) #define ARM_LPAE_PTE_MEMATTR_NC (((arm_lpae_iopte)0x5) << 2) #define ARM_LPAE_PTE_MEMATTR_DEV (((arm_lpae_iopte)0x1) << 2) @@ -458,12 +470,16 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data, */ if (data->iop.fmt == ARM_64_LPAE_S2 || data->iop.fmt == ARM_32_LPAE_S2) { - if (prot & IOMMU_MMIO) + if (prot & IOMMU_MMIO) { pte |= ARM_LPAE_PTE_MEMATTR_DEV; - else if (prot & IOMMU_CACHE) - pte |= ARM_LPAE_PTE_MEMATTR_OIWB; - else + } else if (prot & IOMMU_CACHE) { + if (data->iop.cfg.quirks & IO_PGTABLE_QUIRK_ARM_S2FWB) + pte |= ARM_LPAE_PTE_MEMATTR_FWB_WB; + else + pte |= ARM_LPAE_PTE_MEMATTR_OIWB; + } else { pte |= ARM_LPAE_PTE_MEMATTR_NC; + } } else { if (prot & IOMMU_MMIO) pte |= (ARM_LPAE_MAIR_ATTR_IDX_DEV @@ -932,7 +948,8 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie) if (cfg->quirks & ~(IO_PGTABLE_QUIRK_ARM_NS | IO_PGTABLE_QUIRK_ARM_TTBR1 | IO_PGTABLE_QUIRK_ARM_OUTER_WBWA | - IO_PGTABLE_QUIRK_ARM_HD)) + IO_PGTABLE_QUIRK_ARM_HD | + IO_PGTABLE_QUIRK_ARM_S2FWB)) return NULL; data = arm_lpae_alloc_pgtable(cfg); diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index f9a81761bfceda..aff9b020b6dcc7 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -87,6 +87,7 @@ struct io_pgtable_cfg { * attributes set in the TCR for a non-coherent page-table walker. * * IO_PGTABLE_QUIRK_ARM_HD: Enables dirty tracking in stage 1 pagetable. + * IO_PGTABLE_QUIRK_ARM_S2FWB: Use the FWB format for the MemAttrs bits */ #define IO_PGTABLE_QUIRK_ARM_NS BIT(0) #define IO_PGTABLE_QUIRK_NO_PERMS BIT(1) @@ -95,6 +96,7 @@ struct io_pgtable_cfg { #define IO_PGTABLE_QUIRK_ARM_TTBR1 BIT(5) #define IO_PGTABLE_QUIRK_ARM_OUTER_WBWA BIT(6) #define IO_PGTABLE_QUIRK_ARM_HD BIT(7) + #define IO_PGTABLE_QUIRK_ARM_S2FWB BIT(8) unsigned long quirks; unsigned long pgsize_bitmap; unsigned int ias; From patchwork Tue Aug 27 15:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779745 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) (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 665D01CE6F8; Tue, 27 Aug 2024 15:51:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773918; cv=fail; b=unapzUmQHdsD60dyEdqW1i/HSiIQaNxgmOF6wBq7n4bz+7vsvDwDJa8hckLWYeNKCSwNOxESsfaMMIkii0FHImR6BjwwnDUoQHJdTiMq8kaIbWwJjUfkg0Zc6S84THOYsIqKRGc4XRyD2A4FEPlSZChIK7vaigb+sbinHHs9vpg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773918; c=relaxed/simple; bh=Dl6N0LsdB9vt5Oot1lD9c+Ms3CszglyIKxnMHpzHVnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=SL3hxVcQOoDhdJR6YTHNfwJIfzZ+atfX7ViIDP9CZqJz6kRqHEONkZDwiaJMlNbc0dTtJ9EOdrdQGjVthHdmx2zTYdP7J6ZomhS68SeV0YCxNmpXyKR38bFyAx6BEeEEXR3H7oiJp6nVwC4SutBMvp65SXFf21IlRl2VtBfLOMQ= 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=YUkgElfo; arc=fail smtp.client-ip=40.107.92.50 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="YUkgElfo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ugZJnP1eGTC0WmjkeK61v6FPp9tsuXDcVrrjxibc9n4h/OVb2qWftdO3LMFJxjS7xN69ZaSWFN/PsHTALD0nHR1assKP7NAiWHyba8FxtxBJarqyw8t2vtzqFkPeTCmIteoAA4kRaBfUBcLwU8Meu/HOO3JCQKaDz668e1ujf7qnYWmZ6VOqnXXxQLTGQR66AeW6i+2RbjUjluk6ktFyURL65OxTYeimQE3xj7ugk0JE0SDhsl/frMFo39GOiUSCeqs4hU4lIA5XN3NucrVEkM+YKsNtHvBYO2TpeUbzEggbQ4DAREHr3xGAIxb40vt1JuB2koaJMioKP2yI5iUtcw== 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=mA/O8BSGCnaIIm0bE6X4wZPUqWemQxMeIBu95O0VoPk=; b=izPyuViizdES4d8SNwC81HTWSRgmMVMKJ/P3SONiYz4LfDrgAFbyItWqB9UCNeJIeS7zuANDIkZ4bIpqwAZUDwFEgmVL6p2dbrJvXUIQ+U8kUYn+y7vu7BJm3wU3HSC2nJd9yByi0crtHm0j7OkBrnTDPsW3Zc+Nvp/f5qfWANoOyEf5wz8RovFh+85W1GTQh1Q+VF+nzbMG5R9L718MVuUqtIs1SE31YZUdk2Y4IRJyD9E/38lcwrWilKVk9xSXyRa9kubXLC+IIGHQOFcLojvUSsYcyZXXwE/E7JAM9QpCkF+NA7Ns3YUrDB02CCyaOzlSWF0LM9PRGiGMK+Vtuw== 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=mA/O8BSGCnaIIm0bE6X4wZPUqWemQxMeIBu95O0VoPk=; b=YUkgElfoAfI7FU7c8223Nz1YwiwzlaFGdil4V+X0h99j1Hrjvt/X6Q9HEAP8fT2PvRJ50Zjk3SNiIgSk60M0AcvHpSNjTNGnfyMIbKVuZz9+wbbknU1z0pkXmjS5KZpmlvFExU3IRvUplssTNQi4xfuQRMtbo4DY/lmUw4CyGWBgK1uRxSsmYBvPT1x+vCO/seh2Wp06Yw0kzy/6J+jUdgWf+N8py5pCQ8fPqMthg+iEP9nU4VuEwwpNk8dbot3knbC0Nu3d+oS/N1KuWsVL4IHozcSERR/36YBC4NwBahDhqeCt7mwkcuLZ9LSRKBSox7FQOy5LF51wU5+7CV0/1Q== 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:43 +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:43 +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 3/8] ACPICA: IORT: Update for revision E.f Date: Tue, 27 Aug 2024 12:51:33 -0300 Message-ID: <3-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9P222CA0006.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::11) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: abe3a666-52c0-4a73-0d41-08dcc6b02420 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: Kxs6L4uYfF5q5dR8z/ilM6KmlyyT2UpN1a+465XPN99b8TeTwg5REdUI5gOktvWtB6xl2YmvP/EkIUkLc7aWRVMGocOqb2/ziik1rs0YY29nqQCQNaM4f307cwjeaVucpn5WX42jFuDi4yGcKzB1F52Qwex/cp0feuFiHl3KLV7obJ/WkbKl+uHyfBC5lyBH1J+scKLxFJhe2yM5f6dTAGTc5hquzsLLllf0HHq6FvQhtUzO49+s7vP42dlZLFYMJpEyhRY+xOcRoWNOhutwj8zFe2CRtafAUDmgGjmeRKlnTWZx2vabXCtd34zuoZZAvcj9QcCvkengb1/2j7ezt0qj0i5F2YWMntqGGjwL6S3YEB9BW50ObIpA7cCgtbUaW/Fu4VSYJJBbaKmdbsKTv/WOGYrzD5dR7uJn2cursgLvYqdUgFujWsEB7lZ+0aVMZIMor1300bABmsvnY2nV9boj19nhZdTDx1/imV3LGRaap/V4ntncT/IysXBUeeYkL1JQadFlKyCL1MyJxcU75iTT63OzTiZPt8igtvE0BNQc+PRJ89aUIoClXygWxPaSAHcv9wohVgqkS+/cVgHaTJQdYKPnL2B1K7O+OF4Qg14IvFGm1AYXHgGSOJnNjnTx3Uek4snlJtQLn2xXKDf4+wwOCYCQGkvp9O1lZ5xkNvRGVJASMrAjBDfo2I1BYd0JrNZn5RbiYSc5GFrRuQZxbQzEiIpw1Vdlk7HN6l15VOkE3xP659+fDZv1H1kFABa5dY+h3i2My9nUtnt43T6d7FEo6TYp04wImPtIL37qCCCT/FrA/Qi92OpYvFEav10bfH7x10qVrsts54jXZtNIollu+0oLDKdZ2lyNS6n48509f6vXHie6XA8gy8tGeuVMlLlzNtiJ51JQqanP1fYsXUty6hdykKkkrAE7I2TlvuMM2U0X6i0jTXaozZbu3UGs54dDzj/Uu5IzqQJnX7Zwpa8U3k1qw98ShwYyaPAGgUs8J2FDTnlFl0BkTNQpsDZki7sEaFoXlhn1Kig916S65Rm2zAV8KRhDe/Kj6DNxjScf+Bg2sA+qZZMwFbjqFsf/gTO8IkCJ9D7sVFD/hhPJBnihPtCk/XgKqH9OLk/fJxcrHisbq3ARFTgx4U4djb5hGgsVNq2guo3/7qSKsnVebaHR5bsIQ0AxV41O1wxk4kWz+ijM5gtUZXTTr3U/sYgMQ5rbv71jObctYfeL36yVrCokx0zJ2dPHW0JAI9sCes0Tvvdvf3V9/WwgviKecWuo0u3/y6FVnSe+iqStBw+tJIrMGK1Px3O8paC1v7atM1kqPtYz1RWEQmqG4c36DBE+Ox5P/v8Ct4zdq8NA7coGb3kzrzP1tbVqwuz1fqHL6XE6hXktuIEHgckK9tIXDzzQ9GhBxzYyZs/FXCaHIY+IMQ== 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: PlXVandMAsl4ecgAchIyFkK9ymPdb8Ty+KWhC9xhmtCHEri5dThfs0lmsFxQqFwPcMyKhuk/Bhv7yj4Nl658YFppCkheLTBqf9p/uuDPq6028MbhtP4yHi8NlvJH5nHKmBForaVGwhZQWADoEOZtFC8MEDCtbQ4IqDm3U6N8RlRE0nrBPnny4SAuVW6Um0StQrOmaHWL07tQcqDzYLzl6SFu0PmEO7xDMJRScq69r3N28fMMuCxXQs74Wrd7TVOCQLF85XTQgmAvTHXmXX5Rape4N0tKfXwIgm5lL1V95aUz23ikXTRP2yWd/5cahs8QlxUJeOtR5OnhDbEUTvkwZTuwCGwDljtqJnJafvnKjHMPNrndVqXP1LNukFQgES37KKYyfmrfGNc1SSmAgUH+qynnjuufbtwAZnj7vY/swojh/eFnPOnf8UIUc0I+yNVqgWiTMq8ATBPzkISiI9nRnEHmnO2e4JqV0wx5XEyvE6lKQriiNUvN/HsL/P2/LfeQNLC6jjkH3kgZ0bMoHHYCuDrFAioR82IrP80zrQ0RhKEQEJuJRCWi6JnbDA9yEPSUpRse267J08wZg2NZQDIQvS9evCF0mskB4d6jJPpopOr1K6fSKPfYO7CLOPX1tUWADUpSkqVpSYCKMWAERobVqsT9qEAkgoPvoYxQjT9Ar9SxfR0bkykU7x+V0cYFDzwUSoVbWZG3n4pMEjGlfD9F049bpXPhRMp6psG9IfPYDsiR3iBj4dhZmuhKEzXjUjT4YraF5mFTx7NNIvXaohKm1hUdyjl7tSyn+AzDsN9htG9CaijHFOiPS7C0MkyXcLxw3lZC1h4YGvWX6KnaQ2oQm78FQiUgUqiA6FFCs15D/TGskxp8w5ukFHupRPfgzVmTIh6zALU2w02cjPglRN71VFE0YmniLKSvVj7BapCcytrqdycdcbkdvPIpqAkQI3PCZFJtCZOFrJAZJ1lYLgVq/R2yn7sQouRayjP7kNRl7XwRZ5dOJy5Pj1P1uBhcrjeUf/ByFzjbvzK0PkESZPtebOPG255v7n+5s7EMcqRiHWiqx7p719mn3NHPcaQ2iGBsCHy0ToSTRkvyuooPZ/x56dRjJbnp10VJxrvCnuiU19iAz0AtP0vT4yTmY0ZXI5cjJ9Ie/GlqoKXWnjSwWI5DggtGfugDNfAlNb+0FuvBOoUPPn8Sswj1G/x2bntSRoabOT/YynhfkB8y6wvoFHz9VVnd4Ng8Ib5zzdGUO/OuA4WMgf8bucyr6BQkjqyG6dHpCw4Gvs3q5feNDyInGCpJ1LTTlXAGbo1gbBQJiDyaF6fJMMriOZUvQoWGABgGr1KNvLB2HFRPnKHKTq8K5xEVeSRPs9QDeCSbjlfUWTLe/jUsmeHPKKizkE94BMpqawNSKT3zLmS/AHhxWUgr57uHUe6c7K1hPgcD6sy7yk6Ei+b2JuwMREkfTgrgwEvBDfiaXnEPDCZYJFmcECSTQUTPeKFMlqafzFPQ/OLWwBHC4lk+2dtttkDKttTWLFFQTBcKXklQBAQDVF0uKM9Nr1aZaSxzFTY/cemzBE42oexAuhwIo/EPhTVFPK3i4TGmpqb0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: abe3a666-52c0-4a73-0d41-08dcc6b02420 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:40.3607 (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: zTA7OrkP0f0XSgBgXNjVmpeQ2pNT410L4SDoXu6AbfPe3x2uEeB/dI1GCrilgbpl X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 From: Nicolin Chen ACPICA commit c4f5c083d24df9ddd71d5782c0988408cf0fc1ab The IORT spec, Issue E.f (April 2024), adds a new CANWBS bit to the Memory Access Flag field in the Memory Access Properties table, mainly for a PCI Root Complex. This CANWBS defines the coherency of memory accesses to be not marked IOWB cacheable/shareable. Its value further implies the coherency impact from a pair of mismatched memory attributes (e.g. in a nested translation case): 0x0: Use of mismatched memory attributes for accesses made by this device may lead to a loss of coherency. 0x1: Coherency of accesses made by this device to locations in Conventional memory are ensured as follows, even if the memory attributes for the accesses presented by the device or provided by the SMMU are different from Inner and Outer Write-back cacheable, Shareable. Link: https://github.com/acpica/acpica/commit/c4f5c083 Signed-off-by: Nicolin Chen Signed-off-by: Jason Gunthorpe Acked-by: Rafael J. Wysocki --- include/acpi/actbl2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index e27958ef82642f..9a7acf403ed3c8 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -453,7 +453,7 @@ struct acpi_table_ccel { * IORT - IO Remapping Table * * Conforms to "IO Remapping Table System Software on ARM Platforms", - * Document number: ARM DEN 0049E.e, Sep 2022 + * Document number: ARM DEN 0049E.f, Apr 2024 * ******************************************************************************/ @@ -524,6 +524,7 @@ struct acpi_iort_memory_access { #define ACPI_IORT_MF_COHERENCY (1) #define ACPI_IORT_MF_ATTRIBUTES (1<<1) +#define ACPI_IORT_MF_CANWBS (1<<2) /* * IORT node specific subtables From patchwork Tue Aug 27 15:51:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779744 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 535001CDA1B; Tue, 27 Aug 2024 15:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773917; cv=fail; b=Bc3w9T7gcIe/FMg1h6rSJWKjVObzWOfIKKLfGD2/kMAAief/UfvDrVhWmRWH0la9ySGrMPyB0sqNVlBaP62igBwAi3jAfVItjFhfOK3VzMNoNGVwcC5XK24BthWuyF5hDL+H0jKjCoep+ftF8dFoYo/aiUqctRPPHe0VdE2mv0s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773917; c=relaxed/simple; bh=a8/IyaWLJkq+VE927HYHMyEuWermkViTsra6J34ZHyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OlwbBtwOUz3BxfqzSbTNQ5Y+R8MVnz48bAyX7uNUNPWtHV7kAwXRdUmnKlIE7eGkn5ez84abyXPr9Ihm/6FMpjTARYMFF3NY+tcfweOzsN03MgqJtzM3gwx47FLjcYQKeTLl619rs/E5brnaCrp2d3MgmKZZ0Zly5enD7j2rLTc= 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=Gj2z0s6u; arc=fail smtp.client-ip=40.107.93.48 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="Gj2z0s6u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tzo0/HGjsfUEhCFjovpwa55OfpnAdDxWjLwMigmLQwO9ynFUjdBa2HA8iENJkW1mq4X7fxc0h+0coeDbloMAmcGZ7Ag6hf+L3eJC1t3SPL5pc7DQAl/vEvQnGqp9PQ1IXoDYI5lkkYuxOOwRbIuqtRgjB+J81wGt7MGTmhNE6x1Y6AS4lFmfUqGMzVMrCCdFPombYoL1/xkrN9XSXzvn4WiHK1mfScQNyEESy+Zfg4Inz7rGVQJ7qSOqQ5IAkeLYyElABHc7ZfTPJuxBXZVxLeCrWILWv3+0hujMXkHfefbCekU4KT4TprILxeWtB7492tL2btiHFAV97eymQP3OvA== 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=WX93OvQ3W75W1i7406blpXe9zCyJ+KE/WG/ZywkZmts=; b=egJmRPvkZClqfdCeSUY+czHt+VDT0No1gw5/cx/nPK9ifrWKbVHSY+gkDq0hifn0oul9cNfZses1C8MIbwIbKOFuMv6eP7mpBWDoHY1NhLgx2mFQicXBKqRNjoqBenvoJnDhAI3FMlYrSiB8eANSjS3vQesid8VLzYVtfGm/N+vdaM6AKmQG708BNG9PD0xEB4678rObLC8h/zCz0yfDOuTG41KDxoVBjs1iVzaXbdtojU1juRJwxVqW4qwHPH3yt3MeVW/bLmyitbC5Zl0kwGWz+4wbYj4C6W0Oj2MkXgN5vKMjVJ5QhFpLJg4sC1A3Hd0AxqvdqfPxxu1KGjpNuQ== 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=WX93OvQ3W75W1i7406blpXe9zCyJ+KE/WG/ZywkZmts=; b=Gj2z0s6uqIVoB0b2J4LSvyPaUW1CPxLotxuV/cV88U4nOSnd6SQUQ2Kfz2fkVlXzCDbwB8EafXev3yUANXtOD8FoJ3VFlpbqXjbKLscCijIs3H5TsPl26L4ohr4leHr2qZdymHHK6d4rG/zTPk3ge+Hc7DWEiUUPDE4qDJ6mWPH7IzZCdKo+ldmooJqmGsysFSPr96ymf77phmcVEdREhA068H2ZmDZT7R8CRBM8WXOq9+m+ek2+0CQ13NJD7hmq6DcboOkSMnHUq3/9tcLpZje8IzEX9Q+mEi3XiODPxuxFhNzIdu/Gsg5U4B/FOckVTBkBHQOKOVwitfMHQtC8FA== 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:43 +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:43 +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 4/8] ACPI/IORT: Support CANWBS memory access flag Date: Tue, 27 Aug 2024 12:51:34 -0300 Message-ID: <4-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9P220CA0007.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::12) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e66d053-eb93-4b93-23c6-08dcc6b0241a 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: /w+K58wHUvHBiWHW5q9+11ppjqtJztBrJD99noPkBNqO1QQnIgXPkR4/oD+CjziTPnsFB742LOogDGTmsYqEWvltuFh6sLlsXj3+CUUiQaaEaa+s/RAzaVqEKeH01KVMxHM0N6VixOCfrIkrD6MgrjjMya3Qx1d8XWIITzkZ9h85SFtUTXU1Abbbai89NYMqNGTjJ2fV8XESIt94jHRC2Bgx2UzzESamQMtSvuHvR+p0kYey5y6km+9E+/hb5lXK73S7Grs8Ah9K1Kj2xDMLe3X50RRh0+ga24oHHBiLYpaeTWorerrUn0oHcXsvVfxSenq+B+SR/35PyPxcLyV5IT2FV6k+18YmyxYXlgUM+YNuvnDDhPoZwW8vzeOyhH3Pt4lMxU9f1dCos/OziQxz9GDmVXbLdE816ftVva1wo5N5qVTspSYOfaCj2EVkY0D9x87Lp+ozLIHyYYDSoYGHvTB42/Lws7WyqLPujuMojtZ/HCiTxY/KlQ5kZoXW4kliIP2Ik5nkGR0KIRF7oaEF9Podkz7rQ5uSQL8FG3wUiMzKSC5wxEjvBeKCpa621n6+bthPSeXq/wUBeQBIKGtmkXRc8ARQ9ARGKFUcZ7N4HmtUl+AXVKtGRheGCoIOl0Sdstp6VDakoMFj6EXuWway8RczO5YHPImkfka9Ulz2pMnGbr22E7Ep/qtDd7SFoRifFmIAO25q2PmfcU8WT7l8Agf0VgyZCkQ2plXmwkLO4FELuWMUy1bEqFrn8R3FyE7HMTAY56PkUTX/zbyaFVVsb/IRX6belI3WWFfLLK69qNvEBbTFFSwuep0HcRNsgDhBJE7Ha65SqAbMCiWm03OALSYOsmiKkR0VLftxJR6KGKXau80gsez8postndzm7TSDZUhk5Z1e7XyY3suByOXM03XqRvDGEbAy69NHzccGBtzYf84IYrb250Cs5pYGEXJPo1aoOuqfHTL9MfTZTa/QZde54DK83ZACUdePdrWaqYoOQzbTSvMW9b7Bjupu+ESffj5AD/nW2B2pUQLjI7ecMarQnMBhErMa4s+R9pKCDRi0F+cyjeYsilH6M+oeSgM6ZicYJUpGQEmi064lAH0danb77M8f34X9/4DYC1/RyjoLsaXtHFdpPvRlpcG6aR0ipDrS1SPSsCoe3JaSFQMriog48n1lMwTHMMdGPOSVuQMZPFS1nAhEbbaAKf5gM1ygaKo3/foszEruDBNt+hcP8yPQAMHacHCCkU//dZ3hWdK7MzSlcaZoN+SHJizJb1NPWeqA3PD5f/zI0vs0SPpKfT9iX8cHDRbe9S0QMcU2DePKuoWUM2otHmvq8zvL2ailtdTI4zBJ2waUiiG9zQCwE7Cvn7GrVkRoggNnzPoZ2PZQqykjzjS2gn0/SaWDwiMF 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: wKTR5XanXdg2HCuks0mMcM5Ihmsz3dbRnRtA4LMJWk+yWgAgeersyoqjgiDSaAKZiBnWd19SCrigUSTIRnPV9b5qZOg+I2ofqlDkoRu3/QNSvv4GnDkrkWbKnG6/RkcwYT37B15vLT6EVGcibqEs1uuYnQXIpmIimOUB3CUIE8cW9TciHgj6npPoXNQHG5zMPtKZ8X8zdLgaGYZjqVFTF0sRRC0hEIiCUPKGvt/sBj+VdMykBtsFiHPxkwVLxd/36r6JjiUht8AWjBusIP0dOvtnnMHzXvAxR+mcqHAD/+ofX8QPRgy3FL/TpA15mhFSYDI6Uzp5RJCFG7dcxmewug39XukpT+iyDfJYaKMvQW22ykDP04Yj7TiYNt36qADakU7GNAKIQIE9yvTSs4Adl+XEUs+dT+AG/xqzFcAJQ8ydTL9KRn9cbdUsAQzqUKmFKj8G9yrOXbjB6I+ABnOIQK++g2sz5WNG19Uy4g3zVzuOdwVsJzZlNltW2BiNsP0A60O4hw273FnY70IReK2iTYwN0YjFyLv+C46F3Eu9hpSI/rXLVsjM/fl9t8mi7kuQ8NwUDouX/zxnWYlco1My04XLJxuRnLQBKugEiN/+ANnLKHyEEuJHvn7ADgxtV2C5DZ8pmooD/K48mH00zKCIadb5Qk8TD/qx/9hqnOcgBId282c8e1LkQuyE7WCJOFaAsXpxShbv8ig0Rwj32v5RVaBHd7Wo4qD9kgf/UmXK9a4oVWx/GeYdArNoqQ3w0yVSSPOv5MpAYIE/cUt249rbmBZOu1zfi40rNpZLlE85KP1GLQskYYEm37toJ2eKQpC/f1gPFNU3kSiWOBGqw+fSEmH08WeHETgM8JBkI+ZykjFoogADMGp5Or4aNbpM2B8bpTarFT/FoaI6OJ0Ttr6WFhW+lBZjZ/CG2luD3g0aRBkbcGnppHHkidBvjry4mOejYLjJ8HzbbmkvciyqjDdtiRxodtZ2b74BYKWO4md/acSYvJjygOp6JkfB9TnjK1n0Ogf90ifSpaRgllWmtXpo+00h1YpaqzH+9A4nIm9nJaVwxlZf0mLV6cMuAIBouI2Z//128pFlDuP4e5HFdBlKqDwI/+zQd/ZBLCZ9WP505LqNoiZ7G8qrNNKVoZ6M5uMWNoqgozkGXpf/6OjeEvG7l4GKCZWiYrEslgmAHnlXtPKM4Bbxp8iVCHPy7RyNxWk4zK/OTwsIvTgk1TPBmKTP/Bn+wvUigxgRSszf3VksB38b8hfxf1FmQ9K/mpOWkloJ2V9uOjnb6QWxt/RyX29ztV94oqZZl1nnpXiogBA9+okHlGYVRUvnMVUuW31UktBYQaMEIZMdSlX8cMjEEyNxaMWhMAGdWNNZWVYuBWPCxB9ZlbfwOQ0s5hOVSHzZ4wmx4+RMiOFQTc13ZF5eoauNc1EvLgXkRH36y+HHweioMHWSvjmTlbnShboQSTt+nJfTj7Dnx+ezH2Oi32HccXY+Uu1olFTPYuNrNOGl+CyNbr6yvFmTnjcytCIInh/HF4dYFpqXDWiNXN7QtFVJeiTLLvmEZnlTUHSVO3UejFOjFF3fwbEEY0snZGkG8P+tkcYd X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e66d053-eb93-4b93-23c6-08dcc6b0241a 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:40.3419 (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: u+FeVvAvnx6WK+0ox+0RFDj3rCQA15C6WVWGDDTQw71tV1YM9ZM48D+1SVMxCanU X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 From: Nicolin Chen The IORT spec, Issue E.f (April 2024), adds a new CANWBS bit to the Memory Access Flag field in the Memory Access Properties table, mainly for a PCI Root Complex. This CANWBS defines the coherency of memory accesses to be not marked IOWB cacheable/shareable. Its value further implies the coherency impact from a pair of mismatched memory attributes (e.g. in a nested translation case): 0x0: Use of mismatched memory attributes for accesses made by this device may lead to a loss of coherency. 0x1: Coherency of accesses made by this device to locations in Conventional memory are ensured as follows, even if the memory attributes for the accesses presented by the device or provided by the SMMU are different from Inner and Outer Write-back cacheable, Shareable. Note that the loss of coherency on a CANWBS-unsupported HW typically could occur to an SMMU that doesn't implement the S2FWB feature where additional cache flush operations would be required to prevent that from happening. Add a new ACPI_IORT_MF_CANWBS flag and set IOMMU_FWSPEC_PCI_RC_CANWBS upon the presence of this new flag. CANWBS and S2FWB are similar features, in that they both guarantee the VM can not violate coherency, however S2FWB can be bypassed by PCI No Snoop TLPs, while CANWBS cannot. Thus CANWBS meets the requirements to set IOMMU_CAP_ENFORCE_CACHE_COHERENCY. Signed-off-by: Nicolin Chen Signed-off-by: Jason Gunthorpe --- drivers/acpi/arm64/iort.c | 13 +++++++++++++ include/linux/iommu.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 1b39e9ae7ac178..52f5836fa888db 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -1218,6 +1218,17 @@ static bool iort_pci_rc_supports_ats(struct acpi_iort_node *node) return pci_rc->ats_attribute & ACPI_IORT_ATS_SUPPORTED; } +static bool iort_pci_rc_supports_canwbs(struct acpi_iort_node *node) +{ + struct acpi_iort_memory_access *memory_access; + struct acpi_iort_root_complex *pci_rc; + + pci_rc = (struct acpi_iort_root_complex *)node->node_data; + memory_access = + (struct acpi_iort_memory_access *)&pci_rc->memory_properties; + return memory_access->memory_flags & ACPI_IORT_MF_CANWBS; +} + static int iort_iommu_xlate(struct device *dev, struct acpi_iort_node *node, u32 streamid) { @@ -1335,6 +1346,8 @@ int iort_iommu_configure_id(struct device *dev, const u32 *id_in) fwspec = dev_iommu_fwspec_get(dev); if (fwspec && iort_pci_rc_supports_ats(node)) fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; + if (fwspec && iort_pci_rc_supports_canwbs(node)) + fwspec->flags |= IOMMU_FWSPEC_PCI_RC_CANWBS; } else { node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, iort_match_node_callback, dev); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 15d7657509f662..d1660ec23f263b 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -993,6 +993,8 @@ struct iommu_fwspec { /* ATS is supported */ #define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0) +/* CANWBS is supported */ +#define IOMMU_FWSPEC_PCI_RC_CANWBS (1 << 1) /* * An iommu attach handle represents a relationship between an iommu domain From patchwork Tue Aug 27 15:51:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779746 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) (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 3378C1CEABA; Tue, 27 Aug 2024 15:51:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773919; cv=fail; b=Z1u4vsllLNTF6wW9jmK3N/QtmBJIhabHK/w1xNoFa7J2/6DRkg130oCshAZBYqN7/UCGdLTgcy5QgeW9xfy6PP79VhUR9nJb7k5OM4Ej1o35qR4anUBIxId0wDkv2sd05fQsgaTjZMm8o52TDRIwL7qIczoWbAFiM7zMny+cCHA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773919; c=relaxed/simple; bh=HeFIv0oNDQoWR7S7W805V7J8yMY8RmolvArjw97BQbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=AxbByRSndCXUXGJB9KWKFRcrUKvVSoz8xd15mpdixqbJxzdmd+66b9J8mFvzTl7ECke5RkUiWheKcBH/hPHzmG7352yd7zp+ar0ksbhZTqCELnx0lDMPs4W71qT4bV1AFg3ySWfbhOzaizBaMTM2JHP9NvIplRi19mAB6Az0/0Y= 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=tvlkB2cL; arc=fail smtp.client-ip=40.107.92.50 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="tvlkB2cL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KF7fxDDerVSIwglNDARPh3nTuX9sy3UTEHbQR7S5m3IuN9c3qiW2gcUGd0S0MBG6wmGOW5zNOIWIHuYkar6wb5My7JEa6SbP0BmaizyfnkONtIKAGA5ggIotx91ok7gYBsaTIaur3S/Mc2M/t5Pforsl2ptLGIPWF43S7IS4gDy4DJuEUQGu02lCdCdYg1ZXUSrI0A6vD0AMlMGxCVFTumCAjz20OhKdHsJNdJ2150LCcrCIxPZfhWZ5D8WYQwsHi9tV3yt2Ap8bJY0D9OurrtdpKeZLwTt8oZ8UN/CWI1BNgjzPegGvx8SHg38SbIyLQPLgfs0kx8wxUhlzIm4VeQ== 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=MTEAzwifAPFD26IA6itYKo5ysivjMYWPhikwJ+7Gtyc=; b=MD4qBfqHmgT9JPvm6PA0z4pyaimVcRHr1wlNVHvSyV5x9gbBOCEiC0UujsHRTUs0dY2OwLfqM+9RyqrUi/n0Zubg3y2dDBNsDCqQLAsEZJ07NTQ7mFtgPId/wd5UfPGE5n6tTs+dPPqXebLJHEgGYKXqb1bfk1J5hFBg0JLs3/FEetKoogQOUCPWr/GOKj0fQQcNeKcZCScoRnC7mzKHd1fT2G1MUrW6vblEZnyH4SQzanRvxRRtd563yiFz75YHQ31bHIouwa4FfuCIg9YsVYcwQhvYnTt1CQt/wX3dWSqBsOpbDcRfCQpRglcFEEJ+qzDDthz2vMI3zbCOSnAvVQ== 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=MTEAzwifAPFD26IA6itYKo5ysivjMYWPhikwJ+7Gtyc=; b=tvlkB2cLKzwM7X3wlC5WW9lOubMu1o8E4FGRAuam1g/baWQu/WFH07pnTJR5QEQYBkNd3DSMHZic2ms+2GiRLxiekjWGjL6X7xwIfFzSx/9iaFXxpONLPGftneWdVsKSFv/pvYI4A6ZHPYpdzvKRM7HFqEEFsd2Kdv0zGB3Pk80UDhjWI5WsfIuquNsTnBninlnwSS3cPe8sqNOiII2gIsrwMAwU7QkpzsH1NBrKoFSRUJ8aYPvsuyD8LWNZ56Sg9BOB4+Sgyd/9LbxjCjQs6OPJjaGVyh+PLj3p3T577YDs8hrfwZdAAri1JFvZ/6TuOwDxieH0xWbUj5XSXT+f+g== 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:46 +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:46 +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 5/8] iommu/arm-smmu-v3: Report IOMMU_CAP_ENFORCE_CACHE_COHERENCY for CANWBS Date: Tue, 27 Aug 2024 12:51:35 -0300 Message-ID: <5-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9PR03CA0114.namprd03.prod.outlook.com (2603:10b6:408:fd::29) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: 48b96551-a508-4ad5-efd8-08dcc6b024a8 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: cXZXD+6VGBu01YIf84EfHXKS++Pys3BsQ3+4jI9ghLEzHnnrJFJoHy4pBdf1NubHmi2dQMAnZtSuRrXGEJmoRnQxIh0+6damDSQxLVSL0eJCGucIpfxqmkS8A491ESsjyyxZ35YbayYoLPvYm4hyNyhOGA/LLJLnh7+9/k44T9af0I7QYT5XLMfW86x1Sq4lhD/web29adKD1Ur/YPcusA0/3rLtCmwshSUtQBk4Sh7UDckBf+iBPNuU+1+afmBJzpUaEsAdjvvD6v3/tMHQgixnL3RwJ/SHrbKyqMNl25rEcbLvGpkYyjgLB1cfldhkU93TUfGsfUO313DTk2eQahdenLtRMXPKum3TcT/saEJc3IOM6sYF7sYepVaNOrN3P7oqfpA7QMuDJjHK+Bm69/IRucG8FUZ+5dPzQml1Ff/op2bmdMTTncTzGLUKsZK0ghUhkVdLd18SX0utCS2ewvnv8df9ShSPvpYJED1wQbD7CVV2X2YZJ9ZJRkfbH4d67EpLKFboNXMDJg1H2TXSwq2sVDGiPDVO2mMMbSdYZgXX+K/7+A7h2aAmR02SSffSt5R8IoyDxelPAdK+tmmQ0nc9LzvxnSGrjFjeEOcKh3PQ3m0k+QAC87l9fNhcX0n01n52gXVoAw2fkF+XkcWL9KxlkgjFRrfIJVAKfCUNOifgtf9igxbUQhdftJMCh8K4epVExo1A85VDkUVkrOeYZGRHdBQWJpswHDJvzP9QuVZoegGpA4ZawAqmLcS0HhDL/H4l88U0ZMGm4qM9NohzzwV0jePTp7vzCvwXSISDKRFNaGObDRY+mfSj7r7bdoqrhUKMJ0PkJIsvkd7wKGftGpjl/A9Y/63AGjH7Cx8OVbUPYtc4iy0Hjo8kHMBQSSi9h+DR5Ioe5LWq85exTYZx0J9/dkRzs8mHFxb8G6rG4tFBQezIVE8lxg9fmF/5L2SuvqjvNtHGODwrccTq8hst4prrHgXXze96dsIhWx1zEBpQbN07fOcQW9+6mAq/G5NOsStPTQ9sBdDtIQaRm9xSeMak8GzwCg/pFIv85UOH3hgYsKrgl02UUFqF1RxEHQj741GMOuoPy6OGPn51GJmN+TBeT40DM9FSke0JFSP9+GScxAOJG1hpoNIu9P2p+TwAACH+mma6pFZbAi+VVqVHL6/pnqIrKK2Nbz5BIj5z7ZNvtFIAr0ewkTLiywoXZiRLIY0gQEUPRAVaXQ6XahKJtkDCiZchUwj6ES+ku86rGwlYQ2W5dH7RLkuRtO38jTOpLqsG97s8NMT3KkLrqVOe4c1Dt/WXxb1l5I/eBQy4gTcnSUJ09iaBQi8YveSLvAA+tkpLerhuZiHOxNgaF3iulVMiTzcldwQHNcTbxnH4iCbXiIgdCkzAdAke3R4+2YxB 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: 6gietZMWsw+PGzqTyf9837iy8wgehwLmkjzqpYPVOFvJO7YQt/TK3jfxO1OhWx8H4VBeRXwOA4hPZCK4x+sYtNd6lGZbo8QSW0K+/lkSLoz7hw0B0+rpBbSIXcg+jpitHfrCW4zfSFW86fB6fIC5DtZWL2tzxar3e4z1Z71c2dWRWYPmQ0Yhk+Gb3UVXcV3ZXYxLjvg/KlsxFEX2UnlkT5OEkDCf0chrfWXYs6C8fEpfuEUgrLzLs5V5pwy26/mZtstzxAzPEJPHdIwPLexmhSawABjlPctVrl82R76AFNgv0tRiYky4X6pLkIhNeyr+odrZExYKpVVkc25bLvrNq7ANx/ma/dM84HIJbUoEpZsG3cAWcGfzyHThm+qomZwuHtYS56Iri6HgSfPmPYdDEDfaAEOhY2P8ZjQimH9aMyEXBzaH8QLgLM+YIp+7F+mTYvgYgrZGig/wkcwePNz5TXf3N0G2MmDEUR9FsBKUaRZiUsJOdEi6S0pdGSsM3Jh+3HdtAx13EcVVBlRSWmNRKeN7A6hrQgxwO6BxOY2SWJiRUIpIUoeeCtFF5kbz4R+nTkP/rz193BPSVvpmV5q8XGbYl8gaeUBQQ+dXCifgpzuO9Fp81Eux4s6xb4kipzPJyN9oriqUk5olGe8pmbOahGLH067B6K7BCXpVo46riNPn1e/kgz1nqL1wwB/Ka/bHFizZghdaaliDI09hGTXD1dbez5FDeoQ4TCoXVYg3fN5muLCsqTPQ0UBGIFGwY6AeyHgJTwCi5n9aPPq729+bkrO4HinaNW+k2vtJXcD56y2GFYLR9iBO0S+3mm5Wn2aFVRYIn1mrVYFBf1CkVyaOAy/WFzJdHBm7sEWlgCN6BZAEfFWQAEwzzGGP83Ddbf42JviCx9Y8pVCsy2wGQZOIJ4Xz+99/zcZihO9P9SYejz5QdlkDtbRYKSJlwKJ1/LpP/BYfOzhCUQSv6x6pK38MgZdvHahi8fpge6KKQL9LSgcXSDH2BKC3pPJsNxP+5NV9qR9JbE55cuVCAAxOzSy+vQ/aZBQ5s871gVj7gAoTlQpY/naTxnQM5cU6eNpP162pcXunYwj/TsMAE4gHgB8jYyxzv1gTyiMMWbQo+Oo2LVwrM3LuwoPsJ2hkvRGkvKbPI3uL2zHkY0RMKnEwA8mociag9mpForjYz1xoeCECj+NC9wa2kLe75jBr3SNdy1EoN00jU6MzY6hdu1WKImlNFW9Wu1TkXpPA4dIDflc7GqIXaKjQxTaKf2Iew0Okw6KDZzHci2dUBgaARLQVBXaSa1O9rntF4uiN3h9TB0SS/QgDMbw3/q4Oa4YqPnNvIR4FMiWX4w/qvJ0nuDbtQdxt3piOdRcbE+6Ih/tmKjmJVnSqwqG3T8GAYdyk86voMmE5xe/NVmIdV4kRzugaaLUffQA4poP6Xkbz+F+ROsEq+w4N8br+vCkKjqCRVyGMpgG4AglDnNLEXwY3geFm2Bh7WFe67y6sOHetwfQM5K+45qNQyKfBl2tzp5GPF7rbFzvTJ3bS0iNMaHkfM+k3yPCu1MvDA/GsupG7UfXizbHVKPnUz7qwTEVVEcMAPhs+oICK X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48b96551-a508-4ad5-efd8-08dcc6b024a8 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:41.2450 (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: TdWwNA075Pvqu/TW5w/sVWolm5U13jua6Vzjimz5cWpwhu4pYEeuvpeg73AoHMsh X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 HW with CANWBS is always cache coherent and ignores PCI No Snoop requests as well. This meets the requirement for IOMMU_CAP_ENFORCE_CACHE_COHERENCY, so let's return it. Signed-off-by: Jason Gunthorpe Reviewed-by: Nicolin Chen Reviewed-by: Mostafa Saleh --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 35 +++++++++++++++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + 2 files changed, 36 insertions(+) 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 e2b97ad6d74b03..c2021e821e5cb6 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2253,6 +2253,9 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap) case IOMMU_CAP_CACHE_COHERENCY: /* Assume that a coherent TCU implies coherent TBUs */ return master->smmu->features & ARM_SMMU_FEAT_COHERENCY; + case IOMMU_CAP_ENFORCE_CACHE_COHERENCY: + return dev_iommu_fwspec_get(dev)->flags & + IOMMU_FWSPEC_PCI_RC_CANWBS; case IOMMU_CAP_NOEXEC: case IOMMU_CAP_DEFERRED_FLUSH: return true; @@ -2263,6 +2266,28 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap) } } +static bool arm_smmu_enforce_cache_coherency(struct iommu_domain *domain) +{ + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct arm_smmu_master_domain *master_domain; + unsigned long flags; + bool ret = false; + + spin_lock_irqsave(&smmu_domain->devices_lock, flags); + list_for_each_entry(master_domain, &smmu_domain->devices, + devices_elm) { + if (!(dev_iommu_fwspec_get(master_domain->master->dev)->flags & + IOMMU_FWSPEC_PCI_RC_CANWBS)) + goto out; + } + + smmu_domain->enforce_cache_coherency = true; + ret = true; +out: + spin_unlock_irqrestore(&smmu_domain->devices_lock, flags); + return ret; +} + struct arm_smmu_domain *arm_smmu_domain_alloc(void) { struct arm_smmu_domain *smmu_domain; @@ -2693,6 +2718,15 @@ static int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state, * one of them. */ spin_lock_irqsave(&smmu_domain->devices_lock, flags); + if (smmu_domain->enforce_cache_coherency && + !(dev_iommu_fwspec_get(master->dev)->flags & + IOMMU_FWSPEC_PCI_RC_CANWBS)) { + kfree(master_domain); + spin_unlock_irqrestore(&smmu_domain->devices_lock, + flags); + return -EINVAL; + } + if (state->ats_enabled) atomic_inc(&smmu_domain->nr_ats_masters); list_add(&master_domain->devices_elm, &smmu_domain->devices); @@ -3450,6 +3484,7 @@ static struct iommu_ops arm_smmu_ops = { .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = arm_smmu_attach_dev, + .enforce_cache_coherency = arm_smmu_enforce_cache_coherency, .set_dev_pasid = arm_smmu_s1_set_dev_pasid, .map_pages = arm_smmu_map_pages, .unmap_pages = arm_smmu_unmap_pages, diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 7e8d2f36faebf3..45882f65bfcad0 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -787,6 +787,7 @@ struct arm_smmu_domain { /* List of struct arm_smmu_master_domain */ struct list_head devices; spinlock_t devices_lock; + bool enforce_cache_coherency : 1; struct mmu_notifier mmu_notifier; }; From patchwork Tue Aug 27 15:51:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779742 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 B0AC71C57B1; Tue, 27 Aug 2024 15:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773914; cv=fail; b=App0vTthBQTg9+TdALszaC3uowTRS6XxbU/Mcaoy69q3uWiUl5sn4Kju3wu/G0mO3WSqucZsVmBMf1C6lAfRmXdoHIbJiiekQZVurMLiR+VnThnG/cRbemvhaJy//+ZUriYJStodlyBDkw9imWZGN0jV+NjELNcsPy3IILQ+cB8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773914; c=relaxed/simple; bh=Ri2/NMwnwWi8WDwuf12GXet2Hrc6eubq6GGWo6CYZlM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=GeXRPutnj1ZNQTO4Bs9ur75HffSQ1i/FjYtadPjccRnHPwfqX+K4Zddc39idcl+Iy7HU1M3Y0BiHxIxqWZcgXFhmmQ9tvk8/TbUs+DQdBeru5pqwVOqnuuToQeEL7WKBEzBuOrasaZQOLd9zkmva299TNzmbjZJH45rb8zwkFpY= 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=mesdruqH; arc=fail smtp.client-ip=40.107.93.48 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="mesdruqH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MregP5V+7P1wm2903JaROGy8dXHOX2oY1nsYi7A60byiF/5+f2+WMyYyGrCnIlTGNGdQ9tJfhQCb9rAYkem1P6ryLC19rI0W88gWrQ6Vtjevj/J7Ns8WXQmBpr5BeW2FHUSbzY2NkE8FgT4BLgSQattXdEbDaKpYZdkXYeJ2AJS7Lg124J7+8ZOWw4ATr0ERAO48ammofb1jZrl4UIgGCQfVIFbJJbhK6atUPR3Yw3TnJAnjznuMYTl8U+e4Re0w75pwZlT+JZOHeUm5iKoi+CLxuDnKA6ueRBUy9wUy31gncotP0Dr6qOrbHs5PhzxW9lvYj1ohMj1jQ0FWzPOnXw== 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=RrTvQUvj2jJ9+pTQwnr/tbUoQjdFTfD+BV6H43CS0+M=; b=bI627sIRY68DCyDgsgvhUEb4S3q7m80opGE4EPGdgHMO32dtGy831+kikwY5BAKXBPPz7JNoElSg+9zX0p/PnIMU2PayKLXvv/V459WzVNJCqwyWJu8nFucaHn+Eiv5tazJwF6nbqUkFMvdS1hYKLed/TSouOqJ34wLqG+6+784jWifxR3SjbDcuF8Cq032XUhh9xcKhO4uzI6bajA1z2GWWecSQVsRVblz725XwFG/LmA4kXb6fmvOu3HqGcLNYdEGJafI5vviKWugcu8Ax8hV+PzOdQMpWnch3bcbspfKHBgDIjleqZl754PQ/AeLLAkz6DMTyTBnWK47tZIFgvg== 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=RrTvQUvj2jJ9+pTQwnr/tbUoQjdFTfD+BV6H43CS0+M=; b=mesdruqHppZNB2t6y5qi/iM34H23aVigcX7UAmbQk6jSyU1VqVbtqnl4m+3/cGNpYP9Roe3tCenJ5gkeCcCkoNG8MPm5fSMwf6g1eNtBB7iKtspdUbU8rVzBbibQb5XFyDfyoSD6Ky5IZuh2niU78J2Bs+maJO5nRjLEPWIbDD2dH3BTPg+e2PgAugHL2b49skS7eaR5ZGSeF8jJICxSmZuWcDmuCZib7a2hqcA+LZnT+eGpSWoMy5DPZId1oxw+7OEbfmOhtv33i7qY23yXROgFIzafSq35YD/bpsoCJk7KtwAT6KDU8DtBlJlL4XtyMdYxIO2HlHODvWAwdJYR4g== 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:42 +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:42 +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 6/8] iommu/arm-smmu-v3: Support IOMMU_GET_HW_INFO via struct arm_smmu_hw_info Date: Tue, 27 Aug 2024 12:51:36 -0300 Message-ID: <6-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9PR03CA0890.namprd03.prod.outlook.com (2603:10b6:408:13c::25) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: f41d5432-d9bd-4fc3-7358-08dcc6b023e9 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: oYkFcClMbDjIDSyS7d60yFTrgzW8w/PEIqUcNIp4jX4Eiv0myRFp/Gf2H91Fqj/yMtsRWfUEQPh+wv47a3BzJsYq7kbiC+3uRM2HYqT1+JfwP6XWoJM/EW3DuNHlE9JDBi+Jx8QXL/SKRq+hvpHeJyq0WvVF01Wk4IIThGoxTvcxxW7bmE5VM1RYzvwAGAizsliD1XLXzdjrZIaRCFrds+3R+3t9aPwU4SiKP4PdywVYRs4YY2TvyrZ5Jea3Qhc8eXWsFVJ8DdMGcZCksacJtyFVp0rAD28AiGEiafBduea8UJn+/jr4RfhlJ7cvwPwgU7cXiFC77tDbCdE57KOYxpq+7v1gbL09pjLZxI5+XtC/BVOPbADh/+NCGIWtaQv7v2wMOCVxuDcyprAxlu++NxRwhB8jIPfmnIRilSVyxE/GKdXjAxfT020opXE5tfls2Sh16XVQ8Lr/eNK/CUhnIA2GGlLRk6fIgCZVeAFPd1iGnXVWeUDwzxl5Bfwjsh4pHCJkoyX0Wdl0KflqD2Hy5u+ghkpYroYNhx/uVABJTSLiV6l2YBmaXWDc51SZdfAI5X7qgkcjQFndhPM/myzdrP1iXSancdDTtzww5voZfH/S9Y1JQYBsrstqrqv+z9O8UFVtNoEPttF24/RmlFHdIuCSAVeWor1HqYeBJL3ZHiiKi/20mFGN0LLP0Bw18L6YF4KcHfAWL+fUsU1g7u0p90VX2vS526f59GXbYcLLRgVE05/qUNiR8ibkRbigAm1X4el7XN22CvPPixNVjz7u4vm2yZfimaF+/O9dcIWMeGuAu/VtzugnfsEZE9PeYBq6VqFtfhJT/hwuusnyWy9lP2x7GHHeIMldj55dMDHuyS5K4AkhaMI/TyM3aD/ZG8RVlT4h7gLcKMpVb6aSv1wZ8C//Xt1Oa8CZn6kb4jfN3fpOCvR2D3NELs6x0yY2Jw+2NoYXERddceumPrmWsyV4+Ra+dWHMgxmP4fQ9zTSgRdvNyvCxBmNO7JbM+Zl9GhC3J2aE+kcRt3Ccq7aQSMErAyUks6ihk682Upyu86OrwH8s25NCAntqJ+kcE5oKIwFTLZXXZ3kEJZ4QtJdOlA4FUXsA1QsjRX6atTUPfrYgL34daI6UiNNBiulecHdQqy7c9hU5gOO9pSt/LU7qadsQIyQqL1gvSHj7k6FoCLuqnck/7avZnyNdePnElNcrsL8ah9H4GWvnu6Ler3h63LVxeJZ6KuooUT3qq59cajWsnahf2wNqMdBXNxI6e7xe+NFYSS4EyzgHi4b6mMyw9+5DSUTDhBttyVb/2lO1m8BUikbukjbOI18vz7kSFFqWdQFCWJM03gAyiQiBZ1nTVKIRZwbmIfrL+EII5/StMdnf2849TOxr5bPBHc/97m3malLZ 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: zEpyRSkcjbNh6ChUQSKNbIjxxh5Pa17S6su2R6yRH389LYabefNqKwO+Hxf96jfKx+AaAlCSDogOnKDl76Lf3Ni5rhJmpcwy4FSPBmq4iX021KOdypLBsklmGEOBl+IOrrernr3rHEivwjhFS8HA3c7noE835NbN/9yadcYpxW4lIFLzJKnibjwUhnx4dwPIlvuQc5v0AGHsbUTcDGHqWpEebdLSmBqMyWEb+wqwPepMX3c6O6zlH3eReKnm889Vqd6JyfbsBgDAkXNqSyXhh3k2DpW9X7+LWX7KQJbftlPf8UcHTeBUHFmlOT8IUKosH2i5D0xC74JTc6Nq+lYYwsjueWOM4xAk9bcBvj9Pc2InFvWFeHI3nrc6de0PzgcbbYQZBfOf8m21ukxZudxdxQFA9QOcUS84QiG2hPVDpnR3LH5HVSb3l9jlBFfs3cVjRnFXh3TmNj3BCxuUm86UANnOmWVDzhVMlWCvdsN3plsNz0KG6c1r5+KuYUcoWFkTEYzNotP0lZ9G5DTPRil+C8CHxu6dWjl3XIquFNylyE/Axo5v63rmZpFHLjnnaKaQcmPUhWfkbUSbkiMwtRnb7wMIhcIP8feZRkpE8GByhTiDr56UnHGVboYrjh6RKsLQ6KHx3Pi2kgiVkROqjmQC/veIXW7CjIxZ2xSLKqyEkeEpP6O5m91QSjcVwWo4pPlMk5Eyc/LxzMMerGiWecV9R29s+EfroCsYqzjz9IYcNd0g+c9buFaQJ3cn6jVwY2Mfn3zyeJLaCUYfzRHmdqoFGwLSGnwHOhcFVhO2ofADStV1CSUh6a1yGZruIeRxL6LsUcamQbxZtDQdjf5oB15fKFvluPIHWoDefX9ZIx8sokC8IecVkHviu0h0URKaW0kIdXpBA89C8PxrYUaRZblwsaB0QeEjGH9X5oMAWZ+JS9vxAgFfw8GUp0tHERCKKf3PTs25WT9DG+5oYA/zHK38UzRTOVdBYUvl/1I+njtU+b10KkE1YFRU6odt7dHl5U5Sa195SThjh3k2+6Pv1nfO70J0W3Ffmh95wOEKnTPh8hHCgiEhm7+Px/HPZixOSkoY09h5k4dWLO6pkdwd4uDp11lHzomvoqSp7xNiolH98vPqHpDYXCc4HnryX2v/735+melfeDX8DCmm9SRhW4w4vH3Kp3QPa6EF6Cmvx0ZWwvjIad8kVJy6rAra8Quvrpwuydl8RXooK7n6fj1Kn8dDqY8CppLtiom7mHQmlTAu+HNJ1UZBEvjyQiFMIj3LipUiRu4kpAlRiph0lX8SqWqkatNY0gvL4D6l1Y8X2j9GehcbcKAzAVDsWLsvMbVQGfO4lj1890gMGQriMlu5jCWwDmYiQN/3EHXSpflRWgIYnOVBSipawfEdFfs7UwKSmvdFWS1NSFRgY82qAnQ0xaQzAJcKQ3owhthdOlARxvsE/cUXBXQhcjaVeZrrptvTmcSwqz6n+ntob6ghjwwAE4L6msRHtc+7KHgl0nazi94qwxKgLvJW0fBJfpXCNGqVBjGcUiBfFMB07r/jlF/VOHuwO+kZgKDnEH+NpN0O0XwK4aKQdbraWSSiIXnmU9Anfa6q X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f41d5432-d9bd-4fc3-7358-08dcc6b023e9 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:40.0192 (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: cO854w2fC3F2tr6aiEhUsv+BN16j39kYiGXerTx4YLVg6sjyWZqvr0buenBtLBFz X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 From: Nicolin Chen For virtualization cases the IDR/IIDR/AIDR values of the actual SMMU instance need to be available to the VMM so it can construct an appropriate vSMMUv3 that reflects the correct HW capabilities. For userspace page tables these values are required to constrain the valid values within the CD table and the IOPTEs. The kernel does not sanitize these values. If building a VMM then userspace is required to only forward bits into a VM that it knows it can implement. Some bits will also require a VMM to detect if appropriate kernel support is available such as for ATS and BTM. Signed-off-by: Nicolin Chen Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 ++++++++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 ++ include/uapi/linux/iommufd.h | 35 +++++++++++++++++++++ 3 files changed, 61 insertions(+) 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 c2021e821e5cb6..ec2fcdd4523a26 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2288,6 +2288,29 @@ static bool arm_smmu_enforce_cache_coherency(struct iommu_domain *domain) return ret; } +static void *arm_smmu_hw_info(struct device *dev, u32 *length, u32 *type) +{ + struct arm_smmu_master *master = dev_iommu_priv_get(dev); + struct iommu_hw_info_arm_smmuv3 *info; + u32 __iomem *base_idr; + unsigned int i; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return ERR_PTR(-ENOMEM); + + base_idr = master->smmu->base + ARM_SMMU_IDR0; + for (i = 0; i <= 5; i++) + info->idr[i] = readl_relaxed(base_idr + i); + info->iidr = readl_relaxed(master->smmu->base + ARM_SMMU_IIDR); + info->aidr = readl_relaxed(master->smmu->base + ARM_SMMU_AIDR); + + *length = sizeof(*info); + *type = IOMMU_HW_INFO_TYPE_ARM_SMMUV3; + + return info; +} + struct arm_smmu_domain *arm_smmu_domain_alloc(void) { struct arm_smmu_domain *smmu_domain; @@ -3467,6 +3490,7 @@ static struct iommu_ops arm_smmu_ops = { .identity_domain = &arm_smmu_identity_domain, .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable, + .hw_info = arm_smmu_hw_info, .domain_alloc_paging = arm_smmu_domain_alloc_paging, .domain_alloc_sva = arm_smmu_sva_domain_alloc, .domain_alloc_user = arm_smmu_domain_alloc_user, diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 45882f65bfcad0..4b05c81b181a82 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -80,6 +80,8 @@ #define IIDR_REVISION GENMASK(15, 12) #define IIDR_IMPLEMENTER GENMASK(11, 0) +#define ARM_SMMU_AIDR 0x1C + #define ARM_SMMU_CR0 0x20 #define CR0_ATSCHK (1 << 4) #define CR0_CMDQEN (1 << 3) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 4dde745cfb7e29..83b6e1cd338d8f 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -484,15 +484,50 @@ struct iommu_hw_info_vtd { __aligned_u64 ecap_reg; }; +/** + * struct iommu_hw_info_arm_smmuv3 - ARM SMMUv3 hardware information + * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3) + * + * @flags: Must be set to 0 + * @__reserved: Must be 0 + * @idr: Implemented features for ARM SMMU Non-secure programming interface + * @iidr: Information about the implementation and implementer of ARM SMMU, + * and architecture version supported + * @aidr: ARM SMMU architecture version + * + * For the details of @idr, @iidr and @aidr, please refer to the chapters + * from 6.3.1 to 6.3.6 in the SMMUv3 Spec. + * + * User space should read the underlying ARM SMMUv3 hardware information for + * the list of supported features. + * + * Note that these values reflect the raw HW capability, without any insight if + * any required kernel driver support is present. Bits may be set indicating the + * HW has functionality that is lacking kernel software support, such as BTM. If + * a VMM is using this information to construct emulated copies of these + * registers it should only forward bits that it knows it can support. + * + * In future, presence of required kernel support will be indicated in flags. + */ +struct iommu_hw_info_arm_smmuv3 { + __u32 flags; + __u32 __reserved; + __u32 idr[6]; + __u32 iidr; + __u32 aidr; +}; + /** * enum iommu_hw_info_type - IOMMU Hardware Info Types * @IOMMU_HW_INFO_TYPE_NONE: Used by the drivers that do not report hardware * info * @IOMMU_HW_INFO_TYPE_INTEL_VTD: Intel VT-d iommu info type + * @IOMMU_HW_INFO_TYPE_ARM_SMMUV3: ARM SMMUv3 iommu info type */ enum iommu_hw_info_type { IOMMU_HW_INFO_TYPE_NONE = 0, IOMMU_HW_INFO_TYPE_INTEL_VTD = 1, + IOMMU_HW_INFO_TYPE_ARM_SMMUV3 = 2, }; /** 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: 13779740 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2048.outbound.protection.outlook.com [40.107.93.48]) (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 1EF1F1C93B9; Tue, 27 Aug 2024 15:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773910; cv=fail; b=Knil/LGbEMYIaRqSROAfRksWT14OMxcEH323t5CtV/cncQlIfKrLOZJER3x3RzTcLsBaC88mCRUcYNneoWZgBvOR3KrL8EuCQDZK4rhkfn7vbdbezQPB6fPHhnO+xqowZrieNTP8NGg8ZkymkIzVFZzzZ2lFbTSSPZN7GRY8ovs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773910; c=relaxed/simple; bh=s81VWsIQUGInizR8x5zdjFTg3gs7mmvs5w60jynCcL8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gbQp3CoKkirmfts+qQ1APrN7KGCNmFn/IK14YisC9svBg33B/ASMrtSXQ7bPhz2vVqptZJDsRsgQKOGS8ceJXJF2TIJgVcNO3ZG8bbEpbKgoO4B08OAouChR9QcudMzltb7uxHTeE6DZETGXuNbCNDCjOxJ/O0Jfn/O9Z8VZyzY= 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=XyzU+9an; arc=fail smtp.client-ip=40.107.93.48 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="XyzU+9an" 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) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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+VJI3Elkq49K7GEGgiQB336kyV9XL8jB7z6hHqezXzi3DVTusK7WZAV/Urhq7r5WSMoABl4HHvX9Vh96NWOWPa4chXYrC4Fp68ySy53W4kJjR03Wxd9rOXRzIU6t2mh0Txv+3OlRteZzALJoe0y9Ot0ryucGSYikAuMURho7on9toeODx5iiCGMhHND65emOyJmLcMUgzDdIMcs5yk5jfiqjwPt3K9CG52rUlOtRlWG3jpUAaz7AmYORt1c6ymXF69AtsA2k93r5Ckf6jIH4upsL5ue160IPsM3r4e/vjJ8Q476KHjUDNdd/AbgAGnAgh1X6cJWH3hWWXEBesOpyoPJOKHjDaxRDyek2XTxKsZe+ZCgOW3z0D2t3ImYrY4Ub0e/3XLH8XcFZZnbeAscRKjGrqmT6DII+IiLT5+V08/PNk+NBFDQ8CrdNXEu53Cl/rLXrAaxtZx2KAE31+HtG9tCXUrP7pu8s6Udoja+oaDo/0SZZCIcKk9as2z8Fmo3gEcXpRUKG9NsZ+sz/A0jYYmUvuhEdkpaGG3onvglPBRock5UXjcBzHMhWGZxJYul8w0USygjrk7ZAKio3UQqi1+r30h62zrM1QNNqKHXxXFxR58eVshu4RPI9xvQtAeqSPLUWE0WsTHTzTqhjFie+gNO4iVLhmPTNkCL2+T/sg6KA66n8OMs0wKxMCvt+jmG+RVwXcsAiU+EVe0WHLT7TzFBRGYdPkbRvhELb0nP/D77R9eIWjzBReaCAemdxQOywfKqdOD0K/acUEiJ/UtMxGBOnu0107ynMyNiEYCGVuVHYUvJRTb8Gofu3XN9GGS87YH9SO8aYA8s6uKhXBMNPObXltFwp+6zJ9Tlg6BjFMId8YbxLk293jFC6UCCsLCqOOqmIOGKOLNeqyLkNm1dR5sjeIst1F31WEgyBk+RAgU/hMi7U3MuGX8EtpZsV2iPXboJfBWwcu8q42WGwaANzoV+fc4+u1ewBf1zxHiB3Qqdib7T8ZIwxTGPZJgMqIeKL/6naO/2hmW1WekWnVWWt5ziTOGfuUdzcYLOhW14UyIPNE2vxLJwe7Ts8ar/8ID6NTtQ+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 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); From patchwork Tue Aug 27 15:51:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13779743 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) (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 A94131CCB48; Tue, 27 Aug 2024 15:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773915; cv=fail; b=BY8ys5rTOvBs4C2ElXTszdiA5LwZsvkgxMjGByBn0eLgwVGYe7LR0BvwiCUD7U4ThoyxB8DD3CN/hDh9o5nkPNuJuWIkhkDNnolV4QnNho1kNl6WHQgLjAF370bGVSzSD/mkErAaebpgqC4lO0EAEoSp+O36IVwiyTjVFjONpQU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724773915; c=relaxed/simple; bh=PgqlLHVNEHVJK8FgPcXuidLO0Gu34Zm0662Ty00a7gU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Xwq0sliIn2Gq947O/XD9Jo0j8qyVs3kFeMZviHo+Zybx82Xkp6iIrpNGjhfGT4Ot/xF4X5OB0bo3Mm3PfhMLy0FPT/nzXW+3epzFx4R6ivcYzE9x5z96UjLT3sMG7+uGci+gh7a8JEZhy/2onvXnfB4nBKQ/g35H7ZsW8rMw3PA= 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=krpv20TY; arc=fail smtp.client-ip=40.107.92.50 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="krpv20TY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BdN8AtcsDRm9X05APSN6UMkFwaZNQ4CfEhxjfHrEfKABIA8P7biHHHkWUCm4Jv1lHD+z+c/WmzqF0ACckOhtTcrgHduYmjJS6E/+ez1AGr4mO1GzUi+9sy9TpINzj5I309fNLiQKHqlR8+xN5ABA30MLiulhBo/s2NO6OCMbgtb1qn60THW8ZdqqAu7QlNfZuYBViGJBvc4bCrXsKHdjSUmrper691R6MnKY5+gfidkwA4EFcwacxiectSDeR3VVgboXawwGTcHASvOxXeOloFWNT8Ji7HGWRN5U1t7NXv4Ggif25phc+a7DlubDhdHx96oL0+yw26Fnqlu2Hl0Xyw== 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=YlZdWUBCkn77WOndyIWSIfL6m4lunTUBOtnLJ7cERdE=; b=lFacRkAnCzVQoZa+AaF0lr91hHMnIo+ZxID07m1HORr/pEjXPec3vsr14bNWAeT97MiIzegudyBS6CjjO41tXIbDq29XQN5hfvvWNb3G13+qvPeC7bCyMgrBkeJfsIj2lH4FOYBqL7LaqatNHgfEyadk0y6nPUxWJa9LSDvTCzojZyoe0tY1Zl3tu08n3y49cK2Je5IdfQyVPIuyo4/ftHR7SGxJcxNI+LDVQfPjyHSc4ERzqUviep9ZCXtLEZZMOvEIISIIjPrUjunOZzLYS/1enx1IIFSienWXLAIb/INtNxlB2a4ARuGJlfz3EHTsRPGRGqMbDGhx7qTfERJ7fQ== 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=YlZdWUBCkn77WOndyIWSIfL6m4lunTUBOtnLJ7cERdE=; b=krpv20TY9YMXZFY6Xn+2WGG6DBsB8YcXEYu20fcRFg5MkQHH5r6QGQ5PfH6BRL+T604wm85y+wRAtQXCXHiELr2r5JscWPrv2NPcAH3xdP7SIWmIyYxjKr9XMu8pok7Fn2u8f53F3p2k45BReaeSBztsgRK7MdJ4fuFwXS32yXQkXWXHXF8mk/qqZPDNkuV5q99UWDhLSx8yicncyFvylAcMB5Bauw1iDdLaTLN57wH+JCz8dq6p/ZzStdMZbIsY2N5yFvpM+LohAkBmUmeqnNXos+T959iZVEy7Gn0zAuIEJz55+Mes42MxHUNjf+Pm1Abkdilh1unyFpezCLXlWw== 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:42 +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:42 +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 8/8] iommu/arm-smmu-v3: Support IOMMU_DOMAIN_NESTED Date: Tue, 27 Aug 2024 12:51:38 -0300 Message-ID: <8-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> In-Reply-To: <0-v2-621370057090+91fec-smmuv3_nesting_jgg@nvidia.com> References: X-ClientProxiedBy: BN9P220CA0030.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::35) To CH3PR12MB7763.namprd12.prod.outlook.com (2603:10b6:610:145::10) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB7763:EE_|SN7PR12MB6790:EE_ X-MS-Office365-Filtering-Correlation-Id: d0c8b1d6-025c-4c95-a653-08dcc6b023e9 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: 6rVAzpnN/pQb2SymQqgPrF457P9vQCquKzLF+/gR95OX3qoKER0pcblKH00XLF5oDATPwjyu27YmyQDiqVKoK+2DesQ2N8QIu5tqFbVyqPrv7YYPyNxz+9JZxpGXF4bHJckBrzAAzU/nsE6RgKvYyUkIL/nYkdjUTdk85RbGBp7q0Se4LG2jpLxgDAmKBW6kvYGulPU8jPjN1n09KlOxMAqkAc12zfxSb5MOO9ld3WccjIQeO06hriVRcBb99FszXWZ8f0Ygp/xNl5oIgYuIWXfWSUy1Wa9wbNeDB/SnoerKD9ffARQvm8H5oKOsnp+3Jrzcgxya7OAyddb55DW4o0AuaGM4RdXFzEHhSAZwcpeToEfYTBcPEwfvY2fBH6TyusDlybUIMLpZcJ7RWLGr3j7wV5z4Wuw+2rr+dy88dSVW+eFy8zIKcekYrx3q9PhTqoq4kXxVkTxvqlsrPpeVxBNkiul66rWmruYDewkAGwIpNw+KAKOYUsm/NmUdL1wlV+bspAiCDEEbw5oXaeRGnZ0isr4n9C+medxzQlsScf2lUgWmdPcWBRrdzWmFSSP9v/05ZmLljTOVzfXDm0u8Zzk8ZCB0A41gBDL9kDfEzSFwkk87joXZNqw78xSiUoop3ltpofBsnmfrDRXCX6Wi1tJ+jmSbM8uzChQSM5c0Ug2SeUr7Lg1PwRnUQgQ+2kTMACcrYeQ6BVhcXryTyiz00+lZXTI8rI06nWsZm8e5wTNytDRP6uNtqwB4navBVJtJdUIbuKA2jSIGo/LcSTX8+w1tzxHLbTe20AcB/Kd049eXmd0y1KuWPq/ZXQBHBDCNV6RXHAwbpDpLPi0uXorAXDm70f7x+7adlrFudQ66pmxYfGbdI2L5AsEj5r1ZJh5HcST6VUm8O22LPV9MQb+DOeB46AC6jflir5sygVgqS6b2Rj40PwRmRbYtWC/wNFtS1KZLbb2viEeYUBfisL/h18AwnPwQeRT0Fq+Jb/Qkr4eOkEdXhLGCUvGi9QFYxMhu8x37026EWtYLYVnmFQ+v4vwZ0YujuJGlQrA5iV/yfZ0sWAovbeVyspPjeBG8ci+xUVE6mQSum1GM/fGQYGMuzv4KTJsFgbxjCy+34LJkGHd9Mld0JKL5MJlHTj/ZLaJ6bnF7LwzrWYoowoI5CYgwD4SiSprThhBIWu4gXY/nNrZXYeukuXdgLRVQ3iUsl1tdpTWArNfbyy5viCOMfDOeOL8evN6LVDPPidOJVi0483x6k9D9OQf8OWum90E8fAkU/MzRjyMCrkEI4Yen6tMULbnTgyxQjziA2TPCmTo6+tOzqEYZYQFDtYrdyngjkQBixCcjCze8WitM19+PSO+H4Qwm6E1UUZVYt0/BF+1pMu7GWEKExF4PNHmFl6tUlTr/ 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: ylBqYfAEv4lDm5op0wGAAJIhZ2Ml2QMzr5v6GVKniJrQ3qxaylihfQggzJucbw490u4kpeHijYGbbpa4YYJMdionsBFU8xIuNs5ZSao7sN25wScueOIPXyRKBERGqzCHtqLKangbUN5NZXVFMzghMooI7UTp/I6WO4YQR+k7d3ZBZhcikFGcdiNkfdkFEpZ/hnkwDQ2NA4/BIdzilmt3RcVGhNkCXCT1G6YbijgO9M6AtUh8V303I3Qvw61Oo/C7oTq18Ir+7F9bxr/FJ/jR66dXrPkVf4bTxCChwL/NoSWrJhu6gfmAvHQwdZ3CBtbcr/GmM6s2AGBOHhh8VsXShzwfP71+JaLgQFQlLi9ndYdTwdA6pVEGcADk5RWBReWmWuhSpknk9OtS6uYklwxLuNJbd6CU46B7LCvs6wZ1txrCmjTEzU+wV3kYkLpgsiUjosxsSYrQfiarVgES2pH9x/V8L5oyg7uAvQWJcNnHlxngp7cA0hOA36mnxRDNFg6zDHNkEIrfwB+LUWzfH2kxsBRPIx37k1GALZ6CfsebpdBd2zPHGLaGspiA2icH1gzxPak+nx0M2QeKvYCMTBuodi52FGGPgj9qbxXg6POFTybKmifceixzilVGbYerF25yWcutAsvbtBuTMtqJHXKgw8L0mRUnvWgpTbOZdC8sVec0LKqduKlaw7jBz4YJSjoxTQP3pl+tCgMoSZtmWuOURwMiEMfs7Xii5ltbfQvbXFuNw6zFnaETDHQE2JHEy2lYV0pp609Ox3frjPk25tc02Sh9C1PD9o5Et5igNRI4cctm6gsKwRTv5veqZQPNAoFdNe15yffuJ/iYADNAgiJMsgoiBXIz9VncoNcMdWzw1pgheLHmCIT3ZKoFwo4J25+FeUQktVku8ZSIEepKowoFbfU/1s7sAT9Fuas8A4CfYSv+PO1tBhLbD/b5ThUkw6xw9fSJAJSUPyaeydP6WnGHITjLhLddmlF5kqY6QjHBMa75n5cu8b01qqF6VjwTP8pNngOblkYItrC3U6815D/C5wWqijCGYMkzLlwWZZqGdP86KvUkqKZRC6oCrkC51pfnWpbeNKXp8xE29WMy08NCYFbOm/qFm5e24pa0v48pW+7tNSSjm7qtk6fSvRqjm+J3fdEsgilmcWMGQzGb8eDFX5AafUe6/vXJ8OuELp1KvrHVU0uTMaUdF7uKhlr/MvpoMh8A6Fk5CnNM9/xv7iGa3WYXc61yctN4db4FQsTfsAg38W5RUtFXvdG3zbZxMjyLjC9IhpgBMlVLt3I7j/NGt1zPcg+QCu1uKXbl6m6ZwOsxyt2ejZF0Viri28GoEFLCAp+uT5qOLPvO/090kmo1m9lNKtSLUcYy4Pp4ED5KEuRThqNtv93bwc8CnA5SMwZONssRAcOi9xZvndMyeeM54jeZyaMUhAHcWVybCH6Br4V250PdknVop8Yg0Dp1fLm9nfBupPX6LiZzRA89SH3ksrmqmVJ42W2y2mBIhxMoQtSkbyYJ+VTd4ouf4PmeeepIFgTc2WHxC2gFVxr4+jASW0DBLOf+HLS4mDQKHpsQXa8z1l435FjX+dRLAiyNgXW6 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0c8b1d6-025c-4c95-a653-08dcc6b023e9 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:40.2017 (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: 9x3ObFE5O/tpS9vmmiX+N9Ln2QcIb4YkP2QK36Qvlj0Cbt3MiaqaYquwUjXw+Yu5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6790 For SMMUv3 a IOMMU_DOMAIN_NESTED is composed of a S2 iommu_domain acting as the parent and a user provided STE fragment that defines the CD table and related data with addresses translated by the S2 iommu_domain. The kernel only permits userspace to control certain allowed bits of the STE that are safe for user/guest control. IOTLB maintenance is a bit subtle here, the S1 implicitly includes the S2 translation, but there is no way of knowing which S1 entries refer to a range of S2. For the IOTLB we follow ARM's guidance and issue a CMDQ_OP_TLBI_NH_ALL to flush all ASIDs from the VMID after flushing the S2 on any change to the S2. Similarly we have to flush the entire ATC if the S2 is changed. Signed-off-by: Jason Gunthorpe Reviewed-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 217 +++++++++++++++++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 20 ++ include/uapi/linux/iommufd.h | 20 ++ 3 files changed, 250 insertions(+), 7 deletions(-) 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 8db3db6328f8b7..a21dce1f25cb95 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -295,6 +295,7 @@ static int arm_smmu_cmdq_build_cmd(u64 *cmd, struct arm_smmu_cmdq_ent *ent) case CMDQ_OP_TLBI_NH_ASID: cmd[0] |= FIELD_PREP(CMDQ_TLBI_0_ASID, ent->tlbi.asid); fallthrough; + case CMDQ_OP_TLBI_NH_ALL: case CMDQ_OP_TLBI_S12_VMALL: cmd[0] |= FIELD_PREP(CMDQ_TLBI_0_VMID, ent->tlbi.vmid); break; @@ -1640,6 +1641,59 @@ void arm_smmu_make_s2_domain_ste(struct arm_smmu_ste *target, } EXPORT_SYMBOL_IF_KUNIT(arm_smmu_make_s2_domain_ste); +static void arm_smmu_make_nested_cd_table_ste( + struct arm_smmu_ste *target, struct arm_smmu_master *master, + struct arm_smmu_nested_domain *nested_domain, bool ats_enabled) +{ + arm_smmu_make_s2_domain_ste(target, master, nested_domain->s2_parent, + ats_enabled); + + target->data[0] = cpu_to_le64(STRTAB_STE_0_V | + FIELD_PREP(STRTAB_STE_0_CFG, + STRTAB_STE_0_CFG_NESTED)) | + (nested_domain->ste[0] & ~STRTAB_STE_0_CFG); + target->data[1] |= nested_domain->ste[1]; +} + +/* + * Create a physical STE from the virtual STE that userspace provided when it + * created the nested domain. Using the vSTE userspace can request: + * - Non-valid STE + * - Abort STE + * - Bypass STE (install the S2, no CD table) + * - CD table STE (install the S2 and the userspace CD table) + */ +static void arm_smmu_make_nested_domain_ste( + struct arm_smmu_ste *target, struct arm_smmu_master *master, + struct arm_smmu_nested_domain *nested_domain, bool ats_enabled) +{ + /* + * Userspace can request a non-valid STE through the nesting interface. + * We relay that into an abort physical STE with the intention that + * C_BAD_STE for this SID can be generated to userspace. + */ + if (!(nested_domain->ste[0] & cpu_to_le64(STRTAB_STE_0_V))) { + arm_smmu_make_abort_ste(target); + return; + } + + switch (FIELD_GET(STRTAB_STE_0_CFG, + le64_to_cpu(nested_domain->ste[0]))) { + case STRTAB_STE_0_CFG_S1_TRANS: + arm_smmu_make_nested_cd_table_ste(target, master, nested_domain, + ats_enabled); + break; + case STRTAB_STE_0_CFG_BYPASS: + arm_smmu_make_s2_domain_ste( + target, master, nested_domain->s2_parent, ats_enabled); + break; + case STRTAB_STE_0_CFG_ABORT: + default: + arm_smmu_make_abort_ste(target); + break; + } +} + /* * This can safely directly manipulate the STE memory without a sync sequence * because the STE table has not been installed in the SMMU yet. @@ -2065,7 +2119,16 @@ int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, if (!master->ats_enabled) continue; - arm_smmu_atc_inv_to_cmd(master_domain->ssid, iova, size, &cmd); + if (master_domain->nest_parent) { + /* + * If a S2 used as a nesting parent is changed we have + * no option but to completely flush the ATC. + */ + arm_smmu_atc_inv_to_cmd(IOMMU_NO_PASID, 0, 0, &cmd); + } else { + arm_smmu_atc_inv_to_cmd(master_domain->ssid, iova, size, + &cmd); + } for (i = 0; i < master->num_streams; i++) { cmd.atc.sid = master->streams[i].id; @@ -2192,6 +2255,16 @@ static void arm_smmu_tlb_inv_range_domain(unsigned long iova, size_t size, } __arm_smmu_tlb_inv_range(&cmd, iova, size, granule, smmu_domain); + if (smmu_domain->stage == ARM_SMMU_DOMAIN_S2 && + smmu_domain->nest_parent) { + /* + * When the S2 domain changes all the nested S1 ASIDs have to be + * flushed too. + */ + cmd.opcode = CMDQ_OP_TLBI_NH_ALL; + arm_smmu_cmdq_issue_cmd_with_sync(smmu_domain->smmu, &cmd); + } + /* * Unfortunately, this can't be leaf-only since we may have * zapped an entire table. @@ -2604,8 +2677,8 @@ static void arm_smmu_disable_pasid(struct arm_smmu_master *master) static struct arm_smmu_master_domain * arm_smmu_find_master_domain(struct arm_smmu_domain *smmu_domain, - struct arm_smmu_master *master, - ioasid_t ssid) + struct arm_smmu_master *master, ioasid_t ssid, + bool nest_parent) { struct arm_smmu_master_domain *master_domain; @@ -2614,7 +2687,8 @@ arm_smmu_find_master_domain(struct arm_smmu_domain *smmu_domain, list_for_each_entry(master_domain, &smmu_domain->devices, devices_elm) { if (master_domain->master == master && - master_domain->ssid == ssid) + master_domain->ssid == ssid && + master_domain->nest_parent == nest_parent) return master_domain; } return NULL; @@ -2634,6 +2708,9 @@ to_smmu_domain_devices(struct iommu_domain *domain) if ((domain->type & __IOMMU_DOMAIN_PAGING) || domain->type == IOMMU_DOMAIN_SVA) return to_smmu_domain(domain); + if (domain->type == IOMMU_DOMAIN_NESTED) + return container_of(domain, struct arm_smmu_nested_domain, + domain)->s2_parent; return NULL; } @@ -2649,7 +2726,8 @@ static void arm_smmu_remove_master_domain(struct arm_smmu_master *master, return; spin_lock_irqsave(&smmu_domain->devices_lock, flags); - master_domain = arm_smmu_find_master_domain(smmu_domain, master, ssid); + master_domain = arm_smmu_find_master_domain( + smmu_domain, master, ssid, domain->type == IOMMU_DOMAIN_NESTED); if (master_domain) { list_del(&master_domain->devices_elm); kfree(master_domain); @@ -2664,6 +2742,7 @@ struct arm_smmu_attach_state { struct iommu_domain *old_domain; struct arm_smmu_master *master; bool cd_needs_ats; + bool disable_ats; ioasid_t ssid; /* Resulting state */ bool ats_enabled; @@ -2716,7 +2795,8 @@ static int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state, * enabled if we have arm_smmu_domain, those always have page * tables. */ - state->ats_enabled = arm_smmu_ats_supported(master); + state->ats_enabled = !state->disable_ats && + arm_smmu_ats_supported(master); } if (smmu_domain) { @@ -2725,6 +2805,8 @@ static int arm_smmu_attach_prepare(struct arm_smmu_attach_state *state, return -ENOMEM; master_domain->master = master; master_domain->ssid = state->ssid; + master_domain->nest_parent = new_domain->type == + IOMMU_DOMAIN_NESTED; /* * During prepare we want the current smmu_domain and new @@ -3097,6 +3179,122 @@ static struct iommu_domain arm_smmu_blocked_domain = { .ops = &arm_smmu_blocked_ops, }; +static int arm_smmu_attach_dev_nested(struct iommu_domain *domain, + struct device *dev) +{ + struct arm_smmu_nested_domain *nested_domain = + container_of(domain, struct arm_smmu_nested_domain, domain); + struct arm_smmu_master *master = dev_iommu_priv_get(dev); + struct arm_smmu_attach_state state = { + .master = master, + .old_domain = iommu_get_domain_for_dev(dev), + .ssid = IOMMU_NO_PASID, + /* Currently invalidation of ATC is not supported */ + .disable_ats = true, + }; + struct arm_smmu_ste ste; + int ret; + + if (arm_smmu_ssids_in_use(&master->cd_table) || + nested_domain->s2_parent->smmu != master->smmu) + return -EINVAL; + + mutex_lock(&arm_smmu_asid_lock); + ret = arm_smmu_attach_prepare(&state, domain); + if (ret) { + mutex_unlock(&arm_smmu_asid_lock); + return ret; + } + + arm_smmu_make_nested_domain_ste(&ste, master, nested_domain, + state.ats_enabled); + arm_smmu_install_ste_for_dev(master, &ste); + arm_smmu_attach_commit(&state); + mutex_unlock(&arm_smmu_asid_lock); + return 0; +} + +static void arm_smmu_domain_nested_free(struct iommu_domain *domain) +{ + kfree(container_of(domain, struct arm_smmu_nested_domain, domain)); +} + +static const struct iommu_domain_ops arm_smmu_nested_ops = { + .attach_dev = arm_smmu_attach_dev_nested, + .free = arm_smmu_domain_nested_free, +}; + +static struct iommu_domain * +arm_smmu_domain_alloc_nesting(struct device *dev, u32 flags, + struct iommu_domain *parent, + const struct iommu_user_data *user_data) +{ + struct arm_smmu_master *master = dev_iommu_priv_get(dev); + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); + struct arm_smmu_nested_domain *nested_domain; + struct arm_smmu_domain *smmu_parent; + struct iommu_hwpt_arm_smmuv3 arg; + unsigned int eats; + unsigned int cfg; + int ret; + + if (!(master->smmu->features & ARM_SMMU_FEAT_NESTING)) + return ERR_PTR(-EOPNOTSUPP); + + /* + * Must support some way to prevent the VM from bypassing the cache + * because VFIO currently does not do any cache maintenance. + */ + if (!(fwspec->flags & IOMMU_FWSPEC_PCI_RC_CANWBS) && + !(master->smmu->features & ARM_SMMU_FEAT_S2FWB)) + return ERR_PTR(-EOPNOTSUPP); + + ret = iommu_copy_struct_from_user(&arg, user_data, + IOMMU_HWPT_DATA_ARM_SMMUV3, ste); + if (ret) + return ERR_PTR(ret); + + if (flags || !(master->smmu->features & ARM_SMMU_FEAT_TRANS_S1)) + return ERR_PTR(-EOPNOTSUPP); + + if (!(parent->type & __IOMMU_DOMAIN_PAGING)) + return ERR_PTR(-EINVAL); + + smmu_parent = to_smmu_domain(parent); + if (smmu_parent->stage != ARM_SMMU_DOMAIN_S2 || + smmu_parent->smmu != master->smmu) + return ERR_PTR(-EINVAL); + + /* EIO is reserved for invalid STE data. */ + if ((arg.ste[0] & ~STRTAB_STE_0_NESTING_ALLOWED) || + (arg.ste[1] & ~STRTAB_STE_1_NESTING_ALLOWED)) + return ERR_PTR(-EIO); + + cfg = FIELD_GET(STRTAB_STE_0_CFG, le64_to_cpu(arg.ste[0])); + if (cfg != STRTAB_STE_0_CFG_ABORT && cfg != STRTAB_STE_0_CFG_BYPASS && + cfg != STRTAB_STE_0_CFG_S1_TRANS) + return ERR_PTR(-EIO); + + eats = FIELD_GET(STRTAB_STE_1_EATS, le64_to_cpu(arg.ste[1])); + if (eats != STRTAB_STE_1_EATS_ABT) + return ERR_PTR(-EIO); + + if (cfg != STRTAB_STE_0_CFG_S1_TRANS) + eats = STRTAB_STE_1_EATS_ABT; + + nested_domain = kzalloc(sizeof(*nested_domain), GFP_KERNEL_ACCOUNT); + if (!nested_domain) + return ERR_PTR(-ENOMEM); + + nested_domain->domain.type = IOMMU_DOMAIN_NESTED; + nested_domain->domain.ops = &arm_smmu_nested_ops; + nested_domain->s2_parent = smmu_parent; + nested_domain->ste[0] = arg.ste[0]; + nested_domain->ste[1] = arg.ste[1] & ~cpu_to_le64(STRTAB_STE_1_EATS); + + return &nested_domain->domain; +} + static struct iommu_domain * arm_smmu_domain_alloc_user(struct device *dev, u32 flags, struct iommu_domain *parent, @@ -3108,9 +3306,13 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags, struct arm_smmu_domain *smmu_domain; int ret; + if (parent) + return arm_smmu_domain_alloc_nesting(dev, flags, parent, + user_data); + if (flags & ~PAGING_FLAGS) return ERR_PTR(-EOPNOTSUPP); - if (parent || user_data) + if (user_data) return ERR_PTR(-EOPNOTSUPP); smmu_domain = arm_smmu_domain_alloc(); @@ -3123,6 +3325,7 @@ arm_smmu_domain_alloc_user(struct device *dev, u32 flags, goto err_free; } smmu_domain->stage = ARM_SMMU_DOMAIN_S2; + smmu_domain->nest_parent = true; } smmu_domain->domain.type = IOMMU_DOMAIN_UNMANAGED; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 4b05c81b181a82..b563cfedf22e91 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -240,6 +240,7 @@ static inline u32 arm_smmu_strtab_l2_idx(u32 sid) #define STRTAB_STE_0_CFG_BYPASS 4 #define STRTAB_STE_0_CFG_S1_TRANS 5 #define STRTAB_STE_0_CFG_S2_TRANS 6 +#define STRTAB_STE_0_CFG_NESTED 7 #define STRTAB_STE_0_S1FMT GENMASK_ULL(5, 4) #define STRTAB_STE_0_S1FMT_LINEAR 0 @@ -291,6 +292,15 @@ static inline u32 arm_smmu_strtab_l2_idx(u32 sid) #define STRTAB_STE_3_S2TTB_MASK GENMASK_ULL(51, 4) +/* These bits can be controlled by userspace for STRTAB_STE_0_CFG_NESTED */ +#define STRTAB_STE_0_NESTING_ALLOWED \ + cpu_to_le64(STRTAB_STE_0_V | STRTAB_STE_0_CFG | STRTAB_STE_0_S1FMT | \ + STRTAB_STE_0_S1CTXPTR_MASK | STRTAB_STE_0_S1CDMAX) +#define STRTAB_STE_1_NESTING_ALLOWED \ + cpu_to_le64(STRTAB_STE_1_S1DSS | STRTAB_STE_1_S1CIR | \ + STRTAB_STE_1_S1COR | STRTAB_STE_1_S1CSH | \ + STRTAB_STE_1_S1STALLD | STRTAB_STE_1_EATS) + /* * Context descriptors. * @@ -508,6 +518,7 @@ struct arm_smmu_cmdq_ent { }; } cfgi; + #define CMDQ_OP_TLBI_NH_ALL 0x10 #define CMDQ_OP_TLBI_NH_ASID 0x11 #define CMDQ_OP_TLBI_NH_VA 0x12 #define CMDQ_OP_TLBI_EL2_ALL 0x20 @@ -790,10 +801,18 @@ struct arm_smmu_domain { struct list_head devices; spinlock_t devices_lock; bool enforce_cache_coherency : 1; + bool nest_parent : 1; struct mmu_notifier mmu_notifier; }; +struct arm_smmu_nested_domain { + struct iommu_domain domain; + struct arm_smmu_domain *s2_parent; + + __le64 ste[2]; +}; + /* The following are exposed for testing purposes. */ struct arm_smmu_entry_writer_ops; struct arm_smmu_entry_writer { @@ -830,6 +849,7 @@ struct arm_smmu_master_domain { struct list_head devices_elm; struct arm_smmu_master *master; ioasid_t ssid; + u8 nest_parent; }; static inline struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index 83b6e1cd338d8f..76e9ad6c9403af 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -394,14 +394,34 @@ struct iommu_hwpt_vtd_s1 { __u32 __reserved; }; +/** + * struct iommu_hwpt_arm_smmuv3 - ARM SMMUv3 Context Descriptor Table info + * (IOMMU_HWPT_DATA_ARM_SMMUV3) + * + * @ste: The first two double words of the user space Stream Table Entry for + * a user stage-1 Context Descriptor Table. Must be little-endian. + * Allowed fields: (Refer to "5.2 Stream Table Entry" in SMMUv3 HW Spec) + * - word-0: V, Cfg, S1Fmt, S1ContextPtr, S1CDMax + * - word-1: S1DSS, S1CIR, S1COR, S1CSH, S1STALLD + * + * -EIO will be returned if @ste is not legal or contains any non-allowed field. + * Cfg can be used to select a S1, Bypass or Abort configuration. A Bypass + * nested domain will translate the same as the nesting parent. + */ +struct iommu_hwpt_arm_smmuv3 { + __aligned_le64 ste[2]; +}; + /** * enum iommu_hwpt_data_type - IOMMU HWPT Data Type * @IOMMU_HWPT_DATA_NONE: no data * @IOMMU_HWPT_DATA_VTD_S1: Intel VT-d stage-1 page table + * @IOMMU_HWPT_DATA_ARM_SMMUV3: ARM SMMUv3 Context Descriptor Table */ enum iommu_hwpt_data_type { IOMMU_HWPT_DATA_NONE = 0, IOMMU_HWPT_DATA_VTD_S1 = 1, + IOMMU_HWPT_DATA_ARM_SMMUV3 = 2, }; /**