Track and display the number of kexec boots since the last cold reboot
when CONFIG_KEXEC_HISTORY is enabled.
This extends the previous kernel release tracking feature by adding
a counter that increments with each kexec boot. The counter provides
visibility into the kexec chain depth, which is useful for understanding
boot history in production environments.
Add a new property, "kexec-count" in KHO FDT alongside the existing
"previous-release" property. The counter is:
- Initialized to 0 when kho_in is instantiated.
- Incremented by 1 on each subsequent kexec.
- Printed alongside the previous kernel release version.
The counter is stored as a 32-bit unsigned integer in FDT format and is
only active when CONFIG_KEXEC_HISTORY is enabled.
Signed-off-by: Breno Leitao <leitao@debian.org>
Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
---
kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 06d99627bb3c..fe5a2c5c4c86 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -38,6 +38,7 @@
#define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map"
#define PROP_SUB_FDT "fdt"
#define PROP_PREVIOUS_RELEASE "previous-release"
+#define PROP_KEXEC_COUNT "kexec-count"
#define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */
@@ -1257,6 +1258,7 @@ struct kho_in {
phys_addr_t scratch_phys;
#ifdef CONFIG_KEXEC_HISTORY
char previous_release[__NEW_UTS_LEN + 1];
+ u32 kexec_count;
#endif
struct kho_debugfs dbg;
};
@@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void)
void *root = kho_out.fdt;
u64 empty_mem_map = 0;
int err;
+#ifdef CONFIG_KEXEC_HISTORY
+ u32 kexec_count;
+#endif
err = fdt_create(root, PAGE_SIZE);
err |= fdt_finish_reservemap(root);
@@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void)
#ifdef CONFIG_KEXEC_HISTORY
err |= fdt_property_string(root, PROP_PREVIOUS_RELEASE,
init_uts_ns.name.release);
+ /* kho_in.kexec_count is set to 0 on cold boot */
+ kexec_count = cpu_to_fdt32(kho_in.kexec_count + 1);
+ err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count,
+ sizeof(kexec_count));
#endif
err |= fdt_end_node(root);
err |= fdt_finish(root);
@@ -1468,6 +1477,7 @@ void __init kho_memory_init(void)
static void __init kho_print_previous_kernel(const void *fdt)
{
const char *prev_release;
+ const u32 *count_ptr;
int len;
prev_release = fdt_getprop(fdt, 0, PROP_PREVIOUS_RELEASE, &len);
@@ -1476,8 +1486,19 @@ static void __init kho_print_previous_kernel(const void *fdt)
strscpy(kho_in.previous_release, prev_release,
sizeof(kho_in.previous_release));
- pr_info("This kernel was kexec'ed from kernel release: %s\n",
- kho_in.previous_release);
+
+ /* Read the kexec count from the previous kernel */
+ count_ptr = fdt_getprop(fdt, 0, PROP_KEXEC_COUNT, &len);
+ if (WARN_ON_ONCE(!count_ptr || len <= 0))
+ /*
+ * PROP_KEXEC_COUNT should exist if PROP_PREVIOUS_RELEASE
+ * exists.
+ */
+ return;
+ kho_in.kexec_count = fdt32_to_cpu(*count_ptr);
+
+ pr_info("This kernel was kexec'ed from kernel release: %s (kexec count: %u)\n",
+ kho_in.previous_release, kho_in.kexec_count);
}
#else
static void __init kho_print_previous_kernel(const void *fdt) { }
--
2.47.3
On Fri, Jan 02 2026, Breno Leitao wrote: > Track and display the number of kexec boots since the last cold reboot Nit: this does not track kexec boots, it tracks KHO boots. None of this can work on normal kexec boots. Can you please update the wording to make that clear? > when CONFIG_KEXEC_HISTORY is enabled. > > This extends the previous kernel release tracking feature by adding > a counter that increments with each kexec boot. The counter provides > visibility into the kexec chain depth, which is useful for understanding > boot history in production environments. > > Add a new property, "kexec-count" in KHO FDT alongside the existing > "previous-release" property. The counter is: > > - Initialized to 0 when kho_in is instantiated. > - Incremented by 1 on each subsequent kexec. > - Printed alongside the previous kernel release version. > > The counter is stored as a 32-bit unsigned integer in FDT format and is > only active when CONFIG_KEXEC_HISTORY is enabled. We have such a counter for LUO as well from the properly "liveupdate-number". If you're using LUO, why can't you use that counter directly? If you're not using LUO, I'm curious, what's your use case? Right now KHO only supports reserve-mem outside of LUO. Is that what you plan to use? Also, do we want to keep both counters independently? Or do we have one and drop the other? Pasha, what do you think? [...] -- Regards, Pratyush Yadav
On Fri, Jan 02, 2026 at 09:23:18PM +0100, Pratyush Yadav wrote: > On Fri, Jan 02 2026, Breno Leitao wrote: > > > Track and display the number of kexec boots since the last cold reboot > > Nit: this does not track kexec boots, it tracks KHO boots. None of this > can work on normal kexec boots. Can you please update the wording to > make that clear? > > > when CONFIG_KEXEC_HISTORY is enabled. > > > > This extends the previous kernel release tracking feature by adding > > a counter that increments with each kexec boot. The counter provides > > visibility into the kexec chain depth, which is useful for understanding > > boot history in production environments. > > > > Add a new property, "kexec-count" in KHO FDT alongside the existing > > "previous-release" property. The counter is: > > > > - Initialized to 0 when kho_in is instantiated. > > - Incremented by 1 on each subsequent kexec. > > - Printed alongside the previous kernel release version. > > > > The counter is stored as a 32-bit unsigned integer in FDT format and is > > only active when CONFIG_KEXEC_HISTORY is enabled. > > We have such a counter for LUO as well from the properly > "liveupdate-number". If you're using LUO, why can't you use that counter > directly? > > If you're not using LUO, I'm curious, what's your use case? Right now > KHO only supports reserve-mem outside of LUO. Is that what you plan to > use? > > Also, do we want to keep both counters independently? Or do we have one > and drop the other? Pasha, what do you think? In fact, I do not have plan to use LUO right now. My goal is to pass the kexec release from kernel to another, and for that I am using KHO to pass this information. That said, I am planning to use KHO as the infrastructure to pass the kernel version from one kernel to another. Given that I don't think this "feature" should depend on LUO, maybe the counters should be independent (?!) Thanks --breno
On Tue, Jan 06 2026, Breno Leitao wrote: > On Fri, Jan 02, 2026 at 09:23:18PM +0100, Pratyush Yadav wrote: >> On Fri, Jan 02 2026, Breno Leitao wrote: >> >> > Track and display the number of kexec boots since the last cold reboot >> >> Nit: this does not track kexec boots, it tracks KHO boots. None of this >> can work on normal kexec boots. Can you please update the wording to >> make that clear? >> >> > when CONFIG_KEXEC_HISTORY is enabled. >> > >> > This extends the previous kernel release tracking feature by adding >> > a counter that increments with each kexec boot. The counter provides >> > visibility into the kexec chain depth, which is useful for understanding >> > boot history in production environments. >> > >> > Add a new property, "kexec-count" in KHO FDT alongside the existing >> > "previous-release" property. The counter is: >> > >> > - Initialized to 0 when kho_in is instantiated. >> > - Incremented by 1 on each subsequent kexec. >> > - Printed alongside the previous kernel release version. >> > >> > The counter is stored as a 32-bit unsigned integer in FDT format and is >> > only active when CONFIG_KEXEC_HISTORY is enabled. >> >> We have such a counter for LUO as well from the properly >> "liveupdate-number". If you're using LUO, why can't you use that counter >> directly? >> >> If you're not using LUO, I'm curious, what's your use case? Right now >> KHO only supports reserve-mem outside of LUO. Is that what you plan to >> use? >> >> Also, do we want to keep both counters independently? Or do we have one >> and drop the other? Pasha, what do you think? > > In fact, I do not have plan to use LUO right now. My goal is to pass the > kexec release from kernel to another, and for that I am using KHO to > pass this information. Oh, cool. Nice to see other use cases for KHO. > > That said, I am planning to use KHO as the infrastructure to pass the > kernel version from one kernel to another. > > Given that I don't think this "feature" should depend on LUO, maybe the > counters should be independent (?!) If you aren't using LUO then you certainly can't use its counter. But LUo users are all KHO users. So perhaps we can get away with removing the LUO one and moving it to KHO? -- Regards, Pratyush Yadav
On Fri, Jan 2, 2026 at 9:53 AM Breno Leitao <leitao@debian.org> wrote:
>
> Track and display the number of kexec boots since the last cold reboot
> when CONFIG_KEXEC_HISTORY is enabled.
>
> This extends the previous kernel release tracking feature by adding
> a counter that increments with each kexec boot. The counter provides
> visibility into the kexec chain depth, which is useful for understanding
> boot history in production environments.
>
> Add a new property, "kexec-count" in KHO FDT alongside the existing
> "previous-release" property. The counter is:
>
> - Initialized to 0 when kho_in is instantiated.
> - Incremented by 1 on each subsequent kexec.
> - Printed alongside the previous kernel release version.
>
> The counter is stored as a 32-bit unsigned integer in FDT format and is
> only active when CONFIG_KEXEC_HISTORY is enabled.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> ---
> kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> index 06d99627bb3c..fe5a2c5c4c86 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c
> @@ -38,6 +38,7 @@
> #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map"
> #define PROP_SUB_FDT "fdt"
> #define PROP_PREVIOUS_RELEASE "previous-release"
> +#define PROP_KEXEC_COUNT "kexec-count"
>
> #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */
>
> @@ -1257,6 +1258,7 @@ struct kho_in {
> phys_addr_t scratch_phys;
> #ifdef CONFIG_KEXEC_HISTORY
> char previous_release[__NEW_UTS_LEN + 1];
> + u32 kexec_count;
> #endif
> struct kho_debugfs dbg;
> };
> @@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void)
> void *root = kho_out.fdt;
> u64 empty_mem_map = 0;
> int err;
> +#ifdef CONFIG_KEXEC_HISTORY
> + u32 kexec_count;
> +#endif
>
> err = fdt_create(root, PAGE_SIZE);
> err |= fdt_finish_reservemap(root);
> @@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void)
> #ifdef CONFIG_KEXEC_HISTORY
> err |= fdt_property_string(root, PROP_PREVIOUS_RELEASE,
> init_uts_ns.name.release);
> + /* kho_in.kexec_count is set to 0 on cold boot */
> + kexec_count = cpu_to_fdt32(kho_in.kexec_count + 1);
For KHO preserved data we use native endiness, so do not bother with
cpu_to_fdt32.
> + err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count,
> + sizeof(kexec_count));
> #endif
> err |= fdt_end_node(root);
> err |= fdt_finish(root);
> @@ -1468,6 +1477,7 @@ void __init kho_memory_init(void)
> static void __init kho_print_previous_kernel(const void *fdt)
> {
> const char *prev_release;
> + const u32 *count_ptr;
> int len;
>
> prev_release = fdt_getprop(fdt, 0, PROP_PREVIOUS_RELEASE, &len);
> @@ -1476,8 +1486,19 @@ static void __init kho_print_previous_kernel(const void *fdt)
>
> strscpy(kho_in.previous_release, prev_release,
> sizeof(kho_in.previous_release));
> - pr_info("This kernel was kexec'ed from kernel release: %s\n",
> - kho_in.previous_release);
> +
> + /* Read the kexec count from the previous kernel */
> + count_ptr = fdt_getprop(fdt, 0, PROP_KEXEC_COUNT, &len);
> + if (WARN_ON_ONCE(!count_ptr || len <= 0))
This function is called only once anway.
> + /*
> + * PROP_KEXEC_COUNT should exist if PROP_PREVIOUS_RELEASE
> + * exists.
> + */
> + return;
> + kho_in.kexec_count = fdt32_to_cpu(*count_ptr);
> +
> + pr_info("This kernel was kexec'ed from kernel release: %s (kexec count: %u)\n",
> + kho_in.previous_release, kho_in.kexec_count);
> }
> #else
> static void __init kho_print_previous_kernel(const void *fdt) { }
>
> --
> 2.47.3
>
On 02/01/2026 17:53, Breno Leitao wrote:
> Track and display the number of kexec boots since the last cold reboot
> when CONFIG_KEXEC_HISTORY is enabled.
>
> This extends the previous kernel release tracking feature by adding
> a counter that increments with each kexec boot. The counter provides
> visibility into the kexec chain depth, which is useful for understanding
> boot history in production environments.
>
> Add a new property, "kexec-count" in KHO FDT alongside the existing
> "previous-release" property. The counter is:
>
> - Initialized to 0 when kho_in is instantiated.
> - Incremented by 1 on each subsequent kexec.
> - Printed alongside the previous kernel release version.
>
> The counter is stored as a 32-bit unsigned integer in FDT format and is
> only active when CONFIG_KEXEC_HISTORY is enabled.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> ---
> kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> index 06d99627bb3c..fe5a2c5c4c86 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c
> @@ -38,6 +38,7 @@
> #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map"
> #define PROP_SUB_FDT "fdt"
> #define PROP_PREVIOUS_RELEASE "previous-release"
> +#define PROP_KEXEC_COUNT "kexec-count"
>
> #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */
>
> @@ -1257,6 +1258,7 @@ struct kho_in {
> phys_addr_t scratch_phys;
> #ifdef CONFIG_KEXEC_HISTORY
> char previous_release[__NEW_UTS_LEN + 1];
> + u32 kexec_count;
> #endif
> struct kho_debugfs dbg;
> };
> @@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void)
> void *root = kho_out.fdt;
> u64 empty_mem_map = 0;
> int err;
> +#ifdef CONFIG_KEXEC_HISTORY
> + u32 kexec_count;
> +#endif
>
> err = fdt_create(root, PAGE_SIZE);
> err |= fdt_finish_reservemap(root);
> @@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void)
> #ifdef CONFIG_KEXEC_HISTORY
> err |= fdt_property_string(root, PROP_PREVIOUS_RELEASE,
> init_uts_ns.name.release);
> + /* kho_in.kexec_count is set to 0 on cold boot */
> + kexec_count = cpu_to_fdt32(kho_in.kexec_count + 1);
Should this be kexec_count = cpu_to_fdt32(kho_in.kexec_count) + 1; ?
> + err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count,
> + sizeof(kexec_count));
> #endif
> err |= fdt_end_node(root);
> err |= fdt_finish(root);
> @@ -1468,6 +1477,7 @@ void __init kho_memory_init(void)
> static void __init kho_print_previous_kernel(const void *fdt)
> {
> const char *prev_release;
> + const u32 *count_ptr;
> int len;
>
> prev_release = fdt_getprop(fdt, 0, PROP_PREVIOUS_RELEASE, &len);
> @@ -1476,8 +1486,19 @@ static void __init kho_print_previous_kernel(const void *fdt)
>
> strscpy(kho_in.previous_release, prev_release,
> sizeof(kho_in.previous_release));
> - pr_info("This kernel was kexec'ed from kernel release: %s\n",
> - kho_in.previous_release);
> +
> + /* Read the kexec count from the previous kernel */
> + count_ptr = fdt_getprop(fdt, 0, PROP_KEXEC_COUNT, &len);
> + if (WARN_ON_ONCE(!count_ptr || len <= 0))
> + /*
> + * PROP_KEXEC_COUNT should exist if PROP_PREVIOUS_RELEASE
> + * exists.
> + */
> + return;
> + kho_in.kexec_count = fdt32_to_cpu(*count_ptr);
> +
> + pr_info("This kernel was kexec'ed from kernel release: %s (kexec count: %u)\n",
> + kho_in.previous_release, kho_in.kexec_count);
> }
> #else
> static void __init kho_print_previous_kernel(const void *fdt) { }
>
Hello Usama,
On Fri, Jan 02, 2026 at 06:09:57PM +0300, Usama Arif wrote:
>
> On 02/01/2026 17:53, Breno Leitao wrote:
> > Track and display the number of kexec boots since the last cold reboot
> > when CONFIG_KEXEC_HISTORY is enabled.
> >
> > This extends the previous kernel release tracking feature by adding
> > a counter that increments with each kexec boot. The counter provides
> > visibility into the kexec chain depth, which is useful for understanding
> > boot history in production environments.
> >
> > Add a new property, "kexec-count" in KHO FDT alongside the existing
> > "previous-release" property. The counter is:
> >
> > - Initialized to 0 when kho_in is instantiated.
> > - Incremented by 1 on each subsequent kexec.
> > - Printed alongside the previous kernel release version.
> >
> > The counter is stored as a 32-bit unsigned integer in FDT format and is
> > only active when CONFIG_KEXEC_HISTORY is enabled.
> >
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
> > ---
> > kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++--
> > 1 file changed, 23 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> > index 06d99627bb3c..fe5a2c5c4c86 100644
> > --- a/kernel/liveupdate/kexec_handover.c
> > +++ b/kernel/liveupdate/kexec_handover.c
> > @@ -38,6 +38,7 @@
> > #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map"
> > #define PROP_SUB_FDT "fdt"
> > #define PROP_PREVIOUS_RELEASE "previous-release"
> > +#define PROP_KEXEC_COUNT "kexec-count"
> >
> > #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */
> >
> > @@ -1257,6 +1258,7 @@ struct kho_in {
> > phys_addr_t scratch_phys;
> > #ifdef CONFIG_KEXEC_HISTORY
> > char previous_release[__NEW_UTS_LEN + 1];
> > + u32 kexec_count;
> > #endif
> > struct kho_debugfs dbg;
> > };
> > @@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void)
> > void *root = kho_out.fdt;
> > u64 empty_mem_map = 0;
> > int err;
> > +#ifdef CONFIG_KEXEC_HISTORY
> > + u32 kexec_count;
> > +#endif
> >
> > err = fdt_create(root, PAGE_SIZE);
> > err |= fdt_finish_reservemap(root);
> > @@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void)
> > #ifdef CONFIG_KEXEC_HISTORY
> > err |= fdt_property_string(root, PROP_PREVIOUS_RELEASE,
> > init_uts_ns.name.release);
> > + /* kho_in.kexec_count is set to 0 on cold boot */
> > + kexec_count = cpu_to_fdt32(kho_in.kexec_count + 1);
>
> Should this be kexec_count = cpu_to_fdt32(kho_in.kexec_count) + 1; ?
I don't think so. Basically we want to increment the counter in native
endianess and then convert to the Big Endian (FDT/DT are big endian
AFAIK) and then store (line below) to the DT.
If we convert to big endian and then sum 1, it will mess with the
result.
> + err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count,
> > + sizeof(kexec_count));
Thanks for the review,
--breno
On 02/01/2026 18:24, Breno Leitao wrote:
> Hello Usama,
>
> On Fri, Jan 02, 2026 at 06:09:57PM +0300, Usama Arif wrote:
>>
>> On 02/01/2026 17:53, Breno Leitao wrote:
>>> Track and display the number of kexec boots since the last cold reboot
>>> when CONFIG_KEXEC_HISTORY is enabled.
>>>
>>> This extends the previous kernel release tracking feature by adding
>>> a counter that increments with each kexec boot. The counter provides
>>> visibility into the kexec chain depth, which is useful for understanding
>>> boot history in production environments.
>>>
>>> Add a new property, "kexec-count" in KHO FDT alongside the existing
>>> "previous-release" property. The counter is:
>>>
>>> - Initialized to 0 when kho_in is instantiated.
>>> - Incremented by 1 on each subsequent kexec.
>>> - Printed alongside the previous kernel release version.
>>>
>>> The counter is stored as a 32-bit unsigned integer in FDT format and is
>>> only active when CONFIG_KEXEC_HISTORY is enabled.
>>>
>>> Signed-off-by: Breno Leitao <leitao@debian.org>
>>> Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
>>> ---
>>> kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++--
>>> 1 file changed, 23 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
>>> index 06d99627bb3c..fe5a2c5c4c86 100644
>>> --- a/kernel/liveupdate/kexec_handover.c
>>> +++ b/kernel/liveupdate/kexec_handover.c
>>> @@ -38,6 +38,7 @@
>>> #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map"
>>> #define PROP_SUB_FDT "fdt"
>>> #define PROP_PREVIOUS_RELEASE "previous-release"
>>> +#define PROP_KEXEC_COUNT "kexec-count"
>>>
>>> #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */
>>>
>>> @@ -1257,6 +1258,7 @@ struct kho_in {
>>> phys_addr_t scratch_phys;
>>> #ifdef CONFIG_KEXEC_HISTORY
>>> char previous_release[__NEW_UTS_LEN + 1];
>>> + u32 kexec_count;
>>> #endif
>>> struct kho_debugfs dbg;
>>> };
>>> @@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void)
>>> void *root = kho_out.fdt;
>>> u64 empty_mem_map = 0;
>>> int err;
>>> +#ifdef CONFIG_KEXEC_HISTORY
>>> + u32 kexec_count;
>>> +#endif
>>>
>>> err = fdt_create(root, PAGE_SIZE);
>>> err |= fdt_finish_reservemap(root);
>>> @@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void)
>>> #ifdef CONFIG_KEXEC_HISTORY
>>> err |= fdt_property_string(root, PROP_PREVIOUS_RELEASE,
>>> init_uts_ns.name.release);
>>> + /* kho_in.kexec_count is set to 0 on cold boot */
>>> + kexec_count = cpu_to_fdt32(kho_in.kexec_count + 1);
>>
>> Should this be kexec_count = cpu_to_fdt32(kho_in.kexec_count) + 1; ?
>
> I don't think so. Basically we want to increment the counter in native
> endianess and then convert to the Big Endian (FDT/DT are big endian
> AFAIK) and then store (line below) to the DT.
>
> If we convert to big endian and then sum 1, it will mess with the
> result.
ack, Thanks for explaining, I didnt think of endianess!
>
>> + err |= fdt_property(root, PROP_KEXEC_COUNT, &kexec_count,
>>> + sizeof(kexec_count));
>
> Thanks for the review,
> --breno
© 2016 - 2026 Red Hat, Inc.