Commit af8d27bf authored by Jiri Olsa's avatar Jiri Olsa Committed by Andrii Nakryiko

selftests/bpf: Mark uprobe trigger functions with nocf_check attribute

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: default avatarJiri Olsa <jolsa@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240322134936.1075395-1-jolsa@kernel.org
parent 1684d6eb
...@@ -58,6 +58,10 @@ ...@@ -58,6 +58,10 @@
#define noinline #define noinline
#endif #endif
#ifndef __nocf_check
#define __nocf_check __attribute__((nocf_check))
#endif
/* Are two types/vars the same type (ignoring qualifiers)? */ /* Are two types/vars the same type (ignoring qualifiers)? */
#ifndef __same_type #ifndef __same_type
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
/* adjust slot shift in inc_hits() if changing */ /* adjust slot shift in inc_hits() if changing */
#define MAX_BUCKETS 256 #define MAX_BUCKETS 256
#pragma GCC diagnostic ignored "-Wattributes"
/* BPF triggering benchmarks */ /* BPF triggering benchmarks */
static struct trigger_ctx { static struct trigger_ctx {
struct trigger_bench *skel; struct trigger_bench *skel;
...@@ -167,7 +169,7 @@ static void trigger_fmodret_setup(void) ...@@ -167,7 +169,7 @@ static void trigger_fmodret_setup(void)
* GCC doesn't generate stack setup preample for these functions due to them * GCC doesn't generate stack setup preample for these functions due to them
* having no input arguments and doing nothing in the body. * 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"); asm volatile ("nop");
} }
...@@ -176,7 +178,7 @@ __weak void opaque_noop_func(void) ...@@ -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 /* overhead of function call is negligible compared to uprobe
* triggering, so this shouldn't affect benchmark results much * triggering, so this shouldn't affect benchmark results much
...@@ -185,7 +187,7 @@ __weak int uprobe_target_push(void) ...@@ -185,7 +187,7 @@ __weak int uprobe_target_push(void)
return 1; return 1;
} }
__weak void uprobe_target_ret(void) __nocf_check __weak void uprobe_target_ret(void)
{ {
asm volatile (""); asm volatile ("");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment