memblock: robustness and debug improvements

* add check for memory add/cap ordering
 * add missing debug code to memblock_add_node()
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCAAxFiEEeOVYVaWZL5900a/pOQOGJssO/ZEFAmEuIDsTHHJwcHRAbGlu
 dXguaWJtLmNvbQAKCRA5A4Ymyw79kXGyB/40CJZ/YDKvBWiRymvNWJr3sX5sWbIj
 /+3TBqV5u7OvuCcf0ZjLDxN8b8QqZCLCynx0/x8fKEvL8+agF4v40nqGZc8YeHLA
 bb4Gk8JKz/3stQ8rwa71e2lTJgXdCOECn5Y+oo8Ctrqu3crWrsvZbiV96U7bl2gC
 8a2SW62qO0aK+7+cd6TjcI+u3OPMo7NeXLxikxcRFIoUyTzSW2A8oudAX/WNlwQt
 CS8gEWgvnwdnwvoXiQ+YZ9dENUwp1T5CPXeoKUUPh+nDcDSM5R9RM60JL27iToF3
 6mhpVY3zswnytg8xXN4oSvTX+iMEvjMS34BfeptOdc+Qi4Af31ojfhDO
 =lxko
 -----END PGP SIGNATURE-----

Merge tag 'memblock-v5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock

Pull memblock updates from Mike Rapoport:
 "Robustness and debug improvements:

   - add check for memory add/cap ordering

   - add missing debug code to memblock_add_node()"

* tag 'memblock-v5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
  memblock: Check memory add/cap ordering
  memblock: Add missing debug code to memblock_add_node()
This commit is contained in:
Linus Torvalds 2021-09-02 12:26:31 -07:00
commit 612b23f277

View File

@ -665,6 +665,11 @@ repeat:
int __init_memblock memblock_add_node(phys_addr_t base, phys_addr_t size,
int nid)
{
phys_addr_t end = base + size - 1;
memblock_dbg("%s: [%pa-%pa] nid=%d %pS\n", __func__,
&base, &end, nid, (void *)_RET_IP_);
return memblock_add_range(&memblock.memory, base, size, nid, 0);
}
@ -1680,6 +1685,11 @@ void __init memblock_cap_memory_range(phys_addr_t base, phys_addr_t size)
if (!size)
return;
if (memblock.memory.cnt <= 1) {
pr_warn("%s: No memory registered yet\n", __func__);
return;
}
ret = memblock_isolate_range(&memblock.memory, base, size,
&start_rgn, &end_rgn);
if (ret)