Skip to content

LoongArch: Add KHO support and selftests

George Guo kexec linux-efi linux-kselftest linux-mm lkml loongarch 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest8 patches 12 repliesIn review
  2. v55 patches 12 repliesSuperseded
  3. v44 patches 16 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v33 patches6 repliesSuperseded
v24 patches0 repliesSuperseded

Changes in v6 from the cover letter

- Drop CONFIG_EFI_KHO. Only the LoongArch stub installs the table, from efi_boot_kernel(). The other code is built with CONFIG_EFI and does nothing when there is no table (Pratyush).
- efi_kho_update() returns 0 when there is no table, so kexec on other architectures is not affected.
- Warn if the table cannot be mapped in early boot (Pratyush).
- Document each member of struct linux_efi_kho_data and drop __packed

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8efi: Pass KHO state to the next kernel in a configuration tabledrivers/firmware/efi/efi.c drivers/firmware/efi/libstub/efi-stub.c drivers/firmware/efi/libstub/efistub.h +2 more+134 -05 replies
2/8kho: Write KHO state to the EFI table at kexec timekernel/crash_core.c kernel/kexec_core.c kernel/kexec_internal.h +1 more+45 -00 replies
3/8kho: Include linux/mm.h in kho_block.ckernel/liveupdate/kho_block.c+1 -00 replies
4/8kho: Add kho_disable()include/linux/kexec_handover.h kernel/liveupdate/kexec_handover.c+12 -01 reply
5/8LoongArch: Allow memblock arrays to resizearch/loongarch/kernel/setup.c+3 -06 replies
6/8LoongArch: Enable kexec handover (KHO)arch/loongarch/Kconfig arch/loongarch/kernel/setup.c+19 -00 replies
7/8selftests/kho: Add LoongArch vmtest supporttools/testing/selftests/kho/loongarch.conf tools/testing/selftests/kho/vmtest.sh+13 -10 replies
8/8selftests/liveupdate: Add LoongArch vmtest supporttools/testing/selftests/liveupdate/config.loongarch64 tools/testing/selftests/liveupdate/run-vmtests.sh tools/testing/selftests/liveupdate/vmtest.sh+20 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [PATCH v6 0/8] LoongArch: Add KHO support and selftests

From: George Guo <[email protected]>

This series enables Kexec HandOver (KHO) on 64-bit LoongArch and adds LoongArch to the KHO and liveupdate QEMU selftests.

KHO has to give the next kernel two addresses: the KHO FDT and the bootmem area list. arm64 and riscv put them under /chosen in the boot FDT, and x86 puts them in setup_data. LoongArch systems that boot with EFI and ACPI have no boot FDT, so this series passes the addresses in a Linux EFI configuration table:

- On a cold boot, the LoongArch EFI stub installs the table, zeroed. Kernels started by kexec are given the same EFI system table, so they find the same table.
- In early boot, the kernel reserves the table and calls kho_populate() if the table holds KHO state.
- Just before kexec, the kernel writes the KHO state of the image it is about to run, or zeroes the table if that image has none, for example a crash kernel.

A kernel started by kexec from a kernel that did not install the table has no table and cannot pass KHO state on, so LoongArch turns KHO off at boot in that case.

Patch 1 adds the table, and patch 2 writes it at kexec time. Patch 3 fixes a kho_block.c build failure with CONFIG_KFENCE=y on LoongArch. Patch 4 adds kho_disable(). Patch 5 lets the LoongArch memblock arrays grow, which restoring many preserved regions needs, and patch 6 enables KHO on LoongArch. Patches 7 and 8 add LoongArch to the KHO and liveupdate vmtests.

The series is based on liveupdate-7.4 and depends on "liveupdate: kho:
calculate per-node bootmem sizes before allocating any" [1]. Without it, the KHO vmtest fails on a 1 GiB LoongArch guest because KHO cannot reserve its bootmem areas.

