From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.53.68 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796110482; b=y2rSDPl+C5orGpize8eo0qFp/WiXTXMPDsaPRZEoFRGq2pU24zY7RpUZFfuEWvPij106 szJFJob/V5P2fkjsbiMIr6I08RM5X+MEghqsAuv7y423j2QV6IoKIMzMIfuB+tMfn4Z33 J9n+cUD7cnv5H/xnkXOBRPle4N3BIV56JvskS7g3v8y9qi4KxFgg0cqQrrIvJvuXYM81j oZG77iN0pn0zbs9pPHmqiKXp15mu4KIqwDGZREJjPMkgYByP7rZSYeSe7TUd7ljNdo/Qa rChWWzt5X2zW61gmFs6t90adhOauwqd+YckciB5szflonIg1nv0872df6oEUREw5oRw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110482; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type:X-NV-OnPremToCloud:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=30tqZ/zHmeQWD6ImO0Wn2Pe1atdrsMxydY0vVu/WJ94=; b=VlmMIuS7INjq6q3fuHBx7H1Rx+oTS2QXjkcCFYdCKr0j+R06RO5VeDxl/pymtyb/838h ISE2WBCy5b8OgmpEqRfyzizmTbsY02n49l3DrGDBnYCEh8qN8apjaCcqyI/p66QAylXoc y50iRknNctSVnLFZSpNoJ0pP5ByuKRY364sby+v2kxnGq+20GDEW8spJ0CAZXleKGECld ODh8fscqpeZj1mXCAqj0yBCi6Y7wRiC98c4LCbxFtKVkgpTtzXEV763L6wQ2xeLHKcj9J cvgRCbtLj0X84aL4fKfzljnel4JhHxiyx6YaDTBWotE8uNS3SCTQAulr9khq/qQlVxQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=USzCS+9k; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.53.68 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012068.outbound.protection.outlook.com [52.101.53.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F030A606A33B for ; Tue, 1 Dec 2026 07:34:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F030A606A33B 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, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=USzCS+9k ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uLwtsNRixSRVU2tEbB6tsj5XeA+L1PTy8cVINQA+iU5ZERGyqG2VRg5GA8E8UOnCgl99pltSnXmFqBAt0DgPGIfiZtN2hy9n5DekuWA3luVdwDm0GqBRydidZFUGbjvS1978QGCv23dtDduCWeWUirgZ3gKsAuiBVDD5y1WdSp2aylQr6xu5dEkRLFdZNF2G1uvSchjoIawUJZ0A9nx7Y4MvKSKyZL+i9HtsOEybtmDJFrwaRUk0u/1+CEqL1+ABZJE/VmFr9X6iOjHM9M4giywxPKNbmpw8Mb+raX4F3bWZtFyoySmi4/DjdN3YAQhtEMZFdhabYbccHSIcGtggQw== 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=30tqZ/zHmeQWD6ImO0Wn2Pe1atdrsMxydY0vVu/WJ94=; b=QZ9lKj05Qq5OM8BM9daY2IQxOR2eZUjXAFFgidxaOUIcRyLdKzI+Ld+4qrIDGgcxI+l0ZdZdpXL0r/6jvnuMDfExRXMs1r7B210U4HilVgauDzR+q4Bnxzi2uVu3pcQRgEPMf3iy7YI/ybIZuc4a5DcWhHSIe8HuxoYmkX5XTccSctjVUjgCiiUHxRK4f4dbOOMG1fYyayW0dzkE1MQWCAhZjgjZ0v32mYqXBPizx5iBmaHUXUO6maLy45Wzb8wscA1fQht8dTGAhhJ0Ju6OcZReSkSFu+s2Hq89CroZLvRuaLMYJ+6G+fZbe+VtmFuCe1P6fA6BknkH4+kZUnJn4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.linux.dev smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=30tqZ/zHmeQWD6ImO0Wn2Pe1atdrsMxydY0vVu/WJ94=; b=USzCS+9kHM3ZL3TVL/7ShEG1q6Kn9HSSHw19+PkJsae6I+aGP2jlVhcid/8IROcrYZcFAgWByCLkMYGMK6QqrK2jS7mfIwob5rU1jjOwU9cchHBIzoFjQVn/Uao/aa7V0PnI/7RpAENRfdiJF7fl7JquJZm/yL1HOwuCyQ0Lfr1EFQi82wYruENhULxFD/7k+HXkZ9WqBmWpzsjq7nv51KOASnzIB1/zrg79LDu4w7COddTLB5v9rml4B+60uFrF4xgDM/KFsYdHVNFB7Ka817sNvrtrdSTrkqPB/U55oj/lzE2J7Atk9LEOQKjGwjPp4E2XKtdtq1U3/Dp5ptC+yQ== Received: from BY5PR20CA0027.namprd20.prod.outlook.com (2603:10b6:a03:1f4::30) by DS2PR12MB9799.namprd12.prod.outlook.com (2603:10b6:8:270::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 07:34:35 +0000 Received: from SJ1PEPF000023CB.namprd02.prod.outlook.com (2603:10b6:a03:1f4:cafe::2b) by BY5PR20CA0027.outlook.office365.com (2603:10b6:a03:1f4::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 07:34:35 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023CB.mail.protection.outlook.com (10.167.244.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 07:34:35 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 23:34:20 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 23:34:20 -0800 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Mon, 30 Nov 2026 23:34:19 -0800 From: Nicolin Chen To: Jason Gunthorpe , , Will Deacon , Robin Murphy , Catalin Marinas , Greg Kroah-Hartman , , Danilo Krummrich , Johan Hovold , Marek Szyprowski , CC: Mark Rutland , Pranjal Shrivastava , Mostafa Saleh , , , , Sonang Patel , "Ankit Agrawal" , Subject: [PATCH v4 6/6] iommu/arm-smmu-v3: Probe a guest-level Realm VSMMU via RSI commands Date: Mon, 30 Nov 2026 23:33:58 -0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023CB:EE_|DS2PR12MB9799:EE_ X-MS-Office365-Filtering-Correlation-Id: 38b07208-f591-4584-f26b-08df4f7d8c4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|82310400026|7416014|376014|921020|261021123027099003|10067099003|56012099006|261026140227099003|261022105027099003|261028144727099003|261022075727099003|261021135927099003|261021121427099003|261102123227099003|261026121527099003|261009223027099003|22082099003|18002099003|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: n15Dv9A1qKnfaS8CW+0BG6DpGmv/pEzSrg3GH46VfuQUX3JJkx93yv1IUUQuKMerhECcr1eIqK0U35ooJ/DEUm7edLeHRAWRUY8PgAxpJRpIOm0rQgtyhLI0q9fEKm0WIFzqVjt3//FBRS98u6AyyWhQtuOG3a7ZbThltVLknxIniWPwSyhQyNsyBDxxTLHWiXwYww/L7s6U9FYReRpFs2os97W1PTZPpVUq/AHjDzgpc2Ny9789iuxSoGLJuP+f844jaYVtu40WDhL89kQza4vLog4nNpaATSh0z6xq+hY1qZZ3mhMG4ADM29D1JOebTpDjsF6fo+t/iLtwv7z5dKIZ9y8Je3+Rhnam1M6WFzctAVMDdJOZCWsIP1CqirLJhXMZ9eiXDRsGhpDldQx4QA9SH/lfCpcpypB8J6X948nCRTrLB1Y/whNgxENu2GtDG395dwriA5pdhPf2nBp0HpIeHrEtNWSshhx56yoGmafslbfIU5WRskB6261i5WNshSYi++oUlamnWt2duSHJSjoz0d1D6aRV4ARV8x/8Klvl+82RLlXAng29M6pV0gZ1wdNCV3dylcRm5HaX8GGiANz994cbCXOZf8oFqlMr8ImFshcZe1e+TX0lP7OU0fWGvDljqO8awQxFhDLVkLKcfSj47tcFy+9DeVmhe93uKJTlQWjY6lq1IMOBfPLJtZYD3NmcP23al1oX9SoAm/QPvSANMQ6Avb2GbuoHO5g73ErWziKX0Awl6RyCEpEJCFC5 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(23010399003)(82310400026)(7416014)(376014)(921020)(261021123027099003)(10067099003)(56012099006)(261026140227099003)(261022105027099003)(261028144727099003)(261022075727099003)(261021135927099003)(261021121427099003)(261102123227099003)(261026121527099003)(261009223027099003)(22082099003)(18002099003)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iSGDoFvJs7DtAXDN82ipRWU8Cem2+V8VAL5o+4BWHoUH8I4+5o9283qZhbxeKmRF1DEuuomTDtUdqgMFLCXbPl+0bKPc491MolVmxa1aa4KPGDsNIam7rVggfNyN9egamQtTboKBbBdG9YmNSautTLLv+4ZqsF3c6IkQgXeI9vMkDgAOq+ng6wrEQlI9jhLIcTBOYBhPYyTFqNXLj+lfUBNfZ+mkQ2jJgxwNOWjJflLIM5IdfX69JsnUJp5odp7MlVp7Q9CtC3W7IWPOfOoHf/AGKU9tGD/yaBXzFJm2gLIl0Cpql7EzvtCgpa3InpbDdLdc9G2zzMl11h/ZiCeLHwkoC65yIY8hp1HKU2CxC0H37s1qKn35pigPzguiym2zAcRW3SS8CceJ1YrFERl04/tX93y42Z7GdG0UBxP/TwMUQI/ffK5cqZtojlY6eZdr X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 07:34:35.2812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38b07208-f591-4584-f26b-08df4f7d8c4b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023CB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB9799 In CCA, the ACPI/etc doesn't tell the OS whether the SMMU is a confidential T=1 instance or a normal T=0 one. Instead, it has to be learned by issuing a trusted RSI. Before the kernel can operate the trusted T=1 IOMMU, it also has to validate all the information that it gets from ACPI against the true information that it gets from the RSI call, to ensure the ACPI is correct and prevent substitution attacks. Use RSI_VSMMU_GET_INFO during probe and require the returned register range to match firmware. Then use RSI_ARCH_DEV_ACTIVATE before mapping registers. Currently the driver doesn't support a T=0 SMMU inside a realm. For example it doesn't make the page table allocations into shared memory. If we are in a realm reject any SMMU that is not T=1. Once the SMMU is activated, its DMA will follow the DEV_FLAG_DMA_CC_PRIVATE rules. It must set that flag to ensure its coherent allocations for its own structures are allocated from private memory, not the SWIOTLB shared pool. Also skip the Tegra241 CMDQV in the realm world. The CMDQV hardware can be used in realms. But neither the RMM spec nor the RMM firmware supports the CMDQV yet. From a guest perspective, there is no way to verify the NVDA200C ACPI device with the RMM yet. Thus, its MMIO space cannot be used for now. Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 78 ++++++++++++++++++++- 1 file changed, 77 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 6d4520c473086..f71982d72cae7 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -11,9 +11,11 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -5545,6 +5547,15 @@ static void tegra_cmdqv_dt_probe(struct device_node *smmu_node, struct platform_device *pdev; struct device_node *np; + /* + * A realm can have a CMDQV. But neither the RMM spec nor the firmware + * supports the CMDQV yet. So, a realm guest has no way to verify it via + * the RMM yet. Thus, its MMIO space cannot be used. Realms only get the + * standard SMMU for now. + */ + if (is_realm_world()) + return; + np = of_parse_phandle(smmu_node, "nvidia,cmdqv", 0); if (!np) return; @@ -5572,8 +5583,19 @@ static void tegra_cmdqv_dt_probe(struct device_node *smmu_node, static void acpi_smmu_dsdt_probe_tegra241_cmdqv(struct acpi_iort_node *node, struct arm_smmu_device *smmu) { - const char *uid = kasprintf(GFP_KERNEL, "%u", node->identifier); struct acpi_device *adev; + const char *uid; + + /* + * A realm can have a CMDQV. But neither the RMM spec nor the firmware + * supports the CMDQV yet. So, a realm guest has no way to verify it via + * the RMM yet. Thus, its MMIO space cannot be used. Realms only get the + * standard SMMU for now. + */ + if (is_realm_world()) + return; + + uid = kasprintf(GFP_KERNEL, "%u", node->identifier); /* Look for an NVDA200C node whose _UID matches the SMMU node ID */ adev = acpi_dev_get_first_match_dev("NVDA200C", uid, -1); @@ -5779,6 +5801,56 @@ static struct arm_smmu_device *arm_smmu_impl_probe(struct arm_smmu_device *smmu) return ERR_PTR(ret); } +static void arm_smmu_clear_realm_private(void *dev) +{ + dma_set_cc_private(dev, false); +} + +static int arm_smmu_probe_realm_vsmmu(struct arm_smmu_device *smmu, + const struct resource *res) +{ + struct device *dev = smmu->dev; + unsigned long rsi_ret; + phys_addr_t top; + + if (!is_realm_world()) + return 0; + + /* + * Currently the driver does not support a T=0 SMMU inside a realm. For + * instance it does not make the page table allocations into shared + * memory. If we are in a realm reject any SMMU that is not T=1. + */ + rsi_ret = rsi_vsmmu_get_info(res->start, &top); + if (rsi_ret != RSI_SUCCESS) { + dev_err(dev, "RSI_VSMMU_GET_INFO failed for %pr: %lu\n", res, + rsi_ret); + return -ENODEV; + } + + if (top != res->end + 1) { + dev_err(dev, "VSMMU range %pr ends at %pa\n", res, &top); + return -EINVAL; + } + + rsi_ret = rsi_arch_dev_activate(res->start, RSI_ARCH_DEV_SMMUV3); + if (rsi_ret != RSI_SUCCESS) { + dev_err(dev, "RSI_ARCH_DEV_ACTIVATE failed for %pr: %lu\n", res, + rsi_ret); + return -EIO; + } + + /* + * Once activated, the SMMU DMA follows DEV_FLAG_DMA_CC_PRIVATE so its + * queues and tables are allocated from private memory, not the SWIOTLB + * shared pool. It only translates for a device we've requested the RMM + * to put into T=1. + */ + iommu_device_set_cc_private(&smmu->iommu, dev); + + return devm_add_action_or_reset(dev, arm_smmu_clear_realm_private, dev); +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -5814,6 +5886,10 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } ioaddr = res->start; + ret = arm_smmu_probe_realm_vsmmu(smmu, res); + if (ret) + return ret; + /* * Don't map the IMPLEMENTATION DEFINED regions, since they may contain * the PMCG registers which are reserved by the PMU driver. -- 2.43.0