From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214829; b=XwaozJ7Q83JxtnAp0y4Xt3K/uaq3atwNrvCeVcvFLouCrkU7fE1BWwfYkq3+vVAj0hAU Y40r8/dlpt8gPnbi/uG7NOZMMRwHjUNu08JIf5fmLG2hLpEgcR+1z49VbZxCybX6QnBPQ /Ku5wVTdqgyqh34UiX3RSvReTr2funrfiBgkfUryUHkPJHGbqb+3RVBWezwg6LFnqM3XL IY4RjtU5Lo+DVestwgF7AgNdTUPpbLe/JgY9ulLtSS4tlbt+rj252PLLIOQw+Ps4X5kDS CzMDM+N1OQciL2wpVjdXUxeUM9pYuJvo2DBGGHZoc8epNAoYiC24QJcykiziQTeX7sQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796214829; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=YlB6KTdJhrvN/wZ40aUGcDDOLbN+R3qyjbrO/ClQdEY=; b=ImNpEEDi/2yYj8Yd7j45QviMXcNbRwcX0gx+Lw8DUKfpIoWU2HpJaKIwevy/n5XoUcj4 CcTUy5u6Hy9b5LQrQjLM9uc7yaK+Pa3S3h5tgg5pkAwcZadprwG7YFma5SegB9EngBL2b kubdFcYwpYEgVLgX059qQWpVPHgqWxGTAhwUupDOuEvLkJllVD9NLSWGB9VGN0/zAd03X 8cfEpwN9zMg+wMozDNmEk7gbTjItmeC91YJIrLekjxvfHIIZhDfH05VMnmAQ+vVZz04vg Rl7ETcGTxNyc0MyCc9CTSjF8TDgIedhfZg/5y3kQR1mVPjmhTxUeDS+t+Hm+Zord2Hg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZECOBvrd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01063606A325; Wed, 2 Dec 2026 12:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZECOBvrd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46F861F000C1; Wed, 2 Dec 2026 12:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796214828; bh=YlB6KTdJhrvN/wZ40aUGcDDOLbN+R3qyjbrO/ClQdEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZECOBvrdF0TIE835cUT4NKbSuYUWSr3BN06dYnQUcxLzAdB4SfjUHERpTyhax7kBW FGL+jRXN/btAoP4Rpwt8Wj7gPSiyf4b6UqAXbAJ1vBlhpcRvZDHH6ps+fMFRvC+DoG uYcWhyUf4vVp1JVL4Rtt3PLyMp93AXOnNCtfIXZj54fsR8dq9sDsGp6O05jmnETjPx ePkXvjo8Dr1yQihE8Ttdpcn87Fz1gaq1ypBk5rGL8XJHmVEFcJX0tYZkHzJdL/2Cms rTFZ1jsyo7P/WENfjF2ibWYmx3e11V7G8ZjL0v1wQhO2cHWDsNMW0J2EQ10MS9tunz CvjMa7irT5Kdg== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , Quentin Monnet , Alan Maguire Subject: [PATCH RFC bpf-next 18/31] bpf: Add inlined functions for kprobe multi inline tests Date: Wed, 2 Dec 2026 13:30:22 +0100 Message-ID: <20261202123035.10335-19-jolsa@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202123035.10335-1-jolsa@kernel.org> References: <20261202123035.10335-1-jolsa@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add always inlined functions and their callers for kprobe multi inline tests, the callers are triggered through the tracing test_run. The bpf_kprobe_multi_inline_test4 caller is marked with NOKPROBE_SYMBOL, so inlined instances in it can't be attached. Signed-off-by: Jiri Olsa --- net/bpf/test_run.c | 83 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index cc3236e3c0c4..4a5077590412 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -558,6 +559,81 @@ noinline int bpf_fentry_test10(const void *a) return (long)a; } +/* + * Inlined functions for kprobe multi inline tests, the outer function + * starts with the inner one, so their inlined instances in + * bpf_kprobe_multi_inline_test1 share the address. + */ +static __always_inline int bpf_kprobe_multi_inline_inner(int a) +{ + /* + * Keep an instruction in the inline site, there's no argument + * setup, so it's the first instruction of the outer function + * inline site as well. + */ + asm volatile("nop"); + return a + 1; +} + +static __always_inline int bpf_kprobe_multi_inline_outer(int a) +{ + return bpf_kprobe_multi_inline_inner(a) + 1; +} + +noinline int bpf_kprobe_multi_inline_test1(int a) +{ + return bpf_kprobe_multi_inline_outer(a); +} + +noinline int bpf_kprobe_multi_inline_test2(int a) +{ + return bpf_kprobe_multi_inline_inner(a); +} + +/* + * Inlined functions with instances that can't be attached, because + * kprobes are not allowed in bpf_kprobe_multi_inline_test4: + * + * bpf_kprobe_multi_inline_partial - one instance can be attached + * (test3) and one can't (test4) + * bpf_kprobe_multi_inline_nokprobe - no instance can be attached + */ +static __always_inline int bpf_kprobe_multi_inline_partial(int a) +{ + asm volatile("nop"); + return a + 1; +} + +static __always_inline int bpf_kprobe_multi_inline_nokprobe(int a) +{ + asm volatile("nop"); + return a + 2; +} + +noinline int bpf_kprobe_multi_inline_test3(int a) +{ + return bpf_kprobe_multi_inline_partial(a); +} + +noinline int bpf_kprobe_multi_inline_test4(int a) +{ + return bpf_kprobe_multi_inline_partial(a) + + bpf_kprobe_multi_inline_nokprobe(a); +} +NOKPROBE_SYMBOL(bpf_kprobe_multi_inline_test4); + +/* Inlined function with arguments for kprobe multi inline args test. */ +static __always_inline long bpf_kprobe_multi_inline_args(int a, long b, void *c) +{ + asm volatile("nop"); + return a + b + (long)c; +} + +noinline long bpf_kprobe_multi_inline_test5(int a, long b, void *c) +{ + return bpf_kprobe_multi_inline_args(a, b, c); +} + noinline void bpf_fentry_test_sinfo(struct skb_shared_info *sinfo) { } @@ -710,7 +786,12 @@ int bpf_prog_test_run_tracing(struct bpf_prog *prog, bpf_fentry_test7((struct bpf_fentry_test_t *)0) != 0 || bpf_fentry_test8(&arg) != 0 || bpf_fentry_test9(&retval) != 0 || - bpf_fentry_test10((void *)0) != 0) + bpf_fentry_test10((void *)0) != 0 || + bpf_kprobe_multi_inline_test1(1) != 3 || + bpf_kprobe_multi_inline_test2(1) != 2 || + bpf_kprobe_multi_inline_test3(1) != 2 || + bpf_kprobe_multi_inline_test4(1) != 5 || + bpf_kprobe_multi_inline_test5(1, 2, (void *)3) != 6) goto out; break; case BPF_MODIFY_RETURN: -- 2.56.1