Linux Trace Kernel
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: hang.zhengyang1010@gmail.com
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>, 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>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	bpf@vger.kernel.org, Andrii Nakryiko <andrii@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH] uprobes/x86: Emulate ENDBR as a NOP
Date: Thu, 12 Nov 2026 09:04:06 +0100	[thread overview]
Message-ID: <20261112080406.GA2668804@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20261112-uprobe-endbr-v1-1-284a47a5ae3e@gmail.com>

On Thu, Nov 12, 2026 at 01:26:18PM +0800, Hang Zhengyang via B4 Relay wrote:
> From: Hang Zhengyang <hang.zhengyang1010@gmail.com>
> 
> A uprobe on ENDBR64 is single-stepped, so it takes two traps instead of
> one: insn_is_nop() doesn't recognize ENDBR, and it isn't a branch or a
> push either.  That makes the most common case slow.  With
> -fcf-protection, the default for gcc on Ubuntu, every function starts
> with ENDBR64, so every uprobe on a function entry pays for the
> single-step.  PUSH had the same problem until commit e7ed9d9bd037
> ("uprobes/x86: Emulate push insns for uprobe on x86").
> 
> Userspace IBT is not supported, so ENDBR is just a NOP in user mode.
> Emulate it like the other NOPs.  Don't use is_endbr() for the check: it
> always returns false without CONFIG_X86_KERNEL_IBT.  If userspace IBT
> is ever enabled, uprobes on ENDBR will need rework anyway, since the
> int3 replaces the ENDBR at an indirect branch target.
> 
> The numbers below are from the selftests/bpf trigger benchmarks, with
> an extra target that starts with ENDBR64 (the existing ones are built
> with __nocf_check, so they don't have it).  On a Ryzen 7 PRO 5850U,
> without this patch, a probe on ENDBR64 is as slow as a single-stepped
> one:
> 
>              nop       endbr64   ret (single-step)
>   uprobe     1.33 M/s  0.65 M/s  0.65 M/s
>   uretprobe  0.66 M/s  0.43 M/s  0.43 M/s
> 
> With this patch ENDBR64 is emulated like a NOP.  I could only boot the
> patched kernel in a KVM guest, where uprobe went from 0.19 to 0.99 M/s
> (nop: 1.00) and uretprobe from 0.17 to 0.61 M/s (nop: 0.61).
> 
> Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>
> ---

Uh, no. We must not allow uprobe on ENDBR. If we ever get userspace IBT
(people are actually looking at that), then putting a probe on it will
make indirect function calls #CP.

None of this makes sense.


      reply	other threads:[~2026-11-12  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  5:26 [PATCH] uprobes/x86: Emulate ENDBR as a NOP Hang Zhengyang via B4 Relay
2026-11-12  8:04 ` Peter Zijlstra [this message]

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=20261112080406.GA2668804@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=andrii@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=hang.zhengyang1010@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=tglx@kernel.org \
    --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