From: Pratyush Yadav <pratyush@kernel.org>
To: George Guo <dongtai.guo@linux.dev>
Cc: chenhuacai@kernel.org, rppt@kernel.org,
pasha.tatashin@soleen.com, pratyush@kernel.org,
kernel@xen0n.name, graf@amazon.com, shuah@kernel.org,
loongarch@lists.linux.dev, kexec@lists.infradead.org,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, George Guo <guodongtai@kylinos.cn>,
Kexin Liu <liukexin@kylinos.cn>
Subject: Re: [PATCH 1/7] LoongArch: Add KHO basic support
Date: Mon, 25 May 2026 19:34:13 +0200 [thread overview]
Message-ID: <2vxztsrv5r6y.fsf@kernel.org> (raw)
In-Reply-To: <20260525062810.103367-2-dongtai.guo@linux.dev> (George Guo's message of "Mon, 25 May 2026 14:28:04 +0800")
On Mon, May 25 2026, George Guo wrote:
> From: George Guo <guodongtai@kylinos.cn>
>
> Enable Kexec Handover on LoongArch64:
>
> - Kconfig: select ARCH_SUPPORTS_KEXEC_HANDOVER for 64BIT
> - machine_kexec_file: add cmdline_add_kho() to pass the KHO FDT and
> scratch buffer addresses to the next kernel via the "kho_handover="
> command-line parameter
> - setup: parse "kho_handover=" early and call kho_populate() to hand
> memory regions to the KHO core
>
> Co-developed-by: Kexin Liu <liukexin@kylinos.cn>
> Signed-off-by: Kexin Liu <liukexin@kylinos.cn>
> Signed-off-by: George Guo <guodongtai@kylinos.cn>
> ---
> arch/loongarch/Kconfig | 3 +++
> arch/loongarch/kernel/machine_kexec_file.c | 22 ++++++++++++++++++
> arch/loongarch/kernel/setup.c | 27 ++++++++++++++++++++++
> 3 files changed, 52 insertions(+)
>
[...]
> diff --git a/arch/loongarch/kernel/machine_kexec_file.c b/arch/loongarch/kernel/machine_kexec_file.c
> index 5584b798ba46..ddf4d0e0e7fd 100644
> --- a/arch/loongarch/kernel/machine_kexec_file.c
> +++ b/arch/loongarch/kernel/machine_kexec_file.c
> @@ -55,6 +55,24 @@ static void cmdline_add_initrd(struct kimage *image, unsigned long *cmdline_tmpl
> *cmdline_tmplen += initrd_strlen;
> }
>
> +#ifdef CONFIG_KEXEC_HANDOVER
> +/* Add "kho_handover=<fdt_size>@<fdt_addr>,<scratch_size>@<scratch_addr>" to cmdline. */
> +static void cmdline_add_kho(struct kimage *image, unsigned long *cmdline_tmplen,
> + char *modified_cmdline)
> +{
> + int n;
> +
> + if (!image->kho.fdt || !image->kho.scratch)
> + return;
> +
> + n = sprintf(modified_cmdline + *cmdline_tmplen,
> + "kho_handover=0x%llx@0x%llx,0x%lx@0x%llx ",
> + (u64)PAGE_SIZE, image->kho.fdt,
> + image->kho.scratch->bufsz, (u64)image->kho.scratch->mem);
> + *cmdline_tmplen += n;
Do you have nothing else for a bootloader to pass data to the kernel?
Passing this via the command line seems crazy... All these addresses are
now available directly to unprivileged userspace. Can't you use the
device tree like we do on ARM64?
Also, this commandline parameter isn't documented anywhere.
> +}
> +#endif
> +
> #ifdef CONFIG_CRASH_DUMP
>
> static int prepare_elf_headers(void **addr, unsigned long *sz)
> @@ -220,6 +238,10 @@ int load_other_segments(struct kimage *image,
> cmdline_add_initrd(image, &cmdline_tmplen, modified_cmdline, initrd_load_addr);
> }
>
> +#ifdef CONFIG_KEXEC_HANDOVER
> + cmdline_add_kho(image, &cmdline_tmplen, modified_cmdline);
> +#endif
> +
> if (cmdline_len + cmdline_tmplen > COMMAND_LINE_SIZE) {
> pr_err("Appending command line exceeds COMMAND_LINE_SIZE\n");
> ret = -EINVAL;
> diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
> index 839b23edee87..5934ba6f13e3 100644
> --- a/arch/loongarch/kernel/setup.c
> +++ b/arch/loongarch/kernel/setup.c
> @@ -48,6 +48,7 @@
> #include <asm/setup.h>
> #include <asm/time.h>
> #include <asm/unwind.h>
> +#include <linux/kexec_handover.h>
>
> #define SMBIOS_BIOSSIZE_OFFSET 0x09
> #define SMBIOS_BIOSEXTERN_OFFSET 0x13
> @@ -227,6 +228,32 @@ static int __init early_parse_mem(char *p)
> }
> early_param("mem", early_parse_mem);
>
> +#ifdef CONFIG_KEXEC_HANDOVER
> +static int __init early_parse_kho(char *p)
> +{
> + phys_addr_t fdt_addr, scratch_addr;
> + u64 fdt_size, scratch_size;
> +
> + if (!p)
> + return -EINVAL;
> +
> + fdt_size = memparse(p, &p);
> + if (*p++ != '@')
Can you please wrap these in parenthesis? I am too dumb to remember all
the precedence rules and this immediately makes me question whether we
are doing (*p)++ or *(p++).
> + return -EINVAL;
> + fdt_addr = memparse(p, &p);
> + if (*p++ != ',')
> + return -EINVAL;
> + scratch_size = memparse(p, &p);
> + if (*p++ != '@')
> + return -EINVAL;
> + scratch_addr = memparse(p, &p);
> +
> + kho_populate(fdt_addr, fdt_size, scratch_addr, scratch_size);
> + return 0;
> +}
> +early_param("kho_handover", early_parse_kho);
> +#endif
> +
> static void __init arch_reserve_vmcore(void)
> {
> #ifdef CONFIG_PROC_VMCORE
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2026-05-25 17:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 6:28 [PATCH 0/7] LoongArch: add KHO support and selftests George Guo
2026-05-25 6:28 ` [PATCH 1/7] LoongArch: Add KHO basic support George Guo
2026-05-25 17:34 ` Pratyush Yadav [this message]
2026-05-25 6:28 ` [PATCH 2/7] LoongArch: kho: strip stale kho_handover= from reused cmdline George Guo
2026-05-25 17:49 ` Pratyush Yadav
2026-05-25 6:28 ` [PATCH 3/7] LoongArch: Add missing linux/mm.h include in asm/io.h George Guo
2026-05-25 6:28 ` [PATCH 4/7] LoongArch: kexec: avoid overwriting QEMU's machine FDT at 0x100000 George Guo
2026-05-25 6:28 ` [PATCH 5/7] selftests/kho: add LoongArch vmtest support George Guo
2026-05-25 6:28 ` [PATCH 6/7] selftests/kho: LoongArch: disable PS/2 input devices for QEMU virt George Guo
2026-05-25 6:28 ` [PATCH 7/7] selftests/kho: handle QEMU not exiting after kexec on LoongArch George Guo
2026-05-25 7:48 ` Mike Rapoport
2026-05-25 7:48 ` [PATCH 0/7] LoongArch: add KHO support and selftests Mike Rapoport
2026-05-25 10:25 ` Huacai Chen
2026-05-25 11:24 ` Mike Rapoport
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=2vxztsrv5r6y.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=dongtai.guo@linux.dev \
--cc=graf@amazon.com \
--cc=guodongtai@kylinos.cn \
--cc=kernel@xen0n.name \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liukexin@kylinos.cn \
--cc=loongarch@lists.linux.dev \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
/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