Re: [PATCH v4 06/19] kho: kexec_metadata: Add the feature header

From: Pasha Tatashin

Date: Tue Nov 10 2026 - 11:25:58 EST


> The kexec metadata subtree currently uses a monolithic u32 version field
> to identify the metadata structure layout. Any change to the structure,
> even an optional additive field, requires incrementing the version and
> breaks compatibility between adjacent kernels.
>
> Replace the u32 version field in struct kho_kexec_metadata with
> struct kho_ser_hdr using DECLARE_KHO_SER. Later fields can be appended
> under new feature indices without breaking compatibility across kexec.
> Also make the 3-byte padding hole between previous_release and kexec_count
> explicit as reserved[3].
>
> During deserialization, validate the blob size against the header size
> and reject unknown required features. A legacy v1 metadata blob is
> ignored with a warning.
>
> Signed-off-by: Tarun Sahu <tarunsahu@xxxxxxxxxx>
>
> diff --git a/include/linux/kho/abi/kexec_metadata.h b/include/linux/kho/abi/kexec_metadata.h
> index e9e3f7e38a7c..316b3e5ad01b 100644
> --- a/include/linux/kho/abi/kexec_metadata.h
> +++ b/include/linux/kho/abi/kexec_metadata.h
> @@ -18,28 +18,31 @@
> #ifndef _LINUX_KHO_ABI_KEXEC_METADATA_H
> #define _LINUX_KHO_ABI_KEXEC_METADATA_H
>
> +#include <linux/build_bug.h>
> +#include <linux/kho/abi/feature.h>
> #include <linux/types.h>
> #include <linux/utsname.h>
>
> -#define KHO_KEXEC_METADATA_VERSION 1
> -
> /**
> * struct kho_kexec_metadata - Kexec metadata passed between kernels
> - * @version: ABI version of this struct (must be first field)
> * @previous_release: Kernel version string that initiated the kexec
> + * @reserved: Reserved for structure alignment; must be zero
> * @kexec_count: Number of kexec boots since last cold boot
> *
> - * This structure is preserved across kexec and allows the new kernel to
> + * This structure is preserved across kexec and allows the target kernel to
> * identify which kernel it was booted from and how many kexec reboots
> - * have occurred.
> + * have occurred. Preceded by &struct kho_ser_hdr.
> *
> * __NEW_UTS_LEN is part of uABI, so it safe to use it in here.
> */
> struct kho_kexec_metadata {
> - u32 version;
> char previous_release[__NEW_UTS_LEN + 1];
> + u8 reserved[3];
> u32 kexec_count;
> -} __packed;
> +} __aligned(8);

Why __packed was not removed in the first commit? __aligned(8) should
not be needed, given that it must follow DECLARE_KHO_SER which is 8-byte
aligned.

> +
> +/* Register kho_kexec_metadata with KHO serialization accessors */
here and in all other places, please remove this comment.

> +DECLARE_KHO_SER(kho_kexec_metadata, 72, 0, 0);
>
> #define KHO_METADATA_NODE_NAME "kexec-metadata"
>
> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> index 6f1f55fe3181..2edd772bb6d3 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c
> @@ -1740,6 +1740,7 @@ static __init int kho_out_fdt_setup(void)
>
> static void __init kho_in_kexec_metadata(void)
> {
> + DECLARE_KHO_SER_HDR(kho_kexec_metadata, *fhdr);

Please don't do this, use kho_ser_hdr directly.

--
Pasha