[PATCH v3 0/2] kho: history: track previous kernel version and kexec boot count

Breno Leitao posted 2 patches 1 month ago
There is a newer version of this series
include/linux/kho/abi/kexec_handover.h |  6 ++++++
kernel/liveupdate/kexec_handover.c     | 39 +++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletion(-)
[PATCH v3 0/2] kho: history: track previous kernel version and kexec boot count
Posted by Breno Leitao 1 month ago
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
=======
	[    0.000000] Linux version 6.19.0-rc3-upstream-00047-ge5d992347849
	...
        [    0.000000] KHO: exec from: 6.19.0-rc4-next-20260107upstream-00004-g3071b0dc4498 (count 1)

Motivation
==========

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:

 * eb2266312507 ("x86/boot: Fix page table access in 5-level to 4-level paging transition")
 * 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avoid 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.

Some bugs manifest only after multiple consecutive kexec reboots.
Tracking the kexec count helps identify these cases (this metric is
already used by live update sub-system).

KHO provides a reliable mechanism to pass information between kernels.
By carrying the previous kernel's release string and kexec count
forward, we can print this context at boot time to aid debugging.

The goal of this feature is to have this information being printed in
early boot, so, users can trace back kernel releases in kexec. Systemd
is not helpful because we cannot assume that the previous kernel has
systemd or even write access to the disk (common when using Linux as
bootloaders)

Signed-off-by: Breno Leitao <leitao@debian.org>
---
Changes from v1 to RFC
- Track the number of kexecs since cold boot (Pasha)
- Change the printk() order compared to KHO
- Rewording of the commit summary
- Link to RFC: https://patch.msgid.link/20251230-kho-v1-1-4d795a24da9e@debian.org

---
Changes in v3:
- Remove the extra CONFIG for this feature.
- Reworded some identifiers, properties and printks.
- Better documented the questions raised during v2.
- Link to v2: https://patch.msgid.link/20260102-kho-v2-0-1747b1a3a1d6@debian.org

---
Breno Leitao (2):
      kho: history: track previous kernel version
      kho: history: track kexec boot counter

 include/linux/kho/abi/kexec_handover.h |  6 ++++++
 kernel/liveupdate/kexec_handover.c     | 39 +++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
---
base-commit: 5eec2b2e1f37acff8b926d2494eadaeef59be279
change-id: 20251230-kho-7707e8a2ef1e

Best regards,
--  
Breno Leitao <leitao@debian.org>
Re: [PATCH v3 0/2] kho: history: track previous kernel version and kexec boot count
Posted by SeongJae Park 4 weeks, 1 day ago
On Thu, 08 Jan 2026 08:40:57 -0800 Breno Leitao <leitao@debian.org> wrote:

> 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
> =======
> 	[    0.000000] Linux version 6.19.0-rc3-upstream-00047-ge5d992347849
> 	...
>         [    0.000000] KHO: exec from: 6.19.0-rc4-next-20260107upstream-00004-g3071b0dc4498 (count 1)

Nit.  The above snippet uses tabs for first two lines, while the third line
uses spaces.  I don't really mind this of course, please feel free to ignore.
I just wanted to prove I did read your cover letter ;)

> 
> Motivation
> ==========
> 
> 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:
> 
>  * eb2266312507 ("x86/boot: Fix page table access in 5-level to 4-level paging transition")
>  * 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avoid 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.
> 
> Some bugs manifest only after multiple consecutive kexec reboots.
> Tracking the kexec count helps identify these cases (this metric is
> already used by live update sub-system).
> 
> KHO provides a reliable mechanism to pass information between kernels.
> By carrying the previous kernel's release string and kexec count
> forward, we can print this context at boot time to aid debugging.
> 
> The goal of this feature is to have this information being printed in
> early boot, so, users can trace back kernel releases in kexec. Systemd
> is not helpful because we cannot assume that the previous kernel has
> systemd or even write access to the disk (common when using Linux as
> bootloaders)

Sounds this feature will be useful!  Thank you for detailed cover letter.

> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

The patches also look good to me.  For the series,

Acked-by: SeongJae Park <sj@kernel.org>

> ---
> Changes from v1 to RFC

Nit.  You mean "from RFC (v1) to v2"?  Again, I don't really mind this trivial
thing, so please feel free to ignore.

> - Track the number of kexecs since cold boot (Pasha)
> - Change the printk() order compared to KHO
> - Rewording of the commit summary
> - Link to RFC: https://patch.msgid.link/20251230-kho-v1-1-4d795a24da9e@debian.org
> 
> ---
> Changes in v3:
> - Remove the extra CONFIG for this feature.
> - Reworded some identifiers, properties and printks.
> - Better documented the questions raised during v2.
> - Link to v2: https://patch.msgid.link/20260102-kho-v2-0-1747b1a3a1d6@debian.org


Thanks,
SJ

[...]
Re: [PATCH v3 0/2] kho: history: track previous kernel version and kexec boot count
Posted by Breno Leitao 4 weeks, 1 day ago
Hello SJ,

On Thu, Jan 08, 2026 at 05:45:58PM -0800, SeongJae Park wrote:
> On Thu, 08 Jan 2026 08:40:57 -0800 Breno Leitao <leitao@debian.org> wrote:
> 
> > 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
> > =======
> > 	[    0.000000] Linux version 6.19.0-rc3-upstream-00047-ge5d992347849
> > 	...
> >         [    0.000000] KHO: exec from: 6.19.0-rc4-next-20260107upstream-00004-g3071b0dc4498 (count 1)
> 
> Nit.  The above snippet uses tabs for first two lines, while the third line
> uses spaces.  I don't really mind this of course, please feel free to ignore.
> I just wanted to prove I did read your cover letter ;)

Thanks for reading it very carefully.

[...]
> Sounds this feature will be useful!  Thank you for detailed cover letter.
> 
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> 
> The patches also look good to me.  For the series,
> 
> Acked-by: SeongJae Park <sj@kernel.org>
> 
> > ---
> > Changes from v1 to RFC
> 
> Nit.  You mean "from RFC (v1) to v2"?  Again, I don't really mind this trivial
> thing, so please feel free to ignore.

Ack, my fault here. I am using b4, and I need to learn how to deal with 
RFC -> V1 ambiguity better.

If there is a need to update this patchset, I will get them fixed in the
next version.

Thanks for the review,
--breno