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=1796382963; b=ITQpI5jvMoRyvhmZJEIIfvW6ajqchL3CeEEj2M3uZNjfsZ6A/wAxuwaYAeVNTsJyz9Yj JYh1xbgv0cnUMyt0FA4efCp5xHwD2o0vdEj8BvR2bFgocsLopI3bL9lrGeUEW0F1gflkl S4pLv2GYxlMAy214KJ0GXpEoN6OBnjRGuUBatozWUfGwX095PgwwG8KjoKfzq7Da3Z9Ng 8Ddf7+wzg46VVWY12vweHZRazWw6VG/G3pkZNGqVpYJcS96yzlwKhVyMhP/YLBUBhlyuP BWC2PJBjWOV4PbXsImgO/lyAXP24m47nEGHeb/mel2WtWUqRliQK5mltakczyjK6XXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382963; 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=FpqEJWFBTOdZLjrNnFdJkeZifKnuBRsoUKBjI6e+uMU=; b=VbjMV0qqR6+j/mnDwIc3Ffm3v5JbgCdNtSH30b2obarwUTppRDGDxi3ggkQSwV/LXZ3Q zwWaI86hEU2Q0A9tE372PuByS/wvUUJU32ZP06e7z9bDoWZsw+eaD12gjFRo8FJVxZiZq NFziMS1qb8WEpZlYZQU6gTQEDH9PwsahZ8xA5Cc7+YyW2/Tz661kP8BKwr5JdMlxqmKXE 6XIuNhMq7KvqvZnhqg2jvaDrG4l64R6JinHtjvb3fmBkE3x7oFdgRzcXB7BJdm0mEPkin m02Wjx6ze8P05uCuyytPPZ53tzBt+OkARiETHyl0OztPHE9Padk5+DXXfyDZjmBVzqQ== 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=SDw9xk4w; 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 79DA1606A32C; Fri, 4 Dec 2026 11:16:03 +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=SDw9xk4w Received: by smtp.kernel.org (Postfix) with ESMTPSA id E13831F000C2; Fri, 4 Dec 2026 11:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382963; bh=FpqEJWFBTOdZLjrNnFdJkeZifKnuBRsoUKBjI6e+uMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SDw9xk4wj0WBtnL/haLY/ztgHLD6XbZUP7yUVPf9K5iZadX/+wrNv+1s8CNUm+3JW uxFhKu3K31W+qj3XO19D560XI/GhPy3Qu+NHB95edPj/BiaZ71BvUouLHiM7lfHfRT lTNtf0yik3Bk9BGav9Z/coqBPq9hrtWsqUL2oPu0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marek Szyprowski , Paul Walmsley , Sasha Levin Subject: [PATCH 6.18 666/703] riscv: mm: reserve the DTB before scanning reserved memory Date: Fri, 4 Dec 2026 19:09:25 +0900 Message-ID: <20261204100645.511168903@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marek Szyprowski [ Upstream commit fc91dacd0c2b4f9ca7e0ce30016f5aee6256cba5 ] 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 [ sashal: Moved the early_init_fdt_scan_reserved_mem() call to just after the DTB memblock_reserve(), placing it before the extra dma_contiguous_reserve()/hugetlb_cma_reserve() lines that this tree has after the DTB reserve. ] Signed-off-by: Sasha Levin 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 @@ -299,13 +299,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 @@ -314,6 +307,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(); + dma_contiguous_reserve(dma32_phys_limit); if (IS_ENABLED(CONFIG_64BIT)) hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT);