diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/liveupdate/kexec_handover.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index d79047d9ebb6..b89fe9a9ccc8 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1417,9 +1417,13 @@ int kho_retrieve_subtree(const char *name, phys_addr_t *phys, size_t *size) } EXPORT_SYMBOL_GPL(kho_retrieve_subtree); -static int __init kho_mem_retrieve(const void *fdt) +static void __init kho_mem_retrieve(void) { + const void *fdt = kho_get_fdt(); void *mem_map = kho_get_mem_map(fdt); + int err; + + kho_scratch = phys_to_virt(kho_in.scratch_phys); /* * kho_get_mem_map() should always succeed. If it fails, kho_populate() @@ -1427,12 +1431,20 @@ static int __init kho_mem_retrieve(const void *fdt) * retrieval. */ if (WARN_ON(!mem_map)) - return -EINVAL; + return; kho_in.radix_tree.root = mem_map; mutex_init(&kho_in.radix_tree.lock); - return kho_radix_walk_tree(&kho_in.radix_tree, - kho_preserved_memory_reserve); + + err = kho_radix_walk_tree(&kho_in.radix_tree, kho_preserved_memory_reserve); + if (err) { + /* + * Failed to initialize preserved memory. Clear FDT and radix + * so KHO users don't treat it as a KHO boot. + */ + kho_in.fdt_phys = 0; + kho_in.radix_tree.root = NULL; + } } static __init int kho_out_fdt_setup(void) @@ -1636,16 +1648,10 @@ fs_initcall(kho_init); void __init kho_memory_init(void) { - if (kho_in.scratch_phys) { - kho_scratch = phys_to_virt(kho_in.scratch_phys); - - if (kho_mem_retrieve(kho_get_fdt())) { - kho_in.fdt_phys = 0; - kho_in.radix_tree.root = NULL; - } - } else { + if (kho_in.scratch_phys) + kho_mem_retrieve(); + else kho_reserve_scratch(); - } } void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len, |
