History

selftests/hid: fix kfunc inclusions with newer bpftool

bpftool now embeds the kfuncs definitions directly in the generated vmlinux.h This is great, but because the selftests dir might be compiled with HID_BPF disabled, we have no guarantees to be able to compile the sources with the generated kfuncs. If we have the kfuncs, because we have the `__not_used` hack, the newly defined kfuncs do not match the ones from vmlinux.h and things go wrong. Prevent vmlinux.h to define its kfuncs and also add the missing `__weak` symbols for our custom kfuncs definitions

Benjamin Tissoires committed 1 year ago

Commit 8d355b51 parent 0b1b0c11 file · +11 −8Browse files

Unified · Split

tools/testing/selftests/hid/progs/hid_bpf_helpers.h+11−8
@@ -22,6 +22,9 @@ · 21 unmodified lines
22#define HID_REQ_SET_IDLE HID_REQ_SET_IDLE___not_used22#define HID_REQ_SET_IDLE HID_REQ_SET_IDLE___not_used
23#define HID_REQ_SET_PROTOCOL HID_REQ_SET_PROTOCOL___not_used23#define HID_REQ_SET_PROTOCOL HID_REQ_SET_PROTOCOL___not_used
24 24
25/* do not define kfunc through vmlinux.h as this messes up our custom hack */
26#define BPF_NO_KFUNC_PROTOTYPES
27
25#include "vmlinux.h"28#include "vmlinux.h"
26 29
27#undef hid_bpf_ctx30#undef hid_bpf_ctx
@@ -91,31 +94,31 @@ struct hid_bpf_ops { · 63 unmodified lines
91/* following are kfuncs exported by HID for HID-BPF */94/* following are kfuncs exported by HID for HID-BPF */
92extern __u8 *hid_bpf_get_data(struct hid_bpf_ctx *ctx,95extern __u8 *hid_bpf_get_data(struct hid_bpf_ctx *ctx,
93 unsigned int offset,96 unsigned int offset,
94 const size_t __sz) __ksym;97 const size_t __sz) __weak __ksym;
95extern struct hid_bpf_ctx *hid_bpf_allocate_context(unsigned int hid_id) __ksym;98extern struct hid_bpf_ctx *hid_bpf_allocate_context(unsigned int hid_id) __weak __ksym;
96extern void hid_bpf_release_context(struct hid_bpf_ctx *ctx) __ksym;99extern void hid_bpf_release_context(struct hid_bpf_ctx *ctx) __weak __ksym;
97extern int hid_bpf_hw_request(struct hid_bpf_ctx *ctx,100extern int hid_bpf_hw_request(struct hid_bpf_ctx *ctx,
98 __u8 *data,101 __u8 *data,
99 size_t buf__sz,102 size_t buf__sz,
100 enum hid_report_type type,103 enum hid_report_type type,
101 enum hid_class_request reqtype) __ksym;104 enum hid_class_request reqtype) __weak __ksym;
102extern int hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx,105extern int hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx,
103 __u8 *buf, size_t buf__sz) __ksym;106 __u8 *buf, size_t buf__sz) __weak __ksym;
104extern int hid_bpf_input_report(struct hid_bpf_ctx *ctx,107extern int hid_bpf_input_report(struct hid_bpf_ctx *ctx,
105 enum hid_report_type type,108 enum hid_report_type type,
106 __u8 *data,109 __u8 *data,
107 size_t buf__sz) __ksym;110 size_t buf__sz) __weak __ksym;
108extern int hid_bpf_try_input_report(struct hid_bpf_ctx *ctx,111extern int hid_bpf_try_input_report(struct hid_bpf_ctx *ctx,
109 enum hid_report_type type,112 enum hid_report_type type,
110 __u8 *data,113 __u8 *data,
111 size_t buf__sz) __ksym;114 size_t buf__sz) __weak __ksym;
112 115
113/* bpf_wq implementation */116/* bpf_wq implementation */
114extern int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags) __weak __ksym;117extern int bpf_wq_init(struct bpf_wq *wq, void *p__map, unsigned int flags) __weak __ksym;
115extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ksym;118extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ksym;
116extern int bpf_wq_set_callback_impl(struct bpf_wq *wq,119extern int bpf_wq_set_callback_impl(struct bpf_wq *wq,
117 int (callback_fn)(void *map, int *key, void *wq),120 int (callback_fn)(void *map, int *key, void *wq),
118 unsigned int flags__k, void *aux__ign) __ksym;121 unsigned int flags__k, void *aux__ign) __weak __ksym;
119#define bpf_wq_set_callback(timer, cb, flags) \122#define bpf_wq_set_callback(timer, cb, flags) \
120 bpf_wq_set_callback_impl(timer, cb, flags, NULL)123 bpf_wq_set_callback_impl(timer, cb, flags, NULL)
121 124

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t