[PATCH 0/4] kexec,mm/cma: do not run the next kernel from a fixed-base CMA area

From: Radhey Shyam Pandey

Date: Tue Nov 03 2026 - 12:56:46 EST


Since commit 07d24902977e ("kexec: enable CMA based contiguous
allocation"), kexec_locate_mem_hole() places the next kernel in the
default CMA area and it runs from there in place. If that area has a
fixed base the loaded kernel declares the range it is executing from
as a shared-dma-pool, and cma_activate_area() frees its own image to
the page allocator. On a VEK385 that corrupts kernel text within
~300ms of /sbin/init starting.

Patch 1 is the fix and stands on its own. Patches 2 and 3 close the
same hole for a device tree placing a shared-dma-pool over the kernel
image with no kexec involved; patch 4 is an unrelated cleanup.

Changes since RFC:
- Patch 1 records CMA_DYNAMIC_BASE rather than CMA_FIXED_BASE.
- New patch 2 answers the RFC's open question (Pratyush): -EBUSY from
node_init keeps the reservation, so refusing an overlapping pool no
longer frees [_text, _end) along with it.
- Patch 3 reordered after it, returns -EBUSY, rejects a wrapping
base+size; both Reviewed-by tags dropped for the rework.
- New patch 4 drops the duplicate alignment check (Mike).

Tested on VEK385: with patch 1 kexec declines all three device-tree
pools; without it the booted kernel refuses the overlapping pool.


Link to RFC: https://lore.kernel.org/all/20261014145731.3431527-1-radhey.shyam.pandey@xxxxxxx

Radhey Shyam Pandey (4):
kexec: do not place the next kernel in a fixed-address CMA area
of: reserved_mem: keep the reservation when node_init returns -EBUSY
mm/cma: reject CMA areas that overlap the kernel image
mm/cma: drop the duplicate alignment check in rmem_cma_setup()

drivers/of/of_reserved_mem.c | 14 +++++++++++
include/linux/cma.h | 10 ++++++++
include/linux/of_reserved_mem.h | 5 ++++
kernel/dma/contiguous.c | 5 ----
kernel/kexec_file.c | 12 +++++++++
mm/cma.c | 43 ++++++++++++++++++++++++++++++++-
mm/cma.h | 2 ++
7 files changed, 85 insertions(+), 6 deletions(-)


base-commit: d6bcfc94eb4da6e089c5473970cd96727292fd97
--
2.44.4