bpf: Reliably preserve btf_trace_xxx types
[platform/kernel/linux-starfive.git] / include / trace / bpf_probe.h
index b04c292..1ce3be6 100644 (file)
@@ -75,13 +75,17 @@ static inline void bpf_test_probe_##call(void)                              \
        check_trace_callback_type_##call(__bpf_trace_##template);       \
 }                                                                      \
 typedef void (*btf_trace_##call)(void *__data, proto);                 \
-static struct bpf_raw_event_map        __used                                  \
-       __attribute__((section("__bpf_raw_tp_map")))                    \
-__bpf_trace_tp_map_##call = {                                          \
-       .tp             = &__tracepoint_##call,                         \
-       .bpf_func       = (void *)(btf_trace_##call)__bpf_trace_##template,     \
-       .num_args       = COUNT_ARGS(args),                             \
-       .writable_size  = size,                                         \
+static union {                                                         \
+       struct bpf_raw_event_map event;                                 \
+       btf_trace_##call handler;                                       \
+} __bpf_trace_tp_map_##call __used                                     \
+__attribute__((section("__bpf_raw_tp_map"))) = {                       \
+       .event = {                                                      \
+               .tp             = &__tracepoint_##call,                 \
+               .bpf_func       = __bpf_trace_##template,               \
+               .num_args       = COUNT_ARGS(args),                     \
+               .writable_size  = size,                                 \
+       },                                                              \
 };
 
 #define FIRST(x, ...) x