Re: [PATCH v3 4/7] kho: replace KHO FDT with kstate metadata

Andrey Ryabinin
2025-09-11T16:54:51Z

On 9/10/25 6:50 PM, Rob Herring wrote:
> On Tue, Sep 09, 2025 at 10:14:39PM +0200, Andrey Ryabinin wrote:
>> Store KSTATE physical address & size instead of FDT in kho_data.
>> and initialize KSTATE from kho_populate().
>> To be able to use FDT in parallel with KSTATE place FDT
>> address&size into 'struct kho_fdt' and save/restore it using KSTATE.
>>
>> This finishes wiring KSTATE with KHO, making it fully functional.
>>
>> Signed-off-by: Andrey Ryabinin <arbn@yandex-team.com>
>> ---
>> arch/x86/include/uapi/asm/setup_data.h | 4 +-
>> arch/x86/kernel/kexec-bzimage64.c | 6 +--
>> arch/x86/kernel/setup.c | 3 +-
>> drivers/of/fdt.c | 6 +--
>> include/linux/kexec.h | 2 +-
>> include/linux/kstate.h | 1 +
>> kernel/liveupdate/kexec_handover.c | 60 +++++++++++++++++++++-----
>> 7 files changed, 61 insertions(+), 21 deletions(-)
>>
>> diff --git a/arch/x86/include/uapi/asm/setup_data.h b/arch/x86/include/uapi/asm/setup_data.h
>> index 2671c4e1b3a0..844f5b93473f 100644
>> --- a/arch/x86/include/uapi/asm/setup_data.h
>> +++ b/arch/x86/include/uapi/asm/setup_data.h
>> @@ -83,8 +83,8 @@ struct ima_setup_data {
>> * Locations of kexec handover metadata
>> */
>> struct kho_data {
>> - __u64 fdt_addr;
>> - __u64 fdt_size;
>> + __u64 kstate_addr;
>> + __u64 kstate_size;
>> __u64 scratch_addr;
>> __u64 scratch_size;
>> } __attribute__((packed));
>
> Isn't this part of the ABI which you can't just change.
>
> Rob

Yes, it is part of the ABI and layout of this struct can't be changed.
But this change only affects semantics of fields, layout stays the same,
so this should be ok.

If we kexec from an old kernel and kho_data contains FDT address,
the initialization of KSTATE will just fail and boot should continue as
if there was no kho_data at all. At current stage of KHO development,
without real users, change like this should be fine.