From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381235; b=EGu/YnIWMAtl+Y8jKizMqH6QkASmked6OBkYS1xwiVAdji+FNa9XOzzlJ1M+CBT8Wtrc jNyWv6URwFmGO0VuWwfXMVdAeghXJFuPcYYi8sTg6NihDIfvj5xQtZD98yn2zrHaXEPVp A1i9QRR+qZZXBfqxHV3yZeObrv0Ksmcg4sdrjI/Vf4QrgHbq++rClYRaeup6+4KvA9hFF fDyQPGWQuo+gAUF9Y/BHq2yo7rfK4tHzSnYMnK3wWwlKwHH3ZxWtyGkDLL6MwPk3qBQzi aOetU8x7ka+Y74rwvB3LYIBZmqcfMpLh9of++gvCbyQfR2f3RT7hrGg2OUWm8KpFnWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381235; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=eh4aLNILdHPmkr9melYJ31HWf9oCu8G7X7Ilni944IM=; b=c6pSzmDxaHQa3VrdZc69YhfY701tSh0mOpjPzYgX3LmER7FxAkl0w/i9hMGvMpG7m1oY wwzhZuhj89K8/LXG9ItRT8v/cUtaRXhhAr91MKDTCgZBWimFusDUjzYvoh9k+FQk3RJ36 MWXTU4K2ckS06HJ2K+M62sN9rTGal5vXixiBK8TqTVmhkV0IDEkkhNlyviS8mVAoK3vG4 qHL15v1PS/HXxtw7s3QH5XPTdVsqSz04Ru9nba+K+ceIwQSjsSIOC6NPU/Eaks2Gh2FLm F/EhyKoEIb3ir1fZobY+9RoYrk15OxEtnqlBDkMuj2PY+utyfjtK5qhH02GKavuKhSg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=U1EeHg3G; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26AA6606A335; Fri, 4 Dec 2026 10:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=U1EeHg3G Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98D701F000CE; Fri, 4 Dec 2026 10:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381235; bh=eh4aLNILdHPmkr9melYJ31HWf9oCu8G7X7Ilni944IM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U1EeHg3G0wWoGn8TEtdudB/bP52d2E/0KDeeuAeehD5ruZExAcEOcoxXiIoBKZWSh hFY2MB7Fr0gJpGFlZVjqv1AJs0u6p+wMLBxE7aNMS5hQFFEAk09d6LEoqQbWiOj/lH F2xRwgzXRQlCGgLsbvRHzXTJw6+I+hYlHxiddB3A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski , Paul Walmsley Subject: [PATCH 7.3 577/742] riscv: mm: reserve the DTB before scanning reserved memory Date: Fri, 4 Dec 2026 19:07:21 +0900 Message-ID: <20261204100650.463168432@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Szyprowski commit fc91dacd0c2b4f9ca7e0ce30016f5aee6256cba5 upstream. early_init_fdt_scan_reserved_mem() allocates memory from memblock while it scans /reserved-memory: the reserved_mem array, and the regions that are placed dynamically by size. On RISC-V the DTB was only reserved after that scan, so memblock could hand out the memory the DTB occupies while the DTB was still being parsed. Reserve the DTB before the scan, so that memblock never allocates from it. Fixes: ef69d2559fe9 ("riscv: Move early dtb mapping into the fixmap region") Closes: https://lore.kernel.org/all/b71ac175-fba5-4f61-bbdb-0b98dec9ccee@samsung.com/ Signed-off-by: Marek Szyprowski Link: https://patch.msgid.link/20261104104604.3370384-1-m.szyprowski@samsung.com Cc: stable@vger.kernel.org Signed-off-by: Paul Walmsley Signed-off-by: Greg Kroah-Hartman --- arch/riscv/mm/init.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -291,13 +291,6 @@ static void __init setup_bootmem(void) reserve_initrd_mem(); /* - * No allocation should be done before reserving the memory as defined - * in the device tree, otherwise the allocation could end up in a - * reserved region. - */ - early_init_fdt_scan_reserved_mem(); - - /* * If DTB is built in, no need to reserve its memblock. * Otherwise, do reserve it but avoid using * early_init_fdt_reserve_self() since __pa() does @@ -305,6 +298,13 @@ static void __init setup_bootmem(void) */ if (!IS_ENABLED(CONFIG_BUILTIN_DTB)) memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va)); + + /* + * No allocation should be done before reserving the memory as defined + * in the device tree, otherwise the allocation could end up in a + * reserved region. + */ + early_init_fdt_scan_reserved_mem(); } #ifdef CONFIG_RELOCATABLE