lkml.org 
[lkml]   [2022]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4] bpf/scripts: Generate GCC compatible helper defs header
On Fri, Aug 5, 2022 at 1:18 AM James Hilliard <james.hilliard1@gmail.com> wrote:
>
> The current bpf_helper_defs.h helpers are llvm specific and don't work
> correctly with gcc.
>
> GCC requires kernel helper funcs to have the following attribute set:
> __attribute__((kernel_helper(NUM)))
>
> Generate gcc compatible headers based on the format in bpf-helpers.h.
>
> This leaves the bpf_helper_defs.h entirely unchanged and generates a
> fully separate GCC compatible bpf_helper_defs_attr.h header file
> which is conditionally included if the GCC kernel_helper attribute
> is supported.
>
> This adds GCC attribute style kernel helpers in bpf_helper_defs_attr.h:
> void *bpf_map_lookup_elem(void *map, const void *key) __attribute__((kernel_helper(1)));
>
> long bpf_map_update_elem(void *map, const void *key, const void *value, __u64 flags) __attribute__((kernel_helper(2)));
>
> See:
> https://github.com/gcc-mirror/gcc/blob/releases/gcc-12.1.0/gcc/config/bpf/bpf-helpers.h#L24-L27
>
> This fixes the following build error:
> error: indirect call in function, which are not supported by eBPF
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> Changes v3 -> v4:
> - don't modify bpf_helper_defs.h
> - generate bpf_helper_defs_attr.h for GCC
> - check __has_attribute(kernel_helper) for selecting GCC defs

Great job ignoring the feedback.
Applied.
Just kidding.

\
 
 \ /
  Last update: 2022-08-05 17:28    [W:0.049 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site