Re: [PATCH v4 05/19] kho: Add feature header for fine-grained ABI compatibility
From: tarunsahu
Date: Tue Nov 10 2026 - 13:32:47 EST
"Pasha Tatashin" <pasha.tatashin@xxxxxxxxxx> writes:
> On Tue Nov 10, 2026 at 12:01 AM EST, Tarun Sahu wrote:
>
>> +/**
>> + * DECLARE_KHO_SER - Register a serialized payload structure with KHO.
>> + * @name: Structure tag name (e.g. luo_ser).
>> + * @payload_size: Compile-time expected size of struct @name in bytes.
>> + * @nr_required: Total number of defined required features.
>> + * @nr_optional: Total number of defined optional features.
>> + *
>> + * Size and 8-byte alignment are asserted under CONFIG_64BIT: KHO and LUO are
>> + * 64-bit only, while !CONFIG_KEXEC_HANDOVER stubs pull ABI headers into
>> + * 32-bit builds where u64 has 4-byte or 2-byte alignment.
>> + */
>> +#define DECLARE_KHO_SER(name, payload_size, nr_required, nr_optional) \
>> + static_assert(!IS_ENABLED(CONFIG_64BIT) || \
>> + sizeof(struct name) == (payload_size), \
>> + "struct " #name " size mismatch"); \
>> + static_assert(!IS_ENABLED(CONFIG_64BIT) || \
>> + __alignof__(struct name) == 8, \
>> + "struct " #name " must be 8-byte aligned"); \
>> + extern struct kho_ser_hdr __kho_ser_hdr_##name; \
>
> Remove this extern.
>
>> + enum { \
>> + __KHO_SER_SIZE_##name = (payload_size), \
>> + __KHO_SER_NR_REQUIRED_##name = (nr_required), \
>> + __KHO_SER_NR_OPTIONAL_##name = (nr_optional), \
>> + }
>> +
>> +/**
>> + * DECLARE_KHO_SER_HDR - Declare a feature header variable, field, or parameter.
>> + * @name: Structure tag name registered with DECLARE_KHO_SER().
>> + * @decl: Declarator (e.g. *fhdr, **out_fhdr, or * inside DECLARE_KHOSER_PTR).
>> + *
>> + * Declares @decl with type struct kho_ser_hdr while checking at compile time
>> + * that @name was registered with DECLARE_KHO_SER(), documenting which
>> + * serialized payload structure a feature header pointer belongs to.
>> + */
>> +#define DECLARE_KHO_SER_HDR(name, decl) typeof(__kho_ser_hdr_##name) decl
>
> Remove DECLARE_KHO_SER_HDR, use kho_ser_hdr directly.
I added this, because wherever in the kernel a serialized struture is
preceded with kho_ser_hdr, it will only be called `struct kho_ser_hdr
fhdr` which does not display (to readers) that this declaration of
header variable is not alone, it also holds the serialized structure
after this variable.
Using this macro, it clearly explain, that "Hey, I am header to this
serialized struct and I am compiled time initalized using
DECLARE_KHO_SER for this serialized structure and my pointer holds
location to both feature header followed by serialized structure."
Techinically this is just for readability.
WDYT?
~Tarun
>
> --
> Pasha