Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1287281lqp; Mon, 15 Apr 2024 01:25:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlBCUIxEMwWST2nLze4NeOkcrei9RtU5efApbSaCZ7ygvvRMuo+EXu6JwLjrMv6NF3EXOUEgP6ImjQRuAlmTyvnX/PHrHXU7I0S4eMvw== X-Google-Smtp-Source: AGHT+IFetvY7J+015DXI811D87CRhOa8eG5Rr+HPrn8ICT75V8+eIQoi42arfp2GdIlcOkHqGlsv X-Received: by 2002:a05:6122:9a1:b0:4cb:56c5:580e with SMTP id g33-20020a05612209a100b004cb56c5580emr6768437vkd.11.1713169530349; Mon, 15 Apr 2024 01:25:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713169530; cv=pass; d=google.com; s=arc-20160816; b=AVVQUDL7iExdFKGsDbIsVnMyANfIhjokmLlFjaRczq8VtHBdRuWUIgNZQSJu3LzZ70 yfuWFDH+mG6tL4AhxN9nAm64GwpanBvq79s61ojTQsK/x5EniuYEMlpUgfJb7vbrL8Mc QaDy4YVSkMS1gWaTzmvlIPU1Paj+Cx/Db3n+gG3MMDJM9CW8ySCI43fNrorwseFkq5J0 5woYE2nroQVVSYGiz3PXouKuT4Hm9AVzYal4ECll1B+mjovclVIjxa3BnAWyKYF37far vjqe4YzSSi+TuTInAmLna0UTzpCQSa5dJw2YcwCd7ov0seEBpzgw7nSKYJR+sskVDzny 5lqA== 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=svrY0WgOVENQcdqQ696Y1VOfpDVgzQN8fSQil0UQPzM=; fh=Lwfi3hzQXXwnAsM2zB/Bqf/Q5t6DYFb0qo7Jw4lVxNU=; b=gN8jhFOcsWUH5JPK3cMCWdHhqxGlSs5TsrWfhoXOpsxcXHjce7zoXjXhnmYUjb5GiY r2NwqtWt/3lScuezZJ0U3ZLCR4BQA4FnTPSfHYI9xOs3UcKii05i9WUnF1v+XZEwRsOP UDJTELXTy7LTwe6Pzx5bCa+Xp9DZdY7BF6kqYxb4YGKKgGMFPOWrpudUPgHYrH0nNRux iXqILJvJwLmzn5pAEmBz0y6GS6aXmC8E18XQ6/bDWR0Bslvqj4X2i8awjZrlMx69C4tR TDkIjcdkNgpItCWJDZSnmdsoHtoahdmZNdFI4AOUUk14q/9gCectqlWMmpY/5tM7hgAV cRDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c5Kx8e0e; 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-144755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144755-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k20-20020a05622a03d400b004347394f924si9088730qtx.304.2024.04.15.01.25.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 01:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c5Kx8e0e; 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-144755-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144755-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 09C4C1C21770 for ; Mon, 15 Apr 2024 08:25:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55665376E5; Mon, 15 Apr 2024 08:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c5Kx8e0e" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 0170B364CD; Mon, 15 Apr 2024 08:25:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713169521; cv=none; b=DgrKZMK1hzoQ4r7kyAjsDIa9T6pTUyYjf87l72PFU1ejZFAMI7aUj9cNr0L38OiSWTlFBES/DBh6/foA/Kxa0vidtHF87DgHmlPa0HDe2yzFUXAbtSmNQ71drled0UJJ88JPJuCzKjLifAYw4haAPJRlb4/3f+1AWBFM4R61icw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713169521; c=relaxed/simple; bh=1HzYf5lOHsdfN5KdFicmh6QcGO5toCRG2rpD8PAzJyE=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iWFRZ3WFUNQzZp0nfYpTof+eFyNBRMk6keXPwdxzfKnprdHYdd/sr2hIDtAWhxuQktC0aDpc+TQFnS2gLjd+/yot5ELtlIPG6GH+ex2kr8P3u3EtRLUZY9w+jC3nSzkbdvnCct0qvKqEzDq3YgBhcQLJMndT6fysWf707XuDdAc= 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=c5Kx8e0e; arc=none smtp.client-ip=209.85.218.45 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-f45.google.com with SMTP id a640c23a62f3a-a523dad53e0so336818166b.1; Mon, 15 Apr 2024 01:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713169518; x=1713774318; 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=svrY0WgOVENQcdqQ696Y1VOfpDVgzQN8fSQil0UQPzM=; b=c5Kx8e0eS7U6QJDT/PMj3Tk3VDlZlUhW29sS845m5voogmdOHbWRFnRzRwFU9eYsW8 sCe1J0aDa15gB4L2XtZ2Jtw7gEwcDc5wND4TCk+KftDvaOxQKMSIzYPYxT6UMmwq1lA+ +BQev3u99zBUNv+L5KGr91rV91u826kre3JMJoA4ddWHG58+B1yQjOPEA4WFDvx0TuaI r9Eq+Gg90BvUxQf1Iy7TfoddjiATAYsE/ldE7KBamva5AEKaBIy8Mry8KR2KFpis9Fnj lDkmqEY5eP/Ez0VosJN4zodHxhLbkfvEKFLn2uVWTcLwZsalRrjkQMj/qjMCpqCjORk0 d+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713169518; x=1713774318; 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=svrY0WgOVENQcdqQ696Y1VOfpDVgzQN8fSQil0UQPzM=; b=Mncq71nnoUYOTIQQDSlSQXh3OPSOkluTBfB+P/bd0iO9UHXAHl2FHkbdhjwu8neHWg lagQpBwxzVPJ8lRMLRAVMzKhwVK8M1SLexHXjSwmdU+hcGUJTjJFC/XRsh0g6z5qkvd4 9bgeSQfnDLn9V6BTi+2KxtsoFxTwRVOKG1RcnuBq/6cXoIlI0H5hrTlbZml5DwKFU6qu oDv7arje9o0MBjWSckJD10A5j8rQOXT1oiLx1SQmAiUPK9pe81aydKht70qlxtVQlPBD ohEbWgcnniuLRhAXPjcnSIqKQI+cQGtyKtGMnq6Yarx+cFCPmkvTKP8kSHZ0Cd3joGV8 LgWA== X-Forwarded-Encrypted: i=1; AJvYcCVGkbzVqkYic/JPbUfvHTq9tIpiFj9SsXU9bLvK3mlUqYPxb9fwCnAZrPwiOiQPk0Jvny+C3R0czhs9mv0vQtvgkooowpyUvyotQe/94s+ouAUzgCuw4YiVE9CxXoen/6vDdwGGAag6 X-Gm-Message-State: AOJu0YxMip6iwzLL2+xyKiHwJ04jErhvCFScwj0Po9yxq1JpWNPNGn2i s5yPjGjRe66jmZgpFFTRlvBKQNBCFQqWjGbOF7PhSwxN64FE/6NY X-Received: by 2002:a17:906:510:b0:a52:71d6:d605 with SMTP id j16-20020a170906051000b00a5271d6d605mr859683eja.23.1713169518061; Mon, 15 Apr 2024 01:25:18 -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 i19-20020a170906115300b00a526a992d82sm1045266eja.4.2024.04.15.01.25.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 01:25:17 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Mon, 15 Apr 2024 10:25:16 +0200 To: Steven Rostedt , Masami Hiramatsu , Oleg Nesterov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Song Liu , Yonghong Song , John Fastabend , Peter Zijlstra , Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org Subject: Re: [PATCHv2 1/3] uprobe: Add uretprobe syscall to speed up return probe Message-ID: References: <20240402093302.2416467-1-jolsa@kernel.org> <20240402093302.2416467-2-jolsa@kernel.org> 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: <20240402093302.2416467-2-jolsa@kernel.org> On Tue, Apr 02, 2024 at 11:33:00AM +0200, Jiri Olsa wrote: SNIP > #include > #include > @@ -308,6 +309,88 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool > } > > #ifdef CONFIG_X86_64 > + > +asm ( > + ".pushsection .rodata\n" > + ".global uretprobe_syscall_entry\n" > + "uretprobe_syscall_entry:\n" > + "pushq %rax\n" > + "pushq %rcx\n" > + "pushq %r11\n" > + "movq $" __stringify(__NR_uretprobe) ", %rax\n" > + "syscall\n" > + "popq %r11\n" > + "popq %rcx\n" > + > + /* The uretprobe syscall replaces stored %rax value with final > + * return address, so we don't restore %rax in here and just > + * call ret. > + */ > + "retq\n" > + ".global uretprobe_syscall_end\n" > + "uretprobe_syscall_end:\n" > + ".popsection\n" > +); > + > +extern u8 uretprobe_syscall_entry[]; > +extern u8 uretprobe_syscall_end[]; > + > +void *arch_uprobe_trampoline(unsigned long *psize) > +{ > + *psize = uretprobe_syscall_end - uretprobe_syscall_entry; > + return uretprobe_syscall_entry; fyi I realized this screws 32-bit programs, we either need to add compat trampoline, or keep the standard breakpoint for them: + struct pt_regs *regs = task_pt_regs(current); + static uprobe_opcode_t insn = UPROBE_SWBP_INSN; + + if (user_64bit_mode(regs)) { + *psize = uretprobe_syscall_end - uretprobe_syscall_entry; + return uretprobe_syscall_entry; + } + + *psize = UPROBE_SWBP_INSN_SIZE; + return &insn; not sure it's worth the effort to add the trampoline, I'll check jirka