kho: allow kexec load before KHO finalization

Currently, kho_fill_kimage() checks kho_out.finalized and returns early if
KHO is not yet finalized.  This enforces a strict ordering where userspace
must finalize KHO *before* loading the kexec image.

This is restrictive, as standard workflows often involve loading the
target kernel early in the lifecycle and finalizing the state (FDT) only
immediately before the reboot.

Since the KHO FDT resides at a physical address allocated during boot
(kho_init), its location is stable.  We can attach this stable address to
the kimage regardless of whether the content has been finalized yet.

Relax the check to only require kho_enable, allowing kexec_file_load to
proceed at any time.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Pasha Tatashin <[email protected]>
Reviewed-by: Mike Rapoport (Microsoft) <[email protected]>
Reviewed-by: Pratyush Yadav <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Coiby Xu <[email protected]>
Cc: Dave Vasilevsky <[email protected]>
Cc: Eric Biggers <[email protected]>
Cc: Kees Cook <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
Pasha Tatashin authored and Andrew Morton committed 2025-11-27 14:24:36 -08:00
1 parent 8e068a286a
commit d7255959b6
1 file changed
+1 -1
+1 -1
View File
@@ -1550,7 +1550,7 @@ int kho_fill_kimage(struct kimage *image)
int err = 0;
struct kexec_buf scratch;
if (!kho_out.finalized)
if (!kho_enable)
return 0;
image->kho.fdt = virt_to_phys(kho_out.fdt);