Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 00/11] kexec: Rework segment loading and fix CMA retries
@ 2026-11-12 13:34 Jinjie Ruan
  2026-11-12 13:34 ` [PATCH v8 01/11] kexec: Free the elf core header in kimage_file_post_load_cleanup() Jinjie Ruan
                   ` (10 more replies)
  0 siblings, 11 replies; 23+ messages in thread
From: Jinjie Ruan @ 2026-11-12 13:34 UTC (permalink / raw)
  To: catalin.marinas, will, mark.rutland, chenhuacai, kernel, maddy,
	mpe, npiggin, chleroy, ritesh.list, sshegde, pjw, palmer, aou,
	alex, tglx, mingo, bp, dave.hansen, hpa, akpm, baoquan.he, rppt,
	pasha.tatashin, pratyush, ruanjinjie, leitao, yeoreum.yun,
	mpilaniy, robh, coiby.xu, Yeking, prudo, brads, sourabhjain,
	mkchauras, blum, adityag, qirui.001, hui.wang, sohammetha01,
	guoren, gaohan, ionut.nechita, vishal.l.verma, seanjc, ardb,
	richard.lyu, arnd, tzimmermann, rick.p.edgecombe, kai.huang, kas,
	piliu, thuth, shradhagupta, ebiggers, jbouron, me, mclapinski,
	graf, tangyouling, x86, linux-arm-kernel, linux-kernel, loongarch,
	linuxppc-dev, linux-riscv, kexec

ARM64, LoongArch, RISC-V, x86 and powerpc build the elf core header
and place it together with the initrd and the DTB with almost identical
code.

This series reworks that path into common helpers that the architectures
reuse, and fixes the CMA page and elf core header leaks in the arm64
and LoongArch placement retry loops.

The patch organization is as follows:

- Patch 1 moves the release of the elf core header into the generic
  post-load cleanup, so that the architectures no longer free it
  themselves.

- Patch 2 adds the common helpers

- Patches 3-7 convert arm64, LoongArch, RISC-V, X86 and Powerpc to
  reuse the common helpers

- Patches 8-11 fix the CMA pages leaked by the retry loops and
  the loop that makes no progress

Tested with kexec_file_load() on arm64, LoongArch, RISC-V, X86 and
Powerpc under QEMU, including the CMA retry paths, loading a crash
kernel and booting the second kernel, with the agent help.

This series is also available at:
	https://github.com/ruanjinjie-eng/linux/tree/kexec_rework_cma_bugfx_v9

Changes in v8:
- Rework the common code as Mike suggested: the core provides building
  blocks and the architectures uses them (Mike)
- Build the elf core header once and only place it on the retries (Mike)
- Keep the segment order and the arch placement policy unchanged (Mike)
- Convert x86 and powerpc as well
- Move the CMA fixes to the end of the series (Mike)
- Link to v7: https://lore.kernel.org/all/20261026075201.699550-1-ruanjinjie@huawei.com/

Previous Versions are as below:
- v6: https://lore.kernel.org/all/20260921090450.807575-1-ruanjinjie@huawei.com/
- v5: https://lore.kernel.org/all/20260918100442.3841135-1-ruanjinjie@huawei.com/
- v4: https://lore.kernel.org/all/20260907125404.922123-1-ruanjinjie@huawei.com/
- v3: https://lore.kernel.org/all/20260826092541.3905933-1-ruanjinjie@huawei.com/
- v2: https://lore.kernel.org/all/20260729031235.2840255-1-ruanjinjie@huawei.com/
- v1: https://lore.kernel.org/all/20260723131242.1537633-1-ruanjinjie@huawei.com/#t

Jinjie Ruan (11):
  kexec: Free the elf core header in kimage_file_post_load_cleanup()
  kexec: Add helpers to load the elf core header, initrd and FDT
  arm64: kexec_file: Load the other segments with common helpers
  LoongArch: kexec_file: Load the other segments with common helpers
  riscv: kexec_file: Load the extra segments with common helpers
  x86: kexec_file: Use the common segment helpers
  powerpc: kexec_file: Use the common segment helpers
  kexec: Extract kexec_free_segment_cma() from kimage_free_cma()
  kexec: Add kexec_rollback_segments() helper
  arm64: kexec_file: Fix CMA segment placement retries
  LoongArch: kexec_file: Fix CMA segment placement retries

 arch/arm64/include/asm/kexec.h             |   4 +-
 arch/arm64/kernel/kexec_image.c            |  15 ++-
 arch/arm64/kernel/machine_kexec_file.c     |  87 ++++----------
 arch/loongarch/include/asm/kexec.h         |   3 +-
 arch/loongarch/kernel/kexec_efi.c          |  15 ++-
 arch/loongarch/kernel/kexec_elf.c          |   3 +-
 arch/loongarch/kernel/machine_kexec_file.c |  80 +++++--------
 arch/powerpc/kexec/elf_64.c                |   9 +-
 arch/powerpc/kexec/file_load_64.c          |  18 +--
 arch/riscv/include/asm/kexec.h             |   4 +-
 arch/riscv/kernel/kexec_elf.c              |   3 +-
 arch/riscv/kernel/kexec_image.c            |   3 +-
 arch/riscv/kernel/machine_kexec_file.c     |  83 ++++----------
 arch/x86/kernel/crash.c                    |  25 +----
 arch/x86/kernel/kexec-bzimage64.c          |   8 +-
 arch/x86/kernel/machine_kexec_64.c         |   4 -
 include/linux/kexec.h                      |  14 +++
 kernel/kexec_core.c                        |  25 +++--
 kernel/kexec_file.c                        | 125 +++++++++++++++++++++
 19 files changed, 254 insertions(+), 274 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-11-12 14:21 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 13:34 [PATCH v8 00/11] kexec: Rework segment loading and fix CMA retries Jinjie Ruan
2026-11-12 13:34 ` [PATCH v8 01/11] kexec: Free the elf core header in kimage_file_post_load_cleanup() Jinjie Ruan
2026-11-12 13:47   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 02/11] kexec: Add helpers to load the elf core header, initrd and FDT Jinjie Ruan
2026-11-12 13:59   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 03/11] arm64: kexec_file: Load the other segments with common helpers Jinjie Ruan
2026-11-12 13:45   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 04/11] LoongArch: " Jinjie Ruan
2026-11-12 13:52   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 05/11] riscv: kexec_file: Load the extra " Jinjie Ruan
2026-11-12 13:53   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 06/11] x86: kexec_file: Use the common segment helpers Jinjie Ruan
2026-11-12 14:08   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 07/11] powerpc: " Jinjie Ruan
2026-11-12 14:01   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 08/11] kexec: Extract kexec_free_segment_cma() from kimage_free_cma() Jinjie Ruan
2026-11-12 14:07   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 09/11] kexec: Add kexec_rollback_segments() helper Jinjie Ruan
2026-11-12 14:15   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 10/11] arm64: kexec_file: Fix CMA segment placement retries Jinjie Ruan
2026-11-12 14:14   ` sashiko-bot
2026-11-12 13:34 ` [PATCH v8 11/11] LoongArch: " Jinjie Ruan
2026-11-12 14:21   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox