From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 18E888287E for ; Sun, 7 Dec 2025 22:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765146226; cv=none; b=CPKExVtceavG34nTeIqFpfQ0qC+MgcTiVCYZGpijoLhRu5F8LOiDo7DowKGJ/biJi13Qq6PK8OhNB99p0cu02JKoB61bR8zWUxRQAAr4etpd3oTkX4V02l34uBmq5kNzGI9bdFM7nSfFfZGrGXMgXw189q1ZxHEJjHlUUmigSgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765146226; c=relaxed/simple; bh=o/UYKSK/gkbLh8FWxRxvVU3OkU/Q+/03bFyedFJp1NA=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K5J+bO5qUYKVioUg+QRovPWjakO2j1aPTHZM9PT123es2zTfp2EZAANeAfbC7PrnoobrdljlV8vWCBFN5rHP+nHiQJQ05f5VNBFMwarxo4LsfRTmMJ5RndCk9hwvPdbagvoyvWachxx6PZZwvdD5ZULKWw7VslrBY59p5ay4+VA= 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=XCE66x0+; arc=none smtp.client-ip=209.85.128.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XCE66x0+" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4779a637712so28627905e9.1 for ; Sun, 07 Dec 2025 14:23:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765146222; x=1765751022; 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=+w862P9gwDeWHrowG1HizWcJbg4rpsvYLnk23PcrduI=; b=XCE66x0+QMeUsDpmtND2oSsLY+7Y6KU0mm++Nk+/hSjhd6bho1cLaHQULBnsNpx2kQ cU+Rd4nt5NavdpcTs7k2G5ihzk45DzkGFChYuPPTywwFrFWHdHWdINI+4fqM6Nac/5BV NOx3wVKqPdnTPrYFGGuwtRCSD4FvG9kpt/C4o9vyW2m+zfxvl1PSSfZC/xa/8o/sl+MJ zCPI4gl6PCJ2E0XV2ScZ+uFccl0+rn0aCfca976+4Upw0zSF0BZ2+c1UjJlF3VCLFJVA wDIIf+eCKD2HxW7jAQ5idegVJLB+6et1wIURJo552U0JMzX0LJn0frkHaxLRsw4JXZqN 3BQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765146222; x=1765751022; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+w862P9gwDeWHrowG1HizWcJbg4rpsvYLnk23PcrduI=; b=ftgjzj71ljei7ayvqcH3biBqxcfCTkjR2KnXio//q4V3CAlKyU5AetrVovasijd8MT T17JDYhz6Mo5NX/GXr2bw6aHFI7y4GpAj/tT8Esu63juDOFvYLSjfwfP3cUOpwBwbmH7 Ty7lHdldtNgpy8f2x0O9Ni6+6l5HIZlPv/htaAG2KEBfJLxj9qu17L/yM78+bQgWJ+04 r3DX4NR3OsThbm5s4c0WyPnXryxalg31369F6LFgVRkb3Ir85b3syhUITQuIAsRvMgqy Oz94DnZpCvQQti19ETObyTQwRYwsDU4+LQTB5AgmyVs3xG7qW5wWQsV1tJLHicC5y32Q qEBA== X-Forwarded-Encrypted: i=1; AJvYcCVOtWJzwnbJC74YNSylu3ROZOWeswgxnIjofUJ8E0+fGPwnPlNeiXPukTE8UlCsaKNZQALdUPWFlIz0vHU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3SKV4wmal3ALkvdHMuyfckBidGCrDVbapTyPr0TY8G7TeoxoN 9ljc+o0L5p0PG6krmCr5GgJXpA9llxhwjcYPYAtNY4+yvuecopFuAxyi X-Gm-Gg: ASbGncuzB3dUOLcEaPU5fKiffV6pCcuX3U7hJqdhjF8/gh+ata4r8PW0+BrJ7fYTXSa 403tn4sHcIQe5sYuXs6LIvYbNgiFZPiciBxotSpXO/0iDOJQlFMGWPY+diCGXu3bGgFi1uw4t3j /RxytLMFTJYQjHvAUyVpjZeKV9DMZ1n9D7tEPNJ4EHX2zHn2d7pm8JDesOidusxYNIUWLshiQB1 ONuuC1Y2uvnVdQplNwwVf3QHM9REvbLw46pNxLx9Rg8W2bPli+wt5f2xAsU/lokH/bScLAvA6dd ftjwUiHot9P5H+FdcWB9+vFXalufLPLcMQe6ByjeFqqil/TQWYO5bj9sJQzB0VCD7fBu2IsLnot uPxkGwl5K1u4fCdpf1RzUU2kqD8uZgSdspz0K/vQKtUMptKs3o2jGeXS5MR9ra3Enwtt37m5Vd+ U= X-Google-Smtp-Source: AGHT+IEm2HK0eaJoyNa2SSzEora5+85e9+DGsx6tJi0vt33FJbGSHrWsG8eiRmYxrXpGu63DFLG+Fw== X-Received: by 2002:a05:600c:820b:b0:475:da1a:53f9 with SMTP id 5b1f17b1804b1-47939e043d3mr66573745e9.14.1765146222181; Sun, 07 Dec 2025 14:23:42 -0800 (PST) Received: from krava ([176.74.159.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7d2226e7sm22659293f8f.27.2025.12.07.14.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Dec 2025 14:23:41 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Sun, 7 Dec 2025 23:23:40 +0100 To: Oleg Nesterov , Masami Hiramatsu , Peter Zijlstra , Andrii Nakryiko , David Laight Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , John Fastabend , Steven Rostedt , Ingo Molnar Subject: Re: [RFC PATCH 0/8] uprobe/x86: Add support to optimize prologue Message-ID: References: <20251117124057.687384-1-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: <20251117124057.687384-1-jolsa@kernel.org> On Mon, Nov 17, 2025 at 01:40:49PM +0100, Jiri Olsa wrote: > hi, > the subject is bit too optimistic, in nutshell the idea is to allow > optimization on top of emulated instructions and then add support to > emulate more instructions with high presence in function prologues. > > This patchset adds support to optimize uprobe on top of instruction > that could be emulated and also adds support to emulate particular > versions of mov and sub instructions to cover some of the user space > functions prologues, like: > > pushq %rbp > movq %rsp,%rbp > subq $0xb0,%rsp > > The idea is to store instructions on underlying 5 bytes and emulate > them during the int3 and uprobe syscall execution: > > - install 'call trampoline' through standard int3 update > - if int3 is hit before we finish optimizing we emulate > all underlying instructions > - when call is installed the uprobe syscall will emulate > all underlying instructions David, sorry I used wrong email.. I think the update here might be a problem, any chance you could check? thanks, jirka > > There's an additional issue that single instruction replacement does > not have and it's the possibility of the user space code to jump in the > middle of those 5 bytes. I think it's unlikely to happen at the function > prologue, but uprobe could be placed anywhere. I'm not sure how to > mitigate this other than having some enable/disable switch or config > option, which is unfortunate. > > The patchset is based on bpf-next/master with [1] changes merged in. > > thanks, > jirka > > > [1] https://lore.kernel.org/lkml/20251117093137.572132-1-jolsa@kernel.org/T/#m95a3208943ec24c5eee17ad6113002fdc6776cf8 > --- > Jiri Olsa (8): > uprobe/x86: Introduce struct arch_uprobe_xol object > uprobe/x86: Use struct arch_uprobe_xol in emulate callback > uprobe/x86: Add support to emulate mov reg,reg instructions > uprobe/x86: Add support to emulate sub imm,reg instructions > uprobe/x86: Add support to optimize on top of emulated instructions > selftests/bpf: Add test for mov and sub emulation > selftests/bpf: Add test for uprobe prologue optimization > selftests/bpf: Add race test for uprobe proglog optimization > > arch/x86/include/asm/uprobes.h | 35 +++++++--- > arch/x86/kernel/uprobes.c | 336 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- > include/linux/uprobes.h | 1 + > kernel/events/uprobes.c | 6 ++ > tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c | 129 ++++++++++++++++++++++++++++++++----- > 5 files changed, 434 insertions(+), 73 deletions(-)