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 414081D63D1 for ; Mon, 24 Nov 2025 13:25: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=1763990759; cv=none; b=TZp+Wp+JhJXX5R4frs+BmBaymgf1wtjIyxjXBoiLAlb8uprcAIqSTqQlnqub8VHDJKnYQwFYgYdQKV+AarR87xjD+Quydwe0pWN5yNMnTdvwdGTZDyziEXM+iOq36JGn73WCgOFWmOaUNUNlBB5+2k8ABv2s227yv8tqumXAHvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763990759; c=relaxed/simple; bh=V3pNaPV0kKnax3zGGnv1AnsUhY0LbnCFMQ5OaJ21pJ0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=TPBkOxzmy5v50uaoElP2lT3grZdoa6wfbUQTHkGkrEgIimPveYBlC1pKyBLFktzZACfI/6ziKx+KI4LSxIHcBn4+II9gOfksJMHlmNXMfJ5GlJnKBFSY7foT5fIHDG7FGvcjnEPm2+ATcFNRrOxD0G4+E8TnowP6G7FbipVwyBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CYTjpF4I; 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="CYTjpF4I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A5B3C4CEF1; Mon, 24 Nov 2025 13:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763990758; bh=V3pNaPV0kKnax3zGGnv1AnsUhY0LbnCFMQ5OaJ21pJ0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CYTjpF4IqP6zSOrYyA371vjXfNJC7bd00OTA1CE5rpfF6muw17PEE2UxeKCi15eLq PQxSKfXFIgFWxfzPAYgfMtTjyX5g80i197Ya+zrjB7Sw9Cyy+NCIkFgg7jfzi5qcNW b41ni0lnkTl61chQhTW85fIs872WP5c4GTYZzcUuPdAI1GDVpCZrY9uEhS+l5nDImj l0XWnjCK579Po2HYhTBgnPZthYY/E19895OxnfPmAoIi8XVq96ZrczHVKeplcZsaDA USypK0KqHUs4xEfdivciT9uT3FLODj0pbwolLV7dU9zvVaL6JKk6X10jIl6OpLZxVN I1Nmy/oMt9gXA== From: Pratyush Yadav To: Pratyush Yadav Cc: ranxiaokai627@163.com, rppt@kernel.org, akpm@linux-foundation.org, catalin.marinas@arm.com, changyuanl@google.com, graf@amazon.com, pasha.tatashin@soleen.com, 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: (Pratyush Yadav's message of "Mon, 24 Nov 2025 13:16:55 +0100") References: <20251124025943.94469-1-ranxiaokai627@163.com> Date: Mon, 24 Nov 2025 14:25: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, Pratyush Yadav wrote: > 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? And also an explanation of why this is necessary in the first place. You do explain that in the commit message, but a shorter version as a comment will make this a lot easier to understand instead of having to dig through git history. [...] -- Regards, Pratyush Yadav