From nobody Mon Jan 26 22:46:38 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 226572D1F7C for ; Mon, 26 Jan 2026 16:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443683; cv=none; b=Nux1AcTw4r9qqhZz9yL5Z+X9Qr/NQ4Y/mIGHCikADhVxbEFVoZq0TX7tgXCAQp90I+mf/oNSW6R8m4VVaZOcbTxW7shz3HB8dEIRRrvaf+hep2O9cXVY7TYlz3UZczArffRVRZKCZIWveQA9PU5leMkkPBbncRZ7Iw9WcGK6afw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443683; c=relaxed/simple; bh=a3/6itsyojDSXSTBztKTcvsoFClmMU0YCgGoRYLdYE4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XEv9kd5KBec3uKko1hT4EI13KAGhFvJyAehqg1OoKWwrWPxadchcaXSck3ZNh7rhTfeWQDZZbcvejgjmBk7jEA9dB2H7l6Dk7IYBf9L1DfTyTWZOMDA1HXt76sMbK7+Wd6jdmNAZ/e++RRUpttDGR7lLAdoj5xzVU7SQZfTGwa0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=OsLdwa4q; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="OsLdwa4q" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=FcVEbqYjXo+vbfkN5MEuD8sag+j4VsDI2mVcphwug/E=; b=OsLdwa4qS2h6tHE1R1H3cM2dNU 7GYYoJku2Gwjj/WtI0D7hpoRmGQdBBWHE3jt3m7Ffl2eSDgyBVYbPRzbqL8HGKqHz9nVmL641BLxY IZCnxvktmiwhoxHjsT85b7HCxuiycygkDqsuWhPVu/9GtWtzeE8ZC0sfX8suSVlZChxRpFrU82/r6 cxQ0y/xMVzPtOTjFq8J6K/MucUY9V9uVGmGF/wTOPRjkf6mWhGx7R3CBlBmiVpUH9sL4MK70GMcjt xZW+44BaDVt2/m6Q2/I69cAQK0j+CtgT0MS2Gvc+F4eQROn4HoEhhRIS+/kw2roOmm/99XTwVWacX C+bdbrZQ==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vkP84-00GI7D-2y; Mon, 26 Jan 2026 16:07:52 +0000 From: Breno Leitao Date: Mon, 26 Jan 2026 08:07:23 -0800 Subject: [PATCH v5 1/4] kho: add size parameter to kho_add_subtree() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-kho-v5-1-7cd0f69ab204@debian.org> References: <20260126-kho-v5-0-7cd0f69ab204@debian.org> In-Reply-To: <20260126-kho-v5-0-7cd0f69ab204@debian.org> To: Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, usamaarif642@gmail.com, rmikey@meta.com, clm@fb.com, riel@surriel.com, Breno Leitao , SeongJae Park , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=9034; i=leitao@debian.org; h=from:subject:message-id; bh=a3/6itsyojDSXSTBztKTcvsoFClmMU0YCgGoRYLdYE4=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpd5FN3jRWa5R68zJ7vUANtZyd+HhEj2dt+9+eD HLUzMdQtPqJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaXeRTQAKCRA1o5Of/Hh3 bY3VD/9tgnkHEY/vJUUV5MNFlNjAT3ppl5wnL1PJW5WAYWrFpKDUYVh5XRwsoFdVAfBDET59ArC aapjFAvwIdsoblbQmr0xEzTeXt528VzrKZj1q7f6p1mBjVusezNSFlOzSmhmsPVa+X/4UIEtEPY vYsRxFd4h/8UC6NfSH5eYkw1CvHVBMV+dPXWyyL4KyEGAyS0bNJk7VHfwIswqSWungqecL67V7A 7xuvP81r6QRibXst0rUCNjrmCCB0TiTxNI2/hBpUccrNTE5lMBUGMgSyimQwi3waRsA6wXRTBGC 5ANK9YmiPCAWa0nVVTOG5NvZXeQDwi+b1bi/pzsvBrzuQQFJyVXJS2ujOmBLdcCQfPbwkUHsBnx X7z3aTaVKT+janNMskszvHrTGUU9KaGzUbk2ShsVXyDyc7K4rU9p15N6nUG2h1dYLT6+ztoKs6L c4RIIi5/3uth6m/RU48thqoEyX1mfNWwCGaxJ/buNFtD8U8oSk4+X3VdjIirnW0PlfVumRWj0Oc yZaSjZjqPiumCekZbKEG/1boOTdzF87vKQzs7/CjCrtCkgE49DmhKpjLOW9I+wqTO0t5luQjYuI k9XzOZBEifZZKvBDEiojfqJUnXpzWX9YVuiE1fZc0A7ykEVSqAw9Zd0Zz3qHsR3ycLfYHMFqekh 3NKMQ0u0IZN1gqQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao kho_add_subtree() assumes the fdt argument is always an FDT and calls fdt_totalsize() on it in the debugfs code path. This assumption will break if a caller passes arbitrary data instead of an FDT. When CONFIG_KEXEC_HANDOVER_DEBUGFS is enabled, kho_debugfs_fdt_add() calls __kho_debugfs_fdt_add(), which executes: f->wrapper.size =3D fdt_totalsize(fdt); Fix this by adding an explicit size parameter to kho_add_subtree() so callers specify the blob size. This allows subtrees to contain arbitrary data formats, not just FDTs. Update all callers: - memblock.c: use fdt_totalsize(fdt) - luo_core.c: use fdt_totalsize(fdt_out) - test_kho.c: use fdt_totalsize() - kexec_handover.c (root fdt): use fdt_totalsize(kho_out.fdt) Also update kho_in_debugfs_init() to compute sizes using fdt_totalsize() for the root and sub-FDTs it processes, since these are known to be actual FDT blobs. Suggested-by: Pratyush Yadav Signed-off-by: Breno Leitao Acked-by: SeongJae Park --- include/linux/kexec_handover.h | 4 ++-- kernel/liveupdate/kexec_handover.c | 8 +++++--- kernel/liveupdate/kexec_handover_debugfs.c | 15 +++++++++------ kernel/liveupdate/kexec_handover_internal.h | 5 +++-- kernel/liveupdate/luo_core.c | 3 ++- lib/test_kho.c | 3 ++- mm/memblock.c | 2 +- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h index ac4129d1d7416..abb1d324f42d0 100644 --- a/include/linux/kexec_handover.h +++ b/include/linux/kexec_handover.h @@ -32,7 +32,7 @@ void kho_restore_free(void *mem); struct folio *kho_restore_folio(phys_addr_t phys); struct page *kho_restore_pages(phys_addr_t phys, unsigned long nr_pages); void *kho_restore_vmalloc(const struct kho_vmalloc *preservation); -int kho_add_subtree(const char *name, void *fdt); +int kho_add_subtree(const char *name, void *fdt, size_t size); void kho_remove_subtree(void *fdt); int kho_retrieve_subtree(const char *name, phys_addr_t *phys); =20 @@ -97,7 +97,7 @@ static inline void *kho_restore_vmalloc(const struct kho_= vmalloc *preservation) return NULL; } =20 -static inline int kho_add_subtree(const char *name, void *fdt) +static inline int kho_add_subtree(const char *name, void *fdt, size_t size) { return -EOPNOTSUPP; } diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 8a2b2a7e50fc6..ad2da9e4e6a04 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -726,6 +726,7 @@ static void __init kho_reserve_scratch(void) * kho_add_subtree - record the physical address of a sub FDT in KHO root = tree. * @name: name of the sub tree. * @fdt: the sub tree blob. + * @size: size of the blob in bytes. * * Creates a new child node named @name in KHO root FDT and records * the physical address of @fdt. The pages of @fdt must also be preserved @@ -737,7 +738,7 @@ static void __init kho_reserve_scratch(void) * * Return: 0 on success, error code on failure */ -int kho_add_subtree(const char *name, void *fdt) +int kho_add_subtree(const char *name, void *fdt, size_t size) { phys_addr_t phys =3D virt_to_phys(fdt); void *root_fdt =3D kho_out.fdt; @@ -762,7 +763,7 @@ int kho_add_subtree(const char *name, void *fdt) if (err < 0) goto out_pack; =20 - WARN_ON_ONCE(kho_debugfs_fdt_add(&kho_out.dbg, name, fdt, false)); + WARN_ON_ONCE(kho_debugfs_fdt_add(&kho_out.dbg, name, fdt, size, false)); =20 out_pack: fdt_pack(root_fdt); @@ -1402,7 +1403,8 @@ static __init int kho_init(void) } =20 WARN_ON_ONCE(kho_debugfs_fdt_add(&kho_out.dbg, "fdt", - kho_out.fdt, true)); + kho_out.fdt, + fdt_totalsize(kho_out.fdt), true)); =20 return 0; =20 diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate= /kexec_handover_debugfs.c index 2abbf62ba9424..64970c88c483c 100644 --- a/kernel/liveupdate/kexec_handover_debugfs.c +++ b/kernel/liveupdate/kexec_handover_debugfs.c @@ -24,7 +24,7 @@ struct fdt_debugfs { }; =20 static int __kho_debugfs_fdt_add(struct list_head *list, struct dentry *di= r, - const char *name, const void *fdt) + const char *name, const void *fdt, size_t size) { struct fdt_debugfs *f; struct dentry *file; @@ -34,7 +34,7 @@ static int __kho_debugfs_fdt_add(struct list_head *list, = struct dentry *dir, return -ENOMEM; =20 f->wrapper.data =3D (void *)fdt; - f->wrapper.size =3D fdt_totalsize(fdt); + f->wrapper.size =3D size; =20 file =3D debugfs_create_blob(name, 0400, dir, &f->wrapper); if (IS_ERR(file)) { @@ -49,7 +49,7 @@ static int __kho_debugfs_fdt_add(struct list_head *list, = struct dentry *dir, } =20 int kho_debugfs_fdt_add(struct kho_debugfs *dbg, const char *name, - const void *fdt, bool root) + const void *fdt, size_t size, bool root) { struct dentry *dir; =20 @@ -58,7 +58,7 @@ int kho_debugfs_fdt_add(struct kho_debugfs *dbg, const ch= ar *name, else dir =3D dbg->sub_fdt_dir; =20 - return __kho_debugfs_fdt_add(&dbg->fdt_list, dir, name, fdt); + return __kho_debugfs_fdt_add(&dbg->fdt_list, dir, name, fdt, size); } =20 void kho_debugfs_fdt_remove(struct kho_debugfs *dbg, void *fdt) @@ -130,7 +130,8 @@ __init void kho_in_debugfs_init(struct kho_debugfs *dbg= , const void *fdt) goto err_rmdir; } =20 - err =3D __kho_debugfs_fdt_add(&dbg->fdt_list, dir, "fdt", fdt); + err =3D __kho_debugfs_fdt_add(&dbg->fdt_list, dir, "fdt", fdt, + fdt_totalsize(fdt)); if (err) goto err_rmdir; =20 @@ -138,6 +139,7 @@ __init void kho_in_debugfs_init(struct kho_debugfs *dbg= , const void *fdt) int len =3D 0; const char *name =3D fdt_get_name(fdt, child, NULL); const u64 *fdt_phys; + void *sub_fdt; =20 fdt_phys =3D fdt_getprop(fdt, child, "fdt", &len); if (!fdt_phys) @@ -147,8 +149,9 @@ __init void kho_in_debugfs_init(struct kho_debugfs *dbg= , const void *fdt) name, len); continue; } + sub_fdt =3D phys_to_virt(*fdt_phys); err =3D __kho_debugfs_fdt_add(&dbg->fdt_list, sub_fdt_dir, name, - phys_to_virt(*fdt_phys)); + sub_fdt, fdt_totalsize(sub_fdt)); if (err) { pr_warn("failed to add fdt %s to debugfs: %pe\n", name, ERR_PTR(err)); diff --git a/kernel/liveupdate/kexec_handover_internal.h b/kernel/liveupdat= e/kexec_handover_internal.h index 0202c85ad14f9..a51f97f0fa0e6 100644 --- a/kernel/liveupdate/kexec_handover_internal.h +++ b/kernel/liveupdate/kexec_handover_internal.h @@ -30,7 +30,7 @@ int kho_debugfs_init(void); void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt); int kho_out_debugfs_init(struct kho_debugfs *dbg); int kho_debugfs_fdt_add(struct kho_debugfs *dbg, const char *name, - const void *fdt, bool root); + const void *fdt, size_t size, bool root); void kho_debugfs_fdt_remove(struct kho_debugfs *dbg, void *fdt); #else static inline int kho_debugfs_init(void) { return 0; } @@ -38,7 +38,8 @@ static inline void kho_in_debugfs_init(struct kho_debugfs= *dbg, const void *fdt) { } static inline int kho_out_debugfs_init(struct kho_debugfs *dbg) { return 0= ; } static inline int kho_debugfs_fdt_add(struct kho_debugfs *dbg, const char = *name, - const void *fdt, bool root) { return 0; } + const void *fdt, size_t size, + bool root) { return 0; } static inline void kho_debugfs_fdt_remove(struct kho_debugfs *dbg, void *fdt) { } #endif /* CONFIG_KEXEC_HANDOVER_DEBUGFS */ diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c index dda7bb57d421c..a4721813dd994 100644 --- a/kernel/liveupdate/luo_core.c +++ b/kernel/liveupdate/luo_core.c @@ -172,7 +172,8 @@ static int __init luo_fdt_setup(void) if (err) goto exit_free; =20 - err =3D kho_add_subtree(LUO_FDT_KHO_ENTRY_NAME, fdt_out); + err =3D kho_add_subtree(LUO_FDT_KHO_ENTRY_NAME, fdt_out, + fdt_totalsize(fdt_out)); if (err) goto exit_free; luo_global.fdt_out =3D fdt_out; diff --git a/lib/test_kho.c b/lib/test_kho.c index a20fafaf9846b..f2d7d9108cf41 100644 --- a/lib/test_kho.c +++ b/lib/test_kho.c @@ -143,7 +143,8 @@ static int kho_test_preserve(struct kho_test_state *sta= te) if (err) goto err_unpreserve_data; =20 - err =3D kho_add_subtree(KHO_TEST_FDT, folio_address(state->fdt)); + err =3D kho_add_subtree(KHO_TEST_FDT, folio_address(state->fdt), + fdt_totalsize(folio_address(state->fdt))); if (err) goto err_unpreserve_data; =20 diff --git a/mm/memblock.c b/mm/memblock.c index b3ddfdec7a809..91d4162eec63f 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2510,7 +2510,7 @@ static int __init prepare_kho_fdt(void) if (err) goto err_unpreserve_fdt; =20 - err =3D kho_add_subtree(MEMBLOCK_KHO_FDT, fdt); + err =3D kho_add_subtree(MEMBLOCK_KHO_FDT, fdt, fdt_totalsize(fdt)); if (err) goto err_unpreserve_fdt; =20 --=20 2.47.3 From nobody Mon Jan 26 22:46:38 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 C0D622D661C for ; Mon, 26 Jan 2026 16:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443686; cv=none; b=X6TwXu+gWZRDqcKPISs1oV2GSnF2vZnS4Foi7tZkR3ofhK73n1WhQ+EXeTKBA2BEu6r/YMSc8SVOnvP0sJwwPLR1w8y1S7pnWf1IFGvjFyAcFypEpNLh2HhsrADGuHJXXc2l+cRscqmo54UPyZ1A5PFyh+SybUDZrvojHO28Io8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443686; c=relaxed/simple; bh=FxhEMlYSxj7IocH/QDYLiRAsQ2AOrEP3RLJsCaReCLk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VNGHCS+5wzDvMhvwmoIf2jMkeqKYm5zeV01Ro7oC/SN9aHUIRNYotYl4u8KEFBcwcKBr2jjCU6NF6hQkxoB2xrnLaLX5tFt42o67GNH4tQ9/9btr8zyyFnoYwPJTsOxLUBUaMZg5RCUguky8QjUZtPm4r4EPgrT048X45UZv1NM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=IFBAArkZ; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="IFBAArkZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=7JGr10StQBeBR7KNeSzsI6aZ5StNmX9VCvqO6kZy3tw=; b=IFBAArkZBkmrlMtfkO0gCudcxo qjG0+7l1OBtx17boj2WQXW0YKmJlSJIXxV1I1qqGPAVo3pfL+gxP49gylrOHHViitAsr59l0aNEZ2 Lkd3+Wdt+33LmlJN8l1lLwKt2u5cJaxe2wZJg+h0ADCoNCHqilphtqA6VXLi2W1F9BfSL8GWtNh/p UF4EgvVdvmfiSS30vEwWZ4gnCftmPych44tPlDPyUW+3TmBV2Jo1bp8QX8MvdaxDZro8Qr74JbznB AbkUz0FgQ0hApMYYIbtrL+6rgdOJL0s/jW/RI5XyBcFz56WS5NYTfFfDzsWmTmPyOaic+VKySSM5W gw8UEM4g==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vkP88-00GI7L-J0; Mon, 26 Jan 2026 16:07:56 +0000 From: Breno Leitao Date: Mon, 26 Jan 2026 08:07:24 -0800 Subject: [PATCH v5 2/4] kho: rename fdt parameter to blob in kho_add/remove_subtree() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-kho-v5-2-7cd0f69ab204@debian.org> References: <20260126-kho-v5-0-7cd0f69ab204@debian.org> In-Reply-To: <20260126-kho-v5-0-7cd0f69ab204@debian.org> To: Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, usamaarif642@gmail.com, rmikey@meta.com, clm@fb.com, riel@surriel.com, Breno Leitao , SeongJae Park , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=3996; i=leitao@debian.org; h=from:subject:message-id; bh=FxhEMlYSxj7IocH/QDYLiRAsQ2AOrEP3RLJsCaReCLk=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpd5FN9yco88W0GzD0jdb73XAIa/o6fVHCFpXhH TUpn882EBuJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaXeRTQAKCRA1o5Of/Hh3 bcn/EACKQ20zX7uH+X3Q1wI4dAzNApPR+EwiF3KDnV6lnyAJTk4BFpuLbDSzHXOTZVwVpEEwS4T juqOyVNxYcXd1fIm/hLxr1zF/e6J5hdKboBPIt7F+2HtjFvTQ6ntuDE6qVR/z1l1Givlf51ZEaZ vmRtOKO4uVsoEHb1eTKupgiVFKxbflitt/bgpkhmzALJy3GLM3nAmNAGN8tGbRfHQCKou6N4e31 i6eh2s3yQOupy70iiBgMcMaVEu8RBomFWBkHSOCOZp0+3nlY+JfBzLNwBO+TIRSguRE8ZUoh7A3 j7MFFSjN4rU51mggIBalrOtxG4Z+dPLFCK1usuQPRwxucTl/yvGWWrUmxNbyQq3ht2rStH92+m8 WErXY1PNCu7uYXBDjxh1nem1umAxhBwnkZRjuM4LcL92GZyBGVBSvlo2z9vQ8fK/p5NldbYFi0L 4bedgdgMTWJVGXA2cPOx4AtrO48y/DHJi+ZS99Q5lnletvhWgziAbZsJop97xvJt+iXcMnVtT7S qNz/CFh+GQv3wLX9A/dr+0fKL0qrn7BFfDfbs9yIteQu0PvFWbNLb+O30HRNcyAKnU+54bK/OPI ARrgwpuYPGMfdmhh8IwcrAJDheBQHms5jDKpLJZVVhLdh6GFO2GMeqV2YJ9tEIEbJKAeXXt5BnO sxYi0lvNRra3D8g== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Since kho_add_subtree() now accepts arbitrary data blobs (not just FDTs), rename the parameter from 'fdt' to 'blob' to better reflect its purpose. Apply the same rename to kho_remove_subtree() for consistency. Signed-off-by: Breno Leitao Acked-by: SeongJae Park --- include/linux/kexec_handover.h | 8 ++++---- kernel/liveupdate/kexec_handover.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h index abb1d324f42d0..0666cf298c7f4 100644 --- a/include/linux/kexec_handover.h +++ b/include/linux/kexec_handover.h @@ -32,8 +32,8 @@ void kho_restore_free(void *mem); struct folio *kho_restore_folio(phys_addr_t phys); struct page *kho_restore_pages(phys_addr_t phys, unsigned long nr_pages); void *kho_restore_vmalloc(const struct kho_vmalloc *preservation); -int kho_add_subtree(const char *name, void *fdt, size_t size); -void kho_remove_subtree(void *fdt); +int kho_add_subtree(const char *name, void *blob, size_t size); +void kho_remove_subtree(void *blob); int kho_retrieve_subtree(const char *name, phys_addr_t *phys); =20 void kho_memory_init(void); @@ -97,12 +97,12 @@ static inline void *kho_restore_vmalloc(const struct kh= o_vmalloc *preservation) return NULL; } =20 -static inline int kho_add_subtree(const char *name, void *fdt, size_t size) +static inline int kho_add_subtree(const char *name, void *blob, size_t siz= e) { return -EOPNOTSUPP; } =20 -static inline void kho_remove_subtree(void *fdt) { } +static inline void kho_remove_subtree(void *blob) { } =20 static inline int kho_retrieve_subtree(const char *name, phys_addr_t *phys) { diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index ad2da9e4e6a04..b1f3222a0052a 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -723,13 +723,13 @@ static void __init kho_reserve_scratch(void) } =20 /** - * kho_add_subtree - record the physical address of a sub FDT in KHO root = tree. + * kho_add_subtree - record the physical address of a sub blob in KHO root= tree. * @name: name of the sub tree. - * @fdt: the sub tree blob. + * @blob: the sub tree blob. * @size: size of the blob in bytes. * * Creates a new child node named @name in KHO root FDT and records - * the physical address of @fdt. The pages of @fdt must also be preserved + * the physical address of @blob. The pages of @blob must also be preserved * by KHO for the new kernel to retrieve it after kexec. * * A debugfs blob entry is also created at @@ -738,9 +738,9 @@ static void __init kho_reserve_scratch(void) * * Return: 0 on success, error code on failure */ -int kho_add_subtree(const char *name, void *fdt, size_t size) +int kho_add_subtree(const char *name, void *blob, size_t size) { - phys_addr_t phys =3D virt_to_phys(fdt); + phys_addr_t phys =3D virt_to_phys(blob); void *root_fdt =3D kho_out.fdt; int err =3D -ENOMEM; int off, fdt_err; @@ -763,7 +763,7 @@ int kho_add_subtree(const char *name, void *fdt, size_t= size) if (err < 0) goto out_pack; =20 - WARN_ON_ONCE(kho_debugfs_fdt_add(&kho_out.dbg, name, fdt, size, false)); + WARN_ON_ONCE(kho_debugfs_fdt_add(&kho_out.dbg, name, blob, size, false)); =20 out_pack: fdt_pack(root_fdt); @@ -772,9 +772,9 @@ int kho_add_subtree(const char *name, void *fdt, size_t= size) } EXPORT_SYMBOL_GPL(kho_add_subtree); =20 -void kho_remove_subtree(void *fdt) +void kho_remove_subtree(void *blob) { - phys_addr_t target_phys =3D virt_to_phys(fdt); + phys_addr_t target_phys =3D virt_to_phys(blob); void *root_fdt =3D kho_out.fdt; int off; int err; @@ -796,7 +796,7 @@ void kho_remove_subtree(void *fdt) =20 if ((phys_addr_t)*val =3D=3D target_phys) { fdt_del_node(root_fdt, off); - kho_debugfs_fdt_remove(&kho_out.dbg, fdt); + kho_debugfs_fdt_remove(&kho_out.dbg, blob); break; } } --=20 2.47.3 From nobody Mon Jan 26 22:46:38 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 D9DAF2D73A8 for ; Mon, 26 Jan 2026 16:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443692; cv=none; b=h8bROsBusaoLDrIPIwe6rt6eNuH5dQ2kE8Bt7n4l80erD98O7snBxqcu8+4zrR/qbfqWjRUKztSkjqBSObxMamyXfUkMEnnDx6ARJ3r0Y16IHOtUrufs6H9y97d/GsUsdihiXVXmOeELpYdNZ9h0RkhbNrzBkemVhf9qDNB0DOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443692; c=relaxed/simple; bh=RkXHBAO2rWRvBZyOTvq+Rsg40/Yaxfq39GNC5H2Vd/4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LEIHi7cGaTRxPvWMZ1NvL3gwBvuVkU0O7+Ibuak/7YFE7Rs3+0yEdpICrALlPmzr1R+mUlkonligxwVwzxzBOZxaCTbFyIyBCY8oTzgAgQPYx9X20MdQcmciIlTksAWFytdfC9DOMMJyCtEY5O4dFZI0oHO931x6fABt7R6w9Ys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=f87Wmtga; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="f87Wmtga" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=rELLbr3n1mvaAH8Jb6foKISzoRm/h7jGZezo/WIwGx8=; b=f87WmtgafJ0nCAUDS9JncRQhly cVhSmx5ZJ1zv07ks7ALi3SmIkaE7y3Uq+MCrYJBD6irqIiDQsqjQjYCVptBxjcgguaPyY0NF4MSys FIoY3zLhGiWWz6kwwakMPw7jGock4KmUjaX2ewEqqxJjPYLQKIp7QAtFw9tUJYkegYuPF67QC4pMf L3mahJc/rfFXQRpu0+l8wCrfsFyGfg5lTg7UxoeryoSsaGdaF8nnMhE9q5/dBNyby+ZU045T7k0IS ZozTEA0fqau9HTsATYbncc8Y8Qnvt1erqxTOB3YTcGtEfSKGpkrmQIX3/xnoQX+sHB2N1lstskr5r fn+T/VJw==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vkP8D-00GI7Y-0t; Mon, 26 Jan 2026 16:08:01 +0000 From: Breno Leitao Date: Mon, 26 Jan 2026 08:07:25 -0800 Subject: [PATCH v5 3/4] kho: kexec-metadata: track previous kernel chain Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-kho-v5-3-7cd0f69ab204@debian.org> References: <20260126-kho-v5-0-7cd0f69ab204@debian.org> In-Reply-To: <20260126-kho-v5-0-7cd0f69ab204@debian.org> To: Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, usamaarif642@gmail.com, rmikey@meta.com, clm@fb.com, riel@surriel.com, Breno Leitao , SeongJae Park , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=6745; i=leitao@debian.org; h=from:subject:message-id; bh=RkXHBAO2rWRvBZyOTvq+Rsg40/Yaxfq39GNC5H2Vd/4=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpd5FNIOtcvaP+mCzRl5ihLA/uECxANnIMeuoIs jaAi/aC+dWJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaXeRTQAKCRA1o5Of/Hh3 bWkwD/9l0X8jRNd7k1f9D4OM79/4D9vU14dyIwNlQ7/N8I6GGW2nZTR9d6X6XO1yDSoOTsZsGZ9 TboWX6xqPcIa1VArLdsBJssMemFV0LycOlUnvxGYjA/IkDap1V5hX36tW6A/Ho2VwZ/jgu+Ljl3 Lfo6MKMMuhSN9XgDFQilN03iQlpJ5cuWULi7G1xiDp7zlah8Lbu40s+Lb2ON5oWyUeZ0DlB2nan BAy86Dxz4d6jVuUEdPVc29dJkc2prYctqky680xfm+UviFyUQ+pnixD7NxN2WdhWsr33yOFm8Ls kX/itqBS/sk+bcRwvaKt6uT3IIEquKC25y938o39tqxQ6SO6aS54TqZHgx7JNvtfI1quQSGy6z9 mN8E3bWUwHMhuUndFYp0tUHMf8a6awq9bOv42jfmBpPHQD3wLcY4XRJ5599zwxjED9uBFflRlrs i9f0s/ZMbK+DFkWYa17RdBuLs8UOepoptAQfUQq3WKvLPmw+ei53aVQhzNhHsVhHRt7CipfyYMf 5gW8INgMjkrpGWHaX1SAF43sQuQvue6bAhD0axh/RoRI1YlqpW6ccItEn3RPbWDSQnQ/6N4lr6t LSNFL4zGQkI9/I9+t3sZCZg7AGf3g+20W1DnUkUvNDiyhQQy/wbkzyX0SkTjq5Gdl3JTzNgoVan 9AxGTm/fhR2oxhg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Use Kexec Handover (KHO) to pass the previous kernel's version string and the number of kexec reboots since the last cold boot to the next kernel, and print it at boot time. Example output: [ 0.000000] KHO: exec from: 6.19.0-rc4-next-20260107 (count 1) Motivation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bugs that only reproduce when kexecing from specific kernel versions are difficult to diagnose. These issues occur when a buggy kernel kexecs into a new kernel, with the bug manifesting only in the second kernel. Recent examples include the following commits: * eb2266312507 ("x86/boot: Fix page table access in 5-level to 4-level pag= ing transition") * 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avo= id corruption") * 64b45dd46e15 ("x86/efi: skip memattr table on kexec boot") As kexec-based reboots become more common, these version-dependent bugs are appearing more frequently. At scale, correlating crashes to the previous kernel version is challenging, especially when issues only occur in specific transition scenarios. Implementation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The kexec metadata is stored as a plain C struct (struct kho_kexec_metadata) rather than FDT format, for simplicity and direct field access. It is registered via kho_add_subtree() as a separate subtree, keeping it independent from the core KHO ABI. This design choice: - Keeps the core KHO ABI minimal and stable - Allows the metadata format to evolve independently - Avoids requiring version bumps for all KHO consumers (LUO, etc.) when the metadata format changes The struct kho_metadata contains two fields: - previous_release: The kernel version that initiated the kexec - kexec_count: Number of kexec boots since last cold boot On cold boot, kexec_count starts at 0 and increments with each kexec. The count helps identify issues that only manifest after multiple consecutive kexec reboots. Signed-off-by: Breno Leitao Acked-by: SeongJae Park --- include/linux/kho/abi/kexec_handover.h | 31 ++++++++++++++ kernel/liveupdate/kexec_handover.c | 74 ++++++++++++++++++++++++++++++= ++++ 2 files changed, 105 insertions(+) diff --git a/include/linux/kho/abi/kexec_handover.h b/include/linux/kho/abi= /kexec_handover.h index 2201a0d2c159a..1f017756e9991 100644 --- a/include/linux/kho/abi/kexec_handover.h +++ b/include/linux/kho/abi/kexec_handover.h @@ -11,6 +11,7 @@ #define _LINUX_KHO_ABI_KEXEC_HANDOVER_H =20 #include +#include =20 /** * DOC: Kexec Handover ABI @@ -84,6 +85,36 @@ /* The FDT property for sub-FDTs. */ #define KHO_FDT_SUB_TREE_PROP_NAME "fdt" =20 +/** + * DOC: Kexec Metadata ABI + * + * The "kexec-metadata" subtree stores optional metadata about the kexec c= hain. + * It is registered via kho_add_subtree(), keeping it independent from the= core + * KHO ABI. This allows the metadata format to evolve without affecting ot= her + * KHO consumers. + * + * The metadata is stored as a plain C struct rather than FDT format for + * simplicity and direct field access. + */ + +/** + * struct kho_kexec_metadata - Kexec metadata passed between kernels + * @previous_release: Kernel version string that initiated the kexec + * @kexec_count: Number of kexec boots since last cold boot + * + * This structure is preserved across kexec and allows the new kernel to + * identify which kernel it was booted from and how many kexec reboots + * have occurred. + * + * __NEW_UTS_LEN is part of UAPI, so it safe to use it in here. + */ +struct kho_kexec_metadata { + char previous_release[__NEW_UTS_LEN + 1]; + u32 kexec_count; +} __packed; + +#define KHO_METADATA_NODE_NAME "kexec-metadata" + /** * DOC: Kexec Handover ABI for vmalloc Preservation * diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index b1f3222a0052a..8250f318c4f69 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1267,6 +1268,8 @@ struct kho_in { phys_addr_t fdt_phys; phys_addr_t scratch_phys; phys_addr_t mem_map_phys; + char previous_release[__NEW_UTS_LEN + 1]; + u32 kexec_count; struct kho_debugfs dbg; }; =20 @@ -1352,6 +1355,73 @@ static __init int kho_out_fdt_setup(void) return err; } =20 +static void __init kho_in_kexec_metadata(void) +{ + struct kho_kexec_metadata *metadata; + phys_addr_t metadata_phys; + int err; + + err =3D kho_retrieve_subtree(KHO_METADATA_NODE_NAME, &metadata_phys); + if (err) + /* This is fine, previous kernel didn't export metadata */ + return; + metadata =3D phys_to_virt(metadata_phys); + + /* + * Copy data to the kernel structure that will persist during + * kernel lifetime. + */ + kho_in.kexec_count =3D metadata->kexec_count; + strscpy(kho_in.previous_release, metadata->previous_release, + sizeof(kho_in.previous_release)); + + pr_info("exec from: %s (count %u)\n", kho_in.previous_release, + kho_in.kexec_count); +} + +/* + * Create kexec metadata to pass kernel version and boot count to the + * next kernel. This keeps the core KHO ABI minimal and allows the + * metadata format to evolve independently. + */ +static __init int kho_out_kexec_metadata(void) +{ + struct kho_kexec_metadata *metadata; + int err; + + metadata =3D kho_alloc_preserve(sizeof(*metadata)); + if (IS_ERR(metadata)) + return PTR_ERR(metadata); + + strscpy(metadata->previous_release, init_uts_ns.name.release, + sizeof(metadata->previous_release)); + /* kho_in.kexec_count is set to 0 on cold boot */ + metadata->kexec_count =3D kho_in.kexec_count + 1; + + err =3D kho_add_subtree(KHO_METADATA_NODE_NAME, metadata, + sizeof(*metadata)); + if (err) + kho_unpreserve_free(metadata); + + return err; +} + +static int __init kho_kexec_metadata_init(const void *fdt) +{ + int err; + + if (fdt) + kho_in_kexec_metadata(); + + /* Populate kexec metadata for the possible next kexec */ + err =3D kho_out_kexec_metadata(); + if (err) + pr_warn("failed to initialize kexec-metadata subtree: %d\n", + err); + + return err; +} + static __init int kho_init(void) { const void *fdt =3D kho_get_fdt(); @@ -1378,6 +1448,10 @@ static __init int kho_init(void) if (err) goto err_free_fdt; =20 + err =3D kho_kexec_metadata_init(fdt); + if (err) + goto err_free_fdt; + if (fdt) { kho_in_debugfs_init(&kho_in.dbg, fdt); return 0; --=20 2.47.3 From nobody Mon Jan 26 22:46:38 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 AE2022DB79D for ; Mon, 26 Jan 2026 16:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443697; cv=none; b=krYndwEyToWPgQt2aRrI34I90TmuIjUe5AhXmrcTdyKxGMrcY4Iet0Sd4V/klH8OMq2vusLP+1OOSclt4CdE/O8vvvMQfDtJjm03mA+2x7PNj6AEwMRPiutQ0YV5pMUDXCISJk2sENfjgbR4T2Tc7kxKHrvfNEd1CgdekJLi6Yc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769443697; c=relaxed/simple; bh=LPIeB1HXx7yrXcJ/f/iPyLV8CRN9XseGBN7nDn4O/z8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lPuaNZsKQtQPYwhyIg+FbgxXECGxHJluEIqIz95I31HC6y0iQpidMA46q8Q7XPECuP5CD7pGY8X+btIouHjaNosuWfRMmKycVin0z/BQnZxxhkv/7zC5jLD3eYPqbZegpKVNVWdKzNalE93yq6fiPrFzdNXUh8A/+SecY2XRXRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=soYnZAFu; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="soYnZAFu" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=wD58s7Afm/VpqSfRj+q5T+RmL4WmAdEhDa4vBZoYFyo=; b=soYnZAFuPhU1DxNnsHIw5UePTQ a6FXz3eyOoC936m2ACmAu9h/bYT69r9a6FJkP5u/k8yIwyw4lDlocxXTrhrEOxQmn5IZZHzHTKgXd jJYDjTiSrC48CAIgY86GknFCOdTNCJr+jmto+pl/ijgnrxE3gMb2vLTDGDjb8+4BCegUjjcVqxlsE QapioKiqUz+On5qkl0WtwX6K80gtpXX9fDCQt0pkROmlusOjAyDfQBYX8b0K8eiVlkED2/NSsJjs+ fu/zDA8SfFrx3kMoT44WLucMzOsil77KxgDd7m2mmtKf7vYTG+vQQWIN+MCz7AFbinrs2zrO5akJG P6FvYxbw==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vkP8H-00GI7w-Im; Mon, 26 Jan 2026 16:08:05 +0000 From: Breno Leitao Date: Mon, 26 Jan 2026 08:07:26 -0800 Subject: [PATCH v5 4/4] kho: document kexec-metadata tracking feature Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260126-kho-v5-4-7cd0f69ab204@debian.org> References: <20260126-kho-v5-0-7cd0f69ab204@debian.org> In-Reply-To: <20260126-kho-v5-0-7cd0f69ab204@debian.org> To: Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, usamaarif642@gmail.com, rmikey@meta.com, clm@fb.com, riel@surriel.com, Breno Leitao , SeongJae Park , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=2407; i=leitao@debian.org; h=from:subject:message-id; bh=LPIeB1HXx7yrXcJ/f/iPyLV8CRN9XseGBN7nDn4O/z8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpd5FNsYxGYOfmgeChAKbgeCeJ4Qsp0Qy+6Zkp4 dy+wiT4aQKJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaXeRTQAKCRA1o5Of/Hh3 bT06EACm9JDRKk0yip7QtOwGH/xtGviLyn0x0lI5qHFZZWp/yqdNbU8HOP9iETSZuG/x1Tjn0+t 5wWTV05RZgrHkuZX3izl50nBeBf4TaWcMcYT+HojQG10w77/61U7/ZX/9skWqlbyfS68KrgAfGZ 6p7IfV/c99GbqvTo++uo3Q9aygJQ7lfkBdOMAFCC4oYMiP4CCGdWVsmNAzfH6K3RnYSL24QKHxc 0mmmkLaZnceiRq9U4spubZkyXtIP+s4Ul2zxOEXYBOQBcvCmGFCC6FPfYoi15Tzxe8sC/EIzZQX 4mYzZ9S4gT6QDj8L/FToall4nJr3eCua466cKVXuD2KAP/5Ns7RJTnbfMO2WH6LhdTmrlKEYK77 QX+WNSWjlXAzAsRh6XJ4IeRwUzhPDYtcLRblq97HB+Dw2R7O/tGM/QXcNiN66jXpYi2Ww14Pmnu yFRucwlpyVrkCsqOLuFoLa5EkMZONFYPUTYkWQLk7+VV7vQqS3A7/N2wIndlp4P9CLNSJK1yiCA CJ2ASYS8X84qZyg5UvZSO4ywk6UhmVdbMZrWheyFJ7ccGfggPxuocfWNsFPb2PRJDrCpnutsQ0O SoRrEEJkjnuY6dqwX8x1+Z5d3nf8RjSpga1r6jXGq0ApRL53Ho7IN6JHQ3Q8St4MqPN6CN3Vu8i qa1gXGhv4nZSXWA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Add documentation for the kexec-metadata feature that tracks the previous kernel version and kexec boot count across kexec reboots. This helps diagnose bugs that only reproduce when kexecing from specific kernel versions. Suggested-by: Mike Rapoport Signed-off-by: Breno Leitao Acked-by: SeongJae Park --- Documentation/admin-guide/mm/kho.rst | 39 ++++++++++++++++++++++++++++++++= ++++ 1 file changed, 39 insertions(+) diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-gui= de/mm/kho.rst index 6dc18ed4b8861..3771e764bb513 100644 --- a/Documentation/admin-guide/mm/kho.rst +++ b/Documentation/admin-guide/mm/kho.rst @@ -62,6 +62,45 @@ You can move the system out of KHO finalization phase ag= ain by calling :: After this command, the KHO FDT is no longer available in ``/sys/kernel/debug/kho/out/fdt``. =20 +Kexec Metadata +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +KHO automatically tracks metadata about the kexec chain, passing informati= on +about the previous kernel to the next kernel. This feature helps diagnose +bugs that only reproduce when kexecing from specific kernel versions. + +On each KHO kexec, the kernel logs the previous kernel's version and the +number of kexec reboots since the last cold boot:: + + [ 0.000000] KHO: exec from: 6.19.0-rc4-next-20260107 (count 1) + +The metadata includes: + +``previous_release`` + The kernel version string (from ``uname -r``) of the kernel that + initiated the kexec. + +``kexec_count`` + The number of kexec boots since the last cold boot. On cold boot, + this counter starts at 0 and increments with each kexec. This helps + identify issues that only manifest after multiple consecutive kexec + reboots. + +Use Cases +--------- + +This metadata is particularly useful for debugging kexec transition bugs, +where a buggy kernel kexecs into a new kernel and the bug manifests only +in the second kernel. Examples of such bugs include: + +- Memory corruption from the previous kernel affecting the new kernel +- Incorrect hardware state left by the previous kernel +- Firmware/ACPI state issues that only appear in kexec scenarios + +At scale, correlating crashes to the previous kernel version enables +faster root cause analysis when issues only occur in specific kernel +transition scenarios. + debugfs Interfaces =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.47.3