[PATCH v2 0/2] arm64: use typed entries into copied code for kCFI

Ben Cressey ben at cressey.dev
Wed Nov 11 15:26:03 PST 2026


An arm64 kernel built with CONFIG_CFI=y oopses after "Bye!" on every
kexec that relocates the image. v1 [1] marked machine_kexec() __nocfi.
This version types the copied relocation code instead, as Kees Cook
suggested [2], and does the same for hibernate, as Mark Rutland asked
[3], so that swsusp_arch_resume() loses its __nocfi. Only kexec faults
today, and its fix does not depend on the hibernate patch. x86 follows
as a separate patch.

Kees, the kexec patch is your diff with two comments and the ASSERT
message reworded. It had no sign-off, so it carries Suggested-by. Send
one if you would rather be co-developer or author.

An LLM diagnosed the oops, did that rewording, wrote the hibernate
patch, and drafted the changelogs and this letter.

Tested on v7.4-rc1 with clang. Under QEMU TCG, so functional only,
kexec_file_load(2), kexec_load(2), crash kexec and hibernate/resume pass
with CFI at EL1 and booted at EL2, and with CFI off at EL1. In KVM
guests at EL1 on Graviton4 the three kexec cases pass, where v7.4-rc1
alone oopses under the two load calls, and hibernate/resume passed one
commit before v7.4-rc1. The KHO selftest passes under TCG, and oopses
at v7.4-rc1. Bare metal, BTI at the typed entries on hardware, GCC's
kCFI and LTO are untested.

Changes in v2:
- Type arm64_relocate_new_kernel() and enter its copy at the symbol's
  offset, instead of marking machine_kexec() __nocfi (Kees Cook, Mark
  Rutland).
- Take back v1's statement that arm64_relocate_new_kernel "cannot be
  given a type hash".
- Add the hibernate patch (Mark Rutland).
- Rebase onto v7.4-rc1.
- Drop the Assisted-by tag. The cover letter now says how tools were
  used.

[1] https://lore.kernel.org/20260924-arm64-kexec-nocfi-v1-1-bbae2e2eadc8@cressey.dev
[2] https://lore.kernel.org/202609241804.BB23BF10@keescook
[3] https://lore.kernel.org/arZSe8hNnRPM5FqY@J2N7QTR9R3.cambridge.arm.com

---
Ben Cressey (2):
      arm64: kexec: use a typed entry to fix kCFI oops
      arm64: hibernate: use a typed entry to drop __nocfi

 arch/arm64/include/asm/kexec.h      |  2 ++
 arch/arm64/include/asm/suspend.h    |  5 +++++
 arch/arm64/kernel/hibernate-asm.S   |  7 +++++--
 arch/arm64/kernel/hibernate.c       | 14 +++++++++-----
 arch/arm64/kernel/machine_kexec.c   |  7 +++++--
 arch/arm64/kernel/relocate_kernel.S | 11 +++++++----
 arch/arm64/kernel/vmlinux.lds.S     | 10 ++++++----
 7 files changed, 39 insertions(+), 17 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260924-arm64-kexec-nocfi-496e643578ce




More information about the kexec mailing list