uprobes/x86: Add mapping for optimized uprobe trampolines
authorJiri Olsa <jolsa@kernel.org>
Sun, 20 Jul 2025 11:21:18 +0000 (13:21 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 21 Aug 2025 18:09:20 +0000 (20:09 +0200)
commit91440ff4cafad4c86322a612e523f7f021a493e7
tree7654dd4e419031dd8ca2a2e7e4c4d907ed74802f
parent18a111256a0b4fedfe47101f084441a84d7e357a
uprobes/x86: Add mapping for optimized uprobe trampolines

Adding support to add special mapping for user space trampoline with
following functions:

  uprobe_trampoline_get - find or add uprobe_trampoline
  uprobe_trampoline_put - remove or destroy uprobe_trampoline

The user space trampoline is exported as arch specific user space special
mapping through tramp_mapping, which is initialized in following changes
with new uprobe syscall.

The uprobe trampoline needs to be callable/reachable from the probed address,
so while searching for available address we use is_reachable_by_call function
to decide if the uprobe trampoline is callable from the probe address.

All uprobe_trampoline objects are stored in uprobes_state object and are
cleaned up when the process mm_struct goes down. Adding new arch hooks
for that, because this change is x86_64 specific.

Locking is provided by callers in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20250720112133.244369-9-jolsa@kernel.org
arch/x86/kernel/uprobes.c
include/linux/uprobes.h
kernel/events/uprobes.c
kernel/fork.c