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
1417}1417}
1418EXPORT_SYMBOL_GPL(kho_retrieve_subtree);1418EXPORT_SYMBOL_GPL(kho_retrieve_subtree);
1419 1419
1420static int __init kho_mem_retrieve(const void *fdt)1420static void __init kho_mem_retrieve(void)
1421{1421{
1422 const void *fdt = kho_get_fdt();
1422 void *mem_map = kho_get_mem_map(fdt);1423 void *mem_map = kho_get_mem_map(fdt);
1424 int err;
1425
1426 kho_scratch = phys_to_virt(kho_in.scratch_phys);
1423 1427
1424 /*1428 /*
1425 * kho_get_mem_map() should always succeed. If it fails, kho_populate()1429 * 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
1427 * retrieval.1431 * retrieval.
1428 */1432 */
1429 if (WARN_ON(!mem_map))1433 if (WARN_ON(!mem_map))
1430 return -EINVAL;1434 return;
1431 1435
1432 kho_in.radix_tree.root = mem_map;1436 kho_in.radix_tree.root = mem_map;
1433 mutex_init(&kho_in.radix_tree.lock);1437 mutex_init(&kho_in.radix_tree.lock);
1434 return kho_radix_walk_tree(&kho_in.radix_tree,1438
1435 kho_preserved_memory_reserve);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 }
1436}1448}
1437 1449
1438static __init int kho_out_fdt_setup(void)1450static __init int kho_out_fdt_setup(void)
@@ -1636,16 +1648,10 @@ fs_initcall(kho_init); · 197 unmodified lines
1636 1648
1637void __init kho_memory_init(void)1649void __init kho_memory_init(void)
1638{1650{
1639 if (kho_in.scratch_phys) {1651 if (kho_in.scratch_phys)
1640 kho_scratch = phys_to_virt(kho_in.scratch_phys);1652 kho_mem_retrieve();
1641 1653 else
1642 if (kho_mem_retrieve(kho_get_fdt())) {
1643 kho_in.fdt_phys = 0;
1644 kho_in.radix_tree.root = NULL;
1645 }
1646 } else {
1647 kho_reserve_scratch();1654 kho_reserve_scratch();
1648 }
1649}1655}
1650 1656
1651void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,1657void __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