From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 09FFFC5472C for ; Sat, 24 Aug 2024 14:53:27 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Wrg12581Wz2xyG; Sun, 25 Aug 2024 00:53:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=139.178.84.217 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724421926; cv=none; b=TsTTxaW1EndT+c4BwGFeGQHJE0XGeFRI8FHQ51OlAS0NaYtEU9kJLX9UjbmzIU445GQ7qOIx5n95x1hQPpxJJtZmc7uZY13Qh/mnKvICAPdCah5WiUIOERy72cWLiF75OD2sdaNc6mZmRXFgIRGo8ohYQv/w2j4ZRb0zoosDbZLU+ONnGzTHT93FTv8MvQeBflH8D4BS/Int27I3xY+bpTCT6GIhnpjKG2ZQR8hZtKwZJgnfTc5fIXDl01EzVbUgxOu09DItblFmnP5q1C1NT7vwyyiUXgSGy3EHZfNCgUiHcBneWf3btuFdTYQpLn2X1iXgYrbBcJ5RtETpYHzL0g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1724421926; c=relaxed/relaxed; bh=oZiN97x0pfIACBap77EwQa4Gvbg5L4NzpqBE/epcOC8=; h=Received:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:X-stable: X-Patchwork-Hint:X-stable-base:Content-Transfer-Encoding; b=Yq1XwwzGLvbEbKXEKRpp174frsdDhG+UiFtirFvjUkAP7BdZ5vUxu/lO+NNF1N1dzOqd/6+GG8/n8Oa0y+a4RieBIaoGDJiLH8HpWI+evQUKCmatv+dehMEd0u9G+s9S+W+ZJpHqqCV1gKZeEkVLbjzh6vebSdbvZF1VOK2NmEtKFq/+wfvw02c/u0I4E+1vEOh+tpFncU3Rv9e88hG7nxY6w0mCex0tWZZcjDkpg9C2rDddoGfNQIqR6XPDouujlVkGp31GiMc+mjbkYfst7qGgoZN4YahUonawajaM8pCdfi9ubTT+/qkdZu/YjfSJHb2l7JA6HKI01qMQjjFn+A== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ntXrIjON; dkim-atps=neutral; spf=pass (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ntXrIjON; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=sashal@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Wr2060VZgz2yGD for ; Sat, 24 Aug 2024 00:05:26 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 391B06133A; Fri, 23 Aug 2024 14:05:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2755CC32786; Fri, 23 Aug 2024 14:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724421923; bh=Cdn4LqeJyN/GJnKIRmhMe/SqbV1+ihUQZDrb4xuyVP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ntXrIjON2E7WZE+adsXP5aV7cAk+2Tq5To3jY5LkAE2LLByKLTpFqqkSjTAPEvAHA W8cujjgrSrzr9Rk0uo3/koC8gpYU+hZUe+HfV4h3zBoCfeHIXf/tPm+ef2UDcA1vjt 5NyNF2HKkQfMgYt6QMjKREfyZ2LAmogh5hzxVERsJRsGKTNUNYRaOhMX9AG/v5W2gs WlOjH238Z/IQidMH4uQ2Wz5DBpK4Qbvy+avO1PtUwMZ8PxBZhHSuDdaGYhmuFwkxDa ysj64jSnWAJodQ2Y7GQwVvMfrVrjE/UZBNVXjujTMZRDjG6Mtm/+yccMocSqXZ/Zu8 sZ767PY1MWyuw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe Leroy , Michael Ellerman , Sasha Levin , hbathini@linux.ibm.com, robh@kernel.org, rostedt@goodmis.org, thorsten.blum@toblux.com, willy@infradead.org, arnd@arndb.de, philmd@linaro.org, akpm@linux-foundation.org, tzimmermann@suse.de, kent.overstreet@linux.dev, rppt@kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.15 5/9] powerpc/mm: Fix boot warning with hugepages and CONFIG_DEBUG_VIRTUAL Date: Fri, 23 Aug 2024 10:04:52 -0400 Message-ID: <20240823140507.1975524-5-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240823140507.1975524-1-sashal@kernel.org> References: <20240823140507.1975524-1-sashal@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.165 Content-Transfer-Encoding: 8bit From: Christophe Leroy [ Upstream commit e7e846dc6c73fbc94ae8b4ec20d05627646416f2 ] Booting with CONFIG_DEBUG_VIRTUAL leads to following warning when passing hugepage reservation on command line: Kernel command line: hugepagesz=1g hugepages=1 hugepagesz=64m hugepages=1 hugepagesz=256m hugepages=1 noreboot HugeTLB: allocating 1 of page size 1.00 GiB failed. Only allocated 0 hugepages. ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at arch/powerpc/include/asm/io.h:948 __alloc_bootmem_huge_page+0xd4/0x284 Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 6.10.0-rc6-00396-g6b0e82791bd0-dirty #936 Hardware name: MPC8544DS e500v2 0x80210030 MPC8544 DS NIP: c1020240 LR: c10201d0 CTR: 00000000 REGS: c13fdd30 TRAP: 0700 Not tainted (6.10.0-rc6-00396-g6b0e82791bd0-dirty) MSR: 00021000 CR: 44084288 XER: 20000000 GPR00: c10201d0 c13fde20 c130b560 e8000000 e8001000 00000000 00000000 c1420000 GPR08: 00000000 00028001 00000000 00000004 44084282 01066ac0 c0eb7c9c efffe149 GPR16: c0fc4228 0000005f ffffffff c0eb7d0c c0eb7cc0 c0eb7ce0 ffffffff 00000000 GPR24: c1441cec efffe153 e8001000 c14240c0 00000000 c1441d64 00000000 e8000000 NIP [c1020240] __alloc_bootmem_huge_page+0xd4/0x284 LR [c10201d0] __alloc_bootmem_huge_page+0x64/0x284 Call Trace: [c13fde20] [c10201d0] __alloc_bootmem_huge_page+0x64/0x284 (unreliable) [c13fde50] [c10207b8] hugetlb_hstate_alloc_pages+0x8c/0x3e8 [c13fdeb0] [c1021384] hugepages_setup+0x240/0x2cc [c13fdef0] [c1000574] unknown_bootoption+0xfc/0x280 [c13fdf30] [c0078904] parse_args+0x200/0x4c4 [c13fdfa0] [c1000d9c] start_kernel+0x238/0x7d0 [c13fdff0] [c0000434] set_ivor+0x12c/0x168 Code: 554aa33e 7c042840 3ce0c142 80a7427c 5109a016 50caa016 7c9a2378 7fdcf378 4180000c 7c052040 41810160 7c095040 <0fe00000> 38c00000 40800108 3c60c0eb ---[ end trace 0000000000000000 ]--- This is due to virt_addr_valid() using high_memory before it is set. high_memory is set in mem_init() using max_low_pfn, but max_low_pfn is available long before, it is set in mem_topology_setup(). So just like commit daa9ada2093e ("powerpc/mm: Fix boot crash with FLATMEM") moved the setting of max_mapnr immediately after the call to mem_topology_setup(), the same can be done for high_memory. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://msgid.link/62b69c4baad067093f39e7e60df0fe27a86b8d2a.1723100702.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/mm/mem.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 42338e2921d64..6192088159a91 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -889,6 +889,7 @@ void __init setup_arch(char **cmdline_p) mem_topology_setup(); /* Set max_mapnr before paging_init() */ set_max_mapnr(max_pfn); + high_memory = (void *)__va(max_low_pfn * PAGE_SIZE); /* * Release secondary cpus out of their spinloops at 0x60 now that diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 01fc77564cac1..b26c0fa776de0 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -287,8 +287,6 @@ void __init mem_init(void) swiotlb_init(0); #endif - high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); - kasan_late_init(); memblock_free_all(); -- 2.43.0