* [PATCHv2 bpf-next] selftests/bpf: Mark uprobe trigger functions with nocf_check attribute
@ 2024-03-22 13:49 Jiri Olsa
2024-03-22 17:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Olsa @ 2024-03-22 13:49 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
Cc: bpf, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Stanislav Fomichev, Hao Luo
Some distros seem to enable the -fcf-protection=branch by default,
which breaks our setup on first instruction of uprobe trigger
functions and place there endbr64 instruction.
Marking them with nocf_check attribute to skip that.
Ignoring unknown attribute warning in gcc for bench objects, because
nocf_check can be used only when -fcf-protection=branch is enabled,
otherwise we get a warning and break compilation.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
v2 changes:
- posting separately from uretprobe syscall patchset
- keep the attribute name __nocf_check [Andrii]
tools/include/linux/compiler.h | 4 ++++
tools/testing/selftests/bpf/benchs/bench_trigger.c | 8 +++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 7b65566f3e42..8a63a9913495 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -58,6 +58,10 @@
#define noinline
#endif
+#ifndef __nocf_check
+#define __nocf_check __attribute__((nocf_check))
+#endif
+
/* Are two types/vars the same type (ignoring qualifiers)? */
#ifndef __same_type
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
diff --git a/tools/testing/selftests/bpf/benchs/bench_trigger.c b/tools/testing/selftests/bpf/benchs/bench_trigger.c
index b7aea79495ba..c1f8fb8d2dca 100644
--- a/tools/testing/selftests/bpf/benchs/bench_trigger.c
+++ b/tools/testing/selftests/bpf/benchs/bench_trigger.c
@@ -9,6 +9,8 @@
/* adjust slot shift in inc_hits() if changing */
#define MAX_BUCKETS 256
+#pragma GCC diagnostic ignored "-Wattributes"
+
/* BPF triggering benchmarks */
static struct trigger_ctx {
struct trigger_bench *skel;
@@ -167,7 +169,7 @@ static void trigger_fmodret_setup(void)
* GCC doesn't generate stack setup preample for these functions due to them
* having no input arguments and doing nothing in the body.
*/
-__weak void uprobe_target_nop(void)
+__nocf_check __weak void uprobe_target_nop(void)
{
asm volatile ("nop");
}
@@ -176,7 +178,7 @@ __weak void opaque_noop_func(void)
{
}
-__weak int uprobe_target_push(void)
+__nocf_check __weak int uprobe_target_push(void)
{
/* overhead of function call is negligible compared to uprobe
* triggering, so this shouldn't affect benchmark results much
@@ -185,7 +187,7 @@ __weak int uprobe_target_push(void)
return 1;
}
-__weak void uprobe_target_ret(void)
+__nocf_check __weak void uprobe_target_ret(void)
{
asm volatile ("");
}
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2 bpf-next] selftests/bpf: Mark uprobe trigger functions with nocf_check attribute
2024-03-22 13:49 [PATCHv2 bpf-next] selftests/bpf: Mark uprobe trigger functions with nocf_check attribute Jiri Olsa
@ 2024-03-22 17:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-22 17:10 UTC (permalink / raw)
To: Jiri Olsa
Cc: ast, daniel, andrii, bpf, kafai, songliubraving, yhs,
john.fastabend, kpsingh, sdf, haoluo
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Fri, 22 Mar 2024 14:49:36 +0100 you wrote:
> Some distros seem to enable the -fcf-protection=branch by default,
> which breaks our setup on first instruction of uprobe trigger
> functions and place there endbr64 instruction.
>
> Marking them with nocf_check attribute to skip that.
>
> Ignoring unknown attribute warning in gcc for bench objects, because
> nocf_check can be used only when -fcf-protection=branch is enabled,
> otherwise we get a warning and break compilation.
>
> [...]
Here is the summary with links:
- [PATCHv2,bpf-next] selftests/bpf: Mark uprobe trigger functions with nocf_check attribute
https://git.kernel.org/bpf/bpf-next/c/af8d27bf15c8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-22 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22 13:49 [PATCHv2 bpf-next] selftests/bpf: Mark uprobe trigger functions with nocf_check attribute Jiri Olsa
2024-03-22 17:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox