From: Breno Leitao <leitao@debian.org>
To: Alexander Graf <graf@amazon.com>, Mike Rapoport <rppt@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Pratyush Yadav <pratyush@kernel.org>
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 <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH v3 1/2] kho: history: track previous kernel version
Date: Thu, 08 Jan 2026 08:40:58 -0800 [thread overview]
Message-ID: <20260108-kho-v3-1-b1d6b7a89342@debian.org> (raw)
In-Reply-To: <20260108-kho-v3-0-b1d6b7a89342@debian.org>
Store and display the kernel version from the previous kexec boot.
The current kernel's release string is saved to the "previous-release"
property in the KHO FDT before kexec. On the next boot, if this property
exists, the previous kernel version is retrieved and printed during
early boot.
This helps diagnose bugs that only manifest when kexecing from specific
kernel versions, making it easier to correlate crashes with the kernel
that initiated the kexec.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
include/linux/kho/abi/kexec_handover.h | 3 +++
kernel/liveupdate/kexec_handover.c | 25 ++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/include/linux/kho/abi/kexec_handover.h b/include/linux/kho/abi/kexec_handover.h
index 285eda8a36e4..f4f31e8f575b 100644
--- a/include/linux/kho/abi/kexec_handover.h
+++ b/include/linux/kho/abi/kexec_handover.h
@@ -84,6 +84,9 @@
/* The FDT property for sub-FDTs. */
#define KHO_FDT_SUB_TREE_PROP_NAME "fdt"
+/* The FDT property to track previous kernel (kexec caller) */
+#define KHO_PROP_PREVIOUS_RELEASE "previous-release"
+
/**
* DOC: Kexec Handover ABI for vmalloc Preservation
*
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 3cf2dc6840c9..b2d57868d22f 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -22,6 +22,7 @@
#include <linux/page-isolation.h>
#include <linux/unaligned.h>
#include <linux/vmalloc.h>
+#include <linux/utsname.h>
#include <asm/early_ioremap.h>
@@ -1246,6 +1247,7 @@ 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];
struct kho_debugfs dbg;
};
@@ -1325,6 +1327,8 @@ static __init int kho_out_fdt_setup(void)
err |= fdt_property_string(root, "compatible", KHO_FDT_COMPATIBLE);
err |= fdt_property(root, KHO_FDT_MEMORY_MAP_PROP_NAME, &empty_mem_map,
sizeof(empty_mem_map));
+ err |= fdt_property_string(root, KHO_PROP_PREVIOUS_RELEASE,
+ init_uts_ns.name.release);
err |= fdt_end_node(root);
err |= fdt_finish(root);
@@ -1436,6 +1440,22 @@ void __init kho_memory_init(void)
}
}
+static int __init kho_print_previous_kernel(const void *fdt)
+{
+ const char *prev_release;
+ int len;
+
+ prev_release = fdt_getprop(fdt, 0, KHO_PROP_PREVIOUS_RELEASE, &len);
+ if (!prev_release || len <= 0)
+ return -ENOENT;
+
+ strscpy(kho_in.previous_release, prev_release,
+ sizeof(kho_in.previous_release));
+ pr_info("exec from: %s\n", kho_in.previous_release);
+
+ return 0;
+}
+
void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
phys_addr_t scratch_phys, u64 scratch_len)
{
@@ -1513,7 +1533,10 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
kho_in.scratch_phys = scratch_phys;
kho_in.mem_map_phys = mem_map_phys;
kho_scratch_cnt = scratch_cnt;
- pr_info("found kexec handover data.\n");
+
+ if (kho_print_previous_kernel(fdt))
+ /* Fallback message when previous kernel info unavailable */
+ pr_info("found kexec handover data.\n");
out:
if (fdt)
--
2.47.3
next prev parent reply other threads:[~2026-01-08 16:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 16:40 [PATCH v3 0/2] kho: history: track previous kernel version and kexec boot count Breno Leitao
2026-01-08 16:40 ` Breno Leitao [this message]
2026-01-08 16:40 ` [PATCH v3 2/2] kho: history: track kexec boot counter Breno Leitao
2026-01-09 1:45 ` [PATCH v3 0/2] kho: history: track previous kernel version and kexec boot count SeongJae Park
2026-01-09 11:00 ` Breno Leitao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260108-kho-v3-1-b1d6b7a89342@debian.org \
--to=leitao@debian.org \
--cc=clm@fb.com \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=riel@surriel.com \
--cc=rmikey@meta.com \
--cc=rppt@kernel.org \
--cc=usamaarif642@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox