History

kho: move all memory retrieval logic to kho_mem_retrieve()

The memory retrieval logic is spread out across kho_mem_retrieve() and kho_memory_init(). The incoming scratch area is initialized at kho_memory_init(), and the error handling is done there too. Consolidate all this logic into kho_mem_retrieve() to make the code cleaner.

Pratyush Yadav (Google) committed 3 months ago

Commit e9e4ecd1 parent e228b381 file · +19 −13Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/liveupdate/kexec_handover.c+19−13
@@ -1417,9 +1417,13 @@ int kho_retrieve_subtree(const char *name, phys_addr_t *phys, size_t *size) · 1416 unmodified lines
14171417 }
14181418 EXPORT_SYMBOL_GPL(kho_retrieve_subtree);
14191419
1420−static int __init kho_mem_retrieve(const void *fdt)
1420+static void __init kho_mem_retrieve(void)
14211421 {
1422+ const void *fdt = kho_get_fdt();
14221423 void *mem_map = kho_get_mem_map(fdt);
1424+ int err;
1425+
1426+ kho_scratch = phys_to_virt(kho_in.scratch_phys);
14231427
14241428 /*
14251429 * 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) · 1 unmodified line
14271431 * retrieval.
14281432 */
14291433 if (WARN_ON(!mem_map))
1430− return -EINVAL;
1434+ return;
14311435
14321436 kho_in.radix_tree.root = mem_map;
14331437 mutex_init(&kho_in.radix_tree.lock);
1434− return kho_radix_walk_tree(&kho_in.radix_tree,
1435− kho_preserved_memory_reserve);
1438+
1439+ err = kho_radix_walk_tree(&kho_in.radix_tree, kho_preserved_memory_reserve);
1440+ if (err) {
1441+ /*
1442+ * Failed to initialize preserved memory. Clear FDT and radix
1443+ * so KHO users don't treat it as a KHO boot.
1444+ */
1445+ kho_in.fdt_phys = 0;
1446+ kho_in.radix_tree.root = NULL;
1447+ }
14361448 }
14371449
14381450 static __init int kho_out_fdt_setup(void)
@@ -1636,16 +1648,10 @@ fs_initcall(kho_init); · 197 unmodified lines
16361648
16371649 void __init kho_memory_init(void)
16381650 {
1639− if (kho_in.scratch_phys) {
1640− kho_scratch = phys_to_virt(kho_in.scratch_phys);
1641−
1642− if (kho_mem_retrieve(kho_get_fdt())) {
1643− kho_in.fdt_phys = 0;
1644− kho_in.radix_tree.root = NULL;
1645− }
1646− } else {
1651+ if (kho_in.scratch_phys)
1652+ kho_mem_retrieve();
1653+ else
16471654 kho_reserve_scratch();
1648− }
16491655 }
16501656
16511657 void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t