Re: [PATCH v5 1/5] efi: add a KHO configuration table channel
From: George Guo
Date: Tue Oct 20 2026 - 23:45:29 EST
Hi Pratyush,
Thanks for the detailed review. I've rewriten the comments and commit messages
myself for v6. Replies inline.
On Tue, Sep 22 2026, Pratyush Yadav wrote:
> > +config EFI_KHO
> > + bool
> > + depends on EFI_STUB && EFI_GENERIC_STUB && KEXEC_HANDOVER
> > + help
[...]
> I don't like adding a config for this sort of thing. Do we really need
> this? Why not just have the code always compiled and only used by
> loongarch? I don't really see we need a user decision for this sort of
> thing.
Agreed, v6 drops it.
> > + /*
> > + * Reserve the stub-allocated table so it is neither handed
> > + * out by the buddy allocator nor placed on by kexec
> > + * segments, mirroring the memreserve handling above. This
> > + * runs on every boot, so it also protects the table in the
> > + * next kernel until it reads it.
> > + */
>
> Nit: this comment is too wordy. Can you please make it more concise and
> to the point?
v6:
/* Keep the buddy allocator and kexec segments off the table. */
> > + if (kho->fdt_addr)
>
> When can kho->fdt_addr be NULL? Also, perhaps print a warning if
> early_memremap() fails?
It is 0 when there is nothing to restore:
- on a cold boot, because the stub installs the table zeroed;
- after a kexec into an image without KHO state, such as a crash
kernel, because the table is zeroed just before that kexec.
v6 says this in the struct documentation, and adds a pr_warn() when
early_memremap() fails.
> > + /*
> > + * Keep a persistent mapping of the table, the same way
> > + * efi_memreserve_root_init() keeps the memreserve root mapped:
> > + * efi_kho_update() is also called on the crash kexec path, where
> > + * memremap() is no longer an option.
> > + */
>
> No need to mention memreserve. Just explain the reason here. And keep it
> as short and to the point as possible.
v6:
/* Map it now: the table is also written at panic time. */
> This is unreadable. Please add a human touch to this.
>
> And once again, the fact that it mirrors efi_mem_reserve_persistent()
> isn't important.
v6:
/*
* Write the KHO addresses the next kernel should use, or zeroes
* if it should boot without KHO.
*/
> Why ENODEV? Wouldn't ENOENT be a tiny bit better?
Neither, in v6. No table is the normal case outside LoongArch, so
efi_kho_update() now returns 0. The only error left is a table that
could not be mapped at boot, which returns -ENOMEM.
> This has too much information. You need to make it more to the point.
> For example, "without a device tree" already implies there is no /chosen
> property in the first place. No need to mention the function either.
>
> The lifetime of the table is certainly useful information but again,
> should be much more clear and to the point.
>
> Also, you should document what each of the members of the struct mean.
Agreed. v6:
/**
* struct linux_efi_kho_data - KHO state passed to the next kernel
* @fdt_addr: physical address of the KHO FDT, 0 if there is none
* @fdt_size: size of the KHO FDT
* @bootmem_addr: physical address of the bootmem area list
* @bootmem_size: size of the bootmem area list
*
* Pointed to by the LINUX_EFI_KEXEC_HANDOVER_GUID configuration table.
*
* The EFI stub installs this table zeroed on a cold boot. It stays
* in place across kexec; the running kernel rewrites it just before
* each kexec, and the next kernel reads it during early boot.
*
* The layout is fixed. Changing it requires a new GUID.
*/
> Note: I recently sent a series that renames scratch to bootmem [0]. It
> looks close to landing. So you likely need to rename this to
> bootmem_{addr,size}.
Thanks for the heads-up. It is in liveupdate/next now, so v6 is based
on it and uses bootmem_{addr,size}.
> Why __packed?
No good reason. All four members are u64, so there is no padding
and __packed changes nothing. Dropped.
Thanks,
George