From nobody Mon Dec 1 22:05:07 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 D9F9433032B for ; Thu, 27 Nov 2025 12:28:15 +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=1764246499; cv=none; b=trij98SWnozhEPGD1Ou41DCJc25RiCQR3j/1bFhBlI5mpw8N6sk0Rldt93+qoWSq1NKlP0X50R/xzsaFNWsc1EvK86B6p/4d5XFNF2P/aHOl+tgYGmrGKwDnt2aVOOE2zGrIbOTvtIRldApowHkWwAcRIQ+XOkSImyGsexTkyec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764246499; c=relaxed/simple; bh=/gLBsCsXrDfRQo7aojs9cHsEhzuYjR2idf0DJDqW0XY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=A5dt1yTpYsd7uuqQHNvWj/64CP4ezLcfonJVHOtX39GOTvLzAkAi+44Z73/f438lWkf2VNAfFhbWyRlxQQ00P9AM4EjsBYutWSMJNNMR9GKFZ1lVLI4K6lTuvcelsJZPdsEcn4d4Bq3EKzYiAt1nNcP3A6d0KOT3THss0xxijQo= 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=gAnweojt; 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="gAnweojt" 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=5R bktsfuLErXNRL2ozcCIVf4lkgY78kG3x/0KHQBTFA=; b=gAnweojtvdn39maxnJ Xbw4H1WjVl7mHX91s0G01F50JP0XedAi0gxi5ZhJe46mP8ps9OWdRUa0YyzDd98T aqXrM+ybex0txGqzfe/vbRutNoZW5tXnY6cJOOk2RfSQcN2wo0niV+RS3P7yzqge Po/Z7/pmVrPewN8nqMDyNuKgs= Received: from ubuntu24-z.. (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgAHL8qbQyhpIwGSFQ--.45778S2; Thu, 27 Nov 2025 20:27:09 +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 v4] KHO: Fix boot failure due to kmemleak access to non-PRESENT pages Date: Thu, 27 Nov 2025 12:27:00 +0000 Message-ID: <20251127122700.103927-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: PygvCgAHL8qbQyhpIwGSFQ--.45778S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr48CF43Jw4kJrWxtw1rCrg_yoW8Kr13pF yvkF1jyws8t3W3WFsrZ3WvkrySqw4kC3y3J34DZry5Z3sxJFnaywsYyryIqFyUurZ2gF43 ZF4YqrWfWr18XFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pin2-UUUUUU= X-CM-SenderInfo: xudq5x5drntxqwsxqiywtou0bp/xtbBEA0QTGkkVSOLfAABsM 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 224bdf5becb6..55d66e65274f 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,15 @@ static __init int kho_init(void) unsigned long count =3D kho_scratch[i].size >> PAGE_SHIFT; unsigned long pfn; =20 + /* + * When debug_pagealloc is enabled, __free_pages() clears the + * corresponding PRESENT bit in the kernel page table. + * Subsequent kmemleak scans of these pages cause the + * non-PRESENT page faults. + * Mark scratch areas with kmemleak_ignore_phys() to exclude + * them from kmemleak scanning. + */ + 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