Tested in QEMU: the KHO vmtest passes on LoongArch with both CONFIG_NUMA=n and CONFIG_NUMA=y, and run-vmtests.sh passes all four liveupdate tests on x86_64, aarch64 and loongarch64.

Changes since v5:
- Drop CONFIG_EFI_KHO. Only the LoongArch stub installs the table, from efi_boot_kernel(). The other code is built with CONFIG_EFI and does nothing when there is no table (Pratyush).
- efi_kho_update() returns 0 when there is no table, so kexec on other architectures is not affected.
- Warn if the table cannot be mapped in early boot (Pratyush).
- Document each member of struct linux_efi_kho_data and drop __packed

    (Pratyush).
  - Rename efi_kho_table_phys to efi_kho, mark it __initdata, and join
    wrapped lines (Huacai).
  - Rename kho_sync_channel() to kho_update_efi_table(), and stop
    calling the table a "channel" or "transport" (Mike, Pratyush).
  - New patch 4: turn KHO off at boot on LoongArch when the table is
    missing.
  - New patch 5: allow the memblock arrays to resize on LoongArch. The
    liveupdate luo_stress_files test overflowed the reserved array in
    the next kernel when CONFIG_SMP was not set.
  - New patch 8: add LoongArch to the liveupdate vmtest.
  - Rename scratch to bootmem, following Pratyush's rename series.
  - Drop the luo_session history from patch 3's commit message
    (Pratyush).

- Capitalize the subjects and use the kho: prefix (Huacai).
- Rewrite the cover letter and commit messages (Mike, Pratyush).
- Rebase onto liveupdate-7.4.
- No Assisted-by tags, although my v5 reply said patches written with LLM help would carry one: the Assisted-by references have since been removed from the documentation in mainline.

[1] https://lore.kernel.org/all/[email protected]/

v5: https://lore.kernel.org/loongarch/[email protected]/
v4: https://lore.kernel.org/loongarch/[email protected]/

George Guo (8):
efi: Pass KHO state to the next kernel in a configuration table
kho: Write KHO state to the EFI table at kexec time
kho: Include linux/mm.h in kho_block.c
kho: Add kho_disable()
LoongArch: Allow memblock arrays to resize
LoongArch: Enable kexec handover (KHO)
selftests/kho: Add LoongArch vmtest support selftests/liveupdate: Add LoongArch vmtest support

 arch/loongarch/Kconfig                        |  3 +
 arch/loongarch/kernel/setup.c                 | 19 ++++++
 drivers/firmware/efi/efi.c                    | 68 +++++++++++++++++++
 drivers/firmware/efi/libstub/efi-stub.c       | 22 ++++++
 drivers/firmware/efi/libstub/efistub.h        |  2 +
 drivers/firmware/efi/libstub/loongarch.c      |  2 +
 include/linux/efi.h                           | 40 +++++++++++
 include/linux/kexec_handover.h                |  3 +
 kernel/crash_core.c                           |  6 ++
 kernel/kexec_core.c                           |  5 ++
 kernel/kexec_internal.h                       |  8 +++
 kernel/liveupdate/kexec_handover.c            | 35 ++++++++++
 kernel/liveupdate/kho_block.c                 |  1 +
 tools/testing/selftests/kho/loongarch.conf    | 11 +++
 tools/testing/selftests/kho/vmtest.sh         |  3 +-
 .../selftests/liveupdate/config.loongarch64   |  5 ++
 .../selftests/liveupdate/run-vmtests.sh       |  4 +-
 tools/testing/selftests/liveupdate/vmtest.sh  | 14 +++-
 18 files changed, 247 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/kho/loongarch.conf
 create mode 100644 tools/testing/selftests/liveupdate/config.loongarch64

base-commit: 9a6a70aefe77f6fb9ff2b3037dcf87f6dff65c8c
prerequisite-patch-id: 433e6f8fdec5151f12221a0a34f8fb111b95bb46

Signature · 1 line
2.53.0