From nobody Sat Oct 4 03:04:09 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10EB0320CC6; Thu, 21 Aug 2025 12:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755780172; cv=none; b=nzFyHvvW7UBgovxY8Wug1Y7FLtwaz0uEuW+s1264EE82YLL64O9aw4aEKP0yXpeunPwTKAItIzWGjz0JpBA43iz3H3t+kGpXrAykWUCSns7UOPpjgZ2Jui9nn/I4tOulLv8cO6uUXDep206O+6KgYEVMeX9XYT6yG6liw7LeuOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755780172; c=relaxed/simple; bh=fRuRyExtuleTQ0QZnw8BEriw7fy34Dn7Y/V6jbcJ+AE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=JsSlcVQBFrTLtr5nhiwqPPmxx9FdsWpAcc7gZdkVIQ8/9zka8tjCdFzm+ogoD60UfvZHBxImp6MJjuf48Xgjzjbv6C0vt0tvD57FqGBftzow5FUBn7lk2nXXJwN0lB6TyzeEvGT1cmD14zQnb34o4GeHTRH6YSRds8EBYJiLk1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=knmNnlNr; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="knmNnlNr" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=68tGCHbm2uavV4Zx8UMMGxPgMa8MecvRI7OvCw9rTO8=; b=knmNnlNrEy4vgCCNy2oeO6yRNW YKmOGUjwHTeB2ZGLhJD7+CwCcUi5JUPHlA/Yimn6CzqLAOtAf+Q2iJcWGGjOCSlTaikb7pjv3WOqS WUrQB7mL/64nA89Yq8f01wFaJHAwSp1JBaxKRjdd2TNeUgQyb2Cam84NcS+GeGjX49++k6hv/IktA otGIoGKmc7yiB4ud+5pNH4DE73iO/OnXRryvaanNjYXZYW4nANW+Les5HvFPexybBg13U8H4rxYq/ f7IP9hI6Ol4BMDBrz1oZiEFYQ4gLbyWQxQD4e5FQCG5Ac6y6Lvoa366qszm4HE95DtRwcWow7tNz6 dJSJVOfQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1up4cn-000000075gM-2lXi; Thu, 21 Aug 2025 12:42:38 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 894CE30034B; Thu, 21 Aug 2025 14:42:37 +0200 (CEST) Message-ID: <20250821123656.705837806@infradead.org> User-Agent: quilt/0.68 Date: Thu, 21 Aug 2025 14:28:23 +0200 From: Peter Zijlstra 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 References: <20250821122822.671515652@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Like uprobe_syscall_args; keep things consistent. Signed-off-by: Peter Zijlstra (Intel) --- 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_ =20 #ifdef CONFIG_X86_64 =20 +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 =3D 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; =20 /* If there's no trampoline, we are called from wrong place. */ tramp =3D uprobe_get_trampoline_vaddr(); @@ -377,15 +384,15 @@ SYSCALL_DEFINE0(uretprobe) if (unlikely(regs->ip !=3D trampoline_check_ip(tramp))) goto sigill; =20 - err =3D copy_from_user(r11_cx_ax, (void __user *)regs->sp, sizeof(r11_cx_= ax)); + err =3D copy_from_user(&args, (void __user *)regs->sp, sizeof(args)); if (err) goto sigill; =20 /* expose the "right" values of r11/cx/ax/sp to uprobe_consumer/s */ - regs->r11 =3D r11_cx_ax[0]; - regs->cx =3D r11_cx_ax[1]; - regs->ax =3D r11_cx_ax[2]; - regs->sp +=3D sizeof(r11_cx_ax); + regs->r11 =3D args.r11; + regs->cx =3D args.cx; + regs->ax =3D args.ax; + regs->sp +=3D sizeof(args); regs->orig_ax =3D -1; =20 ip =3D regs->ip; @@ -401,21 +408,21 @@ SYSCALL_DEFINE0(uretprobe) */ if (regs->sp !=3D sp || shstk_is_enabled()) return regs->ax; - regs->sp -=3D sizeof(r11_cx_ax); + regs->sp -=3D sizeof(args); =20 /* for the case uprobe_consumer has changed r11/cx */ - r11_cx_ax[0] =3D regs->r11; - r11_cx_ax[1] =3D regs->cx; + args.r11 =3D regs->r11; + args.cx =3D regs->cx; =20 /* * 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] =3D regs->ip; + args.ax =3D regs->ip; regs->ip =3D ip; =20 - err =3D copy_to_user((void __user *)regs->sp, r11_cx_ax, sizeof(r11_cx_ax= )); + err =3D copy_to_user((void __user *)regs->sp, &args, sizeof(args)); if (err) goto sigill;