From nobody Sat Jul 25 00:15:12 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011003.outbound.protection.outlook.com [52.101.62.3]) (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 A5B693A4F4B for ; Tue, 21 Jul 2026 19:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663346; cv=fail; b=KcE9m4dcHsbWPv48rBEFeYX1eQzKfDudmtZaOrep3MCknnQg9FfDDjsJFD3FhAPQz9GxfaVbbujOTzM7EF0Mdxee4/JXldOHrnC6oYaaI/VLlMCcI0TvBYIs9387PLLRWdnM5sVGS8UkZqzXqpsU+VZwKBGoeO+kB7HOsIuY0yY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663346; c=relaxed/simple; bh=f5J1TPEERhRweUYoClF7lnwnjCmUZ43rPG6BSnaSsqg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ho8Xzg7NE9DstftUNeACF6W+hG8kEDMhNpTY/OOY4/9RYAXriPwr9dyUQMOllcX5gBrVVRjZkmZ+gx+I6jC71++zw2LROJ1btw7L4BCUWKu6BYWh5zdkWonWfGiJM2VNDxJMIbyuOkMQE++ipSWyUag8YIg9JLle1CiTlM8WWMQ= 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=Z8bZ39XU; arc=fail smtp.client-ip=52.101.62.3 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="Z8bZ39XU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dpQ6ePp11poIutnGMfJgNJYFv/9UflMIwEQve1mxaZRaXyfIYh3Fjnm5ggLrg5ssa5owELjNxtl3U2x+qNxfLqR73DmIQMsxTmG5wgajgyRwvtxyBcEdSRHQYhp56Y71Gyg8FkZ1CWkX6JBf5V9n+gGyY8zSZ40fmL4sEI+NIFyyRCuWEgJhTUb/TzkyjSm9JpNluGb/SaGLjoHa3bvQrzU3KtP+0ZdVlN5f/smSd4jMrJQYmad9G0ndv/6VjjJtNGYnwAN3cH6jOPphajd3dpPyYDOATfNufiJ9WBc4XhTXnBHa5goEyFamZcfgZ6NotZ9cGnfQNj47yOaa7dmrDw== 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=mlySgRa3aXx13KatwQ5/JqusdclKYsr1UAq0hIkrSTo=; b=rb/2N4xqljJZD7o5syQ+/OMpPq7GjEY9dadRN8TakwKMZHm4+7mL0/bCO7ED6owZnlofb2YWwmffk4n9YV1SaXBtyMldz55Ast23FYkosxRc4RjU6jzUjPk3Tnjyepeio7ys3g2To18Mw9nBa7nswIrTcNmjdlOgeiZ9cb0cVi03apFgjf8RgG3N2+3aXwkzVJZI8v5d6mFMYPmaUnqfE75NYm5V5T/fS9xY2SZCZjueS0hsIoFDds99XcEDGOrhPL0O/3Zr0CGGCwp7F2AKOnlaVwPnR+RDqZgzWkSP/xsqkTeq89m9n42RX9+ELfRBjdB8w2IseqXKYLCjQLCYTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org 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=mlySgRa3aXx13KatwQ5/JqusdclKYsr1UAq0hIkrSTo=; b=Z8bZ39XUIZmRGm1k7E2UNRRDvluLoWqMpsOqiNk5mE6d86J56AfgEt/dWQmhxi3V1UPZO36yE01NtAAJK4mk+Q02a6YFlSpEaUOmgTv+2gZ7piUAm0ZHnnqNBaXj7ipLGOUq/w65bR1ckY5gZqkhYAt91X2ydjJUUc8OgHX9Hnq2l9+XS1qfxOL0kdH91J/b8k1GmZsnx5Y0px5yryLp3Q5IqKfUahel1uB7m1QK4BYO/FRg+sD6XglWQHt5DwK8FEVEz09wcz4C26Qe0Duj9yCufWo/UPBLPYqfudzndIuV7HZ0vilhtGgeBX7NoiqIxaf0Fm4jORk824VrUdALCQ== Received: from CH0P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::23) by SJ0PR12MB5675.namprd12.prod.outlook.com (2603:10b6:a03:42d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:48:56 +0000 Received: from CH3PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:11c:cafe::2e) by CH0P221CA0007.outlook.office365.com (2603:10b6:610:11c::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:48:56 +0000 X-MS-Exchange-Authentication-Results: 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 CH3PEPF00000017.mail.protection.outlook.com (10.167.244.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:48:56 +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.20; Tue, 21 Jul 2026 12:48:36 -0700 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.20; Tue, 21 Jul 2026 12:48:35 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:35 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 01/12] iommu/arm-smmu-v3: Do not enable EVTQ/PRIQ interrupts in kdump kernel Date: Tue, 21 Jul 2026 12:48:10 -0700 Message-ID: <35000f29472b5e12114073d614168c251551ff0a.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000017:EE_|SJ0PR12MB5675:EE_ X-MS-Office365-Filtering-Correlation-Id: ab9ee0cf-7342-4684-4f03-08dee76119bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|23010399003|82310400026|1800799024|36860700016|18002099003|22082099003|6133799003|56012099006|11063799006|10067099003; X-Microsoft-Antispam-Message-Info: eaJB+wLkzwDp30umt7NJgEQ/a4EzfbGLov5D9ZYfGPQtYneNTWZQpx+enLs/so1/6lIpjg8VI6u8JzJJn20KRKeEYu2kYMq21yr3OxvHRm7reKJomqGpsY4BVRtGA3RpWTWvTAlt3hToETjjhOLC6Spp/Ic2NIMKDKD4N/S3OmRngrqvGTtfgZXO7Sej5YjrmpK17kvkPxSRV9Uysduu90zu7Snoqmn3W+Gnyra81Be7kdPneFx291k9ydPp0m6xnhtZ1wTcBo4koDbrqeKHYJWxfAwyd3dtO2bqoUbhy3hFnsiY9gAV2YHYrIXym2a57ziKCaZ9Ez7DXHu68aqd7XpAsoAIDt3nO/vaAn2gVplRotjDv+OVYaBBSoLRPFMnqe27yBKOCVc3eRDT+1ah6SOSx7/Wo01kgoDPfhokJvvh2x/YlNyhmuN9KFOIkqLn7shMHJpMRqgfKSKnah4OShBoYDmMrkZHXECvNB18UBzqAaydZFzV3biHGgZfip+8SpL4m5twe1R/jDze/W9sr/GXDIJLuR+7kBaQ6/2k9ZFTvEHHcXuqn2HT1Ixz1wqzyW5ABs8pzeaREpa4gfKQoG7Bm6Yk4Empz/UHq0ju6EPgd7IErI0ouN1k6WiCDKnE7gzcSvEUsKEYZDTc/tHwiMeDpaq8qE7D0kz0HWOhyumnjltY/fdXCTGX2j1CPdgGndUvoAfgyrsFtNMuIk+szw== 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)(376014)(23010399003)(82310400026)(1800799024)(36860700016)(18002099003)(22082099003)(6133799003)(56012099006)(11063799006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mJPLdTnopqYkAZcM5q9DNaBBaqZ23ADmQKknlQXJJ1jPc1I0ec2KEqWeU+RSW0SQRqxb+kH5nKgwKO7fEQqugW/CbULAaqvd39tGdBdvtZEkOLO+pXxy0AcKnI2XTls+fvZg+9ijkCxjh569/Wi5T6+ddk/7DCChJQyxSNzSlolR3tKq1q1KlHU5gE7+EgIN6aU0jbsaPvDVvvtzcIeefmi6Cu1W+vzVVsKrgnXTa2bnOTsCQYiOxnJ3k4eLo3uRpewu8id0XiTNhHzhveS+v4kiuI8ccntoGw42vam8AqmtHxbkOtSlHPnJCuCh2KMRezaZFvu9cjJZpxo7+oAeSga0IajSoY4rk0RMy33DJRQt+5MMbITP51Fg+FT+KA+Z6Yk9AWJuYsRNgfWdWBxyJQIPkC1NKUtpm/8I0xmR2vMW6uN62vasgGZ2/XQEVh8x X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:48:56.1190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab9ee0cf-7342-4684-4f03-08dee76119bc 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: CH3PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB5675 Content-Type: text/plain; charset="utf-8" In kdump cases, the crashed kernel's CDs and page tables can be corrupted, which could trigger event spamming. Also, we cannot serve page requests. Skip the IRQ setup for EVTQ/PRIQ in arm_smmu_setup_irqs(). Skip their IRQ handler registration in unique-IRQ and combined-IRQ cases. Note that arm_smmu_device_reset() at this point still enables EVTQEN/PRIQEN transiently before clearing them. A following change will skip the entire queue setup, removing that transient enable window. Reviewed-by: Kevin Tian Reviewed-by: Pranjal Shrivastava Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 58 ++++++++++++++------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index a10affb483a4f..404790d2c7210 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2294,7 +2294,11 @@ static irqreturn_t arm_smmu_combined_irq_thread(int = irq, void *dev) =20 static irqreturn_t arm_smmu_combined_irq_handler(int irq, void *dev) { - arm_smmu_gerror_handler(irq, dev); + irqreturn_t ret =3D arm_smmu_gerror_handler(irq, dev); + + /* In kdump, EVTQ/PRIQ are disabled and there is no thread to wake */ + if (is_kdump_kernel()) + return ret; return IRQ_WAKE_THREAD; } =20 @@ -4625,6 +4629,21 @@ static void arm_smmu_setup_unique_irqs(struct arm_sm= mu_device *smmu) arm_smmu_setup_msis(smmu); =20 /* Request interrupt lines */ + irq =3D smmu->gerr_irq; + if (irq) { + ret =3D devm_request_irq(smmu->dev, irq, arm_smmu_gerror_handler, + 0, "arm-smmu-v3-gerror", smmu); + if (ret < 0) + dev_warn(smmu->dev, "failed to enable gerror irq\n"); + } else { + dev_warn(smmu->dev, + "no gerr irq - errors will not be reported!\n"); + } + + /* No EVTQ/PRIQ interrupts in kdump -- queues are disabled */ + if (is_kdump_kernel()) + return; + irq =3D smmu->evtq.q.irq; if (irq) { ret =3D devm_request_threaded_irq(smmu->dev, irq, NULL, @@ -4637,16 +4656,6 @@ static void arm_smmu_setup_unique_irqs(struct arm_sm= mu_device *smmu) dev_warn(smmu->dev, "no evtq irq - events will not be reported!\n"); } =20 - irq =3D smmu->gerr_irq; - if (irq) { - ret =3D devm_request_irq(smmu->dev, irq, arm_smmu_gerror_handler, - 0, "arm-smmu-v3-gerror", smmu); - if (ret < 0) - dev_warn(smmu->dev, "failed to enable gerror irq\n"); - } else { - dev_warn(smmu->dev, "no gerr irq - errors will not be reported!\n"); - } - if (smmu->features & ARM_SMMU_FEAT_PRI) { irq =3D smmu->priq.q.irq; if (irq) { @@ -4667,7 +4676,7 @@ static void arm_smmu_setup_unique_irqs(struct arm_smm= u_device *smmu) static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) { int ret, irq; - u32 irqen_flags =3D IRQ_CTRL_EVTQ_IRQEN | IRQ_CTRL_GERROR_IRQEN; + u32 irqen_flags =3D IRQ_CTRL_GERROR_IRQEN; =20 /* Disable IRQs first */ ret =3D arm_smmu_write_reg_sync(smmu, 0, ARM_SMMU_IRQ_CTRL, @@ -4682,19 +4691,30 @@ static int arm_smmu_setup_irqs(struct arm_smmu_devi= ce *smmu) /* * Cavium ThunderX2 implementation doesn't support unique irq * lines. Use a single irq line for all the SMMUv3 interrupts. + * + * In kdump, EVTQ/PRIQ are disabled, so no threaded handling. */ - ret =3D devm_request_threaded_irq(smmu->dev, irq, - arm_smmu_combined_irq_handler, - arm_smmu_combined_irq_thread, - IRQF_ONESHOT, - "arm-smmu-v3-combined-irq", smmu); + if (is_kdump_kernel()) + ret =3D devm_request_irq(smmu->dev, irq, + arm_smmu_combined_irq_handler, 0, + "arm-smmu-v3-combined-irq", + smmu); + else + ret =3D devm_request_threaded_irq( + smmu->dev, irq, arm_smmu_combined_irq_handler, + arm_smmu_combined_irq_thread, IRQF_ONESHOT, + "arm-smmu-v3-combined-irq", smmu); if (ret < 0) dev_warn(smmu->dev, "failed to enable combined irq\n"); } else arm_smmu_setup_unique_irqs(smmu); =20 - if (smmu->features & ARM_SMMU_FEAT_PRI) - irqen_flags |=3D IRQ_CTRL_PRIQ_IRQEN; + /* No EVTQ/PRIQ IRQ generation in kdump -- queues are disabled */ + if (!is_kdump_kernel()) { + irqen_flags |=3D IRQ_CTRL_EVTQ_IRQEN; + if (smmu->features & ARM_SMMU_FEAT_PRI) + irqen_flags |=3D IRQ_CTRL_PRIQ_IRQEN; + } =20 /* Enable interrupt generation on the SMMU */ ret =3D arm_smmu_write_reg_sync(smmu, irqen_flags, --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011003.outbound.protection.outlook.com [52.101.52.3]) (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 B76E0470138 for ; Tue, 21 Jul 2026 19:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663353; cv=fail; b=KwAOomF/+YfQXx+1am9+re+g+Rm8UiAQXXh+C/qnwLlSOdY6QkhF7l2ori6e5zVSgrqjDOe2zfsLSTByKUtwcJ8m5hhkZ0cq5rmypRx3beuUf91hoK+pHbjXmID9JFMAJQA9mi9q7cQw7TBFDUt+Wy6r8vIyi2yQ8nhR8wsrLuU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663353; c=relaxed/simple; bh=K1oIJ5Mx4IfqRYlIZ6B4RuIkUxsl4HPT5t3Cck0Gs78=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IPR+yAyJ6CCOiDWBD+oohsxKNDqeKa0ZwabalwUDfZwi0tEZNS03XgUnpl+nvEelf9f4HVceL5ZoCNvRLbQsPt0QeBt+nvZenPnHe7rxSOmzCrUaVF3Qi/bsDSBm9pgZuilSRpRpiAbWmNefOlsZCTY+RdVrJjVBojX1/NxP3yo= 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=j//NfzlV; arc=fail smtp.client-ip=52.101.52.3 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="j//NfzlV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ww8EsJkXm4+8RHjvPfQJsZMqeZhT6wx8daq987JmO9g7TyvJeaXuFx5Y2qY5JzZOLwqTFkrJLsTk48g+O2x0WfIQksUQumhymZSJflavGgx6eu4OSH4alX8beL0RZ2vJV5p/gI1OXUwu5AhlAK1nbMne1mbEJTr7d3PFQDBmXFeSvTEVEEVRqCIspWjHMZXjBtYazDC1ztkyS6CMk7Et1FVBvQQVQbj45r2KbqfnPw17MojP5ejxMemMEZ+OjncuxGxgv07f23NIwb1+Pb8nyapvRxhaNWFiVWjFs0ek7DNHklogjTdBtZ324DZUzEgqFC9DGV9a+CpH3Sm4loHnlA== 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=uzhcPOb0pIG0W5MZPxOMrEW/3mazbjsS9PybLOI1rVQ=; b=Vo+02QW2DOF815YAsZvL0RkZhpIKsL5he7AYFqhBRU7kAD4J3s5TzX37ZBSP8K00Glj7TgMNO04Tq3/Z65sqJQKgYMvY2u+madHLtsecX8HG4v5keFtdmupG9m576ceoF6aW9aXpBNAunynKLQySxOR0MzQavROHA2z+CnT7vyBNuSklPYLFze16PYRVE9gr8sJRt8DM737F0qc74pSHDS48eAMcEc5rzGPlvqBf8m+CM7QX23ffli+co1FkQq2xl3Dfr1IoFp9qRFwuzSrF8KztWksCirK/rp1ouxtIZAIVpW1Bw1HTx0mlA3elKhVyPEP1ZqoC3iumD78+RACilQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=uzhcPOb0pIG0W5MZPxOMrEW/3mazbjsS9PybLOI1rVQ=; b=j//NfzlV0zxFeg1ex9Ewnv5/TBEQGiU+lT94R2rjF9Wg66vmbQ4m2y5ULcpZtjpIaJBouUWqVQrUPy6bqUHkkZ/uF32El+DJG0f2vzi9ScJ8GmAHxiOLXcyVij9eoYon2nge35ffrm3b1mQxUQ2OTrzvHfyqL2xome+N+lxOmvsZAHBBLSTaCEf7OwC4x9+YJknF83iH+Hq4ku8GIMH/xqrFdV/20DClwMklq2dsIlVY5rilRmHP1e70g7T520ZtQ+eS6BYgtxk0+A7L5MCRhDxQtQYpqnBZQf35CuI+PWFSx3BGmsanWue3CtoTSBgrv5okUFGkCU3d+4Y/VXxhJg== Received: from MW4PR03CA0028.namprd03.prod.outlook.com (2603:10b6:303:8f::33) by DS7PR12MB6120.namprd12.prod.outlook.com (2603:10b6:8:98::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:48:59 +0000 Received: from SJ1PEPF000023D8.namprd21.prod.outlook.com (2603:10b6:303:8f:cafe::af) by MW4PR03CA0028.outlook.office365.com (2603:10b6:303:8f::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:48:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023D8.mail.protection.outlook.com (10.167.244.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:48:58 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:37 -0700 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.20; Tue, 21 Jul 2026 12:48:36 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:36 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 02/12] iommu/arm-smmu-v3: Skip EVTQ/PRIQ setup in kdump kernel Date: Tue, 21 Jul 2026 12:48:11 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D8:EE_|DS7PR12MB6120:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b8c2a53-612d-4bd7-30d1-08dee7611b5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|376014|1800799024|56012099006|11063799006|10067099003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: 5iUDSUQY0gU6K5JLowL1CqK1l+UYdfZvAg4RdoI4CfaYY1TtAQhep4VysKkBEQGquICVB3SC9GpL2BAU9ycVx/o0GX8pef55TpNdYFP1Fj9lsrA5PCf0dD9eUhwTCyqMCMALqHt1/zd22ySQnwiYDZeoYZDM7e5qbV95HGSxHTnmj7amLvUlGmeGTvIPaYrIvAHX4CB2xeIdXFrMhHSZVHD/V3QVaq+KXvaFAUbbdsZVSrxusv/iK2m4yqaqfWrwYV9BkP68civ2ceUJuazpLfMNai1mmZiLTNbdXMJ7JZ3m4Hpra2tgq91AYg/V7pCsY5VeB9txOQrDDV9tUERNebPxCNIr07sVheHw4JleaUR3qKPa8DCQkt/JzFMV074sSxNfXLVkSTTey4LukK0sXYoYy47SUL1xu3TcMxvus6Eo33CvQYU1qdJFjMiovtNg4A0OGp+2Rjf/2kVbODwHcQiafl6n9bQN9DqofhM6RSPtVdB4mzDblKc7uX1iDJa26GUpWyMY62vlBBUVRYbXo7GOS/m9OIlyROlpSk4EUlacguu6CsvFVJdQz/JrqiJTLtdHvhEhtf0cFE2cir8fOBCey6YndhH6Q9koet+wV1l9XkRNDwNBf4r+szowpvmU6U2QS2mXqk6nfgQMtB2F7Bfn3/88mRGORPGPpBRC926VdUq7WcmCsWu0z7RnEwbjzIc/UX3mZI4sCIXyqGrVtw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(376014)(1800799024)(56012099006)(11063799006)(10067099003)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m2yQ5P8FsOdq0DfKNFpy7jnshBsvIfBfidfxwskd3AEefA7NfSYyvPAWoy3xOxth+vZurRRyM5myIaJvCOg27xmrb7DsEhYaGPGOxy1Fjinivl2eoINK4OG5xeUeqaqQX9x2ZUTmPrCjgPROEh+Xm7J1ufheQf40rO8IxedowN3/GmSXbXZ0vAyMipvkwCPtrR5j8IvWg0AIgMuPoOPOs2FQ/qmgUIstbaKlNThkEStgFLFhc0ZTeZnahQVTcbcrEdchoIIbpTWTvHR/L38GMRQkM5O5hDBnQDtC2znLGBKlXdpMrfiJnhv+bmFrfV8yF1Ubsv9reBfPU1c3wL5sFibPqIDpGoyyWtve9c3c813vQQv6JCIGAC/VnMcBtdNy4JMM00rADPPzMxYqAI6Q/58Cz36LFsAyWX9mnjWJRZOOzS7yE7kmv7p3ulCYBS+z X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:48:58.8569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b8c2a53-612d-4bd7-30d1-08dee7611b5a 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6120 Content-Type: text/plain; charset="utf-8" In kdump cases, the crashed kernel's CDs and page tables can be corrupted, which could trigger event spamming. Also, we cannot serve page requests. Skip the EVTQ/PRIQ setup entirely rather than enabling then disabling them. Keep the queue allocations themselves, as their Q_MAX_SZ_SHIFT-capped sizes are negligible against a crashkernel reservation. Also add some inline comments explaining that. Suggested-by: Kevin Tian Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Reviewed-by: Pranjal Shrivastava Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 44 +++++++++++++-------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 404790d2c7210..132bee5fbb1d1 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -4821,21 +4821,36 @@ static int arm_smmu_device_reset(struct arm_smmu_de= vice *smmu) arm_smmu_cmdq_issue_cmd_with_sync( smmu, arm_smmu_make_cmd_op(CMDQ_OP_TLBI_NSNH_ALL)); =20 - /* Event queue */ - writeq_relaxed(smmu->evtq.q.q_base, smmu->base + ARM_SMMU_EVTQ_BASE); - writel_relaxed(smmu->evtq.q.llq.prod, smmu->page1 + ARM_SMMU_EVTQ_PROD); - writel_relaxed(smmu->evtq.q.llq.cons, smmu->page1 + ARM_SMMU_EVTQ_CONS); - - enables |=3D CR0_EVTQEN; - ret =3D arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, - ARM_SMMU_CR0ACK); - if (ret) { - dev_err(smmu->dev, "failed to enable event queue\n"); - return ret; + /* + * Event queue + * + * Do not enable in a kdump case, as the crashed kernel's CDs and page + * tables may be corrupted, triggering event spamming. A disabled queue + * simply discards new events, without raising any global error. + */ + if (!is_kdump_kernel()) { + writeq_relaxed(smmu->evtq.q.q_base, + smmu->base + ARM_SMMU_EVTQ_BASE); + writel_relaxed(smmu->evtq.q.llq.prod, + smmu->page1 + ARM_SMMU_EVTQ_PROD); + writel_relaxed(smmu->evtq.q.llq.cons, + smmu->page1 + ARM_SMMU_EVTQ_CONS); + + enables |=3D CR0_EVTQEN; + ret =3D arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, + ARM_SMMU_CR0ACK); + if (ret) { + dev_err(smmu->dev, "failed to enable event queue\n"); + return ret; + } } =20 - /* PRI queue */ - if (smmu->features & ARM_SMMU_FEAT_PRI) { + /* + * PRI queue + * + * Do not enable in a kdump case, as we cannot serve page requests. + */ + if (!is_kdump_kernel() && (smmu->features & ARM_SMMU_FEAT_PRI)) { writeq_relaxed(smmu->priq.q.q_base, smmu->base + ARM_SMMU_PRIQ_BASE); writel_relaxed(smmu->priq.q.llq.prod, @@ -4868,9 +4883,6 @@ static int arm_smmu_device_reset(struct arm_smmu_devi= ce *smmu) return ret; } =20 - if (is_kdump_kernel()) - enables &=3D ~(CR0_EVTQEN | CR0_PRIQEN); - /* Enable the SMMU interface */ enables |=3D CR0_SMMUEN; ret =3D arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010016.outbound.protection.outlook.com [52.101.46.16]) (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 0363E470114 for ; Tue, 21 Jul 2026 19:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663349; cv=fail; b=cTzL2NRsWj+oLG0hKjhVOTNeWgU/7m3Ts6n83xgBNsqhT0ixSG3s06KIHru3D6NC9O06yaRbB1QwuPijrqBDe2e48b7pUUGqesyl4jlwIeUq1R6nIZmLn6uQNBCQyZLG6QqDH2LwLPFBT7XJ9oa110IHPCLBsuidMD04tycZeks= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663349; c=relaxed/simple; bh=Rs7DvUeGH7QMmpEDpD8+3Hv4FOSEKNfgTAi+cEEcdHU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DKR+VZZMd/wrlbax8sN3tLihNdMM5ULoOJF7MEIlyLBNpMksRvwNzOqC8KMv5kIhzfM8BkXXs7cynqiRVtBd7i0EfM9mH6m2dyJN2RwtZU3e+Ykr0mqY2+NEDzPqjafKyr+2Hi3g87BtV/wX26ti1DXKVKf75nMYkv0QlFlGDN0= 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=YleU4jbM; arc=fail smtp.client-ip=52.101.46.16 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="YleU4jbM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ScXZ/0cNwxMYCMYCDET8Tz2EArXaH/8aMHaFzG1Bo6YJPrkm9lMwvlWV8g/KkO49VYKLLa21lpuijnCIInsYM6AA0t1QKt2W9d4ywgPjgGERCJqGB3VTGscu0hpkLMlAQq1PsZZSG/mO+zi3YonLVLnQoe1Z8X4wdHfFdTbW44QhumuWKclDBkIrrKE1JdOlWJWNf2+gXqnlnktcBG3vK//oDoie0YVrAbPVWnXTHKyMUZWm5ftGbPXRkz9H95H+ta4IyD+pYXEMNVS1nVvMv4ay8eok6N3HUDSikEiRFQGP/j/NjqIeAZzygKQ2anPUsos3H1UolrEZ/Uuo6lt4eg== 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=aG2TJvRvZPJ8B/BBpe3JwiMLSypwzwR6aIG99oBYahY=; b=D5KkPaPh728bz7FaAlAF5O7YtOOU4ov15P0nDDql7MzuY3I+WVXf4SG1NoPcsob2gjPLmbPI8S+7V4m3t6mbbD5biRin0oGkWWxYZPEJ7LAddnA9YoJqPyIXaDVVwlbBtEIqmJj9seSzsLTPdUvTQzzMKPf7Y3wl+8HfXq+G2ZIdaX8emenYhU8uxNKnGFkewuf0CdsQMQkK7oqW7UONY5hRN+ADaFvKDHF6mDnURqzzvjIPoAU859KWzy1DkXS0Tx+5JMZlGi4benE/+C482/gRdqWffmQKXK8/OirUCgLuLSYBRs0/O058YQwmS6XNvzC4HcbMlJFTUsKLXSdxaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=aG2TJvRvZPJ8B/BBpe3JwiMLSypwzwR6aIG99oBYahY=; b=YleU4jbMliYQGmtpjheYspb2X6qEsomUluBg1phzPiOX5k6xjFDek1TcFSgOB7IZrEvEQJPtk34PXMVjcL677/g5B8QIqPULaqF+6wXkdmJnfvN86e7PG+JHIQcc+9yJQ1wZJHLo1Q700mZOaKaCog8f+FxNfgSOfTgpyAFavkagG4LpfifKtujuyRI5tVzw17b/if9dquuOEF3OO1ouJRDADNCafPD9z7RFc11jG9ZKCwL/8M/APJi2WLzisglwpmruWIxOTUGg5XKtw1DBEdf6unyBLP4U2vZo5E+6BlJdyS3uyD/Z1qIvSqoPN28Fl/6IOphJoAeEF/+8NlpWXw== Received: from MW4PR04CA0138.namprd04.prod.outlook.com (2603:10b6:303:84::23) by LV8PR12MB9360.namprd12.prod.outlook.com (2603:10b6:408:205::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:49:01 +0000 Received: from SJ1PEPF000023DA.namprd21.prod.outlook.com (2603:10b6:303:84:cafe::a1) by MW4PR04CA0138.outlook.office365.com (2603:10b6:303:84::23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:49:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023DA.mail.protection.outlook.com (10.167.244.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:00 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:38 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 21 Jul 2026 12:48:37 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:37 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 03/12] iommu/arm-smmu-v3: Add strtab parse helpers to a new arm-smmu-v3-kexec.c Date: Tue, 21 Jul 2026 12:48:12 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023DA:EE_|LV8PR12MB9360:EE_ X-MS-Office365-Filtering-Correlation-Id: 64d995ed-4a05-46ef-823d-08dee7611c3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|36860700016|376014|1800799024|5023799004|56012099006|11063799006|10067099003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: C+J0pzNjg51OZvTFmiqvV5mewXoLOULbPjEzfYA/QphHhs2riwxTOCIZk5r869phCZxLQDzYciXt3wqwazIbnqjLChQVX+USCsDmUDZ7p1fpjct8dlpus3NNSs+LpB4hCrXxlys1tCT1KIhok82ER0w5OzwX9NQ6yqwTnCa79erKLVV7cT8vjNQaq+pvts1/88vyZMoWQJ5lmKIbM66njbSk0G1dN4CxN2hmUbep+YNBTAJgLc3BVYZSnrC2Qe7ayhK0bAAi3CCyP3e2t8KmQ/7ZZ9xsY00QbSoV057Rh6zVd8BwctNeCxyogqBDFKKnRds3f2yIO1+6OuEuVRR7K8rCZEutB1ZDtefj6kE+ijN1FJ9miwzaMfzrgWD45ACBmV+FuFeT6hKFiIWvOv95lmzDd9mAm4Bi6wwiqc1HsRlpReiVXA4GRmMrXR/Y3zXUxCgfAmdvaRQzxNxVLBtjC7t72Bswld5qpGWMgNJ8EIFk33rVmSTB7MbyntwheGaFQsp8E3/u7OcR+POVfINdVAiCbgi7KTqRw4Hv7zrXGcAkz/wAlwYpW4Tkht1azLaomoB82eU+9fLfbHpQKutJ4E1m5jRfxc57QNFmZaAvxpRN2EZX2DRrL7qZYsR7qyk9jyrpKERHN1BvzSwXRe57I+AkAF2Aa4JjByuJ8/2vvR3lpx4Zs3v6nc8ztTkWHdFJUgHKj+L5k/0uMl0/y+xO8Q== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(36860700016)(376014)(1800799024)(5023799004)(56012099006)(11063799006)(10067099003)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fRbbgYD4nqdWGJINoHkPMbD/bnl3p2hgO4T+G6iGhFabwiYqyBYeeiQP/ze30VctwuW92uzCXyQq6YUoiO2LbN7B3D0TA/+tR3TuL2+G5jTvUAo8ZT12nqFlgxal6l7s+Xv2f1AgQANTF8bisKb63ByVoJ1qTrZIoZm2Yr7zbjSZavRW0rH/A/2k39nYoD+qBWANAGj1xb2Dx7rbaUnyP6atBzh/Q20f/RuG7bITopAckK8kc/kGQ3wQnv5cD4ONks4sqf5IUlj+jet4anUNcvqsJBdnuclp1rGQ5QfUUqlsFOiohFHtkl5ZqxbNp4L14DcrCXni8XGmAAup9X2K4M9N17ftIkzobBY/IRx2t+su3y6qZsdNxhs95g6wfhvq5ls6MnmRJI8HAlZmugLIdbpJcRA4ndKcVNKB8H6ysA96up0/FFIPtm93NcTyT7V5 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:00.3398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 64d995ed-4a05-46ef-823d-08dee7611c3b 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023DA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9360 Content-Type: text/plain; charset="utf-8" When booting after a kexec, both the kdump adoption and also the in-flight SMMUv3 live-update restoration built on the Kexec Handover (KHO) framework need to parse the previous kernel's STRTAB_BASE/STRTAB_BASE_CFG registers, in order to retain the stream table translating any in-flight DMAs. Add a new arm-smmu-v3-kexec.c holding the common read-only helpers: - arm_smmu_kexec_parse_strtab_2lvl() - arm_smmu_kexec_parse_strtab_linear() - arm_smmu_kexec_check_strtab_l1_desc() These helpers only validate the previous kernel's values against this very kernel's own limits, taking no ownership of the tables: a kdump kernel will adopt the tables via memremaps, while a live-update kernel will claim them using the KHO restore API. Build this new file under a hidden ARM_SMMU_V3_KEXEC Kconfig symbol, which is, for now, merely a CRASH_DUMP. Then, the coming live-update series would need to append its own user to this symbol, e.g. "|| IOMMU_LIVEUPDATE". Suggested-by: Pranjal Shrivastava Assisted-by: Claude:claude-fable-5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/Kconfig | 4 + drivers/iommu/arm/arm-smmu-v3/Makefile | 1 + drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 11 ++ .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c | 159 ++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c diff --git a/drivers/iommu/arm/Kconfig b/drivers/iommu/arm/Kconfig index 5fac08b89deea..04b05d49abf76 100644 --- a/drivers/iommu/arm/Kconfig +++ b/drivers/iommu/arm/Kconfig @@ -109,6 +109,10 @@ config ARM_SMMU_V3_IOMMUFD =20 Say Y here if you are doing development and testing on this feature. =20 +# Common helpers for a kexec'd kernel, e.g. kdump adoption and live update +config ARM_SMMU_V3_KEXEC + def_bool CRASH_DUMP + config ARM_SMMU_V3_KUNIT_TEST tristate "KUnit tests for arm-smmu-v3 driver" if !KUNIT_ALL_TESTS depends on KUNIT diff --git a/drivers/iommu/arm/arm-smmu-v3/Makefile b/drivers/iommu/arm/arm= -smmu-v3/Makefile index 493a659cc66bb..89a27de8dd2f0 100644 --- a/drivers/iommu/arm/arm-smmu-v3/Makefile +++ b/drivers/iommu/arm/arm-smmu-v3/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_ARM_SMMU_V3) +=3D arm_smmu_v3.o arm_smmu_v3-y :=3D arm-smmu-v3.o arm_smmu_v3-$(CONFIG_ARM_SMMU_V3_IOMMUFD) +=3D arm-smmu-v3-iommufd.o arm_smmu_v3-$(CONFIG_ARM_SMMU_V3_SVA) +=3D arm-smmu-v3-sva.o +arm_smmu_v3-$(CONFIG_ARM_SMMU_V3_KEXEC) +=3D arm-smmu-v3-kexec.o arm_smmu_v3-$(CONFIG_TEGRA241_CMDQV) +=3D tegra241-cmdqv.o =20 obj-$(CONFIG_ARM_SMMU_V3_KUNIT_TEST) +=3D arm-smmu-v3-test.o diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index c909c9a88538b..d37492ff08fb3 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -1239,6 +1239,17 @@ tegra241_cmdqv_probe(struct arm_smmu_device *smmu) } #endif /* CONFIG_TEGRA241_CMDQV */ =20 +#ifdef CONFIG_ARM_SMMU_V3_KEXEC +int arm_smmu_kexec_parse_strtab_2lvl(struct arm_smmu_device *smmu, u32 cfg= _reg, + phys_addr_t base, u32 *num_l1_ents); +int arm_smmu_kexec_parse_strtab_linear(struct arm_smmu_device *smmu, + u32 cfg_reg, phys_addr_t base, + u32 *num_ents); +int arm_smmu_kexec_check_strtab_l1_desc(struct arm_smmu_device *smmu, + u64 l1_desc, u32 idx, + phys_addr_t *l2_base); +#endif /* CONFIG_ARM_SMMU_V3_KEXEC */ + struct arm_vsmmu { struct iommufd_viommu core; struct arm_smmu_device *smmu; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c new file mode 100644 index 0000000000000..5346132529427 --- /dev/null +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c @@ -0,0 +1,159 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Common helpers for a kexec'd kernel to parse, validate, and walk throug= h the + * previous kernel's SMMU table structures, shared by the kdump adoption a= nd a + * future live-update restoration. + * + * All of the helpers are read-only against the previous kernel's structur= es: a + * table that is not yet mapped by this kernel gets a transient memremap d= uring + * a walk, followed by an immediate memunmap. They never allocate memory o= r take + * ownership of the previous kernel's tables; the callers make those decis= ions. + */ + +#include + +#include "arm-smmu-v3.h" + +/** + * arm_smmu_kexec_parse_strtab_2lvl() - Validate a 2-level stream table + * @smmu: SMMU device of this kernel + * @cfg_reg: STRTAB_BASE_CFG register value set by the previous kernel + * @base: stream table base address extracted from the STRTAB_BASE register + * @num_l1_ents: pointer to return the number of L1 entries + * + * Validate the 2-level stream table geometry in @cfg_reg and @base's alig= nment + * against this kernel's hardware limits. + * + * Return: 0 on success with @num_l1_ents set, or -EINVAL on a bad geometry + */ +int arm_smmu_kexec_parse_strtab_2lvl(struct arm_smmu_device *smmu, u32 cfg= _reg, + phys_addr_t base, u32 *num_l1_ents) +{ + u32 log2size =3D FIELD_GET(STRTAB_BASE_CFG_LOG2SIZE, cfg_reg); + u32 split =3D FIELD_GET(STRTAB_BASE_CFG_SPLIT, cfg_reg); + u32 num_ents; + size_t size; + + if (log2size < split || log2size > smmu->sid_bits) { + dev_err(smmu->dev, "log2size %u out of range [%u, %u]\n", + log2size, split, smmu->sid_bits); + return -EINVAL; + } + if (split !=3D STRTAB_SPLIT) { + dev_err(smmu->dev, + "unsupported STRTAB_SPLIT %u (expected %u)\n", split, + STRTAB_SPLIT); + return -EINVAL; + } + + num_ents =3D 1U << (log2size - split); + if (num_ents > STRTAB_MAX_L1_ENTRIES) { + dev_err(smmu->dev, "l1 entries %u exceeds max %u\n", num_ents, + STRTAB_MAX_L1_ENTRIES); + return -EINVAL; + } + + size =3D num_ents * sizeof(struct arm_smmu_strtab_l1); + /* + * HW aligns the base down to the L1 table size (min 64 bytes), so any + * unaligned base would make this kernel read a different table. + */ + if (!IS_ALIGNED(base, size)) { + dev_err(smmu->dev, "unaligned l1 stream table base %pa\n", + &base); + return -EINVAL; + } + + *num_l1_ents =3D num_ents; + return 0; +} + +/** + * arm_smmu_kexec_parse_strtab_linear() - Validate a linear stream table + * @smmu: SMMU device of this kernel + * @cfg_reg: STRTAB_BASE_CFG register value set by the previous kernel + * @base: stream table base address extracted from the STRTAB_BASE register + * @num_ents: pointer to return the number of STEs + * + * Validate the linear stream table geometry in @cfg_reg and @base's align= ment + * against this kernel's own limits. + * + * Return: 0 on success with @num_ents set, or -EINVAL on a bad geometry + */ +int arm_smmu_kexec_parse_strtab_linear(struct arm_smmu_device *smmu, + u32 cfg_reg, phys_addr_t base, + u32 *num_ents) +{ + u32 log2size =3D FIELD_GET(STRTAB_BASE_CFG_LOG2SIZE, cfg_reg); + unsigned int max_log2size =3D smmu->sid_bits; + size_t size; + + /* Cap the size at what this kernel itself would have allocated */ + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) + max_log2size =3D min_t( + unsigned int, max_log2size, + ilog2(STRTAB_MAX_L1_ENTRIES * STRTAB_NUM_L2_STES)); + + /* num_ents is limited to a u32, so cap log2size at 31 */ + max_log2size =3D min(max_log2size, 31U); + if (log2size > max_log2size) { + dev_err(smmu->dev, "unsupported log2size %u (> %u)\n", log2size, + max_log2size); + return -EINVAL; + } + + size =3D (1U << log2size) * sizeof(struct arm_smmu_ste); + /* + * HW aligns the base down to the table size, ignoring the low bits, so + * an unaligned base would make this kernel read a different table. + */ + if (!IS_ALIGNED(base, size)) { + dev_err(smmu->dev, "unaligned stream table base %pa\n", &base); + return -EINVAL; + } + + *num_ents =3D 1U << log2size; + return 0; +} + +/** + * arm_smmu_kexec_check_strtab_l1_desc() - Check one stream table L1 descr= iptor + * @smmu: SMMU device of this kernel + * @l1_desc: L1 descriptor value from the previous kernel's stream table + * @idx: index of the L1 descriptor, for diagnostics + * @l2_base: pointer to return the L2 table's physical address + * + * Return: 1 if the descriptor is unused, 0 if it is valid with @l2_base s= et, or + * -EINVAL if it is malformed + */ +int arm_smmu_kexec_check_strtab_l1_desc(struct arm_smmu_device *smmu, + u64 l1_desc, u32 idx, + phys_addr_t *l2_base) +{ + phys_addr_t base =3D l1_desc & STRTAB_L1_DESC_L2PTR_MASK; + u32 span =3D FIELD_GET(STRTAB_L1_DESC_SPAN, l1_desc); + + /* L1STD.L2Ptr is invalid */ + if (!span) + return 1; + + if (span !=3D STRTAB_SPLIT + 1) { + dev_err(smmu->dev, "L1[%u] unsupported span %u (vs %u)\n", idx, + span, STRTAB_SPLIT + 1); + return -EINVAL; + } + + /* + * A valid descriptor never carries a null pointer. Also, HW aligns the + * pointer down to the L2 table size, so an unaligned pointer would make + * this kernel read a different table. + */ + if (!base || !IS_ALIGNED(base, sizeof(struct arm_smmu_strtab_l2))) { + dev_err(smmu->dev, "L1[%u] bad l2 table base %pa\n", idx, + &base); + return -EINVAL; + } + + *l2_base =3D base; + return 0; +} --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012037.outbound.protection.outlook.com [52.101.53.37]) (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 C4059415F15 for ; Tue, 21 Jul 2026 19:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663349; cv=fail; b=WQfbqTxEWhqfxUiObF5Cv5uiW/hjC4/1dDV8Jo3UgFqda99MM+oDwM/9/cWI3sxtV14aDgulIKfjvwco53nOrkg9g5P4QLyjnaMnZMcdUrrSnUy/e+5jTWaHKlM51OGlnKWBI7sZci49bzNcm1VoNWOxUl/iMpzBmBroJ3mWnJ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663349; c=relaxed/simple; bh=OfH0bJaeZr+vpC/haNdJ8CMxCKin7cRkMjNZHM9YOTM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c2B7dQhNHDyy+KC+yh335C+Zmx4zAxZ1acdZiFgMsHeAJNu2goUl+TTJqn0uLEZ3uvTQ0kHzI5VfQy+eDF4ZtKjVmqgR+JJT+EmTlQlv3goupM48l8IB8RfoO/k6anIVHjqaGu+MfjqR4qGcfsD1cTXSl2Rsv2LpdNIBE9CQ8VM= 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=i34/m4mD; arc=fail smtp.client-ip=52.101.53.37 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="i34/m4mD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lt6ycrO9XOz9jZJgMafzkWR1Lo7g/lcRXso1Vox4RxSm/V+6V3YdeUeGfS4QNWEiLQ/mLLIG3/WV+fcPKXcGjzuZB5KXIZxyy7Z5Al90+iyFDPfkeateZvn7B20sReyEk+tSuhtJ1yAd77YXweWWfBnk1+sWQQ7CjkXOb6jdL370HKFDZ9vrxSBoaDl3g9rqZ6dKJJGPF3N1JxiCyeE8xibzMHN3y1TOC25XKEwv/P6BgaE7Dgj3MHungCiEHvIhq4cgeJ+M85CADpOq8HPXlLoa/Rc2w6sGQ7wP6sWqr3Qr5BjfC0juNVUfKaNFvmFJjXLAGwd1X8U90qnLUSbnsw== 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=bb2AuwMR956f2t0mR3cpc+t14D0NTx5BpcAZd2a4/Ig=; b=FPxFUpWOCmF0adxBEpD16MPv1JrhL+gouDurY2P/tDs09oFI6FsNPGN0eniIe8wQLzfo+EMmkBqkgV89FE9d2xcUw9WD58XMer/99PsfNEJhhtpCrlvvc+JPsGA0WBzTH6xP7jL6cAsM1gr28huEQSEC7JVGZJvCrqMWrAOS2D/hqDOzV7UA9NJB2O3zINujzS/7d6vvb/L5xct7lZpDxQEDMODRq7AngkruWWb6eVG5waOszUhnU+l5y7aIfadTkvwUaCrbut5k2FpN1FqnLNPIShoWh3hR75QiZVCvshqcGMxjm+Zc0nsIFXqiExwbJVwsBnE0cO2FRJUvFpL4cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=bb2AuwMR956f2t0mR3cpc+t14D0NTx5BpcAZd2a4/Ig=; b=i34/m4mDdmFZcbEuhEuZ1njJ1lj+qr57A3dBK231WL9CwAxihbcwurLYBeaQ+17jy5i5OXkZycy4dtmFn4FR2CRsdH2cXo+gv8QpKuLdmUkJH3ZUq8u5kTd0dFmZq5E7ZM9JVB/HYMeUFcMcx612BccShm/bMJWoHbdA6j0uckYYxMobhJpP3Qp4Lc7sjbW9shP29xAB3qPFF5S/Q90lxKpcE5dhT6ahOXBdWPOC5EP103acMPumzynYIkiISOM+SoLYmpjB7WkbIm0pX6tEOTePC4FbxvukzDX4CSrFXOgeWyTnrUOJKY+5FcB9fvmKhXnhoT9wHsnO0K3gtcgZsg== Received: from PH8P222CA0003.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:2d7::18) by IA1PR12MB6388.namprd12.prod.outlook.com (2603:10b6:208:388::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:49:02 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:510:2d7:cafe::f) by PH8P222CA0003.outlook.office365.com (2603:10b6:510:2d7::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:49:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:01 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:39 -0700 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.20; Tue, 21 Jul 2026 12:48:38 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:38 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 04/12] iommu/arm-smmu-v3: Destroy vmid_map ida via devres Date: Tue, 21 Jul 2026 12:48:13 -0700 Message-ID: <8b0978c9376f20519a7b827e7e0789dfd86e3b14.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|IA1PR12MB6388:EE_ X-MS-Office365-Filtering-Correlation-Id: 648a7565-b25b-4599-81e8-08dee7611d01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|376014|82310400026|36860700016|1800799024|6133799003|11063799006|56012099006|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 7a6D1sUHxJdqsEKhkyqOMiTmqWkyeSqByJFboy6dClZZgBk1lIy94QsKIWThr1VGVrbWlxtFWZiqh0AWPqWJXA7JXHCTC8qBZx7M73Lr6cy8kuf4jZO4QoQzQYgleGTxDwVGQnL80kcgbK9deD/3AH7sggRdMHAKihtAyMoUsW7xfk16EWWqfvQ7ZQtc4fyH9BDg2su2Bww9QQ46h9JM7RHuGBxmbZu+PlqdFrQa/kO1GcaAIvbzeyuq47/xmKm9RI1u+utddf7H7YqHJ4X93aChiTWuIWzWylyK/bO4W9GId8F7bZLxJwppEg0ctTPxX1AhQ2HWlL4+klPtildLbo3lDDjZHrAlS+sJaTVp1nz1wKcizVXquhw+J49Ucazky/uhwvlJsWU7PP6dDGvvjWZsRby9pnFrOCCZXlAn9d9kyIK348EmNVZGl+6VSs87/b9kdSJ/OlaaazacjJ6A3dnIC72FQr2g+ihUtxhoMFdIGuHoq9LxEMN3jaDltcGeHO3LHTc2PhJb4S65NgH5BBMbt4wra5OB0Ga4iwgtPKlOzw0cnYnc/TaDfpA6Q9fKNF8Eil6F3FSIB6h2Fm/P05yb/+xEpFjaxSKwoo7xzZJST3uK8foe5j/l/epLZLzgimxVIXxhNrvlpfniyYUoOJ7Jg7OdtYMSYLlJ+NkilKn8QsEQuYkMBqkeHXc4eT4AgXyEZXDKVLEaATeabxXIOA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(23010399003)(376014)(82310400026)(36860700016)(1800799024)(6133799003)(11063799006)(56012099006)(10067099003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m9vTzeeGXHUcywcKJkbvxt5j2bQLDSp3Y7X5NaZxY/Ufm5lJE+BZqr4y+uyjtKRPSN78eCEVsPFJtTmJeGyHBnvRN8CNFjmEVR4czYMAmYNxtZG0WMSe10V4lbX2HgyPASGLSPPSdEf51vKTE+QnDymz18oWE6Bvn8nMIr9LxRypb7vr6TJrEKT7QM8G2V7wLZasM4zT0G7oqyUFpDeKJiE+kHlfiejcdkOEY+upCMqvZcGseERex/Jph4+4StYLU8eUVqfpQpX+xNluK6xskqLQFFVLM397YRf82kd9l3W3aBEaREwhAqu46nvDBSIlDLr4A8Gw4AAO225sd3PvvSGauajDvWT9+8g3pyOgYyVXFixpSypxEoeYaHLienkqFVvUcjHwrV3ZPDTTxJaNSZUOim2+QAu017E0+2SFytU6ct8y46CWnKIn8YD+yfAb X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:01.6338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 648a7565-b25b-4599-81e8-08dee7611d01 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6388 Content-Type: text/plain; charset="utf-8" The vmid_map ida is only destroyed in arm_smmu_device_remove(), which does not run when the probe fails. This is currently harmless, as the ida stays empty until the first S2 domain allocation, which can only happen after a successful probe. An upcoming change will start reserving the crashed kernel's VMIDs in this ida, at the probe time of a kdump kernel. A probe failure would then leak the ida's internal allocations. Register a devres action right after ida_init(), making devres the single owner that covers both the unbind and probe failure paths. Also, move the ida_init() call to the entry of arm_smmu_init_strtab(), as the reservation will run in the adoption path prior to the regular stream table setup. Assisted-by: Claude:claude-fable-5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 132bee5fbb1d1..0df6c17a53173 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -4494,20 +4494,27 @@ static int arm_smmu_init_strtab_linear(struct arm_s= mmu_device *smmu) return 0; } =20 +static void arm_smmu_deinit_strtab(void *data) +{ + struct arm_smmu_device *smmu =3D data; + + ida_destroy(&smmu->vmid_map); +} + static int arm_smmu_init_strtab(struct arm_smmu_device *smmu) { int ret; =20 + ida_init(&smmu->vmid_map); + ret =3D devm_add_action_or_reset(smmu->dev, arm_smmu_deinit_strtab, smmu); + if (ret) + return ret; + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) ret =3D arm_smmu_init_strtab_2lvl(smmu); else ret =3D arm_smmu_init_strtab_linear(smmu); - if (ret) - return ret; - - ida_init(&smmu->vmid_map); - - return 0; + return ret; } =20 static int arm_smmu_init_structures(struct arm_smmu_device *smmu) @@ -5548,7 +5555,6 @@ static void arm_smmu_device_remove(struct platform_de= vice *pdev) iommu_device_sysfs_remove(&smmu->iommu); arm_smmu_device_disable(smmu); iopf_queue_free(smmu->evtq.iopf); - ida_destroy(&smmu->vmid_map); } =20 static void arm_smmu_device_shutdown(struct platform_device *pdev) --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010056.outbound.protection.outlook.com [52.101.46.56]) (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 2747147044C for ; Tue, 21 Jul 2026 19:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663352; cv=fail; b=DAhUrEpS+TyHIFBGjS0lAUnFaHUnl8mSU43YNcGijyVuB+Qh2nLzgo4jvdh5COD2ytr9IKMFQigP+dQNilnMgoiXjx1a0cV5r0mzwCc/MreUDKfcCGtw+WWyM6PYkX7l4ojHuPj9WsNhFP3CecPyXT82ZqLTWXgZbTItq+TrTyY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663352; c=relaxed/simple; bh=jDv7SO26W36epWHtdiP7mqa6kNhzzmk9zgj/AsJQvCk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OXrlDdDYZXzph1kJU63q0UTeszIYVnJcWjkpY/ybqj/BtIlzEGP/QqgfgEDWojoQGkhBPb0JYE0LIox0/K3sa7KtX4JcUizAHrezFJ0VmfMrxBfHJnR81AzXZa3xDvDg5nLnLwcRp9oVg0vuSVYzrGolN4vvi2sS97xsatSePj0= 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=iw9hHmbz; arc=fail smtp.client-ip=52.101.46.56 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="iw9hHmbz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=am+l1QLVrN2NjDTtMxf763MQ76rmH3gYO4FyFAz7LTGwIe8zO1zOY6sfluoXki7q6VHqqy/ZB0raQsWcHzO7MZ5tNoSBaOtyaPkDh2Een4/+4h8iZXOdFSqAvsSbhZDnEEf3reovLukMPHSPvwfUqKv95KrAumzf3LR5GKa5UXvzCYslJ2g4x6snMwCD4djyv5XCqNjol4l6xbHiIZhfCdjuVqzrX0aQMbSSyCQFxUEeXY45ly9eJhCJolkXFukveVSrjt5Rfy6v3WRQoXlGWHwjDKmCQ1gd+/MwdhjG7L96eXxUPAtKnFOrjGugEeM9mWcP5fNcH1q1v/Ja4vtJbQ== 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=rDqTOEeOxEoxHNaj3sN5TWxJkCnPsLl51DR2wI56fT0=; b=Tx4SXSDJfMibyheqsPN54hmTmmTa+tSP9+uvKKNUW8LREqAbnuNEkhTtjzgHJSVfOwLeeJu2iMFSenKlb9jb+UBQQdtcFf/w5qM+2RbvaU7GdRPvBg8UbJDTbYg/c8UKkyUSO41BFsSMSTUlJjZewXd/3/B4vg39g+bwr7TffqRZxuIgwCnJgkZsUwSMajIdae9sY0Zc4x+rkjHMzSRql4Jt9Gurb5nDld0noFrLmW9ApM6F+m/HUGmlW2wI/gTRoWDpU+RhHQark7NNdR2OvLI5nNxkAnLTYsAIMJ4tRyRgxEHH0fSyo/Dr0xN4BkYeN/R3xgpz1hCDvo7gIO8Aww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=rDqTOEeOxEoxHNaj3sN5TWxJkCnPsLl51DR2wI56fT0=; b=iw9hHmbzKJX2msg5UXElfa7wni1xGicBONNcWap/ZpvXcpyUM0QooD/CI8HgAGCC56cwpQGI6FS+wiMX0uM1Uu6yS1WGGVVf4nQ9jhzL291jlOB6DDF6VU1R7y0XY/BvuMtDLftqkT2E9fm+MtDR49fN3cRX3zBp9MsC+vGrvmgjOL3o6z0jX3hkxuIQ4aXNaD0gAwbgzj38MIo0LW5p7Kuxfc+xvdNjVVmBEU7QdIiB++v6vT2g3EpRAmitpnp6X0hi54lr4hpcVD8xa3HQVxeFn+I2YznNgZxn79u6fKMJ5zt1sgoDn23XOUbUvoOsaeFWUa58TzRlzCzXqCou7w== Received: from PH8P222CA0022.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:2d7::33) by SJ2PR12MB8112.namprd12.prod.outlook.com (2603:10b6:a03:4f8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Tue, 21 Jul 2026 19:49:04 +0000 Received: from SJ1PEPF000023D3.namprd21.prod.outlook.com (2603:10b6:510:2d7:cafe::2a) by PH8P222CA0022.outlook.office365.com (2603:10b6:510:2d7::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:49:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023D3.mail.protection.outlook.com (10.167.244.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:02 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:40 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 21 Jul 2026 12:48:39 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:39 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 05/12] iommu/arm-smmu-v3: Add ARM_SMMU_OPT_KDUMP_ADOPT for kdump kernel Date: Tue, 21 Jul 2026 12:48:14 -0700 Message-ID: <6fbd503d7476f01455fb61d8d9dae6188ec1739f.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D3:EE_|SJ2PR12MB8112:EE_ X-MS-Office365-Filtering-Correlation-Id: 09dad02e-2a3b-4aa5-ebc8-08dee7611dcb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|82310400026|36860700016|376014|5023799004|11063799006|56012099006|10067099003|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: Q8ejTCexLFTzuzIhbDyMwnqpkYjRY8d9uP3e+zBBWljorT3GvKDOtATUXOwTocYckQ7SdeAxo9uVnMNG01TTJj55bFaEC54gDyCjWy0PP5fG5ecrlpAqQFjxQJ/v27ZEkzXG3Frg/kzYkpEhViQAVASw2hC8vHi2OwjEdw1UbDiEsIoDvkOWoNWAN3T2oVpRcIU2ukLdHSjAOWXizIYYp1vz8klWqnKNZeDTIY9DqPSngH33QF3sMD1dl2QCF1WEi4nWdQxkgx9GbGK7IIoCw2edYGRA+0gfkxaaNBp48POElx5TeJgEkvwOYQnSe2luhe5kbHNVZEBvxcJy9/l7nUj7X5lNtBm3rszouC1nA1mfM0B6+dBN+APZuP7PcFORIieyRE4cCrIuDwksOYy2s28suZz92CAKvP3r/VS7NNc76GXnvuQP6xzjQVKorRsNyRpIPy5ahrbPcjnmQgRHyxvLLIZjyBlKpL+DHsy+HO5v1tx3xpaOnFNKb0nCdFfuHe81Ewy555bKDK970IWwAv4Z4KXzacMCKyRMD5AOtmYuYVMQmbEqlHnjyBPykkBzpJeIDADqdmTxOp/Y9mi+SLhmCll3QKplszcJzXbDeldYkG0amHfaW4tnNTYcUJCbprgMDdjkyNtD8h9I7SXqMvk6nRlbrrWgZT4A1qWORcPvJR2NMG/U/WCwnuiN5Yzn/34M2j4duOKP0yRDOPfKMg== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(82310400026)(36860700016)(376014)(5023799004)(11063799006)(56012099006)(10067099003)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OF30FguaUVO9VAXK1nJuniIGqi0UJdL0kgnZkW14INFlrNKi70EhJwB+bpATlc0946kWV3lBTtPriYkKq7F9UKaCliTBvUrQ+bvgbk2LnA2nuN/VxmHpFm8nZGw4bdivHPEv+t8ylCqle2F2bKCSHBIYhfSiL4Zjm42nRS+bt9rQ2Prs2jTx2iVvOyP36MHMuAOY7ilMWg/UhrzHQCWUB0nrljVrLp1E/3PKIjYy+AwTg/i0dCyH11dQeVD7H2nlRfAQTFXZfeqP/P3hUIB+TKhZ84W/6TQGRiipwVAEWMJ9nW4EUgRue/UQJpaSlQHXoTh2TcIni3vZM5kBUdXzh+jbCjLoUh0hSE91BBZrP3fhKVt0RRYoHiZ7mLSgm2Bqt4eOG9FDE/OttpxtfVR7M85Q5Y/Z7IxGCFp/cRsfElpPOqOWRSUiwM/0oxVBAOfo X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:02.9613 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09dad02e-2a3b-4aa5-ebc8-08dee7611dcb 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D3.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8112 Content-Type: text/plain; charset="utf-8" When transitioning to a kdump kernel, the primary kernel might have crashed while endpoint devices were actively bus-mastering DMA. Currently, the SMMU driver aggressively resets the hardware during probe by clearing CR0_SMMUEN and setting the Global Bypass Attribute (GBPA) to ABORT. In a kdump scenario, this aggressive reset is highly destructive: a) If GBPA is set to ABORT, in-flight DMA will be aborted, generating fatal PCIe AER or SErrors that may panic the kdump kernel b) If GBPA is set to BYPASS, in-flight DMA targeting some IOVAs will bypass the SMMU and corrupt the physical memory at those 1:1 mapped IOVAs. To safely absorb in-flight DMAs, a kdump kernel will have to leave SMMUEN= =3D1 intact and avoid modifying STRTAB_BASE, allowing HW to continue translating in-flight DMAs reusing the crashed kernel's page tables until the endpoint device drivers probe and quiesce their respective hardware. However, the ARM SMMUv3 architecture specification states that updating the SMMU_STRTAB_BASE register while SMMUEN =3D=3D 1 is UNPREDICTABLE or ignored. This leaves a kdump kernel no choice but to adopt the stream table from the crashed kernel. Introduce ARM_SMMU_OPT_KDUMP_ADOPT and adopt functions memremapping all the stream tables extracted from STRTAB_BASE and STRTAB_BASE_CFG. Add them in a new arm-smmu-v3-kdump.c, which is only built when CONFIG_CRASH_DUMP=3Dy. Note that the adoption of the crashed kernel's stream table follows certain strict rules, since the old stream table might be compromised. Thus, apply some basic validations against the values read from the registers. If tests fail, it means the stream table cannot be trusted, so toss it entirely. To avoid OOM due to a potentially corrupted stream table, the memremap for l2 tables is done lazily on the kdump kernel's demand. The new option will be set in a following change, once the device reset and the RMR setup are reworked not to overwrite the adopted stream table, and the crashed kernel's in-use ASIDs and VMIDs are reserved. Suggested-by: Jason Gunthorpe Assisted-by: Claude:claude-fable-5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/Makefile | 1 + drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 21 ++ .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c | 229 ++++++++++++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 21 +- 4 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c diff --git a/drivers/iommu/arm/arm-smmu-v3/Makefile b/drivers/iommu/arm/arm= -smmu-v3/Makefile index 89a27de8dd2f0..2bc52473d960e 100644 --- a/drivers/iommu/arm/arm-smmu-v3/Makefile +++ b/drivers/iommu/arm/arm-smmu-v3/Makefile @@ -4,6 +4,7 @@ arm_smmu_v3-y :=3D arm-smmu-v3.o arm_smmu_v3-$(CONFIG_ARM_SMMU_V3_IOMMUFD) +=3D arm-smmu-v3-iommufd.o arm_smmu_v3-$(CONFIG_ARM_SMMU_V3_SVA) +=3D arm-smmu-v3-sva.o arm_smmu_v3-$(CONFIG_ARM_SMMU_V3_KEXEC) +=3D arm-smmu-v3-kexec.o +arm_smmu_v3-$(CONFIG_CRASH_DUMP) +=3D arm-smmu-v3-kdump.o arm_smmu_v3-$(CONFIG_TEGRA241_CMDQV) +=3D tegra241-cmdqv.o =20 obj-$(CONFIG_ARM_SMMU_V3_KUNIT_TEST) +=3D arm-smmu-v3-test.o diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index d37492ff08fb3..6ef307335d80c 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -928,6 +928,7 @@ struct arm_smmu_device { #define ARM_SMMU_OPT_MSIPOLL (1 << 2) #define ARM_SMMU_OPT_CMDQ_FORCE_SYNC (1 << 3) #define ARM_SMMU_OPT_TEGRA241_CMDQV (1 << 4) +#define ARM_SMMU_OPT_KDUMP_ADOPT (1 << 5) u32 options; =20 struct arm_smmu_cmdq cmdq; @@ -1250,6 +1251,26 @@ int arm_smmu_kexec_check_strtab_l1_desc(struct arm_s= mmu_device *smmu, phys_addr_t *l2_base); #endif /* CONFIG_ARM_SMMU_V3_KEXEC */ =20 +#ifdef CONFIG_CRASH_DUMP +int arm_smmu_kdump_adopt_strtab(struct arm_smmu_device *smmu); +int arm_smmu_kdump_adopt_deferred_l2_strtab(struct arm_smmu_device *smmu, + u32 sid, phys_addr_t base, u32 span, + struct arm_smmu_strtab_l2 **l2table); +#else /* CONFIG_CRASH_DUMP */ +static inline int arm_smmu_kdump_adopt_strtab(struct arm_smmu_device *smmu) +{ + return -EOPNOTSUPP; +} + +static inline int +arm_smmu_kdump_adopt_deferred_l2_strtab(struct arm_smmu_device *smmu, u32 = sid, + phys_addr_t base, u32 span, + struct arm_smmu_strtab_l2 **l2table) +{ + return -EOPNOTSUPP; +} +#endif /* CONFIG_CRASH_DUMP */ + struct arm_vsmmu { struct iommufd_viommu core; struct arm_smmu_device *smmu; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c new file mode 100644 index 0000000000000..a074d59ce3445 --- /dev/null +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c @@ -0,0 +1,229 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Implementation of the kdump stream table adoption for ARM SMMUv3 + * + * When the crashed kernel left the SMMU enabled with in-flight DMAs, the = kdump + * kernel adopts the crashed kernel's stream tables, instead of doing a re= gular + * reset, to keep in-flight DMAs translating until the endpoint device dri= vers + * re-probe and quiesce their devices. + * + * Note: + * - Adoption only starts on an SMMU that the crashed kernel left enabled= , as a + * disabled SMMU (CR0_SMMUEN=3D0) could hold meaningless register value= s. + * - Values read from the crashed kernel's registers get structural valid= ation + * only (format, size, span, alignment, and ID range); the physical add= resses + * are not vetted, as the kdump kernel has no record of which pages hel= d the + * tables. + * - A structural inconsistency at adoption time tosses the entire adopti= on and + * makes the SMMU fall back to a full reset blocking in-flight DMAs. + * - L2 stream tables are adopted lazily at master-inserting time, to bou= nd the + * peak memory use against a corrupted L1 table; any lazy L2 adoption f= ailure + * rejects that device alone, as its blast radius is bounded to the bus. + * - Only a coherent SMMU (ARM_SMMU_FEAT_COHERENCY) is supported, as the = stream + * table adoption is done by memremap with MEMREMAP_WB, which is verifi= ed on + * the real hardware. Callers of these functions are responsible for ga= ting + * ARM_SMMU_FEAT_COHERENCY once during the probe. + */ + +#define dev_fmt(fmt) "kdump: " fmt + +#include +#include + +#include "arm-smmu-v3.h" + +int arm_smmu_kdump_adopt_deferred_l2_strtab(struct arm_smmu_device *smmu, + u32 sid, phys_addr_t base, u32 span, + struct arm_smmu_strtab_l2 **l2table) +{ + struct arm_smmu_strtab_l2 *table; + size_t size; + + /* + * Retest the span in case the L1 descriptor has been overwritten since + * the adopt. Reject this master's insert; panic or SMMU-disable would + * either lose the vmcore or cascade aborts. Do not try to fix it, as it + * would break all other SIDs in the same bus (PCI case). The corruption + * blast radius is already bounded to that bus range. + */ + if (span !=3D STRTAB_SPLIT + 1) { + dev_err(smmu->dev, + "L1[%u] span %u changed since adopt (was %u)\n", + arm_smmu_strtab_l1_idx(sid), span, STRTAB_SPLIT + 1); + return -EINVAL; + } + + size =3D (1UL << (span - 1)) * sizeof(struct arm_smmu_ste); + + /* Same live-corruption check as the span; reject an overwritten base */ + if (!base || !IS_ALIGNED(base, size)) { + dev_err(smmu->dev, "L1[%u] bad l2 table base %pa\n", + arm_smmu_strtab_l1_idx(sid), &base); + return -EINVAL; + } + + /* + * This L2 table is mapped lazily per master; devres frees it at unbind, + * as with the dmam_alloc_coherent() used for a fresh L2. + */ + table =3D devm_memremap(smmu->dev, base, size, MEMREMAP_WB); + if (IS_ERR(table)) { + dev_err(smmu->dev, + "failed to adopt l2 stream table for SID %u\n", sid); + return PTR_ERR(table); + } + + *l2table =3D table; + return 0; +} + +static int arm_smmu_kdump_adopt_strtab_2lvl(struct arm_smmu_device *smmu, + u32 cfg_reg, phys_addr_t base) +{ + struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; + u32 num_l1_ents; + size_t size; + int ret, i; + + ret =3D arm_smmu_kexec_parse_strtab_2lvl(smmu, cfg_reg, base, + &num_l1_ents); + if (ret) + return ret; + + cfg->l2.num_l1_ents =3D num_l1_ents; + + size =3D num_l1_ents * sizeof(struct arm_smmu_strtab_l1); + cfg->l2.l1tab =3D memremap(base, size, MEMREMAP_WB); + if (!cfg->l2.l1tab) + return -ENOMEM; + + cfg->l2.l2ptrs =3D + kcalloc(num_l1_ents, sizeof(*cfg->l2.l2ptrs), GFP_KERNEL); + if (!cfg->l2.l2ptrs) + return -ENOMEM; + + for (i =3D 0; i < num_l1_ents; i++) { + u64 l2ptr =3D le64_to_cpu(cfg->l2.l1tab[i].l2ptr); + phys_addr_t l2_base; + + ret =3D arm_smmu_kexec_check_strtab_l1_desc(smmu, l2ptr, i, + &l2_base); + if (ret < 0) + return ret; + + /* + * If the crashed kernel's l1 descriptors are deeply corrupted, + * blindly memremapping every l2 table here could lead to OOM. + * + * Defer the l2 memremap to arm_smmu_init_l2_strtab(), so peak + * memory is bounded by the kdump kernel's actual demand. + */ + } + + return 0; +} + +static int arm_smmu_kdump_adopt_strtab_linear(struct arm_smmu_device *smmu, + u32 cfg_reg, phys_addr_t base) +{ + struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; + u32 num_ents; + size_t size; + int ret; + + ret =3D arm_smmu_kexec_parse_strtab_linear(smmu, cfg_reg, base, + &num_ents); + if (ret) + return ret; + + /* + * We might end up with a num_ents !=3D sid_bits, which is fine, since the + * ARM_SMMU_OPT_KDUMP_ADOPT case bypasses arm_smmu_write_strtab(). + */ + cfg->linear.num_ents =3D num_ents; + + size =3D num_ents * sizeof(struct arm_smmu_ste); + cfg->linear.table =3D memremap(base, size, MEMREMAP_WB); + if (!cfg->linear.table) + return -ENOMEM; + return 0; +} + +static void arm_smmu_kdump_adopt_cleanup(void *data) +{ + struct arm_smmu_device *smmu =3D data; + struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; + + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) { + kfree(cfg->l2.l2ptrs); + if (cfg->l2.l1tab) + memunmap(cfg->l2.l1tab); + } else { + if (cfg->linear.table) + memunmap(cfg->linear.table); + } +} + +int arm_smmu_kdump_adopt_strtab(struct arm_smmu_device *smmu) +{ + u32 cfg_reg =3D readl_relaxed(smmu->base + ARM_SMMU_STRTAB_BASE_CFG); + u64 base_reg =3D readq_relaxed(smmu->base + ARM_SMMU_STRTAB_BASE); + bool was_2lvl =3D smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB; + phys_addr_t base =3D base_reg & STRTAB_BASE_ADDR_MASK; + u32 fmt =3D FIELD_GET(STRTAB_BASE_CFG_FMT, cfg_reg); + int ret; + + dev_dbg(smmu->dev, "adopting crashed kernel's stream table\n"); + + if (fmt =3D=3D STRTAB_BASE_CFG_FMT_2LVL) { + /* + * Both kernels run on the same hardware, so it's impossible for + * kdump kernel to see the support for linear stream table only. + */ + if (WARN_ON(!(smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB))) + ret =3D -EINVAL; + else + ret =3D arm_smmu_kdump_adopt_strtab_2lvl(smmu, cfg_reg, + base); + } else if (fmt =3D=3D STRTAB_BASE_CFG_FMT_LINEAR) { + /* + * The kdump kernel need not match the crashed kernel. An older + * crashed kernel that predates two-level stream table support + * may have used a linear table on 2-level-capable hardware, so + * enforce the same format here to match the adopted table. + */ + ret =3D arm_smmu_kdump_adopt_strtab_linear(smmu, cfg_reg, base); + if (!ret) + smmu->features &=3D ~ARM_SMMU_FEAT_2_LVL_STRTAB; + } else { + dev_err(smmu->dev, "invalid STRTAB format %u\n", fmt); + ret =3D -EINVAL; + } + + if (ret) { + arm_smmu_kdump_adopt_cleanup(smmu); + goto err; + } + + ret =3D devm_add_action_or_reset(smmu->dev, arm_smmu_kdump_adopt_cleanup, + smmu); + /* devm_add_action_or_reset ran the cleanup upon failure */ + if (ret) { + dev_warn(smmu->dev, "failed to set up cleanup action\n"); + goto err; + } + + return 0; + +err: + dev_warn(smmu->dev, "falling back to full reset\n"); + /* + * Undo the linear adoption's clearing of FEAT_2_LVL_STRTAB so that the + * full-reset fallback uses the hardware-supported format. + */ + if (was_2lvl) + smmu->features |=3D ARM_SMMU_FEAT_2_LVL_STRTAB; + memset(&smmu->strtab_cfg, 0, sizeof(smmu->strtab_cfg)); + smmu->options &=3D ~ARM_SMMU_OPT_KDUMP_ADOPT; + return ret; +} diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 0df6c17a53173..b768080c04db4 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -1938,11 +1938,23 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_= device *smmu, u32 sid) dma_addr_t l2ptr_dma; struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; struct arm_smmu_strtab_l2 **l2table; + u32 l1_idx =3D arm_smmu_strtab_l1_idx(sid); =20 - l2table =3D &cfg->l2.l2ptrs[arm_smmu_strtab_l1_idx(sid)]; + l2table =3D &cfg->l2.l2ptrs[l1_idx]; if (*l2table) return 0; =20 + /* Deferred adoption of the crashed kernel's L2 table */ + if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) { + u64 l2ptr =3D le64_to_cpu(cfg->l2.l1tab[l1_idx].l2ptr); + phys_addr_t base =3D l2ptr & STRTAB_L1_DESC_L2PTR_MASK; + u32 span =3D FIELD_GET(STRTAB_L1_DESC_SPAN, l2ptr); + + if (span) + return arm_smmu_kdump_adopt_deferred_l2_strtab( + smmu, sid, base, span, l2table); + } + *l2table =3D dmam_alloc_coherent(smmu->dev, sizeof(**l2table), &l2ptr_dma, GFP_KERNEL); if (!*l2table) { @@ -1954,8 +1966,7 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_de= vice *smmu, u32 sid) =20 arm_smmu_init_initial_stes((*l2table)->stes, ARRAY_SIZE((*l2table)->stes)); - arm_smmu_write_strtab_l1_desc(&cfg->l2.l1tab[arm_smmu_strtab_l1_idx(sid)], - l2ptr_dma); + arm_smmu_write_strtab_l1_desc(&cfg->l2.l1tab[l1_idx], l2ptr_dma); return 0; } =20 @@ -4510,6 +4521,10 @@ static int arm_smmu_init_strtab(struct arm_smmu_devi= ce *smmu) if (ret) return ret; =20 + if ((smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) && + !arm_smmu_kdump_adopt_strtab(smmu)) + return 0; + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) ret =3D arm_smmu_init_strtab_2lvl(smmu); else --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010002.outbound.protection.outlook.com [52.101.85.2]) (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 BED52284662 for ; Tue, 21 Jul 2026 19:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.2 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663353; cv=fail; b=WZ6Vg1hC2412owlI/M5uvpv8t5FoCBGPd+Mqb3nIgw3HzqSyMNYP2c6MnwDYnFXzYDSY1US2dzaEotJMNq/oKEJDAyEscxdiDyUZq3hSaKQXHml7oKkLsmnBsWSAtVTlXCU8gaAPtRcvv/asp4vFl5gYzL5Geq8yDahItMTosW0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663353; c=relaxed/simple; bh=835Lkyo+MHF72rc63MjWw58AsNuy8pUgvx9Z8I0fglA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fEW7zctMUWktLlr39gKEBVFdKwY/KwlKl3DiX5pTcCOMoCY9Q/Ak7RkiPQNQQfwgTev2n6uun7GuSArVNpO4jreV0iesn9OUaADALOHHXP3fV21CVKh9XNr+yISfzFGSJcXgWRYL2c67fyFApRAm4irXs2J+IxGSbfoBfPuLK4A= 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=E8uak/HX; arc=fail smtp.client-ip=52.101.85.2 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="E8uak/HX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CLa5fGmMrlKn0yv7ofrIzY7BblREu9pa9P9uZ2yDzQK/r4ou9fY5XyoThFaALVIp+XFJbkkfWQ/lkfjqvWzPFfN3ePAt80F6P27/DN5c9yGO1z9mHBvYfj9Kc8hhB/bX/Lgv+twoF3Z/Wsj75Jrch2y41XbXZmOXLwf46F4F8KhMLaXe79YYLZd89McmHrfVLk//+bdlRPRdLyBFHLnbiafK1JNZNJW+YiuQVFSr/cDScHchMFs5q7HTv84XYcTD47Woj3oLNvFzFJAZBFJX2eFg9xT/eI+KMXHn622PpXumQWQV9LmgJQfqNNLn5HWCc8pmY7QtY1Z15EFXfCLriw== 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=yVy+yX/ubX8hOdAfXkTta1FxAkjsEQOIqE+K3yToyoo=; b=NkLsu1s3wHSCHJ+xigF0yfx3yyF6pu1m6/hxp21QkHNi323WtzYDYGlbG4l3NNm2EgIdSUFOamozhGxhomLCx0yz7VTsu0s5F61E1hPv7E1TbWc5vINx4apYNXmH+UkgpwEaTjOTTYJwK69JXgEMD/UjjXSIBaSqe+pCJS/O06fObsayfDNJ2+radHF/Sdw5iGvsb2MVqZdDLk0Cknu5VmPk0j5Oa/mM2FHOex5RjMsfmbGsdfgniu9SIjA3Sk0OKFMdXxFsPzcmwhnqQB2y9iRDoCWJOmQNViyshXs4Ux0l9Z5Mvnsu3DFOyCyclyciDY8j++Oi/ZP/IAYG4gI1WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=yVy+yX/ubX8hOdAfXkTta1FxAkjsEQOIqE+K3yToyoo=; b=E8uak/HX74YujJisezTyO1frPkG+mBJolhpZaOY6+3SVSu7iUldVd13+0Loneb9zBKBPtHodRxqXqUY4F+FEhTxNswadsujksrE5DrScrW681uijVntacvd7BEHhiqrm8VFpRSYzQyPQDZt5eodQg4tUFEbvbzqJ0vOwhviFUOAT9FrhA2ZOmjv/oadhGSyfr+kUOVhWG6CSA0VZyGQsVPEi0J3OEfu7mfuziHuCbP4viHqPkaPeTjfS8/E7FCk+QlZAcHb2b2RZ68S9R1PbH3rJRa1oUi9cOAWcj06oi5VAeRc7dJ10YXGozHpbFS/PF+Xe/3mBfUcLvYa0Cb4hDg== Received: from MW4PR03CA0019.namprd03.prod.outlook.com (2603:10b6:303:8f::24) by SJ1PR12MB6170.namprd12.prod.outlook.com (2603:10b6:a03:45b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:49:05 +0000 Received: from SJ1PEPF000023D8.namprd21.prod.outlook.com (2603:10b6:303:8f:cafe::37) by MW4PR03CA0019.outlook.office365.com (2603:10b6:303:8f::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.16 via Frontend Transport; Tue, 21 Jul 2026 19:49:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023D8.mail.protection.outlook.com (10.167.244.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:04 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:41 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 21 Jul 2026 12:48:40 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:40 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 06/12] iommu/arm-smmu-v3-kexec: Add a CD table parse helper Date: Tue, 21 Jul 2026 12:48:15 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D8:EE_|SJ1PR12MB6170:EE_ X-MS-Office365-Filtering-Correlation-Id: 5777252d-afc2-4626-67c6-08dee7611eea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|23010399003|82310400026|36860700016|6133799003|22082099003|18002099003|3023799007|56012099006|11063799006|5023799004|10067099003; X-Microsoft-Antispam-Message-Info: KRaKwiVu8nJTwGfvcKQpQoyKxfbb8o/vM4Te1+yRJVBbY9tTA4XdrjHmd7gBCSY+u/wvg9bBt8B2/YYebsBUMrETRHunx6O6HbiKsHym2vxZYyfBOGI/6IXF3k++yjY6bSmHjjXUOIMB+5iWmM4hrb6AUpLtHRIfUEy/Cb/WirJOmgqr9rLajwA3Ncf1PQkJ0dUhAlt5ZfiANV+V2DP88Ce4Zcwl7wGxDPXWL3kD5yuaLmM/xnSrY/VDVj7dhzcwQqG9mqBP7bRMJb2ZkrklJtoBoCj4OIKd/hOJoIEWHd9NrmFTgkEQaHdYvW3qdDGCqOsGVxxRa6gib1YfEjHfjYtwNyTbS8MZhq8RF3kqTnUhtysrnpBeCTlpy4OYGRwLQLN8mNh4q3VY0LgIcICR1bUMfqvj5d+CbvenKrgG9RowLhsj4CaYKH7GrPuSeY7FadkdRZqenChpB/HYNHhF/UMiMMNRRY9ijeYOphkDliajuU4KhqQJSChbEciz0z7/956U6GE0nA+FyBcple5TQwHk5agAmy+bf+m+mWWsaUnUe1c1Q9mPWDJmY1qlpZqKrxEgxu7dDACrTdxS7CZIEhyeVhVHgilvnZYt2BKeYIOPvItRbhm26iII/JUH6njUjXEREMdtdjZthoTAvTwuQYKXHZACb/j4EpIP5CaelPaBpa+bD2uh1AYy6BcE1ecySw7aRQ+aDw2rNye1OuKEbQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(23010399003)(82310400026)(36860700016)(6133799003)(22082099003)(18002099003)(3023799007)(56012099006)(11063799006)(5023799004)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /KRny7zZIkO+5F3iKYwJzzsjGPJF40ZwkbmXX6m8rtEuVZqpMQJLF+uZ317nIO05PEtLqRbfF3n4TXTQpJd6AUtRXfuAEJ877MpuUNb66mGcsJaLrxu9qjy4XFgdnheg6/1S7z7XDOvbcbe7AIdpDtJ0ytvl02uNnYJtcyhuXenBapYzeQYHVyHv13yOb1VYdg7LAkwEpIQW2FcqVOyC75ZXLLsbHcdnhSwp36GrGqne8SPqzm9yuYFurmiBcN5SnX9kmlDx6CG19zSeeDQEa3JcUk7iSdx89iMUtMi/UOQrl7SDq8Qp2BLr8p7aQ1VRnM8oYl41q2vb9DHliLXo/Zkth2MVuAgcqB5cl5UwKxHnAPKhsyJb/rhtlV9snwo/ULNMTUfCcB6dy+f79XNFIeoOPEy9I1Xl5YcE/fJlilpe0lOh37VWimxOI4Dj7ifF X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:04.8409 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5777252d-afc2-4626-67c6-08dee7611eea 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6170 Content-Type: text/plain; charset="utf-8" An S1 STE points to a CD table that both of the kexec flavors decode: the kdump adoption scans the CD table to reserve all the in-use ASIDs, and the live-update restoration claims the CD table via the KHO restore API. Add another read-only helper to the arm-smmu-v3-kexec.c: - arm_smmu_kexec_check_ste_cdtab() It validates the CD table geometry in an S1 STE against this kernel's own ssid_bits and the 2-level HW capability. And it accepts a linear CD table on the 2-level capable HW too, since a previous kernel might have used one, like the linear stream table. Assisted-by: Claude:claude-fable-5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 ++ .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index 6ef307335d80c..183c617ecb273 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -1249,6 +1249,9 @@ int arm_smmu_kexec_parse_strtab_linear(struct arm_smm= u_device *smmu, int arm_smmu_kexec_check_strtab_l1_desc(struct arm_smmu_device *smmu, u64 l1_desc, u32 idx, phys_addr_t *l2_base); +int arm_smmu_kexec_check_ste_cdtab(struct arm_smmu_device *smmu, u64 ste0, + phys_addr_t *cdtab, u32 *s1fmt, + u32 *max_contexts); #endif /* CONFIG_ARM_SMMU_V3_KEXEC */ =20 #ifdef CONFIG_CRASH_DUMP diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c index 5346132529427..5ad1fe1922eec 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c @@ -157,3 +157,45 @@ int arm_smmu_kexec_check_strtab_l1_desc(struct arm_smm= u_device *smmu, *l2_base =3D base; return 0; } + +/** + * arm_smmu_kexec_check_ste_cdtab() - Decode the CD table geometry of an S= TE + * @smmu: SMMU device of this kernel + * @ste0: first 64 bits of the previous kernel's S1 STE + * @cdtab: pointer to return the CD table's physical address + * @s1fmt: pointer to return the CD table format + * @max_contexts: pointer to return the number of CDs + * + * Note that a linear CD table on the 2-level capable hardware is accepted= , as a + * previous kernel might have used one, like the linear stream table. + * + * Also, as the CD tables are supposed to be read-only, @cdtab is not vali= dated + * against the table size, but only carries the field's own 64-byte alignm= ent. + * + * Return: 0 on success with the three outputs set, or -EINVAL on a bad ge= ometry + */ +int arm_smmu_kexec_check_ste_cdtab(struct arm_smmu_device *smmu, u64 ste0, + phys_addr_t *cdtab, u32 *s1fmt, + u32 *max_contexts) +{ + phys_addr_t base =3D ste0 & STRTAB_STE_0_S1CTXPTR_MASK; + u32 s1cdmax =3D FIELD_GET(STRTAB_STE_0_S1CDMAX, ste0); + u32 fmt =3D FIELD_GET(STRTAB_STE_0_S1FMT, ste0); + + if (!base || s1cdmax > smmu->ssid_bits) + return -EINVAL; + + if (fmt !=3D STRTAB_STE_0_S1FMT_LINEAR && + fmt !=3D STRTAB_STE_0_S1FMT_64K_L2) + return -EINVAL; + + /* Both kernels run on the same HW, so a genuine STE never has this */ + if (fmt =3D=3D STRTAB_STE_0_S1FMT_64K_L2 && + !(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB)) + return -EINVAL; + + *cdtab =3D base; + *s1fmt =3D fmt; + *max_contexts =3D 1U << s1cdmax; + return 0; +} --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010066.outbound.protection.outlook.com [52.101.85.66]) (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 5F7023644B3 for ; Tue, 21 Jul 2026 19:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663355; cv=fail; b=bAMxwdkEBo+kJtTi0SXdrYGRqroBjEezbj6ppsT5yFSJ50wURRu3KqC3IJ7TuYdElqbrqBkduCAcaesFykdyrz4ZbLviPzVx410PhGjpCf8uaVeI1Auqtkwm0FlCbs3rpUPKdGL6sZngexTDTAhx8TERBHpOGwv9a7nC7DdcZKg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663355; c=relaxed/simple; bh=4wCklL54HSnpnvinSTViaJcQQ2SrT1rK45YcbQNinQo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DMCgFF/jmxVBA0KiGAKZUVay0bdvwRlTDmjsORhq+iEm9tCnI3Cf5HUGgcwxSd4ZsZ291ApGgwJOEo5lh3PGstzLoaepNMSTpgw4rurK0yNFd3YLD4oRhLhdt3EwK+8ZYrKQ3CNiVeI26b53OjAYJpiXGVv0xxFppDVYzxatunU= 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=L1Tz8HVv; arc=fail smtp.client-ip=52.101.85.66 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="L1Tz8HVv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vnXWZrKaDm2OfiIZxl7DnWBf7E2ffjdcFG+c0kwdlVms1rdy9ic+LJ+FPx1qTMTvxXmkkvwnr9DVKRNCaOap8Nc3kGO9L5xPiMhqfWtnv0k33sOYVAftWjH2gUplkQfKIy2I4KMCt1PmWLR7lEc3Zsj3pgrIcDmLEHTNaOSgkZo9c2FbzSuMZt8ftgVROjtYcM5Q1a/ULBcXdm/tJOFcqJ8n0ezM/W3GN2ouBbz/J0rleH2J9rR+4NRpRVpD7Z6eqO5JhVL5RpSz7VswuJ36knY608x8pAObbfB5y9tmLFcgKYoEqEfOd4vTAiAhCiv3aBOLzQfD7pFuS11ig0MtnQ== 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=xkMTKLfdZBkXqZk2HurJE1+UugIL2nuqDFL3byqoIZE=; b=Fw8DnyiHZfzMK4lrA3pHEBAxmZjx3qOExqlJc1fxVCmCMOBKcl/mzBnKyM6P0oqDAVNaKvmi8IVRaOlNJDJmd05S2IYntx1rNFKNMIfcjKB924WoBiMHS0x2dOHxKc56ZkKAe6A1ZAzPGgr8r/KVDUkwAdo01m2g86jYp/qzRG+6nv9dtN3XmR9noIZdQTWRN4uGB7UMOqcr+VUhuofplo7TRoIFzd+WkcCDuwoUs0yOuz+sHmlndyJ5QdPfLPMcfE4UdkxoMnF3aiOcq7/EDIf/1+gKtu5OXa2yRhPsWekNjCjiehw91O+WdCVqDyaSwiuFtWGRlNbb3d23IMkRig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=xkMTKLfdZBkXqZk2HurJE1+UugIL2nuqDFL3byqoIZE=; b=L1Tz8HVvPkl9TakM37zsupMqWBpRLikPROEXGVx0m9mAdWBENSncDJrvPrsdP5br7bATLGtc96aNBIYBxXVkX3MSxh9F90ZFagloBeAQr571SC86UW0Wm1CUoiC9MofTSnJ71Lcq7W7DpVEtw7nynu0qRE/mJ8lsD4VFp7FvyTeDSOEuIyETyN0P71+JNK/Va6a9WBM0IVtPtKwPLk2ZwJV6pB41nJJ5YTfTiNp3TNto4sLZCXu0nnduzSB9W1FpnX9lWAgsb03WBAtBl8H3rQYigH39Z12zuyQ4KUNZ9GK9AV1+ACTqJxdDW/icxevEL5Ok3hdWMH7vKmP01aw2AQ== Received: from PH8P223CA0027.NAMP223.PROD.OUTLOOK.COM (2603:10b6:510:2db::22) by SN7PR12MB8102.namprd12.prod.outlook.com (2603:10b6:806:359::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:49:06 +0000 Received: from SJ1PEPF000023D7.namprd21.prod.outlook.com (2603:10b6:510:2db:cafe::1d) by PH8P223CA0027.outlook.office365.com (2603:10b6:510:2db::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:49:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023D7.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:05 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:42 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 21 Jul 2026 12:48:41 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:41 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 07/12] iommu/arm-smmu-v3-kexec: Add ASID/VMID reservation helpers Date: Tue, 21 Jul 2026 12:48:16 -0700 Message-ID: <9f9d227c0adf472e93293008e7083973688d015e.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D7:EE_|SN7PR12MB8102:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d69b445-1724-4fe9-5639-08dee7611f73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|1800799024|376014|36860700016|10067099003|6133799003|11063799006|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: spy38LJ+JuAdFPjU4i+bB9HTvbavaNjlgRoZ7FSexiHEfvKwkiAROUnGMyp1MxUCoJZ6+8am0RShQz1es5xzi5hqdLnNAalhfjTH6qIYh1KeXDd59BOzPF5iBuxvJZpB8ShIFkrqk5M++LMN57jE1Z7akJNGVuo/WjBxiTGoEYtLK4Y2Xh/lvAvcMTqEGGktt1Wurxr+LrG+jtV+3Tn2BBXD3k3dduNtkrzCit6o/Z7UFzX6ezpxNZqTo/MibF5mU8jgR0xOGl0mhvqGvhRyBkQSzPhKFpES9NiHrRJsDVQSNhNuwaMiJSq76buL2K2nRA1bIGachBsOXHuq9NikedWBlNti/iQW1KshHZSZ+U4mYd85Ej5XBXoQga7oiJhEEqPavshk06w8u6u1aRAup2RELR2JQ7e8OVia/4jRJoMrbmAEWdDQKaVuKjlaE5uVE1VfosroK9vLoZpHM4GYDDtOoi6YyLKsu63JkSoJgrR5s008j5l+ZXLTI8Sf17Xo6k6pH2OtRUZkUZa45fH14O2JMY9glgcIB4Bo2ZV6xxIbYoYz1OTKZcK8w+NfhIiU/esDWz+VAjQHqc+rFUVJxkouVAGmLDeh6vEhBCzrlFq9VjdQufvpIMlRlvg4oV1Bbl60XO6X/4qOPZVKt3JY+3twVY3zVVOGJlljwpcvcAzgmzz6Bs/5s1OYKXZJJTiGtopkPuqcE/YQ6R6Q9k1VDA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(1800799024)(376014)(36860700016)(10067099003)(6133799003)(11063799006)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bFL1wCH5Dr/tpIQApnli8WE2lAik7C93wV6+tDYAMuwhnIyHb+U4JKTbYTgo8hRBRfzit1usJHI1qePST3EURUNWg8VC3q6uRZDpTBhNs8AL0TWftR61xU0kOuGVy4iZ7lswDVB8F68O+4jv2nJmql+zgpjny6EQhUc1Oc+rBLa4MGTRvuvzSSqMRF8MoL057j9xzNKvcHNZX6Bim+Y+gC9F2PR3tDDNq478ZOx4uk+8lbTEQGKD8ZBh4IDyab4etz9CZxEdoYmV8HJth5tJ45s3ucx0lJwYwfvhYzxau31K387LqSFEtlukDy9YsXqG5pm03m3WW6xV/a3rOQmL2cJsxVLO+cIksi/ynaYrDejP6mSSdZ2Qrvj/wBqYCh2OcRu0vFyPVpfthbdpKTo2Vx/l8FY5W2jluFNEC9u+0FZn67tYw2vJ3wlu8ZTGhQ1P X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:05.7412 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d69b445-1724-4fe9-5639-08dee7611f73 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8102 Content-Type: text/plain; charset="utf-8" An adopted stream table keeps translating in-flight DMAs, so the SMMU also keeps caching the TLB entries tagged with the previous kernel's ASIDs and VMIDs. Any kexec flavor retaining those translations must reserve all the in-use IDs, so that this kernel cannot ever give any of its own domains an overlapping ID that would alias the previous kernel's cached TLB entries. Add the reservation helpers to arm-smmu-v3-kexec.c: - arm_smmu_kexec_scan_and_resv_ids() - arm_smmu_kexec_unresv_ids() At adoption time, arm_smmu_kexec_scan_and_resv_ids() runs a one-off scan: walking the stream table set up in the strtab_cfg and every CD table behind an S1 STE, it reserves the ASIDs in the asid xarray and the S2VMIDs in the vmid ida. The scan memremaps each table transiently, which is a necessity even for a live update: the ID reservation must be complete by the end of the SMMU probe itself, before this kernel starts allocating any ID for its own domains, yet the CD tables are only claimed when their masters get to re-probe, long after that point. Thus, the scan cannot rely on any claimed mapping and must map each table by itself. The scan walks untrusted tables, yet every loop is strictly index-bounded: the iteration counts derive from the log2size and s1cdmax fields, which are validated against this kernel's own sid_bits and ssid_bits, so a corrupted table cannot extend the walk. Since both kernels allocate ASIDs from 1, reserving any in-use ASID would often find it already taken in the xarray, either by another scan or by a live domain. A reservation made by another scan is permanent, so it is safe to rely on. A live domain will free its ASID for reuse at some point, and the scan must then fail and fall back. To tell these two cases apart, store the per-scan ID as an xarray value entry: a value entry identifies another scan's reservation and a pointer entry identifies a live domain. Note that the scan ID scopes a failing scan's rollback to exactly the entries that it inserted, so a rollback cannot erase another scan's reservations. Also add an arm_smmu_kexec_resv_lock mutex serializing entire scans and any rollback of failing ones, so that a concurrently probing SMMU can only rely on the reservations that will persist. Assisted-by: Claude:claude-fable-5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 4 + .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c | 260 ++++++++++++++++++ 2 files changed, 264 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index 183c617ecb273..5c03de5aed27b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -1241,6 +1241,8 @@ tegra241_cmdqv_probe(struct arm_smmu_device *smmu) #endif /* CONFIG_TEGRA241_CMDQV */ =20 #ifdef CONFIG_ARM_SMMU_V3_KEXEC +extern struct mutex arm_smmu_kexec_resv_lock; + int arm_smmu_kexec_parse_strtab_2lvl(struct arm_smmu_device *smmu, u32 cfg= _reg, phys_addr_t base, u32 *num_l1_ents); int arm_smmu_kexec_parse_strtab_linear(struct arm_smmu_device *smmu, @@ -1252,6 +1254,8 @@ int arm_smmu_kexec_check_strtab_l1_desc(struct arm_sm= mu_device *smmu, int arm_smmu_kexec_check_ste_cdtab(struct arm_smmu_device *smmu, u64 ste0, phys_addr_t *cdtab, u32 *s1fmt, u32 *max_contexts); +int arm_smmu_kexec_scan_and_resv_ids(struct arm_smmu_device *smmu); +void arm_smmu_kexec_unresv_ids(struct arm_smmu_device *smmu); #endif /* CONFIG_ARM_SMMU_V3_KEXEC */ =20 #ifdef CONFIG_CRASH_DUMP diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c index 5ad1fe1922eec..582192ab8390c 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kexec.c @@ -199,3 +199,263 @@ int arm_smmu_kexec_check_ste_cdtab(struct arm_smmu_de= vice *smmu, u64 ste0, *max_contexts =3D 1U << s1cdmax; return 0; } + +/* + * Identifies the ASID reservations of an arm_smmu_kexec_scan_and_resv_ids= call. + * + * A failing scan can only roll back its own insertions. Two scans of the = same + * SMMU (e.g. a probe retry) must not share an ID, as the retried scan may= fail + * and roll back, while the prior one's committed reservations must persis= t. So + * it must not be a per-SMMU value, but a per-scan one. + * + * Serialized by arm_smmu_kexec_resv_lock. + */ +static unsigned long arm_smmu_kexec_scan_id; +DEFINE_MUTEX(arm_smmu_kexec_resv_lock); + +static int arm_smmu_kexec_resv_asid(struct arm_smmu_device *smmu, u32 asid) +{ + int ret; + + /* A valid CD never has ASID 0; both kernels share the same HW limit */ + if (!asid || asid >=3D 1UL << smmu->asid_bits) + return -EINVAL; + + guard(mutex)(&arm_smmu_asid_lock); + + /* The value entry marks the ASID as in-use and identifies its scan */ + ret =3D xa_insert(&arm_smmu_asid_xa, asid, + xa_mk_value(arm_smmu_kexec_scan_id), GFP_KERNEL); + /* + * An -EBUSY against a value entry safely shares a permanent reservation + * made by another scan. A pointer entry means a live domain that will + * free its ASID for reuse eventually: keep -EBUSY to fail the scan. + */ + if (ret =3D=3D -EBUSY && xa_is_value(xa_load(&arm_smmu_asid_xa, asid))) + ret =3D 0; + return ret; +} + +static int arm_smmu_kexec_resv_vmid(struct arm_smmu_device *smmu, u32 vmid) +{ + int ret; + + /* A translating STE never has VMID 0, which is reserved for bypass */ + if (!vmid || vmid >=3D 1UL << smmu->vmid_bits) + return -EINVAL; + + ret =3D ida_alloc_range(&smmu->vmid_map, vmid, vmid, GFP_KERNEL); + if (ret < 0 && ret !=3D -ENOSPC) /* -ENOSPC means already reserved */ + return ret; + return 0; +} + +static int arm_smmu_kexec_resv_cd_asids(struct arm_smmu_device *smmu, + struct arm_smmu_cd *cds, u32 num_cds) +{ + int ret =3D 0; + u32 i; + + for (i =3D 0; i < num_cds; i++) { + u64 val =3D le64_to_cpu(cds[i].data[0]); + u32 asid =3D FIELD_GET(CTXDESC_CD_0_ASID, val); + + if (!(val & CTXDESC_CD_0_V)) + continue; + ret =3D arm_smmu_kexec_resv_asid(smmu, asid); + if (ret) + break; + } + return ret; +} + +/* + * Reserve the ASIDs of all the valid CDs of an S1 STE in the previous ker= nel's + * CD tables. The CD tables are transiently memremapped for the scan. + */ +static int arm_smmu_kexec_resv_s1_asids(struct arm_smmu_device *smmu, u64 = ste0) +{ + struct arm_smmu_cdtab_l1 *l1tab; + u32 num_l1_ents, num_cds, i; + u32 max_contexts, s1fmt; + phys_addr_t cdtab; + int ret; + + ret =3D arm_smmu_kexec_check_ste_cdtab(smmu, ste0, &cdtab, &s1fmt, + &max_contexts); + if (ret) + return ret; + + if (s1fmt =3D=3D STRTAB_STE_0_S1FMT_LINEAR) { + struct arm_smmu_cd *cds; + + cds =3D memremap(cdtab, max_contexts * sizeof(*cds), MEMREMAP_WB); + if (!cds) + return -ENOMEM; + ret =3D arm_smmu_kexec_resv_cd_asids(smmu, cds, max_contexts); + memunmap(cds); + return ret; + } + + num_l1_ents =3D DIV_ROUND_UP(max_contexts, CTXDESC_L2_ENTRIES); + l1tab =3D memremap(cdtab, num_l1_ents * sizeof(*l1tab), MEMREMAP_WB); + if (!l1tab) + return -ENOMEM; + + /* max_contexts being under a full leaf makes the only leaf partial */ + num_cds =3D min_t(u32, max_contexts, CTXDESC_L2_ENTRIES); + + /* Aliased L2 tables cannot extend the walk; they only repeat a scan */ + for (i =3D 0; i < num_l1_ents; i++) { + u64 l1_desc =3D le64_to_cpu(l1tab[i].l2ptr); + phys_addr_t l2_base =3D l1_desc & CTXDESC_L1_DESC_L2PTR_MASK; + struct arm_smmu_cdtab_l2 *l2; + + if (!(l1_desc & CTXDESC_L1_DESC_V)) + continue; + + /* A valid descriptor never carries a null pointer */ + if (!l2_base) { + ret =3D -EINVAL; + break; + } + + l2 =3D memremap(l2_base, num_cds * sizeof(*l2->cds), MEMREMAP_WB); + if (!l2) { + ret =3D -ENOMEM; + break; + } + ret =3D arm_smmu_kexec_resv_cd_asids(smmu, l2->cds, num_cds); + memunmap(l2); + if (ret) + break; + } + memunmap(l1tab); + return ret; +} + +static int arm_smmu_kexec_resv_ste_ids(struct arm_smmu_device *smmu, + struct arm_smmu_ste *ste) +{ + u32 vmid =3D FIELD_GET(STRTAB_STE_2_S2VMID, le64_to_cpu(ste->data[2])); + u64 ste0 =3D le64_to_cpu(ste->data[0]); + + if (!(ste0 & STRTAB_STE_0_V)) + return 0; + + switch (FIELD_GET(STRTAB_STE_0_CFG, ste0)) { + case STRTAB_STE_0_CFG_ABORT: + case STRTAB_STE_0_CFG_BYPASS: + return 0; + case STRTAB_STE_0_CFG_S1_TRANS: + return arm_smmu_kexec_resv_s1_asids(smmu, ste0); + case STRTAB_STE_0_CFG_NESTED: + /* + * A guest-owned CD table is in the IPA space, unreachable. Its + * ASIDs are only tagged with the S2VMID reserved below, so they + * cannot alias this kernel's VMID-0 or EL2 S1 domains. + */ + fallthrough; + case STRTAB_STE_0_CFG_S2_TRANS: + return arm_smmu_kexec_resv_vmid(smmu, vmid); + default: + return -EINVAL; + } +} + +/** + * arm_smmu_kexec_scan_and_resv_ids() - Reserve a stream table's in-use IDs + * @smmu: SMMU device of this kernel, with an adopted or restored strtab_c= fg + * + * Scan the stream table set up in the strtab_cfg and every CD table behin= d an + * S1 STE, reserving all of the in-use ASIDs and VMIDs. The caller must ho= ld the + * arm_smmu_kexec_resv_lock, so that a failing scan can roll back, prior t= o any + * concurrent scan, via arm_smmu_kexec_unresv_ids(). + * + * Note that the scan selects the linear or 2-level walk per this kernel's= own + * ARM_SMMU_FEAT_2_LVL_STRTAB, so the caller must have matched the feature= bit + * to the format of the adopted stream table in the strtab_cfg. + * + * Return: 0 on success, -EINVAL on any malformed table entry, or -ENOMEM = on a + * memory shortage + */ +int arm_smmu_kexec_scan_and_resv_ids(struct arm_smmu_device *smmu) +{ + struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; + int ret =3D 0; + u32 i, j; + + lockdep_assert_held(&arm_smmu_kexec_resv_lock); + + /* Allocate a new ID for this scan, to scope its rollback */ + arm_smmu_kexec_scan_id++; + + if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB)) { + for (i =3D 0; i < cfg->linear.num_ents; i++) { + ret =3D arm_smmu_kexec_resv_ste_ids( + smmu, &cfg->linear.table[i]); + if (ret) + return ret; + } + return 0; + } + + /* Aliased L2 tables cannot extend the scan; they only repeat a scan */ + for (i =3D 0; i < cfg->l2.num_l1_ents; i++) { + u64 l1_desc =3D le64_to_cpu(cfg->l2.l1tab[i].l2ptr); + struct arm_smmu_strtab_l2 *l2; + phys_addr_t base; + + ret =3D arm_smmu_kexec_check_strtab_l1_desc(smmu, l1_desc, i, + &base); + if (ret =3D=3D 1) + continue; + if (ret) + return ret; + + /* + * This kernel will map the previous kernel's L2 tables lazily + * or not at all. Here, take a transient view for this scan. + */ + l2 =3D memremap(base, sizeof(*l2), MEMREMAP_WB); + if (!l2) + return -ENOMEM; + for (j =3D 0; j < ARRAY_SIZE(l2->stes); j++) { + ret =3D arm_smmu_kexec_resv_ste_ids(smmu, &l2->stes[j]); + if (ret) + break; + } + memunmap(l2); + if (ret) + return ret; + } + return 0; +} + +/** + * arm_smmu_kexec_unresv_ids() - Roll back a failing reservation scan + * @smmu: SMMU device of this kernel that failed its reservation scan + * + * Roll back the current scan for a failing arm_smmu_kexec_scan_and_resv_i= ds() + * call, typically to a full reset. + * + * arm_smmu_kexec_resv_lock must be held for arm_smmu_kexec_scan_and_resv_= ids() + * and the roll back. + */ +void arm_smmu_kexec_unresv_ids(struct arm_smmu_device *smmu) +{ + unsigned long index; + void *entry; + + lockdep_assert_held(&arm_smmu_kexec_resv_lock); + + mutex_lock(&arm_smmu_asid_lock); + xa_for_each(&arm_smmu_asid_xa, index, entry) { + if (entry =3D=3D xa_mk_value(arm_smmu_kexec_scan_id)) + xa_erase(&arm_smmu_asid_xa, index); + } + mutex_unlock(&arm_smmu_asid_lock); + + /* No domain exists yet, so the ida holds only the reservations */ + ida_destroy(&smmu->vmid_map); +} --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010013.outbound.protection.outlook.com [52.101.85.13]) (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 9872D472F66 for ; Tue, 21 Jul 2026 19:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663358; cv=fail; b=TAk0doSz4wIFStemxV2f8eU3bBMnIV49fxWjpIvM4dtFB5A/hpGmsdXoKJHicDitIU51C4LXmGzO/YBdsm7dmcyAAqJ5ehealzEk0Q7pZUhWT6yOR90RFm8FveL/BhZmwG6FzyZKvwhBdnznbc70QABzxLaJ3XfVELra6ki/hZE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663358; c=relaxed/simple; bh=kPDydixpSkpAqhIfk0ShAc5jTd5/fVQ5Hd2kVGVL228=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r/Bup60ZPgLJVX6bR7kszrCa2bNyLOjsVgG9Vb8Xr3oZxxqDnz/TTZSjaEvLThm1pu7Tqdps8nt9nsNAy5l+f3Tr8J6hNZknFwouFE6I+OQT8ah6vA/0VpCDpcnb+fn8nG7wG2AFIZvErpkdivlMDKadKwF6/YEFasVOuEi5c+A= 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=Vk3RsjNZ; arc=fail smtp.client-ip=52.101.85.13 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="Vk3RsjNZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ie5ObF5Rid57RKdO5h2H5xLHpGg6N/4lEEFa/Su8gOAs4vKeq0xxjAmtvqdEj/PlZ5Ea7Mc3Pq1ZbPHoW+lvsYXoJHN2l1Eg6oKTWTLak38JIPo8FPN4xNt4k7meJjr3EWUxy4kXNQRFWTlFrvoA0cwMd32FxYc0FgAPXd1lCAUsRKfBY0bXQulxMXK7NLdK0OUtnFkyvCWRD5as46jQRPDcFQGe7Qwg3IFfBvMBxneAU0CVSBba7bGOuSDsXCZWP3Jy+W+kygyOnqqeTW0ahHGiVwNw/hR/IrHJetAnBaqJB5/5rn8IEq+D2KWyHZWuaF8WMUz2Alo1xtzgJ013NQ== 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=RuSRKrfgYqJkyN0UJbZ3icPKwC/5GQZhFz848vY+zlA=; b=QS2rqGMBOAYMRvd6X2gMWLWjNIWxn4Tsk8e/ZV1QDZszZiDIWL81WHYhONhs8q1IpoovsDUX8aWpbs3Z1SXnGXCDbmgh+3aVRgoCPG9TcNdLilWyhCJoIJqjOYRsTPk2vLgd+lyyDsH6lyxazm02Vuj2aPEdTzxG8dBEd7DXElEilTWh+8wdaLzZeG8EpltMMSMz2brrTXQUPF17l90aO4YlfNe0vus4AuEz07b8UJIX8fH4eIC+LMYCgJVoF8qvW0YbshGMRrAYbTAZ18anmhIbV1/fu6mdYpvetBBXDiYKD+9+kc/0FrZ/bG9QJ1WtKmnP+8KYaJVFbDbYZ1GtcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=RuSRKrfgYqJkyN0UJbZ3icPKwC/5GQZhFz848vY+zlA=; b=Vk3RsjNZPevKvY1bCXAxMD5Kv5DzPS3Mdp0Co5napfNNc/qcZ8gIzCkdKMNne4jPAUcPLaQAP0kfIf/Ore8IATnkI5O0SLP6FYDSiASuyzhCT995i2c8i3IwkM3CJQLCsxAtTWLd1H75tuk1BpoN4ATbfB1x0lO6CDijQO67xs1FX3d8ljYEWgWWlR3CgFh+5ifYLDpBQwUS+2ORzDswmPIH5c9sMOYPmLMRJfydj8+g06+vrMaboO37ikVWFTKF+Rmz8RQaKWDZEO1ySr2mn5hYXBlsBpB0KUGxpWQWhetQ9WKQnOTYqQ7miUgTIqNxgLK15aiFXxd4IkjoFbwCWw== Received: from BY1P220CA0020.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::7) by SA5PPFE494AA682.namprd12.prod.outlook.com (2603:10b6:80f:fc04::8e7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:49:08 +0000 Received: from SJ1PEPF000023D9.namprd21.prod.outlook.com (2603:10b6:a03:5c3:cafe::64) by BY1P220CA0020.outlook.office365.com (2603:10b6:a03:5c3::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:49:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SJ1PEPF000023D9.mail.protection.outlook.com (10.167.244.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:07 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 12:48:43 -0700 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.20; Tue, 21 Jul 2026 12:48:42 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:42 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 08/12] iommu/arm-smmu-v3-kdump: Reserve crashed kernel's ASIDs and VMIDs Date: Tue, 21 Jul 2026 12:48:17 -0700 Message-ID: <28a26f13a91bf26a7b8215a0bea493627cd9c832.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D9:EE_|SA5PPFE494AA682:EE_ X-MS-Office365-Filtering-Correlation-Id: 99af9240-6b06-489b-87a3-08dee7612098 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|1800799024|376014|36860700016|10067099003|3023799007|6133799003|11063799006|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: gF1Yu9U45Z2c7Bjt2r+lnyR5tn0hcn8bcvLcRuNeOly6qNMbmTHHcmHoZiznv/Fb4E79Q6T05DQU8swXPCyBVo3/bsUb90yNo8voEyQZKS7yDsGM2IH5HxFK54bcLIZQu1Ivs6lova+z09n5A9Mo2YezxBENvtDgUt9rDnMOAKteOivp7zQ5PUHxTwvPyv5f8Pc7oUFh+EXb8i7Xbh32x+Rg8bHYlY+sLh8AmC8U9FT+pb3dLow8ZhST5p8oeMQ5laTDpfQOdk1nIQIk9dBg4wM/SqTbVNBHF2uMrIRDZs3qF8Q8CkPmS1uWlxBHEQT2bZR6AqxzUR2j/92KqNTLOnhC8nAYeZmgHmfXJzSuci7TAeH4DK95lapT/018Z2OsS5h3D4Xe8D1XMu1KsBBmOHP7OjBHTPvdeZhOQclol3qpzGMHnvHhBPNFXIC0LcMTRgaNpGTDtMUNBHhHqmjtNPBJApdH21YuG3jAwIISej37qRSf7R+pkTIj6yKrqEQN0o9hPqsLOD68C5eSri+v6d1YvYvXbWnIOJrAiBtbfYQUFpV9fTjvT3anxlGxJ/sDqSF59qPKmhXclf0aDnfe6z3SXbkAqdgp/eZBPNPjhy7zypp10wAmIpASCJTF6usc03PuB5jR8PBmnAZG1c5tevxS8IK0iu/IbIBLMnbw+s90cK8GFFQxkba7UNZ39IRU1kCX6lZg//37Vzy1XdI4xA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(1800799024)(376014)(36860700016)(10067099003)(3023799007)(6133799003)(11063799006)(56012099006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vC86OmV6jJshgXYCQFfVAcGeBQEL3kT9RGtt7HT6hgyfu9/Hj63VKGGy9G7dn/mwyMz4gcaPG+cqKcgzJitwQL8CFl65G+M2JX9u0B3c//mDGJ40ftpEaPvVckJoDOJm7es8AAiOANlx5QsoFeXXqmRLtGBUFik+SPal3EG9gU7AxpAuApj6o7niLBc54UeBVenz7pKSX+IXN0rjLMWEOuJAHJ621dvoNDVKo8l4RTLZlymrvInWqJtbd2O9Qq6S3edYSPezXBRqWNHWR1S4gOTSR60bHxA5wuYceQ9/jUPAWKWhXGXC5V0HCU7k7E0mKDCXRFBH6m3lOgvFXnu/ljtXJ9CEI0VZ0/ETWLyi/AL+h9uDAu65WMHj4Zw7mTvBlOocPmVT+iY6Ip6HUgieKpk+kbUK0gGs1UvQLfaYvnori1eOuhGUV4p/Eczjy0Ey X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:07.6636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99af9240-6b06-489b-87a3-08dee7612098 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA5PPFE494AA682 Content-Type: text/plain; charset="utf-8" The adopted stream table keeps translating in-flight DMA, so the SMMU keeps caching TLB entries tagged with the crashed kernel's ASIDs and VMIDs. If this kernel handed one of those IDs to its own domain, the new domain's DMA could hit the crashed kernel's cached translations, e.g. a stale entry left behind by an invalidation that the crash cut short. Scan the adopted stream table at adoption time, reserving every ID in use via arm_smmu_kexec_scan_and_resv_ids(), under the arm_smmu_kexec_resv_lock so that a failing scan can atomically roll back all of its reservations via arm_smmu_kexec_unresv_ids(). Nested STE's guest-owned CD table is in IPA space and left alone: its ASIDs only pair with the nonzero S2VMID being reserved, so they cannot alias this kernel's VMID-0 or EL2 stage-1 domains. Note that, on an E2H/VHE host, the kernel's stage-1 domains are tagged by the EL2 ASID, and the TLBI_EL2_* commands take no VMID. So isolating this kernel by a reserved VMID alone would not work. Reserving the ASIDs covers both the E2H and the NSEL1 cases. Reservations are never released: a kdump kernel reboots after it saves the vmcore, and the full-reset fallback flushes the entire TLB, which turns any stale reservation into a merely unused ID. If the scan finds any inconsistent structure, toss the entire adoption and fall back to the full reset. Suggested-by: Jason Gunthorpe Assisted-by: Claude:claude-fable-5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c | 15 ++++++++++++++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c index a074d59ce3445..3e0d544c6bc53 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c @@ -205,16 +205,29 @@ int arm_smmu_kdump_adopt_strtab(struct arm_smmu_devic= e *smmu) goto err; } =20 + mutex_lock(&arm_smmu_kexec_resv_lock); + ret =3D arm_smmu_kexec_scan_and_resv_ids(smmu); + if (ret) { + dev_warn(smmu->dev, "failed to reserve in-use ASIDs/VMIDs\n"); + arm_smmu_kdump_adopt_cleanup(smmu); + goto err_unresv; + } + ret =3D devm_add_action_or_reset(smmu->dev, arm_smmu_kdump_adopt_cleanup, smmu); /* devm_add_action_or_reset ran the cleanup upon failure */ if (ret) { dev_warn(smmu->dev, "failed to set up cleanup action\n"); - goto err; + goto err_unresv; } + mutex_unlock(&arm_smmu_kexec_resv_lock); =20 return 0; =20 +err_unresv: + /* The full reset will flush the entire TLB, so release everything */ + arm_smmu_kexec_unresv_ids(smmu); + mutex_unlock(&arm_smmu_kexec_resv_lock); err: dev_warn(smmu->dev, "falling back to full reset\n"); /* diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index b768080c04db4..9d9fd11d26efa 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -4516,6 +4516,7 @@ static int arm_smmu_init_strtab(struct arm_smmu_devic= e *smmu) { int ret; =20 + /* Init first, as a kdump adoption reserves in-use VMIDs in the ida */ ida_init(&smmu->vmid_map); ret =3D devm_add_action_or_reset(smmu->dev, arm_smmu_deinit_strtab, smmu); if (ret) --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010034.outbound.protection.outlook.com [40.93.198.34]) (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 9EE0E471431 for ; Tue, 21 Jul 2026 19:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.198.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663354; cv=fail; b=m3ZfvO3C8A2TFG4ewYkMJulBp4cJGXMAHD4PLEoDQDemuSp7xIWB08dri7AS9AxY/aaQahJIzwGVd3akX5KdmhMt4RACzbQ0L3Veb4dY+qqqvDHCux9A5DGotLCmNGxaqUKgFISBLQxYY828/2rIj1SPnhZkET1c3kfiO35zS64= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663354; c=relaxed/simple; bh=I5kgfePobd/m7UTxTDrv6nHIS00XzZmqQPtExIO1H8A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pv9Cu1PtVs4V5yIIdxcpH+SDIONZl7/dVe+b2tNh0jxfMpjMIQ9kPQ9YQ0uh8C69N5KIiHLEe7sUKY3wM2YCWN2mh/jqegnbQm7rFALtkkVlvfxIE9H7NDS474oQVL9BjgTgc/3JDfelnmALCbtzqwcCVdnHKzEV0NGa2UXPHFY= 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=SIanxxfw; arc=fail smtp.client-ip=40.93.198.34 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="SIanxxfw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RWwBCGTC/+zjOpwZLSjjgC2n8ksqRm4pLxYIqkAtS0ss3QQ72REoigCEMuo9MtqTAeFk5gqNC9pApYQ1RwdPY4xEq/Ia9CUeypWHmd6JwvrXYnhkqThdQpSOUGTJZZi3cg/r7/7KqdxQqUtTaWxIzbENX7yqZfr7oqgNTcTc0DnjZWDmCTIyLWt1MARrYOLN56QrXzwCs5j1qAEsPXguCImxeyPC85NxB/QDrouCcYgsL0ybN2CN+w5QQgi/RrS/+ZrHhOAFGUXCAE/mhk13Bv+wkPLZQf9AccSzRNF8bObs6SuCzbgk/kPw5pTefg4enkS17hfrIEfvg1ERhUdWyw== 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=Ic2DhKJuGcm0UPf8zApGgBw0OXgJPIeIu+S1+GgaEm0=; b=vUagIBo6ygKCEkNqzDUSyhIPTFMRcl+/O6sOf8g1Ieq5jzL/LpaPpilBeFUcZ4IpBkan6HmXXrs6rt9LHX6dRpmQWWo2mwc7P/XYLcbmdN4ujnv7YNKJNU0o58s1SZtlLhQmtEJ2EQvpur1Xv71X6N3PIkSefJ4VtYARd6i3gIJ1f6CwmEYAZWH2VVyRJKVc1dSuN8+J/siKhK7U+kxZCT7YISeau34GEn72b3+O9haExQkuEeq8rjGgy3+D9RjgAlEqa9x3C4NTmv36X01j8G5fQnSxKWzK7X86RIv+B99bXPpKIJ6RFJfw9llgNhijin49w8sNW5irOyb15MEbAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org 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=Ic2DhKJuGcm0UPf8zApGgBw0OXgJPIeIu+S1+GgaEm0=; b=SIanxxfwLWFVWdgEMSXKKoKUvYMzmeM/r3B0TyjmtF9y7Nw6LIAIdfO/wJTWOuyq/RFD0Mi1gmGanUwC/pwJViXnNUeoalFApcjymDAZiJGSjbBGOQ7kP/vVkUBzytWpHMKcNyNJf7oIGDqPHN0NBIHrrcgU2s3ZkJLmkKgB7WdweL4nP/WO8f++1cfst9V8q2kaF0YjZM1x7fxD5YD3ZSMlnaqxT0v+Bs1qFbjtoR7PdzC64M3aKqImldk7YoJl6dclfb6pYPp4OXFOMI65LHU6/e/UTaUTW48zP97W/1j9NsvQH3YmXYnis3s/Zn5+qkw/t6j34ppzQ21ImNPP7w== Received: from DM6PR01CA0020.prod.exchangelabs.com (2603:10b6:5:296::25) by CHAPR12MB999223.namprd12.prod.outlook.com (2603:10b6:610:301::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.18; Tue, 21 Jul 2026 19:49:06 +0000 Received: from CH3PEPF00000018.namprd21.prod.outlook.com (2603:10b6:5:296:cafe::37) by DM6PR01CA0020.outlook.office365.com (2603:10b6:5:296::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 19:49:06 +0000 X-MS-Exchange-Authentication-Results: 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 CH3PEPF00000018.mail.protection.outlook.com (10.167.244.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.0 via Frontend Transport; Tue, 21 Jul 2026 19:49:06 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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.20; Tue, 21 Jul 2026 12:48:44 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 21 Jul 2026 12:48:43 -0700 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.20 via Frontend Transport; Tue, 21 Jul 2026 12:48:43 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 09/12] iommu/arm-smmu-v3-kdump: Implement is_attach_deferred() Date: Tue, 21 Jul 2026 12:48:18 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000018:EE_|CHAPR12MB999223:EE_ X-MS-Office365-Filtering-Correlation-Id: 5afd3d34-86af-41cc-27d6-08dee7611fa1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700016|23010399003|376014|18002099003|22082099003|10067099003|56012099006|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: aeJVWDEHQe/Ue6DrXj/V5NiK4SIFl9p5t5BDm+gpTLjtRnNyIRdgw9KKvG3wcAwz5gkgMuX1uZosgkG3Y+kSEbEyl9vFSlggeuDVv56ebn8RBDF5r3+4mn5lX9jgRUQD+cX6oOfUk16fSsDZuT/j6I0Wehn1GVC5HFNWbbt1sbXdnT8lb89d8WV4o7VJW7cm+YfOfkJrYrOokGdXElzMrVP/oHnEcjtRDkL57YE3IaBDQQXEbasUiCH3BHiJ4P3AkWiDC0DH3Ts9PiN/VChIBFMbyg8XChjUm11IB9nu2sJ3HHhaB97EXJGV9Q/6fU3W6rn9n3B4CcbQYS6dVW+tjS9QSz+xnOJXbDAWtP1jAUPIEuuuLvT3nncMRhMNHNwt8AgmL7xgWnGSoYbaG/jTzsKgHjPW0hMAmN9qzF3khBnE2/7QCoUddzP1Xp/JmFyuPG3GHKeSg7n1wXntv3S3bHUflltRdULMOXeB3S742UTTSpo8pAkRyXLB0YHKJr+RtqFS3sAEtnwuQYD6d1JEsyMDOP5Y07Ehr4hs2mPbH45UH1yrsWsX96Gq6w5irq/nmHFYXDaXtakgY8bY9fRf1BUrlgJpdujwgz/J76Joqg7gmUKWjF8SmrY2qdqsXiuZ9LwR6dTVVL8jwNg7cx4eau8XImUflQHWvqCj4xS4AFi68SJ6FSAcZBBlMA4n48G0gznrm+yJfBqpYpGr/9ZQpw== 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)(82310400026)(1800799024)(36860700016)(23010399003)(376014)(18002099003)(22082099003)(10067099003)(56012099006)(11063799006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zEj+OyIWc/h0vJ44vd9HxFPnj1ZQ514AYJA1SuPMNjwPVUz2ejm9l+L8XRCh0r+DYs+psT9TrYL0ZI7u6fvMgHRvdVtau5WxW5E8Boq473uA/ZkejqJDgDcy0osl3FVakfXQ2k54ZacZ2xqRgTgAiPxycgLUs9JLVgKFbWcipsWtHZ5svBhxC+deLHXpwibVe6nJ3n+d5oHApPlZlVQf2tsxtVzCcyoz2K2VLF5FtGAp2ZpZtFk0CPUMpwct3j30NyW6lCGMaaeXVSX7oV/hRChz+5eXVF5v4xqZP+791odA5RktsHtO+NxN3AkVOcKXC7f0CK6BGyEiSDnYp3IE68VQmsowzMWlwjAVgmFgyrVI4Q6pPTOdB7Y4nPYdR5m/oQEgBsiJPHbA8ZkEDu5IaEQr3MBzjhWxmsQzBjqoDihCg2WzNnwu4j98H5BYOIKj X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 19:49:06.0044 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5afd3d34-86af-41cc-27d6-08dee7611fa1 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: CH3PEPF00000018.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CHAPR12MB999223 Content-Type: text/plain; charset="utf-8" Though the kdump kernel adopts the crashed kernel's stream table, the iommu core will still try to attach each probed device to a default domain, which overwrites the adopted STE and breaks in-flight DMA from that device. Implement an is_attach_deferred() callback to prevent this. For each device that has STE.V=3D1 and STE.Cfg!=3DAbort in the adopted table, defer the def= ault domain attachment, until the device driver explicitly requests it. Also, move arm_smmu_get_step_for_sid() to the header for the kdump function to use. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Reviewed-by: Pranjal Shrivastava Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 22 ++++++++++++++++ .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c | 19 ++++++++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 25 ++++++++----------- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index 5c03de5aed27b..0bc1de6463785 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -1208,6 +1208,21 @@ void arm_smmu_attach_commit(struct arm_smmu_attach_s= tate *state); void arm_smmu_install_ste_for_dev(struct arm_smmu_master *master, const struct arm_smmu_ste *target); =20 +static inline struct arm_smmu_ste * +arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid) +{ + struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; + + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) { + /* Two-level walk */ + return &cfg->l2.l2ptrs[arm_smmu_strtab_l1_idx(sid)] + ->stes[arm_smmu_strtab_l2_idx(sid)]; + } else { + /* Simple linear lookup */ + return &cfg->linear.table[sid]; + } +} + int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, struct arm_smmu_cmdq *cmdq, struct arm_smmu_cmd *cmds, int n, @@ -1263,6 +1278,7 @@ int arm_smmu_kdump_adopt_strtab(struct arm_smmu_devic= e *smmu); int arm_smmu_kdump_adopt_deferred_l2_strtab(struct arm_smmu_device *smmu, u32 sid, phys_addr_t base, u32 span, struct arm_smmu_strtab_l2 **l2table); +bool arm_smmu_kdump_is_attach_deferred(struct arm_smmu_master *master); #else /* CONFIG_CRASH_DUMP */ static inline int arm_smmu_kdump_adopt_strtab(struct arm_smmu_device *smmu) { @@ -1276,6 +1292,12 @@ arm_smmu_kdump_adopt_deferred_l2_strtab(struct arm_s= mmu_device *smmu, u32 sid, { return -EOPNOTSUPP; } + +static inline bool +arm_smmu_kdump_is_attach_deferred(struct arm_smmu_master *master) +{ + return false; +} #endif /* CONFIG_CRASH_DUMP */ =20 struct arm_vsmmu { diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c index 3e0d544c6bc53..ea7a2bdd77a58 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c @@ -240,3 +240,22 @@ int arm_smmu_kdump_adopt_strtab(struct arm_smmu_device= *smmu) smmu->options &=3D ~ARM_SMMU_OPT_KDUMP_ADOPT; return ret; } + +bool arm_smmu_kdump_is_attach_deferred(struct arm_smmu_master *master) +{ + struct arm_smmu_device *smmu =3D master->smmu; + int i; + + for (i =3D 0; i < master->num_streams; i++) { + struct arm_smmu_ste *ste =3D + arm_smmu_get_step_for_sid(smmu, master->streams[i].id); + u64 ent0 =3D le64_to_cpu(ste->data[0]); + + /* Defer only when there might be in-flight DMAs */ + if ((ent0 & STRTAB_STE_0_V) && + FIELD_GET(STRTAB_STE_0_CFG, ent0) !=3D STRTAB_STE_0_CFG_ABORT) + return true; + } + + return false; +} diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 9d9fd11d26efa..fdfb69d2e51ac 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2898,21 +2898,6 @@ static int arm_smmu_domain_finalise(struct arm_smmu_= domain *smmu_domain, return 0; } =20 -static struct arm_smmu_ste * -arm_smmu_get_step_for_sid(struct arm_smmu_device *smmu, u32 sid) -{ - struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; - - if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) { - /* Two-level walk */ - return &cfg->l2.l2ptrs[arm_smmu_strtab_l1_idx(sid)] - ->stes[arm_smmu_strtab_l2_idx(sid)]; - } else { - /* Simple linear lookup */ - return &cfg->linear.table[sid]; - } -} - void arm_smmu_install_ste_for_dev(struct arm_smmu_master *master, const struct arm_smmu_ste *target) { @@ -4318,6 +4303,15 @@ static int arm_smmu_def_domain_type(struct device *d= ev) return 0; } =20 +static bool arm_smmu_is_attach_deferred(struct device *dev) +{ + struct arm_smmu_master *master =3D dev_iommu_priv_get(dev); + + if (master->smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) + return arm_smmu_kdump_is_attach_deferred(master); + return false; +} + static const struct iommu_ops arm_smmu_ops =3D { .identity_domain =3D &arm_smmu_identity_domain, .blocked_domain =3D &arm_smmu_blocked_domain, @@ -4326,6 +4320,7 @@ static const struct iommu_ops arm_smmu_ops =3D { .hw_info =3D arm_smmu_hw_info, .domain_alloc_sva =3D arm_smmu_sva_domain_alloc, .domain_alloc_paging_flags =3D arm_smmu_domain_alloc_paging_flags, + .is_attach_deferred =3D arm_smmu_is_attach_deferred, .probe_device =3D arm_smmu_probe_device, .release_device =3D arm_smmu_release_device, .device_group =3D arm_smmu_device_group, --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from PH0PR06CU001.outbound.protection.outlook.com (mail-westus3azon11011034.outbound.protection.outlook.com [40.107.208.34]) (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 537B5415F1C for ; Tue, 21 Jul 2026 21:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.208.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669946; cv=fail; b=Pcr3LFJ+upQ/z5HdLnoaTht+t0JAOK61y+iGtFMKk/XIOhjcY07MJb03OwYAcbZ7+UJb44b68bopFOkNEfw7jMpK4bRGBBGPEE8DKIapaUpkWl+knDbXuv/vsKYdwuilOAcBtJv4tkUmCmkXra+t74EZTdKvl8coyMiiURO3buI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669946; c=relaxed/simple; bh=wx5lzu8ij5dsskIXUk5NCbsIgE9VSOqRyMvYnrNLwN4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZXsJIJF+LCH9dK08y2d1+GlkKt+n0UfM5FxKREIJNMuGl0B83OqGJNvEttkmhaxExA0eLOt4AORtmHOIzOXA6PfL73xu9cZziytYJOvyp2hSv4MrwqgaWz6RzaLVgGvsihsARp+bPGWU5ghvHQpEHqVqTHxuYjBtkoMbeHvQHeo= 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=FJLzFk6w; arc=fail smtp.client-ip=40.107.208.34 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="FJLzFk6w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WPrHJma7YXjR9XCWzn3qf8yuYoC5vdhmPUA6QdGriHCAgbTkAfGFLl7PNZku6i8hUCEaaGBQZvbiot9og1SsluKmX4A81M5dI3/HZLLrXu+/NaifSWZ0chsJK65Od44Dqy5p5OXoWHnpyG04VzjScu9fTNRBRejZxUgagrSgJNPiYaYwem6mHX/7YsGTTm0p0KmR6RW2iDNrgXE4al0vrMHpaJ47rgTta/GwLMq/Bc6iWUJoz7PyKq1hjarjlW1AoLayGqdKizbLCQXbZOLaafVkFbTkK9ETfUXIQeBzzeRN9BTQGU1ZhKrJFLMo1EZY6OlcWKU6pt+NqkOkrlPNog== 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=W9P3vws4w5HswrYp8KQrTpZhQIyy8K3WwtSm5u6Ky6Q=; b=yeheL7OSxpaUG3I2SPP8YWjdWg7A8qqaCdcTjkJWE/EBO79s7Y5hoyEYBEie6kK+IGFugrwTp1xqqyoKSdyFjUxV17Nju6fF5BX5OYexamszd+6dG9dMvL7DhKbYxmcIse+aoS6Hq/C9ZmQTwH7C65uwp9XHdGqyQAQNYg+oIqRWFKb6xzzJ47ubMCbwT919F1sO6XRZRuidBbZ50UOB7UU2FssElG1YK8Wo+iMrXYHdQZAKS3QfkwdTY3inlkfHnmf6JKOaQ2UI3/YMkDf9wE6foq+c5lWfbI9hE4p1kphyjku5PwCCcxCieU83ca65u7yRHFsGNlD4rMchV+j+iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=W9P3vws4w5HswrYp8KQrTpZhQIyy8K3WwtSm5u6Ky6Q=; b=FJLzFk6wx2CTQbitgfBNxYNSyqlM6WoJXayaN7vvi6SxwHKroa+Xv6LG+YGpArif6FOp/y1o0/FMtegzpEJ8LRl9q5J35UT309CqzIbfIku8srgJUhqeynOOvH4va1EWCiNCI+ksFp6n88+ZLBkdg9thySvmr3TdnAxrbNpIFVEI3jwTUhKO7pKiYjlJJTsMLGUESMkgbM/VGBN5Fm94jtKPBGkFgsMrFZz/K8+NC/KkwUyHrS5leqCRfTSYhILBuTV1KJ0SnEodNbH4umM8tCWQfA059n9FTIQ9NIky41+jm2TTcPengyqkBjvLyJ3oKDBLTJyFLcQZp2tTNiZ7Rw== Received: from SA0PR11CA0056.namprd11.prod.outlook.com (2603:10b6:806:d0::31) by LVXPR12MB999195.namprd12.prod.outlook.com (2603:10b6:408:3dc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.15; Tue, 21 Jul 2026 21:39:00 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:d0:cafe::54) by SA0PR11CA0056.outlook.office365.com (2603:10b6:806:d0::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.18 via Frontend Transport; Tue, 21 Jul 2026 21:39:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Tue, 21 Jul 2026 21:39:00 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 14:38:44 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.20; Tue, 21 Jul 2026 14:38:43 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 21 Jul 2026 14:38:42 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 10/12] iommu/arm-smmu-v3: Retain CR0_SMMUEN during kdump device reset Date: Tue, 21 Jul 2026 14:38:37 -0700 Message-ID: <255196e7cc7c444726fdeaf30aec4583f52ada99.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|LVXPR12MB999195:EE_ X-MS-Office365-Filtering-Correlation-Id: 4aa938c7-8fa5-4ad7-3ddd-08dee7707a07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700016|23010399003|82310400026|22082099003|6133799003|11063799006|56012099006|10067099003|18002099003; X-Microsoft-Antispam-Message-Info: jDt9qkNhrDB7cToAs90huVEooAhjtQ5PMpHpgoQus8Cez4jTVKUAHEDQo35MQV27nIZoSjYRhHCH59bKN03cxWuOntXPgYRB+XDY6tAwJuPgXO1bkfl7vU26/kCaHxrMljlE/lvSDXApkajTnm1SkQ9x0A0FhTqbv6tzm/V5qK5kdjx+MHX861lU7fQccobwd0ynhxUSeXLCLasMehul2Mp2bJ9wmgOsetje8GqObayryfF0CzROTqaZba7zJVivPUMxDURbxRIoHWjyXz0xDKSVZAxcivVGOMaKqkcNWxAbSWyv1gRmxrmw1jD0JfIdV/nQ06nha2rdH1OD9wjrWKmTl3iRZlaT98W4/iPtej3qyhQ4O4xt204/neRylEPRcLqiRriEROkYRsGzo5BEUINSoowlCfgy+pi+NOlZtKj2VtgCzeGlW5oeAx6LEVlyBr7oSgm5tzmqxzV0zMq7HbY1ZXVIkUlqQqK9Rd1ze99TCbDndv5FhwE+/Bxj2lIXwHOHaDYQjt5N8Sx1iVXICL9dBSmq92xKfut1EK0nc6sprL3+jSd1J7uauBCHFzty1yinGj79EJT7nfm63h/Tot5ZampBu+sOxhR/q35m/jJfqlLHIGU5ADw0Y+w5grNdTZodSnXgpuUv4E7GK/oSZOqaW/7LkeFuv7/1hfw0eOFyJCbhKSRpbmVnv2E1Scp9AS899lJzvCvMidv0Q8QQ8A== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700016)(23010399003)(82310400026)(22082099003)(6133799003)(11063799006)(56012099006)(10067099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pUgKVT5gFXwNhqc/+LwRkvw+rAhHgwsBySXcukcXn17H0cZWvYHtW4DHwGyybk1eeOLVGu/RL6FNC1QqboX8HK91ZLn3V990pf64020+RUkLk1nAMFAccWC/Nul5F72Ls2tHzcLorPDvcYAYgnphsDTOhO2hb357NmeJLmxWHDkY1j1VcBggOyXRG2SpfNKVEmMSUAS099pGM7n2Mplzpnjt4j+6hLoFnWLr26zgUsEnQc7YxfrNxm2qqvgGJbQQymB1vVG293mbmahgZxM/Nb0GAl93K2XlmpbaYaQmOOsD7xb3TVLe5UaFMkDySY/+Q2up+AeGuphHuFXr/WAdZDDighg7TZSIxOOWbbhf/GNUyMj5AOh4WkzybwHetd7tR5kqNk1nKxJ7bd0D4eK/9c9944zuxOYJ8xDUSrCXzgrjsZ9ebsNK6MvajErKJp0N X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 21:39:00.1479 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4aa938c7-8fa5-4ad7-3ddd-08dee7707a07 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LVXPR12MB999195 Content-Type: text/plain; charset="utf-8" When ARM_SMMU_OPT_KDUMP_ADOPT is detected, do not disable SMMUEN and skip the CR1/CR2/STRTAB_BASE update sequence in arm_smmu_device_reset(). Those register writes are all CONSTRAINED UNPREDICTABLE while CR0_SMMUEN=3D=3D1, = so leaving them intact lets in-flight DMAs continue to be translated by the adopted stream table. Initialize 'enables' to 0, so it can carry the retained CR0 fields in the kdump case, clearing only the queue enable bits. Then, preserve them when enabling the command queue. Clear latched gerror bits if necessary. Reviewed-by: Kevin Tian Reviewed-by: Pranjal Shrivastava Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 60 +++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index fdfb69d2e51ac..aff7b6b4527a5 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -4781,10 +4781,28 @@ static void arm_smmu_write_strtab(struct arm_smmu_d= evice *smmu) static int arm_smmu_device_reset(struct arm_smmu_device *smmu) { int ret; - u32 reg, enables; + u32 reg, enables =3D 0; =20 - /* Clear CR0 and sync (disables SMMU and queue processing) */ reg =3D readl_relaxed(smmu->base + ARM_SMMU_CR0); + + /* + * In a kdump case (set when CR0_SMMUEN=3D1 and !GERROR_SFM_ERR), retain + * all the live CR0 fields, e.g. CR0_SMMUEN to avoid aborting in-flight + * DMA and CR0_ATSCHK to carry on the ATS-check policy, while clearing + * only the queue enable bits for this kernel to take over the queues. + * + * According to spec, updating STRTAB_BASE/CR1/CR2 when CR0_SMMUEN=3D1 is + * CONSTRAINED UNPREDICTABLE. So, skip those register updates and rely + * on the adopted stream table from the crashed kernel. + */ + if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) { + dev_info(smmu->dev, + "kdump: retaining SMMUEN for in-flight DMA\n"); + enables =3D reg & ~(CR0_CMDQEN | CR0_EVTQEN | CR0_PRIQEN); + goto reset_queues; + } + + /* Clear CR0 and sync (disables SMMU and queue processing) */ if (reg & CR0_SMMUEN) { dev_warn(smmu->dev, "SMMU currently enabled! Resetting...\n"); arm_smmu_update_gbpa(smmu, GBPA_ABORT, 0); @@ -4814,12 +4832,41 @@ static int arm_smmu_device_reset(struct arm_smmu_de= vice *smmu) /* Stream table */ arm_smmu_write_strtab(smmu); =20 +reset_queues: + if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) { + /* + * Disable queues since arm_smmu_device_disable() was skipped. + * CR0 fields are independent per spec, so the queue enable bits + * can be cleared while retaining SMMUEN=3D1. + */ + ret =3D arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, + ARM_SMMU_CR0ACK); + if (ret) { + dev_err(smmu->dev, "failed to disable queues\n"); + return ret; + } + } + + /* + * GERROR bits are latched. Read after queue disabling so that unhandled + * errors would be visible. Ack everything prior to re-enabling the CMDQ + * as a stale CMDQ_ERR would halt the CMDQ and new command will timeout. + * Acking SFM_ERR is defined too, although it would not exit the SFM. + */ + if (is_kdump_kernel()) { + u32 gerror =3D readl_relaxed(smmu->base + ARM_SMMU_GERROR); + u32 gerrorn =3D readl_relaxed(smmu->base + ARM_SMMU_GERRORN); + + if ((gerror ^ gerrorn) & GERROR_ERR_MASK) + writel(gerror, smmu->base + ARM_SMMU_GERRORN); + } + /* Command queue */ writeq_relaxed(smmu->cmdq.q.q_base, smmu->base + ARM_SMMU_CMDQ_BASE); writel_relaxed(smmu->cmdq.q.llq.prod, smmu->base + ARM_SMMU_CMDQ_PROD); writel_relaxed(smmu->cmdq.q.llq.cons, smmu->base + ARM_SMMU_CMDQ_CONS); =20 - enables =3D CR0_CMDQEN; + enables |=3D CR0_CMDQEN; ret =3D arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, ARM_SMMU_CR0ACK); if (ret) { @@ -4885,7 +4932,12 @@ static int arm_smmu_device_reset(struct arm_smmu_dev= ice *smmu) } } =20 - if (smmu->features & ARM_SMMU_FEAT_ATS) { + /* + * In a kdump adopt case, retain the crashed kernel's ATS-check policy + * captured above rather than forcing it on. + */ + if (!(smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) && + (smmu->features & ARM_SMMU_FEAT_ATS)) { enables |=3D CR0_ATSCHK; ret =3D arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, ARM_SMMU_CR0ACK); --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010009.outbound.protection.outlook.com [52.101.201.9]) (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 9890F35C6A0 for ; Tue, 21 Jul 2026 21:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.201.9 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669948; cv=fail; b=FIt7nYD9glhXc9dpvP8fk7tvaWKnn+Pc/9fm2gKRuZrN2ijDZez1z2TzmF6iavCLxrQYdPOiruxPoAUy5zSJ19tn34nLm0bbjvMNTSXsYizz7WWk5ubz2WhlSpwpknPJ7o4CR/zbdMf4vsE3qd65z6NBBB2EKLI9JPMWFrSr4Cg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669948; c=relaxed/simple; bh=UergahTC6c3/FVCvNWA4rPKSL3j4toYJjGckmF6sUa8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qV71w4nurpwrjlSrTQY19nE21GWX7cttta1ilrN1/Olrp0rX+hjbIE21nQsiDKaHQ26o5C61EJLXL5ZZZPglLaejCfwAwrsl6e21tllTARvahcRgwPSgY3xHpg4uHLJxfwMb2Bg+suNFV4kHlJJUDXzGWNOmOBnnJ9MlAnr53o4= 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=OG4hsQhQ; arc=fail smtp.client-ip=52.101.201.9 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="OG4hsQhQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wUWsEomSlxI2CG82ecqJtPBSq1r6kFjdnhUfrKDAba6318Q0vLOEXVcUYVb82kMSUIsMqjrarwdCrjttLux7GNYKe0GOZx+XbQy8SfDaQuoQ7lqkj1vt4W/ZiYkgjH3zrS6DbyHxTt3p/miO+PcgNBxc76kY+vaI7guUoiTLTFfJao74oMpRGNyGmlyZSTuEivQRV+KlglRDFQiC0YwxR3IBI1Q7bhpjdPhfFR1We5FTS1V4Q6Mpp0TaRpEKd9I+yh/DHwp0r65IZ1qCPNRKkxbYCyhJzqO/CKhWpsMJ85tJCuec4cvlZos7AZxBo/Ttg9lWySaZVvfEywNtPiZ6qQ== 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=uWINbuYSW6lgh/AzF7TvovqvT9fTYN1oiEEVah7JEl8=; b=XuGZnv1iP1SXJdeHEEqhFq6Ndz+GDgpMhXqyA0s5Syl9uQZSxwBgt9GyXyODTCsSa5grrvU8K7GjiIx/g+OMUTwNG/meWJzgYQixAGmooJxqVBEoAco3VNn3cE6TVSKnRTacyVJnZGYjjwRyV+U9QGiUyc7AHradMc92yIBMWp5SRJR+X5a41L8ar+BDAOrmB1NDv3i+KRo7J1mfXCsIB/9r0mZXV9hYS46dx1BoID4ZtoyrERUjG+dn3o/9ewjuhsVynqrRAhgg4z80HV70Fp+Fkq0FqRTUJ6rgwB7jouR6ZViJez0kF0fqvhHvF6fsyBIGgXuUIvsTQS3GpaUe2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kernel.org 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=uWINbuYSW6lgh/AzF7TvovqvT9fTYN1oiEEVah7JEl8=; b=OG4hsQhQ5ZqAwrnNJZyM8yFBhfPWmjjI4lWEdC/N9pUK+Oue8N2Siawq7HIilaqMdBRiEYWMHmbt6E696haJ3VsKPJAy3PwJMKLvDIguOWj7BO65exC7uqsont1SQgfRR/IVhW8RG65b2pCEhFnhWkcpxKRuzCJISJlqkkmnxltj+TcPi2Yt9eRrmTjy0cywmTFuL7PQM8VAsELUPeYlCXlYkqqcezSmfIW+D5ljw9Gem5xDN3vZ7rkGoOl7dCDWZhWPrZraRd/LjhBKDROZNinKLrlIV3OvljHg27vNdsZoSequ2784NyFwFNrywb/iIrehv5IF4jgZ0Tnlkx5zCw== Received: from SA1P222CA0156.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::19) by SN7PR12MB7324.namprd12.prod.outlook.com (2603:10b6:806:29b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Tue, 21 Jul 2026 21:39:01 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:806:3c3:cafe::9f) by SA1P222CA0156.outlook.office365.com (2603:10b6:806:3c3::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 21:39:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Tue, 21 Jul 2026 21:39:01 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Tue, 21 Jul 2026 14:38:45 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.20; Tue, 21 Jul 2026 14:38:44 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 21 Jul 2026 14:38:44 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 11/12] iommu/arm-smmu-v3: Skip RMR bypass for kdump adoption Date: Tue, 21 Jul 2026 14:38:38 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|SN7PR12MB7324:EE_ X-MS-Office365-Filtering-Correlation-Id: d69333fe-e217-446b-be5e-08dee7707ac5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|30052699003|376014|82310400026|23010399003|11063799006|56012099006|10067099003|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: iaeZnLTGuRIGfJvypEPBWNhzq58A4r42zQQL9K0F4j7DR6TlqZEeXL5IbA5xPF1xTMnwyf3SgbsBjwUC97/i4+D3y+wr9tNRSisGidMaFNiC+E5ukg5Oqz2kMJStSWYNxudi3xn4GkugYqkuyO8p9/1GaYKVEo8t0DJsv0gpkzJNqtCHrUqMJgoE877zfY5s0KsEFm52CrgkkO0+dl6Lxd4NLKzMdtB+rJdmpGSBK1iLjkbqehNhizDb8bYc9Sft8MIl2Bs6yJbFgP8c2z75/v4tzH4YIP0JsjF+KnXQPKlK44c8O0itGpN8qn6cX0GL21sth77L6Xwy4lGIZEV3B8XnHjKUQKtTx5lTj6+yXmc6oV2lNokcoVm1yxVw9RMQThcO4Z7MIP+2I8Hy3btvO9U9nM1rUvnjjZdqpdOTKMZs/hEvycQcLbGShisy88+g7SNv5WfAma2xZ7YdzDEW5lCAlDFarp4w/Vr7dJQyNfkyIHF/jBQlA8l5wmBCdYcPU02JpjVg8Utjb47gUCiDlCXB70CAo6bgivOHOXdfgFTX/w+GhYAjUta3w8v+jueHH9BTaTBxm8nuCkOmkDPwf8vR+Yyrv++FNTEp9XkCZQwKf3+uO5DH7fTyREV08mevvkLEiCnjc3Df8mvxfcvLdv0nKCuxfIowTMdNnwtWpvccu2YU+AkMRsJXftxerwBfWawjR8YZc7np66OIiLhZVw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(30052699003)(376014)(82310400026)(23010399003)(11063799006)(56012099006)(10067099003)(6133799003)(22082099003)(18002099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZARte6+2VWqU9NLrA6qpo5/QWek7K54M+7JPnPty4ThBKjcVx7V0dYRn+0VLIlYYzP2j6ywOpjqDiW5b/5418m7TgasrjxG16PsGYPO0lfuPVH+68SWPxww75oKrBB78uwqenhkXpT2xsn8DzanWCrDhJESf3mIkcmeyBbHvK0wdEboAf4gk0d+OE95R1f6vFwJeLAPXSjuqY0GVPWtPTOjBN1PW474pB5ZbaBgnMUQPqpPR8LD9Ub41xvS1aX/xp7WhP5Ppx7bkYwZDZFRf1mP3yUfNbxBeDTZw+EXDzVv7J4XKU2sRDi4Q765B0zxemKIeGvFZld7F7Vy7KQIStNOXbOZmD8IKbC2xa0AJ6map9HtyKRCHFvaaGaW84Pf5VCi762iyaHxZAiWJ3cyve2KvkdWewDP+QdNe+rIa2bunb9Mt3btpATbG2971UvlQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 21:39:01.3812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d69333fe-e217-446b-be5e-08dee7707ac5 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7324 Content-Type: text/plain; charset="utf-8" RMR bypass STEs are installed during SMMUv3 probe for StreamIDs listed by IORT RMR nodes. A normal boot switches the driver to a fresh stream table whose initial STEs abort, so those RMR SIDs need bypass entries before it becomes live. This preserves firmware/guest-owned traffic, including vSMMU guest MSI cases built around RMR-described SIDs. ARM_SMMU_OPT_KDUMP_ADOPT is the opposite case: the driver keeps SMMUEN set and adopts the crashed kernel's stream table, so RMR SIDs already have the only translation state known to be safe for active in-flight DMA. Replacing an adopted STE with bypass can turn translated DMA into physical DMA, then point it at the wrong memory. arm_smmu_make_bypass_ste() also rewrites the STE in place after clearing it first. While the table is live, a concurrent hardware STE fetch can observe V=3D0 or mixed old/new state. Leaving the adopted STE unmodified keeps the kdump kernel using the crashed kernel's translation. That gives the endpoint driver a chance to probe and quiesce the device. If the old STE was already abort or invalid, installing bypass would create new DMA permission; leaving it alone is a safer failure mode. Later domain setup still gets the RMR direct mappings through the reserved-region path. Reviewed-by: Pranjal Shrivastava Assisted-by: Codex:gpt-5.5 Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index aff7b6b4527a5..168865af868ad 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -5421,6 +5421,14 @@ static void arm_smmu_rmr_install_bypass_ste(struct a= rm_smmu_device *smmu) struct list_head rmr_list; struct iommu_resv_region *e; =20 + /* + * Kdump adoption keeps the crashed kernel's table live. Rewriting the + * adopted STE here could expose an in-flight fetch to a transient V=3D0 + * entry, or change Cfg=3Dtranslate to Cfg=3Dbypass. Must skip here. + */ + if (smmu->options & ARM_SMMU_OPT_KDUMP_ADOPT) + return; + INIT_LIST_HEAD(&rmr_list); iort_get_rmr_sids(dev_fwnode(smmu->dev), &rmr_list); =20 @@ -5437,10 +5445,7 @@ static void arm_smmu_rmr_install_bypass_ste(struct a= rm_smmu_device *smmu) continue; } =20 - /* - * STE table is not programmed to HW, see - * arm_smmu_initial_bypass_stes() - */ + /* The fresh stream table is not yet live. */ arm_smmu_make_bypass_ste(smmu, arm_smmu_get_step_for_sid(smmu, rmr->sids[i])); } --=20 2.43.0 From nobody Sat Jul 25 00:15:12 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012057.outbound.protection.outlook.com [52.101.43.57]) (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 2AD6843C7AE for ; Tue, 21 Jul 2026 21:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669953; cv=fail; b=IclRWHh4Y+xThBuRM4KcrrxD9tWz738mpJs6dlccxqMDHmCF2+4TvBD/cZGUq/EvcE/Iu2FaAxrucIe91XPTTcdQD15mx/6VgfE/J8KdZ3ezM9yLcnCneMuJurWi7cu12eToAUolKLCP4wGFlZCfDbcP0Bgshhkd1tlFiEn3jvc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669953; c=relaxed/simple; bh=PSFzcWMNcD2Fk/GtRGv7UdYS1EWZS8w5FnmWPH6Gem8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cDFW/qdvywrkkUJMAiYgKm1MuGaB2yNpGZs0e9u26NI9eN9ipm+dQIrUWFr3rnYcKbH95ZuYzaHmfBeKeNz3p4osmvsoYGaBe8rooeZpT/N6mIJQI3SKq1LlC5ysyxPC4/yGIa5AucwsEV6lbI2Jfjv602ffqPNu+Ld1EDcWsrI= 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=OSlk1KBH; arc=fail smtp.client-ip=52.101.43.57 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="OSlk1KBH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SqdpI37GfsgLZ9Xgc5NsGl1iyU0PNTN/+8Ob4W5MUwmSLtEAhGU+zPK+euSbd6mrodsSaFytAHtr2NlovqqNjLp7mQ7MikpN6xq2IPtdmkRH9QSroKtdIWowPwpIEd/0NOJOKIGsk5p7wwfWYRgHkpieXCtL4ByTAYu9G6bp+M+9a7wovpUJQ3W6lBFIZlb7oBpKs5QbNLPWu5AWfclpF/Zgua73kECmobn2BpWtYI9ZIEsZWpVqKjSgKln/dWfwhYVrmXQY5DKqmx2il9Juct/KADiLSk0B+TlPyKOORRBY2QwOn+OAFMrkxXIk/J3ej2oQSdRodeKndbLX44IyZA== 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=rIpNseA2QTaw0inpiCE3UDKt3XhcTNuN23NO8baE66k=; b=XO+lZwbGLyBy901eQIy3ztJL2zyRaCdvsrDPGPFAjLgRhVtqRjxdLJyGQ9h/QB4izoz4jTMMY2osGFvpAbAMHMVBNcbXlrgWKZsXxNMtooTsOW4XUPCP2mA38nVYvdTPSpMhp7SkiQDUxyEYEZNFx/XArPV73l1pElb+Q4BvX+ukuvwW0+jCd5KjG13ApvqsKM8l69nzer0Do/cE7oSD0Ky4jIVveM5oE2cR9ZO/FZkWqmFng5mIFYic3OIjg7Wksu5qqmCcR3iBpX14QgKLklIFAq0AOhdope/zprt8z8eHDB8JjvOE/zd34GrXWyNHh1u9JZ/TysWnCY+36C7JCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org 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=rIpNseA2QTaw0inpiCE3UDKt3XhcTNuN23NO8baE66k=; b=OSlk1KBHwW8UvSR+Z9xWMeC4YGtXEveO6L2FysY9MwUY5J24LvxTY+BmUd4T4hdqPA1b4zA2ttadV3AmlQ/VK2IGp9cpEiN1eb/JDAzu0h45bl/uWMpOWmOQxgSRcAL99mt7P/w4HjiV2sf8eLV6qgCApk1YmDuKtMxV/4uRyarpOSxFHvMMTuJ9UU7+/uzKYqv8yPyNoRjBHjI1k6oWGCvT8E4xJJ335troPKVMblOQ9ROi84+HM626AVqWFZ1ozLn0dgpFKBMxSRyRr9PQunBzwUVPDvbv/wn+Cv5ejVmN+pgT7xWhdtF4ZJ02XPPssicicthJp8VbL2Rp+nfAyA== Received: from MW4P222CA0002.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::7) by DM6PR12MB4404.namprd12.prod.outlook.com (2603:10b6:5:2a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.10; Tue, 21 Jul 2026 21:39:05 +0000 Received: from MWH0EPF000C6191.namprd02.prod.outlook.com (2603:10b6:303:114:cafe::65) by MW4P222CA0002.outlook.office365.com (2603:10b6:303:114::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.245.10 via Frontend Transport; Tue, 21 Jul 2026 21:39:05 +0000 X-MS-Exchange-Authentication-Results: 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 MWH0EPF000C6191.mail.protection.outlook.com (10.167.249.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Tue, 21 Jul 2026 21:39:05 +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.20; Tue, 21 Jul 2026 14:38:46 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.20; Tue, 21 Jul 2026 14:38:46 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 21 Jul 2026 14:38:45 -0700 From: Nicolin Chen To: , , CC: , , , , , , , Subject: [PATCH v9 12/12] iommu/arm-smmu-v3: Detect ARM_SMMU_OPT_KDUMP_ADOPT in probe() Date: Tue, 21 Jul 2026 14:38:39 -0700 Message-ID: <629e0eeb1dac857bce3ebcf027938888ab95483f.1784663184.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000C6191:EE_|DM6PR12MB4404:EE_ X-MS-Office365-Filtering-Correlation-Id: bcd75bb5-4407-4ac0-9745-08dee7707d00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|82310400026|23010399003|36860700016|6133799003|22082099003|18002099003|56012099006|11063799006|10067099003; X-Microsoft-Antispam-Message-Info: zX0jU8nfbMPkC4SNTpSVotnaauMoevS92hDt4BP+XcBZjiSuY5TVzYb7WoTpoyAlcUw+tz9TYeGJ3vLXZ0yi4vsC1knDu3RCk363UM4hyp0utBhd8F/EpEVD3L+9U83Ubhw0F0DR7OOrPz02siDYkxIQK569rJsCbk5n+pmaBBOsv+ETSPXP1niAoG+zjMBK3QfGoon/WqfTZ4tUEcBR2wDpn1F3mhAGXu/ajE4FlvneZC92sdUBYfPzDU5yuYwzE2ao5TT3SSqcL/q1ap/nvywsQjtL+8XhJ3lZVBDWz4oBACh/ezawm7DKEXlv9knDuwgkqyw+AeuAuTjWer8i+h5sgU3tA9OI+2JjFDIhetLnaj8kg74QqsxmuImx1A2m9Ik4DWIfqQjl1IzBJiKQ5dv6WwVQL0F6ERpq80lZgKtqWruC31oW4OQMGDzfUHbGC101IkHFk6IKlAzhZX4AJh8YbdgEprq2d1dUf3OAeI1m+aINRgNgrnGbdRfgq7/WHrGtSrpEmaY0VVv+4lFz8VxwmQxAN9JWMpcyM3h9k5ZaT5CIYyxJWcW5HcO0MrMMM2U5mMCRPE43+Xbye7FaNxrt4V4btd1n/ceOKpkx+GPcdVp0ciW1wv2rWzdd0toYw9U6mQirHpC7Tl9CD6ACzOiW+gqN00Np2nvInIMCsn1ABN3QYhNfG+wTyjItolo6WsiK3NYbfc4w3N7CtLTIEA== 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)(1800799024)(376014)(82310400026)(23010399003)(36860700016)(6133799003)(22082099003)(18002099003)(56012099006)(11063799006)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8I5yMzq0I/w9pf4B8YDWHP/sXk1pOM1catmchh3p+ylGT4H/Pfd3I8MXLJ/xwvj6Xh2Av2kK0S27J2lGh1//S1mN6EtljwHK7OPQzQfYVRUPh7T9a8zw4IcmzOcKKMawo/7js2DmW2dtvWOJgjuLZkosHENBd2JqtA2lnWSYvEXo6tub6ye74qIhGJ8AezyohCXVAdVWzag9qWU2mSx3X5RHrPp21Z+8npdiX6l5oKuXNUek5tE5APim/HqSIJeUpOWPAclPiAq2sWti4TXFdA5NSLQtos4VVMLENwupqNCj5nHE1yCP6slqk6Gi/e6YWq2HDRKOtksL1Iv8QqzpfiGWKN2LRgEJ4h6UqqTaoFp2BH2FlpqqJqLmXcJ+Ko0cQ7XTH/ODlHYQ1zKp8AXeh1IqCutHd1H/qVbTXQva92DEEw7yxPogMX02p3su0XBh X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2026 21:39:05.1949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bcd75bb5-4407-4ac0-9745-08dee7707d00 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: MWH0EPF000C6191.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4404 Content-Type: text/plain; charset="utf-8" arm_smmu_device_hw_probe() runs before arm_smmu_init_structures(), so it's natural to decide whether the kdump kernel must adopt the crashed kernel's stream table. Given that memremap is used to adopt the old stream table, set this option only on a coherent SMMU. And make sure SMMU isn't in Service Failure Mode. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Reviewed-by: Pranjal Shrivastava Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 5 ++++ .../iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c | 27 +++++++++++++++++++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 4 +++ 3 files changed, 36 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index 0bc1de6463785..06146b535a1fc 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -1279,6 +1279,7 @@ int arm_smmu_kdump_adopt_deferred_l2_strtab(struct ar= m_smmu_device *smmu, u32 sid, phys_addr_t base, u32 span, struct arm_smmu_strtab_l2 **l2table); bool arm_smmu_kdump_is_attach_deferred(struct arm_smmu_master *master); +void arm_smmu_device_kdump_probe(struct arm_smmu_device *smmu); #else /* CONFIG_CRASH_DUMP */ static inline int arm_smmu_kdump_adopt_strtab(struct arm_smmu_device *smmu) { @@ -1298,6 +1299,10 @@ arm_smmu_kdump_is_attach_deferred(struct arm_smmu_ma= ster *master) { return false; } + +static inline void arm_smmu_device_kdump_probe(struct arm_smmu_device *smm= u) +{ +} #endif /* CONFIG_CRASH_DUMP */ =20 struct arm_vsmmu { diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c b/drivers/io= mmu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c index ea7a2bdd77a58..cc52bfdcb30ae 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-kdump.c @@ -259,3 +259,30 @@ bool arm_smmu_kdump_is_attach_deferred(struct arm_smmu= _master *master) =20 return false; } + +void arm_smmu_device_kdump_probe(struct arm_smmu_device *smmu) +{ + u32 gerror, gerrorn, active; + + /* No adoption if SMMU is disabled (i.e., there is no in-flight DMA) */ + if (!(readl_relaxed(smmu->base + ARM_SMMU_CR0) & CR0_SMMUEN)) + return; + + /* For now, only support a coherent SMMU that works with MEMREMAP_WB */ + if (!(smmu->features & ARM_SMMU_FEAT_COHERENCY)) { + dev_warn(smmu->dev, + "non-coherent SMMU unsupported; reset to block all DMAs\n"); + return; + } + + gerror =3D readl_relaxed(smmu->base + ARM_SMMU_GERROR); + gerrorn =3D readl_relaxed(smmu->base + ARM_SMMU_GERRORN); + active =3D gerror ^ gerrorn; + if (active & GERROR_SFM_ERR) { + dev_warn(smmu->dev, + "SMMU in Service Failure Mode, must reset\n"); + return; + } + + smmu->options |=3D ARM_SMMU_OPT_KDUMP_ADOPT; +} diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 168865af868ad..cfa0991cbd332 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -5257,6 +5257,10 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_= device *smmu) =20 dev_info(smmu->dev, "oas %lu-bit (features 0x%08x)\n", smmu->oas, smmu->features); + + if (is_kdump_kernel()) + arm_smmu_device_kdump_probe(smmu); + return 0; } =20 --=20 2.43.0