From: George Guo <dongtai.guo@linux.dev>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: maobibo@loongson.cn, loongarch@lists.linux.dev,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
George Guo <guodongtai@kylinos.cn>
Subject: [PATCH v4 0/2] LoongArch: kexec: avoid clobbering the QEMU FDT
Date: Wed, 1 Jul 2026 23:59:55 +0800 [thread overview]
Message-ID: <20260701155957.534779-1-dongtai.guo@linux.dev> (raw)
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/20260604114106.391502-1-dongtai.guo@linux.dev/
[2] https://lore.kernel.org/all/20260701023747.56221-1-dongtai.guo@linux.dev/
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/20260604114106.391502-1-dongtai.guo@linux.dev/
v2: https://lore.kernel.org/all/20260601033820.38805-1-dongtai.guo@linux.dev/
v1: https://lore.kernel.org/all/20260528135828.196953-1-dongtai.guo@linux.dev/
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(-)
--
2.25.1
next reply other threads:[~2026-07-01 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 15:59 George Guo [this message]
2026-07-01 15:59 ` [PATCH v4 1/2] LoongArch: kexec: use core control page for relocation trampoline to avoid QEMU FDT conflict George Guo
2026-07-01 15:59 ` [PATCH v4 2/2] LoongArch: kexec: load the command line in its own segment George Guo
2026-07-09 9:11 ` [PATCH v4 0/2] LoongArch: kexec: avoid clobbering the QEMU FDT Huacai Chen
2026-07-09 12:48 ` George Guo
2026-07-10 14:12 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701155957.534779-1-dongtai.guo@linux.dev \
--to=dongtai.guo@linux.dev \
--cc=chenhuacai@kernel.org \
--cc=guodongtai@kylinos.cn \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox