From nobody Tue Dec 2 01:04:37 2025 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (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 588CA7E0FF for ; Mon, 24 Nov 2025 03:00:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763953260; cv=none; b=BGEiFVyp/0N4iBcdREbe3xymnAh4tvoVgyp49hlEnagu28iLAqFHDyVvLXKnOarmWXa9+qckWTfsmzJG0wjHI6bbzXIquH+j0LyWXAiOyBqrZjGGkaEkUEdtbej/NtlpTas9KFzVleeN0BPiYQC3LPdAwwJGThf7laIxePfEQDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763953260; c=relaxed/simple; bh=xQlv1MkmkaChFFGuMpABVPSiUOUvf0eNfT9gA9na5f0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qhW52UoIaOxxCFuamv9uN/36QaxP4yuJRjNltTTZsaxG9J2suFNjhQ5ZJDO0ZnkN95Ii8FLH47wqQqgGvrSzRdOQfJg7pkpKYCMeaEAbjnvv2W+TWz97r1jabfRn1UpCb9MHZoS7ZQwlvMO7qL8X7jjeLQUSjem5pke7y+EzN7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=a+u6cjdK; arc=none smtp.client-ip=220.197.31.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="a+u6cjdK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=aj BFle3394S63r7o3GjvBvQuiLfN/Ig0/iHFsHDKh6g=; b=a+u6cjdK/vVLA4Ky44 ucKxYdqADV1cb7Ncpa8wifHxd5Q/qhDArIeT7BMS/eIKaAJDXMRHp8AsyhKSfrBE ezhlTjXla/J6vhSHDI5o8T/JYCcxB+pxxtEPOjHb1TaFcswZHln3MoMl2VVrBkf3 s50ncygxqhlBNIdTGTe7vt1Mk= Received: from ubuntu24-z.. (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wAnsIUhyiNpPbjtBw--.103S2; Mon, 24 Nov 2025 10:59:47 +0800 (CST) From: ranxiaokai627@163.com To: rppt@kernel.org, akpm@linux-foundation.org, catalin.marinas@arm.com, changyuanl@google.com, graf@amazon.com, pasha.tatashin@soleen.com, pratyush@kernel.org Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ran.xiaokai@zte.com.cn, ranxiaokai627@163.com Subject: [PATCH v3] KHO: Fix boot failure due to kmemleak access to non-PRESENT pages Date: Mon, 24 Nov 2025 02:59:43 +0000 Message-ID: <20251124025943.94469-1-ranxiaokai627@163.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wAnsIUhyiNpPbjtBw--.103S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr48CF43Jw4kJrWxtw1rCrg_yoW8ZF1UpF yvkF1jyw45t3W3XF9rZ3Wv9ryIqw1DGw43J34jvry5Zr9xJFnay39Yvry0qFyUurWvgF43 ZF4YqrWfXr48XFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pin2-UUUUUU= X-CM-SenderInfo: xudq5x5drntxqwsxqiywtou0bp/xtbBEBEQTGkjx-FAdQAAsU Content-Type: text/plain; charset="utf-8" From: Ran Xiaokai When booting with debug_pagealloc=3Don while having: CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=3Dy CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=3Dn 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) Reviewed-by: Pratyush Yadav --- kernel/liveupdate/kexec_handover.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 224bdf5becb6..c729d455ee7b 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -11,6 +11,7 @@ =20 #include #include +#include #include #include #include @@ -1369,6 +1370,7 @@ static __init int kho_init(void) unsigned long count =3D kho_scratch[i].size >> PAGE_SHIFT; unsigned long pfn; =20 + kmemleak_ignore_phys(kho_scratch[i].addr); for (pfn =3D base_pfn; pfn < base_pfn + count; pfn +=3D pageblock_nr_pages) init_cma_reserved_pageblock(pfn_to_page(pfn)); --=20 2.25.1