memblock: don't allocate new reserve_mem regions on a KHO boot
Subsystems (4)
PATCH v4 1/1 memblock: don't allocate new reserve_mem regions on a KHO boot
On a KHO boot, a reserve_mem region that can't be revived is allocated from KHO_NOPRSRV memory, which includes the bootmem the next kernel boots out of. With CONFIG_KEXEC_HANDOVER_DEBUG, preserving the region then fails:
WARNING: kernel/liveupdate/kexec_handover.c:1245 at kho_preserve_pages+0x168/0x180 failed to prepare memblock FDT for KHO: -22
Without it, the next kernel puts its memmap on top of the region and the ramoops records in it are lost.
There is no use case for adding regions across a live update, so fail instead of allocating, and drop the TODO. A KHO boot with kho=off hands nothing over, so it still allocates.
Add kho_is_enabled() and is_kho_boot() stubs so the memblock tests still build.
---
Changes in v4:
- only fail when KHO is enabled, a KHO boot with kho=off hands nothing over (Mukesh).
- add a kho_is_enabled() stub to the memblock tests.
Changes in v3:
- add an is_kho_boot() stub to the memblock tests (Mike).
- add Pasha's Reviewed-by.
Changes in v2:
- fail on a KHO boot instead of allocating outside bootmem, as agreed with Pratyush [1]. this drops v1's patch 1.
- not an RFC anymore.
- based on v7.4-rc1.
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
mm/memblock.c | 12 +++++++++++- tools/testing/memblock/internal.h | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
mm/memblock.c +11 -1
@@ -2827,7 +2827,17 @@ static int __init reserve_mem(char *p)if (reserve_mem_kho_revive (name, size, align))return 1 ; -/* TODO: Allocation must be outside of KHO_NOPRSRV region */ +/* +* On a KHO boot memblock only allocates from KHO_NOPRSRV memory here, +* which includes the bootmem the next kernel boots out of. Only regions +* handed over by the previous kernel are supported, unless KHO is +* disabled and nothing will be handed over. +*/ +if (kho_is_enabled () &&is_kho_boot ()) { +pr_err ("reserve_mem: can't allocate \"%s\" on a KHO boot\n" , name); +return -EOPNOTSUPP ; + } + start =memblock_phys_alloc (size, align);if (!start) {pr_err ("reserve_mem: memblock allocation failed\n" );
tools/testing/memblock/internal.h +10 -0
@@ -51,4 +51,14 @@ static inline bool kho_bootmem_overlap(phys_addr_t phys, size_t size) return false; } +static inline bool kho_is_enabled (void ) +{ +return false; +} + +static inline bool is_kho_boot (void ) +{ +return false; +} +#endif
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.56.0
From: Mike Rapoport (Microsoft) <[email protected]>
Quoted 9 lines · Jose A. Perez de Azpillaga
On a KHO boot, a
reserve_memregion that can't be revived is allocated fromKHO_NOPRSRVmemory, which includes the bootmem the next kernel boots out of. WithCONFIG_KEXEC_HANDOVER_DEBUG, preserving the region then fails:WARNING: kernel/liveupdate/kexec_handover.c:1245 at kho_preserve_pages+0x168/0x180 failed to prepare memblock FDT for KHO: -22[...]
Applied to for-next branch of memblock.git tree, thanks!
[1/1] memblock: don't allocate new reserve_mem regions on a KHO boot
commit: d9a27fa1050902a6e38bdb780b0277cbf1dfa5a5
tree: https://git.kernel.org/pub/scm/linux/kernel/git/mm/memblock
branch: for-next
--
Sincerely yours,
Mike.