From patchwork Wed Jul 3 21:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: D Scott Phillips X-Patchwork-Id: 13722790 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 46ACFC2BD09 for ; Wed, 3 Jul 2024 21:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=Gr7An4FBlsxD40lNG1jTKUTNLtqBPLf1gB0zofVMejc=; b=AUbsxiuOfu+TyQSlLIHnQ1tbTQ NqTofkdkx4HXJkttPjROsuFFRqoDPLegP9jUjjSshwKd84UzQICfYgO7xZpl1OrJzrjka4lfR9BPx zROzcwIJoHqjreoIsDg2BicAUhfqqi2So6cwm3QEEfq2STzk47eQzzJIAdywtH6GOCx7k5Yrz19wC tIpZcTwbzfgYyFF4X3qSP1Ww0BPcaEiSiDNQ+mw8hYBbkvnWvAYTLm25DMLDTfJ0lfK7FRsnHLeJY 98c88koN18lyS7Dt5LU9h1EYp/V+tQWNyWTFIJG3sQtMTY5jgxrc1GfC0t5/SVecXk46S8GcjXXjS N0gxUN7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP7CW-0000000BSHN-0bXR; Wed, 03 Jul 2024 21:07:40 +0000 Received: from mail-bn1nam02on20723.outbound.protection.outlook.com ([2a01:111:f403:2407::723] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP7CI-0000000BSCz-3bBR for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2024 21:07:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mVCo85U4y0fjzr1UKL2lM7PctJ7B15R+z7R2QpI1mJRB7HxiC/UrV8PKm9N0vBd6wcU0QEoBpJuOEgVneH6v5mHbboTNgDlg9Yzy2S0bW/8gtj971GZGja+cKzo21HzHmitFyo7Bl9JEYOVlatbqCA6ufEpj4e/5KOukfn93BKSK5m3TyCGI3UPVkYqe3hEeLwSGN2Tu9+0V4I0YnQC3jEf1mbrXB+kRfQTS7o0T1sru5XMzYJOqBeFCm8FJ4Hin86IdOm9LaX0igwD2w6wQ1Lt3C7okbxhLvurMGcmmGNl3B6y0ZoeYjKvmZqkLJWIzKIuQCyVrVmwfOUP5IcD9ew== 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=Gr7An4FBlsxD40lNG1jTKUTNLtqBPLf1gB0zofVMejc=; b=XpElD11//1ImMTeCj8gd4Q1+osofuAWNmX0DtGDWufx3EetyuE71+1o1+ZNEawPx4inG4VyUmIUaPIBOMrCa/XZeVzAJzoCSKrq8uNAifMxv5cwtimb0jQOIbaNJq7g0QPfkVE9QjFipJsRtv1KnwpfpuI84RE3K+uyKEU1qlfjlByOTmyd6ZzPkYzxHA0aldJLbHcNfkHjwsLwMbvzMHWnqdNJDDbUta81S4LWX4Gy1e2qCbE+O6CYXXrbd5Aaum0v9cJKvN2i5ovbokPD86c/1KKPjuGWyQsInVnUC4uGqeQyWuL+nYFiDF/jiafa6MpTvabg9DRC2U+/X24pP8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gr7An4FBlsxD40lNG1jTKUTNLtqBPLf1gB0zofVMejc=; b=tmcaTVoKx/5760xRmV2KUtBp/ybDI2aRZWuU1G4OyrP/gtHqTt5cJXL/8qZFlVyv4d0KH36dDPd3tIrU9W2iQh+fBo9lcANow2rqQLEsk8NZ4+4Gm5tjjkmhlMhvjWEANDS6dTgo8DpC1DwMprhlrEjH8/Ac7vnxmrFAWMLethU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from LV2PR01MB7792.prod.exchangelabs.com (2603:10b6:408:14f::10) by CO1PR01MB8843.prod.exchangelabs.com (2603:10b6:303:275::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.40; Wed, 3 Jul 2024 21:07:13 +0000 Received: from LV2PR01MB7792.prod.exchangelabs.com ([fe80::2349:ebe6:2948:adb9]) by LV2PR01MB7792.prod.exchangelabs.com ([fe80::2349:ebe6:2948:adb9%3]) with mapi id 15.20.7719.028; Wed, 3 Jul 2024 21:07:13 +0000 From: D Scott Phillips To: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon Cc: Andrew Morton , "Kirill A. Shutemov" , linux-kernel@vger.kernel.org, patches@amperecomputing.com Subject: [PATCH] arm64: limit MAX_PHYSMEM_BITS based on vmemmap Date: Wed, 3 Jul 2024 14:07:07 -0700 Message-ID: <20240703210707.1986816-1-scott@os.amperecomputing.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: CH0PR03CA0215.namprd03.prod.outlook.com (2603:10b6:610:e7::10) To LV2PR01MB7792.prod.exchangelabs.com (2603:10b6:408:14f::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR01MB7792:EE_|CO1PR01MB8843:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ff62432-ad64-4a53-84ed-08dc9ba41c0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: weo4NxN64TwHUyQuJXrfiRgSnq3BxcX6RtUzk6bvexVFuATn/H3ytQDLyLjHC9+uzP3BAQdZ9HXUbc2iuhrPJ4pQtx17pXZC+/Rf6zrz4N5pSMKYXvX/bVFtmZjik17f3cgYZ0rYPuK3VzGZEXqYgCvPohk0XLUsW9jwe83ZHD15KUCXRfhQMkGHRp2oapPmCpKNQXTF+tNTzKvuPVSJ14W2+UBPkEQrPFSVjgqgfSzFQ+9r2bAHm6bXTH+J46gkVQiOuzGA8TGKOYBbVggxGReNgGLrdEumZNqABOZn2Bjn28/0vOaFGZOPhMSCpmE01FSkyc/QQt+KT1TnT0c2OR37OHEXvpFV7uOmvxi+BzwN+ZhSyBvEX3ZeBjb75uAaGXN7FA9bBbCpgumatHKk0chFl/i7acR31Kw/Mib7rnmd/+mr1y9XDVfqbqtu5lrMVLbBoUvzdZIJn1pCw3kVXD3tP3KsNrt6cMt0g0S1TBvQ1iUWIu5BrE6UZfsEUnOYwVCE+hYGWOGnoejtHct4Yw/W1mwuQYn8yNfx6j9KORuCqZGVgPBc0KcUu933MHiGhuv3jtFHhRxXzXUNSlGqshT55u3KdDnMxplj9dvc8DJ4FJHWZSO65Ja6fRMuzjK+ns8cKR0Ku3vl4zd8Ur2biM02naHwlKCqczh8mfZJiscEqxoUNOXa2USc7A8IBEyG9NA+UtjAtXqg3cH6pxyxoJewr3EMc0/wEtHiDxdRSCTUiINQFJHVo31ILRBrdNyTRJg5MBHZHQb/ehmVkAJ+AicsDwwsmuDnZEUmvOa20qUszoEAsXdL6z4cuFTLVQsJGdl9TkpF8uUhvSJXlkpWkBMTTgGzwSAv2tHDFOWcAZziSB/m0qiQD/sp+AxE2H19QpLMadjowAY0Vt4XV4TB6byAY+DMtWHwEvpuqKAOoImO3p0OXHNzTf9/0qK9io4J7M1odYc8iAUmz/0aR1ZVrSeN+w/Q4OKWrG/Z29nmgYAxcGHcufai0DTWTy27SORL/zf2uVJVX2T3U5cEOJZXSi+MeIHWd7wm61AqQYeF+vRRrL67a32tfoN11qEVkF3P9ifdUMIo4UeaUfarp6Nahl9F7LSXMxivDNaJ/+WbZN9NiQ7jxJHlfAQIY2FGlyxHC6w6/CskUVaiIfKfluI8uY37ESliuW1lZTcE4eYZGnZOG3xwq+f2apm++pel2ht/A5t4AhcQIjbxus8pkqQiidzkAPWtcQG3Johi6Sr6UmT/jVSqD/S5Po01miqQzUibxt266toXlX1CwAUfa+g9LybVqXi68LcwNkj4i/5y0PgRl+TmVvETBYRXGB/slEoVXGS7hyyxBuOtKaB2MQw5rE/pfn4b/Gpi3COA/u/nC30XDoEe7xPntAbJLqlvV2+tp4GAKHBE1WrkFwYNeOyQRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR01MB7792.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dnxNFAOChIUh+Ti3r1xoPcO2RAhuN1+0k/JhNvEi8VZJF6/tOk3pM9kaa6L1P49oZgfhzDon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ieZFB13kMEvMDbXCGliAi17Pkq8hFiGI/obhnGm7TeDBlSvYdlEDsJhdpQnJlQVc0SGwdlAP33DK2QaSmG7B/eSZu6eY1yFDSJZspgw4r+84wl8yaNbb5RFCy/s0cpdEOdrXcBxhnUpOK1E4i5dWtJP4ti9cbYcc+SOAmIejW22YIerE07WP/yvkLqI0gtC8TbaARe8sNnvn2OYiGNe7aeVRlfSLgwPHLp53sqbftzsfDUvcBec/dpnc9F9LwDTGj1aGwqhkyLpfbbMaQWIb9R/CzKjP5tS0BrN+HysYAlp/iH0k7OdmBIwAYI1KqcNpjV1OUAqpluClfl6liBcV1+Ist5P5rG9kQWnzJhObCupP4ykDE1ildfAViaVQXxVE0JYO9tngX1bQG8mDpxfOJ0NrbJq7T01rauPvGTAK3H0JYgLpVAHYKCNDIsOdcgBxmzxrZ/H6WpBG2D0rZa2mBCanX8= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ff62432-ad64-4a53-84ed-08dc9ba41c0d X-MS-Exchange-CrossTenant-AuthSource: LV2PR01MB7792.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 21:07:12.9815 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FgogFPLoWqb2F7f9crIrJiCJdbP951AXIqBW0Cw+Z4keq/tjxzNIMiqBJkEEwKbG5MCnXNC05qbyPDW7ekvSS1gKLSOkLUzpdim3xZbOsTDqUNAkPO85PJz2McAoggAT X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB8843 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240703_140726_931176_555860AD X-CRM114-Status: GOOD ( 12.22 ) 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 Prior to the memory map adjustments in v6.9-rc1, the amdgpu driver could trip over the warning of: `WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));` in vmemmap_populate()[1]. After the adjustments, it becomes a translation fault and panic. The cause is that the amdgpu driver allocates some unused space from iomem_resource and claims it as MEMORY_DEVICE_PRIVATE and devm_memremap_pages() it. An address above those backed by the vmemmap is used. Adjust MAX_PHYSMEM_BITS so that addresses not backed by the vmemmap will not be chosen as device private addresses. [1]: Call trace: vmemmap_populate+0x30/0x48 __populate_section_memmap+0x40/0x90 sparse_add_section+0xfc/0x3e8 __add_pages+0xb4/0x168 pagemap_range+0x300/0x410 memremap_pages+0x184/0x2d8 devm_memremap_pages+0x30/0x90 kgd2kfd_init_zone_device+0xe0/0x1f0 [amdgpu] amdgpu_device_ip_init+0x674/0x888 [amdgpu] amdgpu_device_init+0x7bc/0xed8 [amdgpu] amdgpu_driver_load_kms+0x28/0x1c0 [amdgpu] amdgpu_pci_probe+0x194/0x580 [amdgpu] local_pci_probe+0x48/0xb8 work_for_cpu_fn+0x24/0x40 process_one_work+0x170/0x3e0 worker_thread+0x2ac/0x3e0 kthread+0xf4/0x108 ret_from_fork+0x10/0x20 Signed-off-by: D Scott Phillips --- arch/arm64/include/asm/sparsemem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/sparsemem.h b/arch/arm64/include/asm/sparsemem.h index 8a8acc220371c..8387301f2e206 100644 --- a/arch/arm64/include/asm/sparsemem.h +++ b/arch/arm64/include/asm/sparsemem.h @@ -5,7 +5,7 @@ #ifndef __ASM_SPARSEMEM_H #define __ASM_SPARSEMEM_H -#define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS +#define MAX_PHYSMEM_BITS ilog2(VMEMMAP_RANGE) /* * Section size must be at least 512MB for 64K base