LoongArch: kexec: avoid clobbering the QEMU FDT
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest2 patches 3 repliesIn review
- v31 patch 1 replySuperseded
Changes in v4 from the cover letter
- Add patch 2: load the command line in its own kexec segment, dropping the fixed KEXEC_CMDLINE_ADDR that overlaps the QEMU FDT (addresses the command line concern from the v3 review).
- Patch 1 (relocation trampoline): drop the KEXEC_CMDLINE_ADDR comment added in v3 that claimed 0x108000 does not overlap the FDT (it does; patch 2 removes the fixed address entirely). No functional change otherwise.
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | LoongArch: kexec: use core control page for relocation trampoline to avoid QEMU FDT conflictarch/ | +8 | 0 replies | |
| 2/2 | LoongArch: kexec: load the command line in its own segmentarch/ arch/ arch/ | +41 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/2] LoongArch: kexec: avoid clobbering the QEMU FDT
This series fixes two ways the LoongArch kexec path can clobber the firmware-provided FDT that QEMU places at physical 0x100000, which made the second kernel boot silently (earlycon auto-detection reads a corrupted FDT).
Patch 1 moves the relocation trampoline off the hardcoded 0x100000 onto the kexec core's control_code_page (as arm64/riscv do), so machine_kexec_prepare() no longer overwrites the FDT.
Patch 2 removes the remaining fixed command-line address (KEXEC_CMDLINE_ADDR, 0x108000). QEMU's machine FDT declares fdt_totalsize = 1MB and thus claims the whole [0x100000, 0x200000) upper half of the reserved 2MB, so 0x108000 lives inside the FDT and only survives because the FDT's real content is small (~3.6KB) and 0x108000 falls in the trailing slack. The command line is passed to the second kernel in register a1, not at a fixed address, so it is loaded into its own kexec segment instead, removing the overlap regardless of FDT size.
This addresses the two questions raised on the v3 trampoline patch [1]:
- "how to avoid the cmdline overlapping FDT" -> patch 2.
- "how to avoid the control page being corrupted by the new kernel" -> the trampoline is executed only by the current kernel and is dead once the new kernel starts, so being overwritten afterwards is harmless; the kexec core also keeps the control page outside every relocation destination, so it cannot be corrupted during relocation. The command line is different (it is read by the new kernel), which is why only the trampoline uses the core page.
Tested with tools/testing/selftests/kho/vmtest.sh on LoongArch (QEMU, kexec_file_load): the second kernel boots with the full command line and earlycon, and KHO restore succeeds.
This series depends on [2] ("LoongArch: kexec: Fix address space mismatch in command line lookup"), whose char head[] change patch 2 builds on.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Add patch 2: load the command line in its own kexec segment, dropping the fixed KEXEC_CMDLINE_ADDR that overlaps the QEMU FDT (addresses the command line concern from the v3 review).
- Patch 1 (relocation trampoline): drop the KEXEC_CMDLINE_ADDR comment added in v3 that claimed 0x108000 does not overlap the FDT (it does; patch 2 removes the fixed address entirely). No functional change otherwise.
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
George Guo (2):
LoongArch: kexec: use core control page for relocation trampoline to
avoid QEMU FDT conflict
LoongArch: kexec: load the command line in its own segment
arch/loongarch/include/asm/kexec.h | 1 + arch/loongarch/kernel/machine_kexec.c | 38 ++++++++++------------ arch/loongarch/kernel/machine_kexec_file.c | 33 +++++++++++++++++-- 3 files changed, 49 insertions(+), 23 deletions(-)
Signature · 1 line
2.25.1