diff options
author | Benjamin Tissoires <bentiss@kernel.org> | 2024-06-08 11:01:15 +0200 |
---|---|---|
committer | Benjamin Tissoires <bentiss@kernel.org> | 2024-06-14 11:20:16 +0200 |
commit | ebc0d8093e8c97de459615438edefad1a4ac352c (patch) | |
tree | 0777c8ebab5266327d80405b15f034ebc06d4d90 /drivers/hid/bpf/hid_bpf_jmp_table.c | |
parent | 99b40bf8053fa261d368ef78848961c04aa93c74 (diff) | |
download | linux-ebc0d8093e8c97de459615438edefad1a4ac352c.tar.gz linux-ebc0d8093e8c97de459615438edefad1a4ac352c.tar.bz2 linux-ebc0d8093e8c97de459615438edefad1a4ac352c.zip |
HID: bpf: implement HID-BPF through bpf_struct_ops
We do this implementation in several steps to not have the CI failing:
- first (this patch), we add struct_ops while keeping the existing infra
available
- then we change the selftests, the examples and the existing in-tree
HID-BPF programs
- then we remove the existing trace points making old HID-BPF obsolete
There are a few advantages of struct_ops over tracing:
- compatibility with sleepable programs (for hid_hw_raw_request() in
a later patch)
- a lot simpler in the kernel: it's a simple rcu protected list
- we can add more parameters to the function called without much trouble
- the "attach" is now generic through BPF-core: the caller just needs to
set hid_id and flags before calling __load().
- all the BPF tough part is not handled in BPF-core through generic
processing
- hid_bpf_ctx is now only writable where it needs be
Acked-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/r/20240608-hid_bpf_struct_ops-v3-3-6ac6ade58329@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Diffstat (limited to 'drivers/hid/bpf/hid_bpf_jmp_table.c')
-rw-r--r-- | drivers/hid/bpf/hid_bpf_jmp_table.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/hid/bpf/hid_bpf_jmp_table.c b/drivers/hid/bpf/hid_bpf_jmp_table.c index aa8e1c79cdf5..8a54ba447718 100644 --- a/drivers/hid/bpf/hid_bpf_jmp_table.c +++ b/drivers/hid/bpf/hid_bpf_jmp_table.c @@ -81,6 +81,9 @@ static int hid_bpf_program_count(struct hid_device *hdev, if (type >= HID_BPF_PROG_TYPE_MAX) return -EINVAL; + if (type == HID_BPF_PROG_TYPE_RDESC_FIXUP && hdev->bpf.rdesc_ops) + n += 1; + FOR_ENTRIES(i, jmp_table.tail, jmp_table.head) { struct hid_bpf_prog_entry *entry = &jmp_table.entries[i]; |