Re: [PATCH RFC bpf-next 3/3] selftests/bpf: Mark uprobe trigger functions with nocf_check attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 18, 2024 at 2:32 AM Jiri Olsa <jolsa@xxxxxxxxxx> 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.
>
> Adding -Wno-attributes for bench objects, becase 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@xxxxxxxxxx>
> ---
>  tools/include/linux/compiler.h                     | 4 ++++
>  tools/testing/selftests/bpf/Makefile               | 2 +-
>  tools/testing/selftests/bpf/benchs/bench_trigger.c | 6 +++---
>  3 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
> index 7b65566f3e42..14038ce04ca4 100644
> --- a/tools/include/linux/compiler.h
> +++ b/tools/include/linux/compiler.h
> @@ -58,6 +58,10 @@
>  #define noinline
>  #endif
>
> +#ifndef __nocfcheck
> +#define __nocfcheck __attribute__((nocf_check))
> +#endif

Let's preserve spelling of the attribut, __nocf_check ?

BTW, just FYI, seems like kernel is defining it as:

#define __noendbr    __attribute__((nocf_check))

Thought somewhere deep in x86-specific code, so probably not a good
idea to use it here?

> +
>  /* 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/Makefile b/tools/testing/selftests/bpf/Makefile
> index e425a946276b..506d3d592093 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -726,7 +726,7 @@ $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
>  # Benchmark runner
>  $(OUTPUT)/bench_%.o: benchs/bench_%.c bench.h $(BPFOBJ)
>         $(call msg,CC,,$@)
> -       $(Q)$(CC) $(CFLAGS) -O2 -c $(filter %.c,$^) $(LDLIBS) -o $@
> +       $(Q)$(CC) $(CFLAGS) -O2 -Wno-attributes -c $(filter %.c,$^) $(LDLIBS) -o $@

let's better use `#pragma warning disable` in relevant .c files,
instead of this global flag?

>  $(OUTPUT)/bench_rename.o: $(OUTPUT)/test_overhead.skel.h
>  $(OUTPUT)/bench_trigger.o: $(OUTPUT)/trigger_bench.skel.h
>  $(OUTPUT)/bench_ringbufs.o: $(OUTPUT)/ringbuf_bench.skel.h \

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux