mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: George Guo <dongtai.guo@linux.dev>
To: Huacai Chen <chenhuacai@kernel.org>,
	Pratyush Yadav <pratyush@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	Shuah Khan <shuah@kernel.org>, WANG Xuerui <kernel@xen0n.name>,
	Alexander Graf <graf@amazon.com>, Kexin Liu <liukexin@kylinos.cn>,
	George Guo <guodongtai@kylinos.cn>,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	kexec@lists.infradead.org, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v3 1/3] LoongArch: kexec: add KHO support for FDT-based
Date: Fri, 17 Jul 2026 15:15:51 +0800	[thread overview]
Message-ID: <20260717071551.11904-1-dongtai.guo@linux.dev> (raw)
In-Reply-To: <CAAhV-H5B6Mj2-AffkstJ4f8EEmvvPOGXoDy2QNudKD2kSz2XkA@mail.gmail.com>

Hi Huacai, Pratyush,

Thanks for the direction.  You were both right that the v3 approach was
the wrong shape, and I have dropped it.

Let me restate the constraint and report what I did.

> But LoongArch is different, the efistub doesn't create a FDT, instead
> it passes the EFI system table and command line to the core kernel
> directly.

So LoongArch has no boot FDT, and the arm64 /chosen path does not apply.
My v3 synthesized an FDT and rewrote the DEVICE_TREE_GUID entry only to
reuse the generic reader.  That was the hacky part, and it is gone.

I followed the x86 model instead.  x86 has no boot FDT either; it carries
the KHO pointer in setup_data (struct kho_data) and calls kho_populate()
directly.  LoongArch has no setup_data, but it does pass the EFI system
table.  So I use the EFI configuration table as the channel:

- The first kernel builds a small handover struct (the KHO FDT and
  scratch addresses), adds a dedicated GUID entry pointing to it, and
  loads both as kexec segments.  machine_kexec() switches the system
  table to the extended table before jumping.
- The next kernel scans the configuration table for that GUID, reads the
  struct, and calls kho_populate() directly.

There is no synthesized FDT, no DEVICE_TREE_GUID rewrite, and nothing on
the command line.  I did not go back to the v1 command line because that
exposes the addresses to unprivileged userspace through /proc/cmdline.

I tested this on real LoongArch hardware (ACPI/UEFI) with the live update
two-stage kexec test and the test passes:

$ sudo ./luo_kexec_simple --stage 1
# [STAGE 1] Starting pre-kexec setup...
# [STAGE 1] Creating state file for next stage (2)...
# [STAGE 1] Creating session 'test-session' and preserving memfd...
# [STAGE 1] Forking persistent child to hold sessions...
# [STAGE 1] Child PID: 1242. Resources are pinned.
# [STAGE 1] You may now perform kexec reboot.
$ sudo kexec -l /boot/vmlinuz-7.1.0-rc6 --initrd=/boot/initramfs-7.1.0-rc6.img --reuse-cmdline
$ sudo kexec -e

$ sudo ./luo_kexec_simple --stage 2
# [STAGE 2] Starting post-kexec verification...
# [STAGE 2] Retrieving session 'test-session'...
# [STAGE 2] Restoring and verifying memfd (token 0x1a)...
# [STAGE 2] Test data verified successfully.
# [STAGE 2] Finalizing test session...
# [STAGE 2] Finalizing state session...
#
--- SIMPLE KEXEC TEST PASSED ---
$ sudo dmesg | grep kexec
[    0.000000] [      T0] KHO: found kexec handover data.

I will send this as v4, folding in Mike's two selftest comments.  If you
see a problem with the EFI configuration table approach, please tell me
before I post.

Thanks,
George

  reply	other threads:[~2026-07-17  7:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  9:28 [PATCH v3 0/3] LoongArch: add KHO support and selftests George Guo
2026-06-01  9:39 ` [PATCH v3 1/3] LoongArch: kexec: add KHO support for FDT-based George Guo
2026-06-01  9:39   ` [PATCH v3 2/3] LoongArch: kexec: add KHO support for ACPI-only George Guo
2026-06-01  9:39   ` [PATCH v3 3/3] selftests/kho: add LoongArch vmtest support George Guo
2026-06-14 10:23     ` Mike Rapoport
2026-07-13 13:53   ` [PATCH v3 1/3] LoongArch: kexec: add KHO support for FDT-based Pratyush Yadav
2026-07-14 12:17     ` Huacai Chen
2026-07-17  7:15       ` George Guo [this message]
2026-06-09 14:39 ` [PATCH v3 0/3] LoongArch: add KHO support and selftests George Guo
2026-06-09 15:55   ` Pratyush Yadav

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=20260717071551.11904-1-dongtai.guo@linux.dev \
    --to=dongtai.guo@linux.dev \
    --cc=chenhuacai@kernel.org \
    --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=pratyush@kernel.org \
    --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

Powered by JetHome