From: Peter Zijlstra <peterz@infradead.org>
To: jolsa@kernel.org, oleg@redhat.com, andrii@kernel.org,
mhiramat@kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
alx@kernel.org, eyal.birger@gmail.com, kees@kernel.org,
bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
x86@kernel.org, songliubraving@fb.com, yhs@fb.com,
john.fastabend@gmail.com, haoluo@google.com, rostedt@goodmis.org,
alan.maguire@oracle.com, David.Laight@ACULAB.COM,
thomas@t-8ch.de, mingo@kernel.org, rick.p.edgecombe@intel.com
Subject: [PATCH 1/6] uprobes/x86: Add struct uretprobe_syscall_args
Date: Thu, 21 Aug 2025 14:28:23 +0200 [thread overview]
Message-ID: <20250821123656.705837806@infradead.org> (raw)
In-Reply-To: <20250821122822.671515652@infradead.org>
Like uprobe_syscall_args; keep things consistent.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
arch/x86/kernel/uprobes.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -311,6 +311,12 @@ static int uprobe_init_insn(struct arch_
#ifdef CONFIG_X86_64
+struct uretprobe_syscall_args {
+ unsigned long r11;
+ unsigned long cx;
+ unsigned long ax;
+};
+
asm (
".pushsection .rodata\n"
".global uretprobe_trampoline_entry\n"
@@ -324,8 +330,8 @@ asm (
"uretprobe_syscall_check:\n"
"popq %r11\n"
"popq %rcx\n"
-
- /* The uretprobe syscall replaces stored %rax value with final
+ /*
+ * The uretprobe syscall replaces stored %rax value with final
* return address, so we don't restore %rax in here and just
* call ret.
*/
@@ -366,7 +372,8 @@ static unsigned long trampoline_check_ip
SYSCALL_DEFINE0(uretprobe)
{
struct pt_regs *regs = task_pt_regs(current);
- unsigned long err, ip, sp, r11_cx_ax[3], tramp;
+ struct uretprobe_syscall_args args;
+ unsigned long err, ip, sp, tramp;
/* If there's no trampoline, we are called from wrong place. */
tramp = uprobe_get_trampoline_vaddr();
@@ -377,15 +384,15 @@ SYSCALL_DEFINE0(uretprobe)
if (unlikely(regs->ip != trampoline_check_ip(tramp)))
goto sigill;
- err = copy_from_user(r11_cx_ax, (void __user *)regs->sp, sizeof(r11_cx_ax));
+ err = copy_from_user(&args, (void __user *)regs->sp, sizeof(args));
if (err)
goto sigill;
/* expose the "right" values of r11/cx/ax/sp to uprobe_consumer/s */
- regs->r11 = r11_cx_ax[0];
- regs->cx = r11_cx_ax[1];
- regs->ax = r11_cx_ax[2];
- regs->sp += sizeof(r11_cx_ax);
+ regs->r11 = args.r11;
+ regs->cx = args.cx;
+ regs->ax = args.ax;
+ regs->sp += sizeof(args);
regs->orig_ax = -1;
ip = regs->ip;
@@ -401,21 +408,21 @@ SYSCALL_DEFINE0(uretprobe)
*/
if (regs->sp != sp || shstk_is_enabled())
return regs->ax;
- regs->sp -= sizeof(r11_cx_ax);
+ regs->sp -= sizeof(args);
/* for the case uprobe_consumer has changed r11/cx */
- r11_cx_ax[0] = regs->r11;
- r11_cx_ax[1] = regs->cx;
+ args.r11 = regs->r11;
+ args.cx = regs->cx;
/*
* ax register is passed through as return value, so we can use
* its space on stack for ip value and jump to it through the
* trampoline's ret instruction
*/
- r11_cx_ax[2] = regs->ip;
+ args.ax = regs->ip;
regs->ip = ip;
- err = copy_to_user((void __user *)regs->sp, r11_cx_ax, sizeof(r11_cx_ax));
+ err = copy_to_user((void __user *)regs->sp, &args, sizeof(args));
if (err)
goto sigill;
next prev parent reply other threads:[~2025-08-21 12:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 12:28 [PATCH 0/6] uprobes/x86: Cleanups and fixes Peter Zijlstra
2025-08-21 12:28 ` Peter Zijlstra [this message]
2025-08-25 10:24 ` [tip: perf/core] uprobes/x86: Add struct uretprobe_syscall_args tip-bot2 for Peter Zijlstra
2025-08-21 12:28 ` [PATCH 2/6] uprobes/x86: Optimize is_optimize() Peter Zijlstra
2025-08-25 10:24 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-26 5:51 ` [PATCH 2/6] " David Laight
2025-08-26 8:18 ` Peter Zijlstra
2025-08-27 19:32 ` David Laight
2025-08-26 8:25 ` Jiri Olsa
2025-08-26 8:33 ` Jiri Olsa
2025-08-21 12:28 ` [PATCH 3/6] uprobes/x86: Accept more NOP forms Peter Zijlstra
2025-08-25 10:24 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-21 12:28 ` [PATCH 4/6] uprobes/x86: Fix uprobe syscall vs shadow stack Peter Zijlstra
2025-08-21 18:26 ` Edgecombe, Rick P
2025-08-25 10:24 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-21 12:28 ` [PATCH 5/6] uprobes/x86: Make asm style consistent Peter Zijlstra
2025-08-25 10:24 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-08-21 12:28 ` [PATCH 6/6] uprobes/x86: Add SLS mitigation to the trampolines Peter Zijlstra
2025-08-25 10:24 ` [tip: perf/core] " tip-bot2 for Peter Zijlstra
2025-09-10 1:05 ` [PATCH 6/6] " Masami Hiramatsu
2025-08-21 14:18 ` [PATCH 0/6] uprobes/x86: Cleanups and fixes Jiri Olsa
2025-08-21 18:27 ` Edgecombe, Rick P
2025-08-21 19:52 ` Jiri Olsa
2025-08-21 19:57 ` Edgecombe, Rick P
2025-08-22 8:42 ` Jiri Olsa
2025-08-22 18:05 ` Andrii Nakryiko
2025-09-09 12:48 ` Jiri Olsa
2025-09-09 15:20 ` Andrii Nakryiko
2025-09-09 16:39 ` Jiri Olsa
2025-09-09 16:44 ` Andrii Nakryiko
2025-08-22 15:51 ` Oleg Nesterov
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=20250821123656.705837806@infradead.org \
--to=peterz@infradead.org \
--cc=David.Laight@ACULAB.COM \
--cc=alan.maguire@oracle.com \
--cc=alx@kernel.org \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eyal.birger@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=thomas@t-8ch.de \
--cc=x86@kernel.org \
--cc=yhs@fb.com \
/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®