BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Daniel Borkmann" <daniel@iogearbox.net>, <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <jolsa@kernel.org>,
	"Menglong Dong" <dongml2@chinatelecom.cn>,
	"Steven Rostedt" <rostedt@goodmis.org>
Subject: Re: [PATCH bpf 1/2] x86/ftrace: Use jmp mode only where functions are aligned
Date: Sat, 24 Oct 2026 19:10:57 +0000	[thread overview]
Message-ID: <DMDB1EESN4U0.KLEICFNC4NUP@gmail.com> (raw)
In-Reply-To: <20261024073712.1074591-1-daniel@iogearbox.net>

On Sat, Oct 24, 2026 at 12:37 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> Bit 0 has that meaning only for the direct trampolines that a dyn_ftrace
> record can point to, so jmp mode relies on every other target being even.
> Select HAVE_DYNAMIC_FTRACE_WITH_JMP only where it is, with
> CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT or without CONFIG_CC_OPTIMIZE_FOR_SIZE.

Disabling it for -Os builds is not great.
Can we fix the users of ftrace_call_replace() instead ?

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 17d6edf..654c3f2 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -190,11 +190,11 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
 	const char *new;

 	ip = (unsigned long)(&ftrace_call);
-	new = ftrace_call_replace(ip, (unsigned long)func);
+	new = text_gen_insn(CALL_INSN_OPCODE, (void *)ip, func);
 	smp_text_poke_single((void *)ip, new, MCOUNT_INSN_SIZE, NULL);

 	ip = (unsigned long)(&ftrace_regs_call);
-	new = ftrace_call_replace(ip, (unsigned long)func);
+	new = text_gen_insn(CALL_INSN_OPCODE, (void *)ip, func);
 	smp_text_poke_single((void *)ip, new, MCOUNT_INSN_SIZE, NULL);

 	return 0;
@@ -503,7 +503,7 @@ void arch_ftrace_update_trampoline(struct ftrace_ops *ops)

 	mutex_lock(&text_mutex);
 	/* Do a safe modify in case the trampoline is executing */
-	new = ftrace_call_replace(ip, (unsigned long)func);
+	new = text_gen_insn(CALL_INSN_OPCODE, (void *)ip, func);
 	smp_text_poke_single((void *)ip, new, MCOUNT_INSN_SIZE, NULL);
 	mutex_unlock(&text_mutex);
 }


  parent reply	other threads:[~2026-10-24 19:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24  7:37 [PATCH bpf 1/2] x86/ftrace: Use jmp mode only where functions are aligned Daniel Borkmann
2026-10-24  7:37 ` [PATCH bpf 2/2] selftests/bpf: Test kprobe and fentry programs on one function Daniel Borkmann
2026-10-24 19:10 ` Alexei Starovoitov [this message]
2026-10-25 13:18   ` [PATCH bpf 1/2] x86/ftrace: Use jmp mode only where functions are aligned Jiri Olsa
2026-10-25 15:27     ` Daniel Borkmann
2026-10-25 17:38       ` Alexei Starovoitov

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=DMDB1EESN4U0.KLEICFNC4NUP@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dongml2@chinatelecom.cn \
    --cc=jolsa@kernel.org \
    --cc=rostedt@goodmis.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