diff options
| author | Pratyush Yadav (Google) <pratyush@kernel.org> | 2026-08-01 10:48:24 +0200 |
|---|---|---|
| committer | Mike Rapoport (Microsoft) <rppt@kernel.org> | 2026-08-04 09:25:32 +0300 |
| commit | 01a0dd3d6fb73fa02ff775c9f4d8feff9e8265c0 (patch) | |
| tree | 65a80ad9aaae4e395eaee1e5593179b1393b9014 /kernel | |
| parent | 4513fea02a860a07fdfea41108482dfaa33a00c7 (diff) | |
kho: initialize preserved memory map radix tree earlier
Currently the preserved memory radix tree is initialized from
kho_memory_init(), which happens relatively late in MM init. In a coming
patch, the tree will be used from kho_memory_init_early(). Move the tree
initialization there.
Simplify some of the code in kho_mem_retrieve() by getting rid of the
err variable and jumping to err directly.
Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
Link: https://patch.msgid.link/20260801084833.1897543-16-pratyush@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/liveupdate/kexec_handover.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index c1e9f0102896..147e19376505 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1533,24 +1533,8 @@ static void __init kho_mem_retrieve(void) const struct kho_radix_walk_cb cb = { .leaf = kho_preserved_memory_reserve, }; - const void *fdt = kho_get_fdt(); - void *mem_map = kho_get_mem_map(fdt); - int err; - /* - * kho_get_mem_map() should always succeed. If it fails, kho_populate() - * catches that and never sets kho_in.scratch_phys, which stops memory - * retrieval. - */ - if (WARN_ON(!mem_map)) - return; - - err = kho_radix_init_tree(&kho_in.radix_tree, mem_map); - if (err) - goto err; - - err = kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL); - if (err) + if (kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL)) goto err; return; @@ -1762,15 +1746,40 @@ fs_initcall(kho_init); void __init kho_memory_init_early(void) { + const void *fdt = kho_get_fdt(); + void *mem_map; + if (!is_kho_boot()) return; /* + * kho_get_mem_map() should always succeed. If it fails, kho_populate() + * catches that and never sets kho_in.scratch_phys, which stops memory + * retrieval. + */ + mem_map = kho_get_mem_map(fdt); + if (WARN_ON(!mem_map)) + goto err; + + /* * kho_scratch_overlap() needs kho_scratch to be initialized. It * is used by free_area_init() on KHO boots, so initialize it * early. */ kho_scratch = phys_to_virt(kho_in.scratch_phys); + + if (kho_radix_init_tree(&kho_in.radix_tree, mem_map)) + goto err; + + return; + +err: + /* + * Failed to initialize preserved memory radix tree. Clear FDT + * and scratch so KHO users don't treat it as a KHO boot. + */ + kho_in.fdt_phys = 0; + kho_in.scratch_phys = 0; } void __init kho_memory_init(void) |
