Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1762168lqm; Fri, 3 May 2024 06:05:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuQvPy9gpdW3DuhBU12lXGswMj1R64DdvKK4IMupmmQwFadnTBA5ibO9/1c4zGnNNT7ZkNcYTSRjOgbGEaYhfmeLqgJh9XhWqOAwQHHA== X-Google-Smtp-Source: AGHT+IG98MBz0ebR+DwP81ue6Zn4m27iRVq6U1imaBQjuPmgaAKsC1CZAOJ/lGOrKsJBCQrCeHzL X-Received: by 2002:a05:6830:22c1:b0:6ee:3d39:6255 with SMTP id q1-20020a05683022c100b006ee3d396255mr3001568otc.29.1714741535404; Fri, 03 May 2024 06:05:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714741535; cv=pass; d=google.com; s=arc-20160816; b=Gvp3FXRmwt9JC7jQ884nWHP2MChqnvF8A/Cdel3amB7X4BMbfZionwbK81zJyPdd9Y 8bGOG9tgUdqnt8AfAVG+AYvat+Jb1zob7Uyfn0xuJ6ax//m4A7Za+TJQPgVAsAhQl4kY fg8BIdKOpEanhox52CaFlUJX+VcdkJUajM7f3VNpMBBkRN/EvZM2vUaAoWuR/S7i+9+O p3+HHnWOE3EAR9WwDi27UqiKzJ6MSjc0+sEppb3ntdPCLkXOozFGLcleQvAC3GGMVX7J e30Jn+iQsEnPdLfvpm54hVNsKAh6xQcjf3cFP9Jc89f5fK4FwqhcNPo40JRJeqfOPV+7 GkTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:date:from:dkim-signature; bh=rfzmlT4PMypwMBle7ZsZNzT+S9kweSo9iiTEGtqzGjk=; fh=RTUIP4uqeFp0GyCusSQIwz/hdzRozE/CbhOa9U8/lAA=; b=UYlOBxEiT/fbRKGDhOY43YJNjzy6/G+bkfriepub84lA8tC/7ww9S36RSU5GknLkZJ 5HRku6CJxI9YOx5AvxXhRbsQ7iEOh0E4R7waa2g0ztzDFGKTCEG5RMNqP2DzmEGyyj3z Skv4bR4kTTNl2Zy/mLIjGBYfCuq5XoP7WG7AmCDsh7x1ALEStJvu9NLP7j6a2yFoj1Hp KrVWYEwBD6a65p+ccgRpu8O3zBjGmcF542S1mZN3c16cJU9AK3txZUdvAoK5LkQtt3tL w012LEBaYcuTU4M0noE+Bl+9czhcIEZr9br4SMeeNrmTuC9TQ5pZKist//gIq7QG9Ges 56ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SU68yLv6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-167669-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167669-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t10-20020a9d66ca000000b006ee359ba02bsi969439otm.139.2024.05.03.06.05.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 06:05:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167669-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SU68yLv6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-167669-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167669-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 80EA6284E38 for ; Fri, 3 May 2024 13:05:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 375AC153BE8; Fri, 3 May 2024 13:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SU68yLv6" Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C465C152E17; Fri, 3 May 2024 13:04:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714741471; cv=none; b=gXRVxDdnEIf8RKa8az65w7rQmujOhFMO0V++cuZoFS9Q2c0Lum6Rym4O7G/OgUxXYBLzMJbeu0ysmlCSsn/17gbaATgHP0UVCPLOAAl280vMMVq5gpOne3E6izBTXjTQfUQFeMMGAVx4mxEIQqxQ40BaPqnVNjjg6DGwafBtu14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714741471; c=relaxed/simple; bh=fOlo+GMuztfiqTj7P5x+iF4RQcbKQS7tGnnk8lGMy1w=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YNj8cE70Ve1iAvshZzZGHvGT5C+RcK7hj8A9JiF9u7GbEXT5YKi4h390G7O8GnVSvN7hd3jnTmCDk2ufHqQIHa7oUMh59EhqbLeMSyMlyNudW8ZRYo7z/rO2UsMW1YC7qbp4BNQyo+ycM12kLURBc0e1KXpM4ciU9ExAciv9r8Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SU68yLv6; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a599af16934so91253366b.1; Fri, 03 May 2024 06:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714741468; x=1715346268; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=rfzmlT4PMypwMBle7ZsZNzT+S9kweSo9iiTEGtqzGjk=; b=SU68yLv6uFL9bW3BPLNolvcy6eT/6hb4dvkJ6J0lZx+TfQUc+erd5jWCnMquLT0VCm hHsHNy7a8i+gGbNa7inyj1opmiHTDIsO6+fdrCgp3FsSGWJg8KtmWmsSwudpNbONC4m1 OfiIdr/f4cpwHe9qb/mDjMks6EAE3GSROR7VXfONjjyvptuVjsoa0VAcRlIEYommSGXs fGsBQBRJbNWVA66r2LTnWTdQRjocil1gAZQhlSoqY78pNQY7FYU2tm9ngkVnyill/Xcl oeVbWzFS3Wfng285OOcA6OtUV5WNzQLhCUV6EMNF8H8ZfTKQbSo9M/DY+tdo/GDek9UH tKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714741468; x=1715346268; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rfzmlT4PMypwMBle7ZsZNzT+S9kweSo9iiTEGtqzGjk=; b=GaW+MWUd/N8ZOrs3GxRNCMOLq040R9Rr8Xqh0Guevwa76M2EY4BrZp3NKYzI48FRVI Fh4KrTfy6JcE7mmZ/SPTZZOVRw0BGpGs2ngpEoN/zwJJQkX+PVlCCiDffNRpCJyzIc8I wyQWCkt0AxUivh8gvi193Rp5eaqLmt6Pvu8qDxnXxMYCtRWqzRNTFzWHTPLgsRaHOOkw YQXMElh7Toax3wIEEt65ffjUXMTRKEstAPDPg7jft2f22AnjwVKDw00t2qlKW/U4ukKO P0+w6KCx9SMNAp27kgERVKTh4kSXyZHFQLdPZzQMamNFynXI/UXkG4WgRTd2vHixJw7U /BVw== X-Forwarded-Encrypted: i=1; AJvYcCU7/lpiAI54od51pq+ScTr4lDhblR5SVppCBd7KLKybnbGjYKO1CZaBgkzrgKGYg/R8HQfw2jk1Bm2+T4p4vynXKQAB0MLARRxTqb3UJe0s0/EJix/Cgp5w/Yn86RQFeJ+/jJecZv4DRtl95iu/GBo+0dlJsQxoKZ5UOmpvmx8mK7Pv2pyKteP3Qv4TUDL7ZBYXcNeKaIrn5yZCjsA36ZuMU6hYK8VaYJFBziqRFdOoBjQVAqe39YOQsfka X-Gm-Message-State: AOJu0YxlJBj1qME9ZHPAUxhKkYS64zXtz2Dxv5o8OcPr+VMDvTTVWcPC itMUvXUIt4ps+Lff8JwlPxLy+rOb88fexF7BiXnJLuBN89zWUWDqOj4ymTMz X-Received: by 2002:a17:906:2ac7:b0:a52:19ea:8df0 with SMTP id m7-20020a1709062ac700b00a5219ea8df0mr1601884eje.66.1714741467755; Fri, 03 May 2024 06:04:27 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id kk1-20020a170907766100b00a599c00442fsm234634ejc.150.2024.05.03.06.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 06:04:27 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Fri, 3 May 2024 15:04:25 +0200 To: Peter Zijlstra Cc: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Thomas Gleixner , "Borislav Petkov (AMD)" , Ingo Molnar , Andy Lutomirski , rick.p.edgecombe@intel.com Subject: Re: [PATCHv4 bpf-next 2/7] uprobe: Add uretprobe syscall to speed up return probe Message-ID: References: <20240502122313.1579719-1-jolsa@kernel.org> <20240502122313.1579719-3-jolsa@kernel.org> <20240503113453.GK40213@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240503113453.GK40213@noisy.programming.kicks-ass.net> On Fri, May 03, 2024 at 01:34:53PM +0200, Peter Zijlstra wrote: > On Thu, May 02, 2024 at 02:23:08PM +0200, Jiri Olsa wrote: > > Adding uretprobe syscall instead of trap to speed up return probe. > > > > At the moment the uretprobe setup/path is: > > > > - install entry uprobe > > > > - when the uprobe is hit, it overwrites probed function's return address > > on stack with address of the trampoline that contains breakpoint > > instruction > > > > - the breakpoint trap code handles the uretprobe consumers execution and > > jumps back to original return address > > > > This patch replaces the above trampoline's breakpoint instruction with new > > ureprobe syscall call. This syscall does exactly the same job as the trap > > with some more extra work: > > > > - syscall trampoline must save original value for rax/r11/rcx registers > > on stack - rax is set to syscall number and r11/rcx are changed and > > used by syscall instruction > > > > - the syscall code reads the original values of those registers and > > restore those values in task's pt_regs area > > > > - only caller from trampoline exposed in '[uprobes]' is allowed, > > the process will receive SIGILL signal otherwise > > > > Did you consider shadow stacks? IIRC we currently have userspace shadow > stack support available, and that will utterly break all of this. nope.. I guess it's the extra ret instruction in the trampoline that would make it crash? > > It would be really nice if the new scheme would consider shadow stacks. I seem to have the hw with support for user_shstk, let me test that thanks, jirka