From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1D322BE7C0 for ; Mon, 24 Nov 2025 12:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763986619; cv=none; b=dHasQDR9xXlEmneB7fk+dSCW859ykkPahI/752r17GUWf7u+aIMGgwmeNcozfKQ7BlKDNO3c06+y217ZSWcG0gDhQytkR7oZ6MJRpeXsFUE3F9OVNL+9mEqWp3zXuyMvzGBhLeoKhdAiOcBO1kdEZufqxuiOr9R8RqaRPt4kXB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763986619; c=relaxed/simple; bh=dZiPM1LFz4RF63yPFs4ZgFUL2y/p+IJlKxTQbSlwnNw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=BKDpPjFMQ0H7PJXFUabTvH4mPaMjfpJh78S7/fe6gYruvK2IVUFvqmcqcD0rB4gFij+0BTT+M5WQt2mr9aAE6+NyL9WE1eGet/WEpk2LNEFYavTaOxN7HHff5YZEQVFp2cE/xtlhrmjwBmWk83YH6Qdhzz1ecNpj13dp9wLMWsE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Vk41JS3B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Vk41JS3B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1D65C4CEF1; Mon, 24 Nov 2025 12:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763986618; bh=dZiPM1LFz4RF63yPFs4ZgFUL2y/p+IJlKxTQbSlwnNw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Vk41JS3BrTpprUfDmHaAWqzmYN5LKPTP0ikZeODbHurhakhmNlbEtrkZ0/4NlNYP0 UtTmKaGui+1CuOO9Fc+Am73Tx5ttc9GQMIb6wyR1JPjbWt37ealpc6i2ZwvIaw4ks+ IskBvVXpaM256dD32hbqKvx8NITZs2PAXJMTR7mb5vkI/uqgKG/U1gxBrgPxdnUfWY oO7mpKVWZM7yQDfy+uPkrlkPgixJZnkayC7VHnZFnbGELU65n5c3RLwD30onJxBViW QTYAiULrfLWlPgAr1bGaBxZnLYMQtMQKrcVr3dpsU20tbKxrP0F7uz73WMMygGZ2so /lgH1gnK1nKrw== From: Pratyush Yadav To: ranxiaokai627@163.com Cc: rppt@kernel.org, akpm@linux-foundation.org, catalin.marinas@arm.com, changyuanl@google.com, graf@amazon.com, pasha.tatashin@soleen.com, pratyush@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ran.xiaokai@zte.com.cn Subject: Re: [PATCH v3] KHO: Fix boot failure due to kmemleak access to non-PRESENT pages In-Reply-To: <20251124025943.94469-1-ranxiaokai627@163.com> (ranxiaokai's message of "Mon, 24 Nov 2025 02:59:43 +0000") References: <20251124025943.94469-1-ranxiaokai627@163.com> Date: Mon, 24 Nov 2025 13:16:55 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Mon, Nov 24 2025, ranxiaokai627@163.com wrote: > From: Ran Xiaokai > > When booting with debug_pagealloc=on while having: > CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y > CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=n > the system fails to boot due to page faults during kmemleak scanning. > > This occurs because: > With debug_pagealloc is enabled, __free_pages() invokes > debug_pagealloc_unmap_pages(), clearing the _PAGE_PRESENT bit for > freed pages in the kernel page table. > KHO scratch areas are allocated from memblock and noted by kmemleak. But > these areas don't remain reserved but released later to the page allocator > using init_cma_reserved_pageblock(). This causes subsequent kmemleak scans > access non-PRESENT pages, leading to fatal page faults. > > Mark scratch areas with kmemleak_ignore_phys() after they are allocated > from memblock to exclude them from kmemleak scanning before they are > released to buddy allocator to fix this. > > Fixes: 3dc92c311498 ("kexec: add Kexec HandOver (KHO) generation helpers") > Signed-off-by: Ran Xiaokai > Reviewed-by: Mike Rapoport (Microsoft) > --- > kernel/liveupdate/kexec_handover.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index 224bdf5becb6..c729d455ee7b 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -11,6 +11,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -1369,6 +1370,7 @@ static __init int kho_init(void) > unsigned long count = kho_scratch[i].size >> PAGE_SHIFT; > unsigned long pfn; > > + kmemleak_ignore_phys(kho_scratch[i].addr); Can you please put the explanation you gave in [0] for why this is not necessary in KHO boot as a comment here? After that, Reviewed-by: Pratyush Yadav [0] https://lore.kernel.org/all/20251122175735.92578-1-ranxiaokai627@163.com/ > for (pfn = base_pfn; pfn < base_pfn + count; > pfn += pageblock_nr_pages) > init_cma_reserved_pageblock(pfn_to_page(pfn)); -- Regards, Pratyush Yadav