mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Cressey <ben@cressey.dev>
To: Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	 "Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  linux-pm@vger.kernel.org,
	Kees Cook <kees@kernel.org>,
	 Sami Tolvanen <samitolvanen@google.com>,
	kexec@lists.infradead.org,  llvm@lists.linux.dev,
	Nathan Chancellor <nathan@kernel.org>,
	 Zhaoyang Huang <zhaoyang.huang@unisoc.com>,
	 Jeson Gao <jeson.gao@unisoc.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 0/2] arm64: use typed entries into copied code for kCFI
Date: Wed, 11 Nov 2026 15:26:03 -0800	[thread overview]
Message-ID: <20261111-arm64-kexec-nocfi-v2-0-ddf0c4aa326f@cressey.dev> (raw)

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


             reply	other threads:[~2026-11-11 23:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 23:26 Ben Cressey [this message]
2026-11-11 23:26 ` [PATCH v2 1/2] arm64: kexec: use a typed entry to fix kCFI oops Ben Cressey
2026-11-11 23:26 ` [PATCH v2 2/2] arm64: hibernate: use a typed entry to drop __nocfi Ben Cressey
2026-11-18 18:33   ` Catalin Marinas
2026-11-18 18:26 ` (subset) [PATCH v2 0/2] arm64: use typed entries into copied code for kCFI Catalin Marinas

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=20261111-arm64-kexec-nocfi-v2-0-ddf0c4aa326f@cressey.dev \
    --to=ben@cressey.dev \
    --cc=catalin.marinas@arm.com \
    --cc=jeson.gao@unisoc.com \
    --cc=kees@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=nathan@kernel.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=samitolvanen@google.com \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    --cc=zhaoyang.huang@unisoc.com \
    /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

all inboxes | Powered by JetHome®