mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: kexec@lists.infradead.org, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	 "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Kai Huang <kai.huang@intel.com>,
	Nikolay Borisov <nik.borisov@suse.com>,
	 linux-kernel@vger.kernel.org, Simon Horman <horms@kernel.org>,
	Dave Young <dyoung@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	bsz@amazon.de
Subject: Re: [PATCH v7 8/8] [DO NOT MERGE] x86/kexec: Add CFI type information to relocate_kernel()
Date: Mon, 17 Mar 2025 12:40:14 +0000	[thread overview]
Message-ID: <970a4932cb95bc8934dc2ad15e8e84a2a51d2232.camel@infradead.org> (raw)
In-Reply-To: <7tq4tti5pv7fjboiapuglkcsodl4nsk53rj36skg4xb2bkysei@ncoz2ztiddm7>

[-- Attachment #1: Type: text/plain, Size: 3004 bytes --]

On Fri, 2025-03-14 at 10:52 -0700, Josh Poimboeuf wrote:
> 
> IIRC, the reasons were the patched alternative, and also you wanted to
> disassemble (but note that's still possible with gdb).

It's meaningful output from 'objdump -S' that I miss. But OK.

> Here was a patch to make it work:
> 
>   https://lore.kernel.org/20241218212326.44qff3i5n6cxuu5d@jpoimboe

I've reworked that and the CR4 filtering, and now it doesn't like me
using SYM_TYPED_FUNC_START() to add the CFI information for the
relocate_kernel() function.

  LD      vmlinux.o
vmlinux.o: warning: objtool: bad call to elf_init_reloc_text_sym() for
data symbol .data..relocate_kernel
 ...

  SORTTAB vmlinux
incomplete ORC unwind tables in file: vmlinux
Failed to sort kernel tables

This happens when I build with (clang and) CONFIG_CFI_CLANG, with and
updated version of your patch above, and this on top of it. This is at
https://git.infradead.org/users/dwmw2/linux.git/shortlog/refs/heads/kexec-debug

From 0f08a44613764e9b38a1c3332812685b61c99c2e Mon Sep 17 00:00:00 2001
From: David Woodhouse <dwmw@amazon.co.uk>
Date: Mon, 16 Dec 2024 10:26:24 +0000
Subject: [PATCH] x86/kexec: Add CFI type information to relocate_kernel()

A previous commit added __nocfi to machine_kexec() because it makes an
indirect call to relocate_kernel() which lacked CFI type information,
and caused the system to crash.

Use SYM_TYPED_FUNC_START() to ensure that the type information is
present, and remove the __nocfi tag.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 arch/x86/kernel/machine_kexec_64.c   | 2 +-
 arch/x86/kernel/relocate_kernel_64.S | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 016862d2b544..e1f5fc858aee 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -396,7 +396,7 @@ void machine_kexec_cleanup(struct kimage *image)
  * Do not allocate memory (or fail in any way) in machine_kexec().
  * We are past the point of no return, committed to rebooting now.
  */
-void __nocfi machine_kexec(struct kimage *image)
+void machine_kexec(struct kimage *image)
 {
 	unsigned long reloc_start = (unsigned long)__relocate_kernel_start;
 	relocate_kernel_fn *relocate_kernel_ptr;
diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
index 814af7fa6318..c859fbe507e8 100644
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -5,6 +5,7 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/cfi_types.h>
 #include <linux/stringify.h>
 #include <asm/alternative.h>
 #include <asm/page_types.h>
@@ -68,7 +69,7 @@ SYM_DATA_END(kexec_debug_idt)
  * opinions about it.
  */
 	.code64
-SYM_CODE_START_NOALIGN(relocate_kernel)
+SYM_TYPED_FUNC_START(relocate_kernel)
 	/*
 	 * %rdi indirection_page
 	 * %rsi pa_control_page
-- 
2.48.1


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]

  parent reply	other threads:[~2025-03-17 12:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12 14:34 [PATCH v7 0/8] x86/kexec: Add exception handling for relocate_kernel David Woodhouse
2025-03-12 14:34 ` [PATCH v7 1/8] x86/kexec: Debugging support: load a GDT David Woodhouse
2025-03-13 10:42   ` [tip: x86/boot] x86/kexec: Add relocate_kernel() debugging support: Load " tip-bot2 for David Woodhouse
2025-03-14 10:16   ` tip-bot2 for David Woodhouse
2025-03-12 14:34 ` [PATCH v7 2/8] x86/kexec: Debugging support: Load an IDT and basic exception entry points David Woodhouse
2025-03-13 10:42   ` [tip: x86/boot] x86/kexec: Add relocate_kernel() debugging " tip-bot2 for David Woodhouse
2025-03-12 14:34 ` [PATCH v7 3/8] x86/kexec: Debugging support: Dump registers on exception David Woodhouse
2025-03-13 10:42   ` [tip: x86/boot] x86/kexec: Add relocate_kernel() debugging " tip-bot2 for David Woodhouse
2025-03-12 14:34 ` [PATCH v7 4/8] x86/kexec: Add 8250 serial port output David Woodhouse
2025-03-13 10:35   ` Ingo Molnar
2025-03-12 14:34 ` [PATCH v7 5/8] x86/kexec: Add 8250 MMIO " David Woodhouse
2025-03-12 14:34 ` [PATCH v7 6/8] x86/kexec: Invalidate GDT/IDT from relocate_kernel() instead of earlier David Woodhouse
2025-03-12 14:34 ` [PATCH v7 7/8] [DO NOT MERGE] x86/kexec: Add int3 in kexec path for testing David Woodhouse
2025-03-13 10:44   ` Ingo Molnar
2025-03-13 11:06     ` David Woodhouse
2025-03-13 17:06       ` Ingo Molnar
2025-03-13 18:38         ` David Woodhouse
2025-03-12 14:34 ` [PATCH v7 8/8] [DO NOT MERGE] x86/kexec: Add CFI type information to relocate_kernel() David Woodhouse
2025-03-14 16:07   ` Josh Poimboeuf
2025-03-14 17:23     ` David Woodhouse
2025-03-14 17:52       ` Josh Poimboeuf
2025-03-14 18:29         ` David Woodhouse
2025-03-17 12:40         ` David Woodhouse [this message]
2025-03-18  0:17           ` Josh Poimboeuf
2025-03-18  0:24             ` Josh Poimboeuf
2025-03-18 15:56               ` David Woodhouse
2025-03-18 17:14                 ` Josh Poimboeuf
2025-03-18 21:06                   ` David Woodhouse
2025-03-18 22:41                     ` Josh Poimboeuf
2025-03-19 13:04                       ` David Woodhouse
2025-03-19 15:47                         ` Josh Poimboeuf
2025-03-22 11:38                           ` David Woodhouse
2025-03-13 10:46 ` [PATCH v7 0/8] x86/kexec: Add exception handling for relocate_kernel Ingo Molnar
2025-03-13 10:54   ` Ingo Molnar
2025-03-13 19:58     ` David Woodhouse
2025-03-14  9:25       ` David Woodhouse
2025-03-14 10:21         ` Ingo Molnar
2025-03-14 10:37           ` David Woodhouse

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=970a4932cb95bc8934dc2ad15e8e84a2a51d2232.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=bp@alien8.de \
    --cc=bsz@amazon.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dyoung@redhat.com \
    --cc=horms@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=kai.huang@intel.com \
    --cc=kexec@lists.infradead.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®