Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] riscv: kexec: fix kexec_file with CMA-backed segments
@ 2026-10-23  7:33 Han Gao via B4 Relay
  2026-10-23  7:33 ` [PATCH 1/5] riscv: kexec: Disable the MMU before walking the entry list Han Gao via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Han Gao via B4 Relay @ 2026-10-23  7:33 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Andrew Morton, Baoquan He, Mike Rapoport, Pasha Tatashin,
	Pratyush Yadav, Yao Zi
  Cc: Han Gao, Han Gao, linux-riscv, linux-kernel, llvm, kexec

I ran into these while doing kexec_file reboots in a loop on a Zhihe
A210 board. Things mostly worked, but every few rounds the next kernel
would hang or purgatory would spin, depending on where the segments and
the DTB happened to land. Most of it goes back to segments now being
allocated from CMA, which exposed a few assumptions that no longer hold.
They are separate bugs, so each one gets its own patch.

Patch 1 lets the RISC-V relocation code turn the MMU off even when the
entry list has no indirection page, which is the normal case with CMA.
Patch 2 fixes the purgatory relocations, which assumed a PC-relative low
part always sits right after its high part. Patches 3 and 4 are in the
generic code: CMA quietly caps the alignment below what the RISC-V
kernel needs, and the tail of CMA segment pages was never cleared even
though the purgatory digest expects zeroes there. Patch 5 reserves the
DTB early enough that a CMA pool cannot be placed on top of it.

With all five applied, the board survives repeated kexec_file reboots,
including the layouts where every segment comes from CMA.

---
Han Gao (5):
      riscv: kexec: Disable the MMU before walking the entry list
      riscv: kexec_file: Pair PC-relative low parts with their high parts
      kexec_file: Honor the segment alignment for CMA allocations
      kexec_core: Clear the unused part of CMA segments
      riscv: mm: Reserve the DTB before scanning reserved memory

 arch/riscv/kernel/kexec_relocate.S     | 29 ++++++------
 arch/riscv/kernel/machine_kexec_file.c | 84 ++++++++++++++++++++++++++--------
 arch/riscv/mm/init.c                   | 18 ++++----
 kernel/kexec_core.c                    |  6 +--
 kernel/kexec_file.c                    |  7 +++
 5 files changed, 99 insertions(+), 45 deletions(-)
---
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
change-id: 20261023-riscv-kexec-cma-fixes-9bc69798a5cf

Best regards,
--  
Han Gao <gaohan@iscas.ac.cn>




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

end of thread, other threads:[~2026-10-23  8:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23  7:33 [PATCH 0/5] riscv: kexec: fix kexec_file with CMA-backed segments Han Gao via B4 Relay
2026-10-23  7:33 ` [PATCH 1/5] riscv: kexec: Disable the MMU before walking the entry list Han Gao via B4 Relay
2026-10-23  7:39   ` sashiko-bot
2026-10-23  7:33 ` [PATCH 2/5] riscv: kexec_file: Pair PC-relative low parts with their high parts Han Gao via B4 Relay
2026-10-23  7:45   ` sashiko-bot
2026-10-23  7:33 ` [PATCH 3/5] kexec_file: Honor the segment alignment for CMA allocations Han Gao via B4 Relay
2026-10-23  8:18   ` sashiko-bot
2026-10-23  7:33 ` [PATCH 4/5] kexec_core: Clear the unused part of CMA segments Han Gao via B4 Relay
2026-10-23  8:04   ` sashiko-bot
2026-10-23  7:33 ` [PATCH 5/5] riscv: mm: Reserve the DTB before scanning reserved memory Han Gao via B4 Relay
2026-10-23  8:06   ` sashiko-bot

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