From patchwork Thu May 9 17:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13660019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FA9EC25B10 for ; Thu, 9 May 2024 17:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=La0h+PYE6CC/BkHq3Xtgm+Z+ypOFUPkx12PQmuJGy1I=; b=TrUyG+ED3Q69ed zAV0TsCEK6E1HApk+usyEg/WeZmWvUjx36zGVAtNRXk6k0EPc92Dy7YgjYr7F62O8FV1u+iSx9DxQ tv4qilV4U7R5OFVI1Ztj7lVCedNlyzF05FUUWJLO45DC7sRYx9s/t6XcOj2l9HbLGHkQ6SSKl9BfR bV4gYTk2A77XMbxU+4wBuHJA05K8aZeBtts3cHqPkJBGWgMfa3zESICrPCY61vR0nD2ogA73BLkbq wTOvZzjn2qWRFNox+6x+8jSw10dQf3n/a2aWdiMa7owvZbIIHEDpxoIBOz/A7iAQYcI8Z43DsjyXJ MiFxCLZgfPixt08yW9hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s57qQ-00000002HFw-0W3R; Thu, 09 May 2024 17:46:14 +0000 Received: from mail-dm6nam10on2060a.outbound.protection.outlook.com ([2a01:111:f400:7e88::60a] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s57qM-00000002HCR-0JGU for linux-arm-kernel@lists.infradead.org; Thu, 09 May 2024 17:46:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VtOrJ/VpfPp6NwSpdV3xOjbzTnTkvfkTZH14qD77qs1dQlGAtMrj3uIXK0vHJN6irho3sU8l26E5Pe2UEc7Giv+36IozjlaO4VvS+eFQOO5jjNJ2hgX3KP/jkL+NPWYz5GbwUv1evPQe/NNTMwSzCJkwUBJwLefkJVC7DzhvqOg6xzE5dKeEajckw3QF8hLsbObhl4V7GUjESm0+LgFSDtl3gA09MHuyVO0JQNw1f3TSrToPIDvKD+hBIwyBbUuKS4OWQ8Ya/n3FbRxwkTG5g+Gv1dkekF8aYW5dP1cfVTrtliJfjK0jiLEVd7NbRaRD3UkEKyejef1TutgFVi/wRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=fXlcxeUYxxtK56rKrWseS6G2HW+H8SKknCCRyUpB+AE=; b=ngc/G0eiMtBmcrgM8YY5v5vC3gb2yuZ/AuMf+MH9fDxBd7V8NXGikJYEgYdRjGnN8lPR5RYO5MDGCFZLx9jmIYNQaiiys5YxuaXbxUOl80u0TiLTxRgOSFCkGh/frRu0Syzfk91C1BUzVUk/ixipNZLARF7pN7cfnjveC1fqvDe5WLv9oj+aqT0Gto3zPJgTIO+iMH1rImwOO0PrrvfDOA/14ipiq9Xr5uQ9ycjO3Xa+uEXOCmT7ys7dquN0A48Y2BjH3Vd1dY4tUMU2Grt/24hi8RnFTDapMwf6x7EFL4vQY36YEbhN9IkVTnyhq0EUdpHS7a8J6eweKMExkO3FAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fXlcxeUYxxtK56rKrWseS6G2HW+H8SKknCCRyUpB+AE=; b=lSeSirkWe0Xi2bIUMSSEtHSRFMvr5LUBxbhq+Ie3gPJhNgVOZ7HVX/4s4n0ukACbNJTU5AGL687semQVi59isQaxdYlz0iEQ1DibJqdAYpDjhNvFoOdrd154Rhw9QymzUY6M3Dw8M1/3Uyg2edVCCb/q7PiAuVzxyC0hYRf/zZ2oSq5yFBU88Be9Om62rXrE2+MZSaBXmMQsQ0p2ccPdsibnxK1P7I13D3wYyh+mp4WoY1oqwjsfuQkqMYiN1Tug7miWcqfr4pUz4OxrsOXJEJSOeVCD5RVrlE9/hQdLiexpOHc5nML8b30zLC3LGvZ7b+FYb9yh5n4TlBtTNGLGIg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by DM4PR12MB5819.namprd12.prod.outlook.com (2603:10b6:8:63::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.43; Thu, 9 May 2024 17:45:55 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%3]) with mapi id 15.20.7544.045; Thu, 9 May 2024 17:45:53 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, Robin Murphy , Thierry Reding , Krishna Reddy Cc: Jerry Snitselaar , patches@lists.linux.dev, Will Deacon Subject: [PATCH rc] iommu/arm-smmu: Use the correct type in nvidia_smmu_context_fault() Date: Thu, 9 May 2024 14:45:51 -0300 Message-ID: <0-v1-24ce064de41f+4ac-nvidia_smmu_fault_jgg@nvidia.com> X-ClientProxiedBy: MN2PR16CA0048.namprd16.prod.outlook.com (2603:10b6:208:234::17) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|DM4PR12MB5819:EE_ X-MS-Office365-Filtering-Correlation-Id: cbc1f2bc-3f50-4726-c674-08dc704fdf2b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: UJ0FaNr3fWpucdJRu9TVqK0eVzMjUwwIywESrRImVVKyWBvIKaS1X3hEwTXVXEzcA0JlL6LBTV221LGDPCMGl/6r8GsZJzgcl9BOTW9qDu04EXhTXfRaz4pzxGXsVKMDxX+N5T05+8N52XEngF++OCJ/2Z1vs686W+v+U2ClouemVZPDyC9PjNlXmHLGrswzSJXmWG8iBtHMooyg++2OJQ1RZNVz995dVKI8JxB7sr17o/ie0ATEYdd+2Mp1KlsZvSBBDIGFd1gXTF8QrrS1RKZiC3EL/zSscs4DHOS/JPTItJ6QuuBkWpbb9ivWyeH4we1A1Z2lZxdWl+zzhLF75SeyHmXKsrdbIKo+tK6g54WnskPE+gtNt0Ve3HD5uxhc9sUAkt4fvA3dTrOp+WiVLqdBSgIhWd8DSJ03Ud2A9i0GBvN75J9EvckfUbWUp8OvGb7Grh5T5fYGZf9cEKMhx0FNKO8c/g52+Q/lubTR51TDoCOeSM0hJiO9XFQVcNZ0/Sp2G6EXJ8KuBivZfkd0DRQqjiqRbAnwumrs4rtpA5jY65/Ed53Ny4TjdxUwACrd94/upbyC0nbnkexjTt/cRGldpOUbf7GpTMvFWQNuFrHnI0/vSj1GHUyforiV1rukfz9Hq3UXzT3PXqEg5PFx/N/yuYyvVn9ZO7nSkodcom70KfplRx4h1GshhlHy7fPaB8QEk/QpzVN65QggCreSDQ99rn02IiT4zF+Xsd6WNBEHX9sGpJ/RK35EnzkegiKDipdknOvPfNVRV4GByFXyJPvaU2ewoxYweAaujiXCHIhNeKvV/HPHuncD1yYxPWBfFxuRQQAcN+UTWaKUYogkw3Okbe7Vm9f8oHoYL1DhWjsvvhofE9TN+/TwDzWSJShr6L1hfkUBqNI9KJThA+aWveeCQKKaRqTq/A6b59g8YoHgNZsZD3qu//DInyWTlW1yub0Qne2179Meqc07dGZuc9/KN1igQ8+m6AQ2ZIwgbVAhPw9Y4SMO6MwksO7h1RlPeEGepxLXnIDqoe11+EJHAXJAfhICNFE2e19tii8PxE+8ER+FxLBjzWSV5m2bICaj/BWDnLyfW+6LcHeLa5VAOfaeaINhHIo4EYz6clQDia8w/hcFrkxDwwH++Qq0++zIHyO2qGeQmMo4xPFxO1ljo+nGcC1WsX5wu4I05xS9VgZutTj0idl2RitBGtOXS5Hg3iw55nquMm8QoFploFdJLfJOd0gF2CVqp/ZE+Pn06h08o4QQM+ZPO3qES/1WayCbDX9RyRD3fajaNso+0GV1qA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KN8+Phu+u/O1xwEMPybW2coPpu4ucPFdIzbL1lhgabiEUIugO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qs5R39OmpefY662hobbX5crzsdbfqNacb84KuGbgTW0tWI1DP7s5J5yynRq3kw0CyjkuRZ27sf7mMT5Q6OLidXc+oO8RrTWU29W4Cuh2xx/XVRdlnnkA94UAHRyv7SZ0gwzPwff63pFo1OSvOxyiNblNDuq3XwUmivB9nTfEos4Sv9ecX+N6f7zF3GHja+6M6OEtrvnNwVhsGu9hIITidWQti1wtFKSasIqZEDb7kf67cOmynATBaSS2ySacafGMaYs85xPC1ogdFD8g2qMhbxGwxwB3w0nsPSiMuWFu08dQGGuQzKdRXSk0ZlA4veeEcswJwwHolxnLNrefr1vG0+ifExNu9bDCErVs/NDQM8W219MEblOz7DiGHpfUxutkutsxXAt6G1MrJbsAvWP3VDm3iwuNsj/K/NXNCkVVb+3YkZZdfRCyYGkqJeTI4wHdVCR64HoHw3ScAEir4yM88URyB7m X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbc1f2bc-3f50-4726-c674-08dc704fdf2b X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2024 17:45:52.9877 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0L98A8FH4y1jbH8PzV7RDdX+Z942dGup7JikSxaoOgG3bQzNG6W9AHIMWoTCllot X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5819 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240509_104610_160423_35F9E820 X-CRM114-Status: GOOD ( 11.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This was missed because of the function pointer indirection. nvidia_smmu_context_fault() is also installed as a irq function, and the 'void *' was changed to a struct arm_smmu_domain. Since the iommu_domain is embedded at a non-zero offset this causes nvidia_smmu_context_fault() to miscompute the offset. Fixup the types. Unable to handle kernel NULL pointer dereference at virtual address 0000000000000120 Mem abort info: ESR = 0x0000000096000004 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x04: level 0 translation fault Data abort info: ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 CM = 0, WnR = 0, TnD = 0, TagAccess = 0 GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 user pgtable: 4k pages, 48-bit VAs, pgdp=0000000107c9f000 [0000000000000120] pgd=0000000000000000, p4d=0000000000000000 Internal error: Oops: 0000000096000004 [#1] SMP Modules linked in: CPU: 1 PID: 47 Comm: kworker/u25:0 Not tainted 6.9.0-0.rc7.58.eln136.aarch64 #1 Hardware name: Unknown NVIDIA Jetson Orin NX/NVIDIA Jetson Orin NX, BIOS 3.1-32827747 03/19/2023 Workqueue: events_unbound deferred_probe_work_func pstate: 604000c9 (nZCv daIF +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : nvidia_smmu_context_fault+0x1c/0x158 lr : __free_irq+0x1d4/0x2e8 sp : ffff80008044b6f0 x29: ffff80008044b6f0 x28: ffff000080a60b18 x27: ffffd32b5172e970 x26: 0000000000000000 x25: ffff0000802f5aac x24: ffff0000802f5a30 x23: ffff0000802f5b60 x22: 0000000000000057 x21: 0000000000000000 x20: ffff0000802f5a00 x19: ffff000087d4cd80 x18: ffffffffffffffff x17: 6234362066666666 x16: 6630303078302d30 x15: ffff00008156d888 x14: 0000000000000000 x13: ffff0000801db910 x12: ffff00008156d6d0 x11: 0000000000000003 x10: ffff0000801db918 x9 : ffffd32b50f94d9c x8 : 1fffe0001032fda1 x7 : ffff00008197ed00 x6 : 000000000000000f x5 : 000000000000010e x4 : 000000000000010e x3 : 0000000000000000 x2 : ffffd32b51720cd8 x1 : ffff000087e6f700 x0 : 0000000000000057 Call trace: nvidia_smmu_context_fault+0x1c/0x158 __free_irq+0x1d4/0x2e8 free_irq+0x3c/0x80 devm_free_irq+0x64/0xa8 arm_smmu_domain_free+0xc4/0x158 iommu_domain_free+0x44/0xa0 iommu_deinit_device+0xd0/0xf8 __iommu_group_remove_device+0xcc/0xe0 iommu_bus_notifier+0x64/0xa8 notifier_call_chain+0x78/0x148 blocking_notifier_call_chain+0x4c/0x90 bus_notify+0x44/0x70 device_del+0x264/0x3e8 pci_remove_bus_device+0x84/0x120 pci_remove_root_bus+0x5c/0xc0 dw_pcie_host_deinit+0x38/0xe0 tegra_pcie_config_rp+0xc0/0x1f0 tegra_pcie_dw_probe+0x34c/0x700 platform_probe+0x70/0xe8 really_probe+0xc8/0x3a0 __driver_probe_device+0x84/0x160 driver_probe_device+0x44/0x130 __device_attach_driver+0xc4/0x170 bus_for_each_drv+0x90/0x100 __device_attach+0xa8/0x1c8 device_initial_probe+0x1c/0x30 bus_probe_device+0xb0/0xc0 deferred_probe_work_func+0xbc/0x120 process_one_work+0x194/0x490 worker_thread+0x284/0x3b0 kthread+0xf4/0x108 ret_from_fork+0x10/0x20 Code: a9b97bfd 910003fd a9025bf5 f85a0035 (b94122a1) Cc: stable@vger.kernel.org Fixes: e0976331ad11 ("iommu/arm-smmu: Pass arm_smmu_domain to internal functions") Reported-by: Jerry Snitselaar Closes: https://lore.kernel.org/all/jto5e3ili4auk6sbzpnojdvhppgwuegir7mpd755anfhwcbkfz@2u5gh7bxb4iv Signed-off-by: Jason Gunthorpe Tested-by: Jerry Snitselaar Acked-by: Jerry Snitselaar --- drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) Joerg, once Jerry ack's this you should grab it for this cycle. Thanks, Jason base-commit: dff9180946cc45d90a77e1c8645989cdcfd31437 diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c index 87bf522b9d2eec..957d988b6d832f 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c @@ -221,11 +221,9 @@ static irqreturn_t nvidia_smmu_context_fault(int irq, void *dev) unsigned int inst; irqreturn_t ret = IRQ_NONE; struct arm_smmu_device *smmu; - struct iommu_domain *domain = dev; - struct arm_smmu_domain *smmu_domain; + struct arm_smmu_domain *smmu_domain = dev; struct nvidia_smmu *nvidia; - smmu_domain = container_of(domain, struct arm_smmu_domain, domain); smmu = smmu_domain->smmu; nvidia = to_nvidia_smmu(smmu);