From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.59 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794439589; b=czIkyOvco8RwUWNGbejwL0KC0mVxFjMfg2JpOKUUPmiV855dSTLbKhUAO0I266NFKdkT QYOqYqcD1ycpgbf4EViEoBEJGZEjsLEP61d6DAEAgs6douAXqn8nsF92Cz8FwSKobyR7g mJ9KfCA/8C+xMhiv/r4pYTl1IXLNTNN2jRpbs56YtJtUGKSAAoz47gkAK+78092LOY1Bi DKUQqXboqKO6ZkohJvOH4X/+UzOMzmTz7qu26yJw8I8k1j2UASr6GKtT9+LujgCsozx86 f/1s1yyFLTjTK7c+by3ipMVaSu4DHO519ASurvtt/pWLb/Zb/rQjXtlbfvfYsVgXqTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794439589; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Subject:X-Change-ID:To:Cc:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding:Date:Message-Id; bh=t9kO9XGAegdg1V2vmzxAZZmN+Wm2FOyrI5Nk2f8kXVM=; b=Xte/C7ujXpVi0mDIgzJEKtFn+Gjttgo33xAV85rN4pC0sAUUTDkdDRXwNEEl5lshGtOK HwJxD9R2jze0mIA56Y+PJOlUSOjYOua0+ZfRlMqg/cXwPZMhFGCX7oURbBMEVvs5YT5zW WhHTMg4DgGvpjL11JOKeFWuLx73ZKQqGDttu6y2aeuyISOlejnhnx8jr4TP2RBdqMWoSr Ol0ErCSK1s3KNwBOVmnBwXyQOI7D2EXeUrHRaeS6rof0H6SfKgmLbhn+KDlQMwnjACcYP n5exJ5qwmYTjE9/P6GpgqEZktMpgXO00MIdSv6PTakcjRpmznZNnN5/ARNBnFYR0LwQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cressey.dev; spf=pass smtp.mailfrom=cressey.dev; dkim=pass header.d=cressey.dev header.i=@cressey.dev header.a=rsa-sha256 header.s=key1 header.b=MOdWtvWo; arc=none smtp.remote-ip=95.215.58.59 Received: from mta1.migadu.com (out-59.mta1.migadu.com [95.215.58.59]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F50F606A32E for ; Wed, 11 Nov 2026 23:26:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4F50F606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cressey.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cressey.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=cressey.dev header.i=@cressey.dev header.a=rsa-sha256 header.s=key1 header.b=MOdWtvWo X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=b/8lLMDlwRa4+gznMkDz96CHWdfImhJ5sxzvM1VsIDw=; c=simple/simple; d=cressey.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794439585; v=1; x=1795044385; b=MOdWtvWoXkBNJaA4bOpDVYlDcwCRHMWccYHPEbF14qgfh4c/hoMYub9Ykk3C6TU4x5jiOuyo QtwZI1Kpx1hB0E/VWP32Df9LYBv63Id4NtJP7W12/dsZQpEW+zd454PRyEn3fj8rVm+xecFZfeU 6dAsxcEO2SH7Khx3jWWXoWRUcTJv5tXsaJh4AmNCdLog3tU4ljPqfph6wDa39AF8U8NJivVZ1Dl LNXOzq7NGhUfzDtRWXclH4mNedpphhvNyidaudP1JiBEiwA1SfAW+muNTi6OdEoNZHGkvXzM2A2 mzGDMFy5U1DxpaBp1CvBkOyOrkM8b2bLy3GCU7W7rWXcg== X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 4893caac69ce6e85; Wed, 11 Nov 2026 23:26:25 +0000 X-Mizu-Trace-ID: 4893caac69ce6e85 X-Migadu-Flow: FLOW_OUT From: Ben Cressey Subject: [PATCH v2 0/2] arm64: use typed entries into copied code for kCFI X-Change-ID: 20260924-arm64-kexec-nocfi-496e643578ce To: Catalin Marinas , Will Deacon , Mark Rutland , Pasha Tatashin , "Rafael J. Wysocki" , Pavel Machek Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Kees Cook , Sami Tolvanen , kexec@lists.infradead.org, llvm@lists.linux.dev, Nathan Chancellor , Zhaoyang Huang , Jeson Gao , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Date: Wed, 11 Nov 2026 15:26:03 -0800 Message-Id: <20261111-arm64-kexec-nocfi-v2-0-ddf0c4aa326f@cressey.dev> 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