We use a well known VID/PID on a driver that doesn't need to talk to
the device, ensures we created the device against the target driver,
then load our program and ensure we have unbound to this driver and use
hid-generic instead.
Reviewed-by: Peter Hutterer
Signed-off-by: Benjamin Tiss
This will be useful to introduce variants in tests to test the
interactions between HID-BPF and some kernel modules.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c| 2 +-
tools/testing/selftests/hid/hid_common.h | 46
tools
Allows to have an abstract class uhid_device which handles all of the
uhid part without having to mess up with individual fds.
struct attach_prog_args is now never used in hid_bpf.c, so drop it as well
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c| 77
We use a well known VID/PID on a driver that doesn't need to talk to
the device, ensures we created the device against the target driver,
then load our program and ensure we have unbound to this driver and use
hid-generic instead.
Signed-off-by: Benjamin Tissoires
---
tools/testing/self
ply have a couple of writeable fields
in the new struct hid_bpf_driver, and then hid-core can make its educated
decision.
Signed-off-by: Benjamin Tissoires
---
Documentation/hid/hid-bpf.rst| 2 +-
drivers/hid/bpf/hid_bpf_dispatch.c | 31
drivers/hid/bpf/hid_b
Add a test for the newly enabled feature to control the connect_mask
of hid-generic.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 60 +-
tools/testing/selftests/hid/progs/hid.c| 6 ++-
.../testing/selftests/hid/progs
tps://gitlab.freedesktop.org/libinput/libinput/-/issues/1014
Signed-off-by: Benjamin Tissoires
---
Benjamin Tissoires (7):
selftests/hid: add dependency on hid_common.h
selftests/hid: cleanup C tests by adding a common struct uhid_device
selftests/hid: allow to parametrize bus/vid/pid/rdesc on the t
Allows to recompile the C tests when that file changes
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/hid/Makefile
b/tools/testing/selftests/hid/Makefile
index 72be55ac4bdf
oaded and the normal
driver takes back the control of the device.
Signed-off-by: Benjamin Tissoires
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 1 +
drivers/hid/hid-core.c | 14 --
drivers/hid/hid-generic.c| 5 +++--
3 files changed, 12 insertions(+), 8 dele
3892a629c
[4/4] selftests/hid: Add HIDIOCREVOKE tests
https://git.kernel.org/hid/hid/c/321f7798cfb8
Cheers,
--
Benjamin Tissoires
Add 4 tests for the new revoke ioctl, for read/write/ioctl and poll.
Signed-off-by: Benjamin Tissoires
Reviewed-by: Peter Hutterer
---
new in v4
Changes to v4:
- fix a few error messages
- also check for ENODEV errno when required
- use ENODEV instead of its plain value
---
tools/testing
and BPFs to revoke the hidraw node.
Signed-off-by: Benjamin Tissoires
Reviewed-by: Peter Hutterer
---
new in v4
Changes to v4:
- dropped the common code in favor of hid_common.h
---
tools/testing/selftests/hid/.gitignore | 1 +
tools/testing/selftests/hid/Makefile | 2 +-
tools/testing
When adding new tests programs, we need the same mechanics to create
new virtual devices, and read from their matching hidraw node.
Extract the common part into its own header so we can easily add new
tests C-files.
Signed-off-by: Benjamin Tissoires
---
new in v5
---
tools/testing/selftests
Add 4 tests for the new revoke ioctl, for read/write/ioctl and poll.
Signed-off-by: Benjamin Tissoires
---
new in v4
---
tools/testing/selftests/hid/hidraw.c | 143 +++
1 file changed, 143 insertions(+)
diff --git a/tools/testing/selftests/hid/hidraw.c
b
start adding
the ioctl and BPFs to revoke the hidraw node.
Signed-off-by: Benjamin Tissoires
---
new in v4
---
tools/testing/selftests/hid/.gitignore | 1 +
tools/testing/selftests/hid/Makefile | 2 +-
tools/testing/selftests/hid/hidraw.c | 522 +
3 files
On Tue, 23 Jul 2024 18:21:50 +0200, Benjamin Tissoires wrote:
> After HID-BPF struct_ops was merged into 6.11-rc0, there are a few
> mishaps:
> - the bpf_wq API changed and needs to be updated here
> - libbpf now auto-attach all the struct_ops it sees in the bpf object,
> leadin
Turns out that we would en up in a bad state if we attempt to attach
twice the same HID-BPF struct_ops, so have a test for it.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 18 ++
1 file changed, 18 insertions(+)
diff --git a/tools/testing
If the struct_ops is already attached, we should bail out or we will
end up in various locks and pointer issues while unregistering.
Signed-off-by: Benjamin Tissoires
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 5 +
1 file changed, 5 insertions(+)
diff --git a/drivers/hid/bpf
at a time, or we end up locking the syscall.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 8
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/hid/hid_bpf.c
b/tools/testing/selftests/hid/hid_bpf.c
index dc0408a831d0..9c935fd0dffc 10
Since commit f56f4d541eab ("bpf: helpers: fix bpf_wq_set_callback_impl
signature"), the API for bpf_wq changed a bit.
We need to update the selftests/hid code to reflect that or the
bpf program will not load.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/p
same struct_ops to be attached
more than once as this enters various locks, confusions, and kernel
oopses.
Signed-off-by: Benjamin Tissoires
---
Benjamin Tissoires (4):
selftests/hid: fix bpf_wq new API
selftests/hid: disable struct_ops auto-attach
HID: bpf: prevent the same
e" as
this is not a struct bpf_wq *.
This is a change of API, but there doesn't seem to be much users of bpf_wq
right now, so we should be able to go with this right now.
Fixes: 81f1d7a583fa ("bpf: wq: add bpf_wq_set_callback_impl")
Signed-off-by: Benjamin Tissoires
---
kerne
See the previous patch: the API was wrong, we were provided the pointer
to the value, not the actual struct bpf_wq *.
Signed-off-by: Benjamin Tissoires
---
changes in v2:
- amended to retrieve something from the third argument of the callback
---
tools/testing/selftests/bpf/bpf_experimental.h
e" as
this is not a struct bpf_wq *.
This is a change of API, but there doesn't seem to be much users of bpf_wq
right now, so we should be able to go with this right now.
Signed-off-by: Benjamin Tissoires
---
Changes in v2:
- amended the selftests to retrieve something from the third ar
On Jul 06 2024, Alexei Starovoitov wrote:
> On Fri, Jul 5, 2024 at 1:54 PM Eduard Zingerman wrote:
> >
> > On Fri, 2024-07-05 at 15:44 +0200, Benjamin Tissoires wrote:
> > > See the previous patch: the API was wrong, we were provided the pointer
> > > to the va
See the previous patch: the API was wrong, we were provided the pointer
to the value, not the actual struct bpf_wq *.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/bpf/bpf_experimental.h | 2 +-
tools/testing/selftests/bpf/progs/wq.c | 8
tools/testing
e" as
this is not a struct bpf_wq *.
This is a change of API, but there doesn't seem to be much users of bpf_wq
right now, so we should be able to go with this right now.
Fixes: 81f1d7a583fa ("bpf: wq: add bpf_wq_set_callback_impl")
Signed-off-by: Benjamin Tissoires
---
kerne
e" as
this is not a struct bpf_wq *.
This is a change of API, but there doesn't seem to be much users of bpf_wq
right now, so we should be able to go with this right now.
Signed-off-by: Benjamin Tissoires
---
Benjamin Tissoires (2):
bpf: helpers: fix bpf_wq_set_callback
On Mon, 01 Jul 2024 14:39:48 +0200, Benjamin Tissoires wrote:
> We had several complains in linux-next that there were warnings:
>
> CKI was not happy: it was the same situation than in an early report
> when HID-BPF was initially included: the automatically generated
> vmlinux.h
hooks for hid_hw_output_report")
Signed-off-by: Benjamin Tissoires
---
drivers/hid/bpf/hid_bpf_dispatch.c | 2 +-
include/linux/hid_bpf.h| 14 --
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c
b/drive
.
Documentation/hid/hid-bpf:185: include/linux/hid_bpf.h:147:
ERROR: Unexpected indentation.
Reported-by: Stephen Rothwell
Fixes: 8bd0488b5ea5 ("HID: bpf: add HID-BPF hooks for hid_hw_raw_requests")
Signed-off-by: Benjamin Tissoires
---
include/linux/hid_bpf.h | 11 +++--
d source argument to HID low level functions")
Signed-off-by: Benjamin Tissoires
---
drivers/hid/bpf/hid_bpf_dispatch.c | 6 +++---
drivers/hid/bpf/hid_bpf_struct_ops.c | 2 +-
drivers/hid/hid-core.c | 4 ++--
drivers/hid/hidraw.c | 6 +++---
include/linux/h
bpf_ops.
Fixes: d7696738d66b ("selftests/hid: convert the hid_bpf selftests with
struct_ops")
Reported-by: kernel test robot
Closes: https://lore.kernel.org/r/202406270328.bscln1if-...@intel.com/
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/progs/hid_bpf_helpers.h | 16
fails.
We have multiple pointer to int cast complains and some docs that were
not rendered properly.
Include everything here.
Signed-off-by: Benjamin Tissoires
---
Changes in v2:
- Also fix the pointer to int casts
- Also fix the docs complains
- Link to v1:
https://lore.kernel.org/r/2024062
bpf_ops.
Fixes: d7696738d66b ("selftests/hid: convert the hid_bpf selftests with
struct_ops")
Reported-by: kernel test robot
Closes: https://lore.kernel.org/r/202406270328.bscln1if-...@intel.com/
Signed-off-by: Benjamin Tissoires
---
Same situation than in an early report when HID-BPF wa
On Jun 26 2024, Alexei Starovoitov wrote:
> On Wed, Jun 26, 2024 at 6:46 AM Benjamin Tissoires wrote:
> >
> > This allows to intercept and prevent or change the behavior of
> > hid_hw_raw_request() from a bpf program.
> >
> > The intent is to solve a couple of
On Wed, 26 Jun 2024 15:46:21 +0200, Benjamin Tissoires wrote:
> This series is a followup of the struct_ops conversion.
>
> Therefore, it is based on top of the for-6.11/bpf branch of the hid.git
> tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git/log/?h=for-6.
We don't want this call to allow an infinite loop in HID-BPF, so let's
have some tests.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
tools/testing/selftests/hid/hid_bpf.c | 41 +
tools/testing/selftests/hid/progs/
.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
tools/testing/selftests/hid/hid_bpf.c | 36
tools/testing/selftests/hid/progs/hid.c| 39 ++
.../testing/selftests/hid/progs/hid_bpf_helpers.h | 4 +++
3 files changed
introduce a new kfunc for it: hid_bpf_try_input_report()
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
Documentation/hid/hid-bpf.rst | 2 +-
drivers/hid/bpf/hid_bpf_dispatch.c | 56 --
drivers/hid/hid-core.c | 5 ++--
include
Now that bpf_wq is available, we can write a test with it. Having
hid_bpf_input_report() waiting for the device means that we can
directly call it, and we get that event when the device is ready.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
tools/testing/selftests/hid/hid_bpf.c
allows to work with the following pseudo code:
in struct_ops/hid_device_event:
- schedule a bpf_wq, which calls hid_bpf_input_report()
- once this struct_ops function terminates, hid_bpf_input_report()
immediately starts before the next event
Signed-off-by: Benjamin Tissoires
---
no changes
ensure that we can not loop between hooks for
hid_hw_output_report() and manual calls to hid_bpf_hw_output_report()
from that same hook
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
drivers/hid/bpf/hid_bpf_dispatch.c | 5 ++
tools/testing/selftests/hid/hid_bpf.c | 102
n call the feature request on a different HID device on the
same physical device.
Signed-off-by: Benjamin Tissoires
---
changes in v2:
- make use of SRCU
---
drivers/hid/bpf/hid_bpf_dispatch.c | 38
drivers/hid/bpf/hid_bpf_struct_ops.c | 1 +
drivers/hid/
we can not loop between hooks for
hid_hw_raw_request() and manual calls to hid_bpf_hw_request() from that
hook
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
tools/testing/selftests/hid/hid_bpf.c | 109
tools/testing/selftests/hid/progs/hid.c
f" is very interesting because while
writing such a bpf program, you need to match at least the report number
and/or the source of the call. So a blind "if there is a
hid_hw_raw_request() call, I'm emitting another one" makes no real
sense.
Signed-off-by: Benjamin Tissoires
---
no
accommodate for this.
Signed-off-by: Benjamin Tissoires
---
new in v2
---
drivers/hid/bpf/hid_bpf_dispatch.c | 6 +-
drivers/hid/bpf/hid_bpf_struct_ops.c | 2 ++
drivers/hid/hid-core.c | 8 +++-
include/linux/hid_bpf.h | 6 --
4 files changed, 18
n the
same physical device.
Signed-off-by: Benjamin Tissoires
---
changes in v2:
- make use of SRCU
---
drivers/hid/bpf/hid_bpf_dispatch.c | 37
drivers/hid/bpf/hid_bpf_struct_ops.c | 1 +
drivers/hid/hid-core.c | 6 ++
include/linux
This allows to know who actually sent what when we process the request
to the device.
This will be useful for a BPF firewall program to allow or not requests
coming from a dedicated hidraw node client.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
drivers/hid/bpf
han only the last
program in the chain could change the size of the incoming buffer.
Reported-by: Dan Carpenter
Link:
https://lore.kernel.org/all/00f7b624-219f-4a05-a7ad-5335f15a41c7@moroto.mountain
Fixes: 4a86220e046d ("HID: bpf: remove tracing HID-BPF capability")
Signed-off-by: Benja
the function was already declared as sleepable.
Cheers,
Benjamin
Signed-off-by: Benjamin Tissoires
---
Changes in v2:
- made use of srcu, for sleepable users
- Link to v1:
https://lore.kernel.org/r/20240621-hid_hw_req_bpf-v1-0-d7ab8b885...@kernel.org
---
Benjamin Tissoires
On Jun 21 2024, Alexei Starovoitov wrote:
> On Fri, Jun 21, 2024 at 9:08 AM Benjamin Tissoires wrote:
> >
> > On Jun 21 2024, Alexei Starovoitov wrote:
> > > On Fri, Jun 21, 2024 at 1:56 AM Benjamin Tissoires
> > > wrote:
> > > >
> > > >
On Jun 21 2024, Alexei Starovoitov wrote:
> On Fri, Jun 21, 2024 at 1:56 AM Benjamin Tissoires wrote:
> >
> > Same story than hid_hw_raw_requests:
> >
> > This allows to intercept and prevent or change the behavior of
> > hid_hw_output_report() from a bpf program.
We don't want this call to allow an infinite loop in HID-BPF, so let's
have some tests.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 41 +
tools/testing/selftests/hid/progs/hid.c | 37
.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 36
tools/testing/selftests/hid/progs/hid.c| 39 ++
.../testing/selftests/hid/progs/hid_bpf_helpers.h | 4 +++
3 files changed, 79 insertions(+)
diff
introduce a new kfunc for it: hid_bpf_try_input_report()
Signed-off-by: Benjamin Tissoires
---
Documentation/hid/hid-bpf.rst | 2 +-
drivers/hid/bpf/hid_bpf_dispatch.c | 56 --
drivers/hid/hid-core.c | 5 ++--
include/linux/hid_bpf.h
Now that bpf_wq is available, we can write a test with it. Having
hid_bpf_input_report() waiting for the device means that we can
directly call it, and we get that event when the device is ready.
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 38
allows to work with the following pseudo code:
in struct_ops/hid_device_event:
- schedule a bpf_wq, which calls hid_bpf_input_report()
- once this struct_ops function terminates, hid_bpf_input_report()
immediately starts before the next event
Signed-off-by: Benjamin Tissoires
---
drivers/hid
ensure that we can not loop between hooks for
hid_hw_output_report() and manual calls to hid_bpf_hw_output_report()
from that same hook
Signed-off-by: Benjamin Tissoires
---
drivers/hid/bpf/hid_bpf_dispatch.c | 5 ++
tools/testing/selftests/hid/hid_bpf.c | 102
n call the feature request on a different HID device on the
same physical device.
Signed-off-by: Benjamin Tissoires
---
Here checkpatch complains about:
WARNING: use of RCU tasks trace is incorrect outside BPF or core RCU code
However, we are jumping in BPF code, so I think this is correct, but I'
we can not loop between hooks for
hid_hw_raw_request() and manual calls to hid_bpf_hw_request() from that
hook
Signed-off-by: Benjamin Tissoires
---
tools/testing/selftests/hid/hid_bpf.c | 109
tools/testing/selftests/hid/progs/hid.c | 79
f" is very interesting because while
writing such a bpf program, you need to match at least the report number
and/or the source of the call. So a blind "if there is a
hid_hw_raw_request() call, I'm emitting another one" makes no real
sense.
Signed-off-by: Benjamin Tissoires
---
driv
n the
same physical device.
Signed-off-by: Benjamin Tissoires
---
Here checkpatch complains about:
WARNING: use of RCU tasks trace is incorrect outside BPF or core RCU code
However, we are jumping in BPF code, so I think this is correct, but I'd
like to have the opinion on the BPF folks.
-
This allows to know who actually sent what when we process the request
to the device.
This will be useful for a BPF firewall program to allow or not requests
coming from a dedicated hidraw node client.
Signed-off-by: Benjamin Tissoires
---
drivers/hid/bpf/hid_bpf_dispatch.c | 12
han only the last
program in the chain could change the size of the incoming buffer.
Reported-by: Dan Carpenter
Link:
https://lore.kernel.org/all/00f7b624-219f-4a05-a7ad-5335f15a41c7@moroto.mountain
Fixes: 4a86220e046d ("HID: bpf: remove tracing HID-BPF capability")
Signed-off-by: Benja
the function was already declared as sleepable.
Cheers,
Benjamin
Signed-off-by: Benjamin Tissoires
---
Benjamin Tissoires (12):
HID: bpf: fix dispatch_hid_bpf_device_event uninitialized ret value
HID: add source argument to HID low level functions
HID: bpf: add HID-BPF hooks for hid_
On Sat, 08 Jun 2024 11:01:12 +0200, Benjamin Tissoires wrote:
> The purpose of this series is to rethink how HID-BPF is invoked.
> Currently it implies a jmp table, a prog fd bpf_map, a preloaded tracing
> bpf program and a lot of manual work for handling the bpf program
> lifetime
On Jun 10 2024, Alexei Starovoitov wrote:
> On Sat, Jun 8, 2024 at 2:01 AM Benjamin Tissoires wrote:
> >
> > +
> > +static int hid_bpf_ops_init_member(const struct btf_type *t,
> > +const struct btf_member *member,
> > +
On Jun 10 2024, Alexei Starovoitov wrote:
> On Sat, Jun 8, 2024 at 2:01 AM Benjamin Tissoires wrote:
> >
> > The idea is to provide a list of stucts and their editable fields.
> >
> > Currently no functional changes are introduced here, we will add some
> > more w
device export 3 nodes,
all with the same name.
Signed-off-by: Benjamin Tissoires
---
changes in v3:
- amend for new WRITE_RANGE API
new in v2
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 3 +++
include/linux/hid_bpf.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff
The idea is to provide a list of stucts and their editable fields.
Currently no functional changes are introduced here, we will add some
more writeable fields in the next patch.
Signed-off-by: Benjamin Tissoires
---
changes in v3:
- rewrote WRITE_RANGE macro to not deal with offset from the
Without this helpers like bpf_printk() or bpf_map_update() are not
available, making anything but change of bytes impossible to do.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
new in v2
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 1 +
1 file changed, 1 insertion(+)
diff --git a
There is no real reasons to paper over warnings for such small programs.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
drivers/hid/bpf/progs/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid
warning: unused variable ‘tilt’ [-Wunused-variable]
Signed-off-by: Peter Hutterer
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/hid/bpf/progs/XPPen__Artist24
This is the current decision we took: we don't provide automatic loading
of HID-BPF by the kernel directly, but rely on an external tool for it.
This tool is currently udev-hid-bpf, so let's make people aware of it.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no cha
Now that we are using struct_ops, the docs need to be changed.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
changes in v2
- use BPF_F_BEFORE
---
Documentation/hid/hid-bpf.rst | 156 +++---
include/linux/hid_bpf.h | 8 +--
2 files changed
I got a weird verifier error with a subprog once, so let's have a test
for it.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
tools/testing/selftests/hid/hid_bpf.c | 41 +
tools/testing/selftests/hid/progs/hid.c
We can now rely on struct_ops as we cleared the users in-tree.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
changes in v2:
- remove now unused enum hid_bpf_attach_flags
---
drivers/hid/bpf/Makefile| 2 +-
drivers/hid/bpf/entrypoints/Makefile
Very mechanical:
- Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines
- add a matching SEC(".struct_ops.link")
- in ArtistPro16Gen2 make the 2 functions static and have a new one
calling them
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
d
We are going to switch over struct_ops, so instead of having to manually
replace all fields one by one, let's have a common place to change it.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 4 ++--
dr
This is mostly mechanical: attach_prog is dropped, and
the SEC are converted into struct_ops.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2 but the commit message.
---
samples/hid/Makefile | 5 ++--
samples/hid/hid_bpf_attach.bpf.c | 18
We drop the need for the attach() bpf syscall, but we need to set up
the hid_id field before calling __load().
The .bpf.c part is mechanical: we create one struct_ops per HID-BPF
program, as all the tests are for one program at a time.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
ouble
- 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
Signed-off-by: Ben
no code change, but this way we reduce code duplication and we
can export it later.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
drivers/hid/bpf/hid_bpf_dispatch.c | 47 ++
1 file changed, 27 insertions(+), 20 deletions
Those operations are the ones from HID, not HID-BPF, and I'd like to
reuse hid_bpf_ops as the user facing struct_ops API.
Signed-off-by: Benjamin Tissoires
---
no changes in v3
no changes in v2
---
drivers/hid/bpf/hid_bpf_dispatch.c | 22 +++---
drivers/hid/hid-c
).
The matching user-space loader (udev-hid-bpf) MR is at
https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/-/merge_requests/86
I'll put it out of draft once this is merged.
Cheers,
Benjamin
Signed-off-by: Benjamin Tissoires
---
Changes in v3:
- took Alexei's review into account
-
On Jun 07 2024, Alexei Starovoitov wrote:
> On Fri, Jun 7, 2024 at 8:28 AM Benjamin Tissoires wrote:
> > +struct hid_bpf_ops {
> > + /* hid_id needs to stay first so we can easily change it
> > +* from userspace.
> > +*/
> > +
device export 3 nodes,
all with the same name.
Signed-off-by: Benjamin Tissoires
---
new in v2
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 3 +++
include/linux/hid_bpf.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/bpf/hid_bpf_struct_ops.c
b
The idea is to provide a list of stucts and their editable fields.
Currently no functional changes are introduced here, we will add some
more writeable fields in the next patch.
Signed-off-by: Benjamin Tissoires
---
new in v2
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 91
Without this helpers like bpf_printk() or bpf_map_update() are not
available, making anything but change of bytes impossible to do.
Signed-off-by: Benjamin Tissoires
---
new in v2
---
drivers/hid/bpf/hid_bpf_struct_ops.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/bpf
There is no real reasons to paper over warnings for such small programs.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
drivers/hid/bpf/progs/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid/bpf/progs
warning: unused variable ‘tilt’ [-Wunused-variable]
Signed-off-by: Peter Hutterer
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c
b/drivers
This is the current decision we took: we don't provide automatic loading
of HID-BPF by the kernel directly, but rely on an external tool for it.
This tool is currently udev-hid-bpf, so let's make people aware of it.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
Documen
Now that we are using struct_ops, the docs need to be changed.
Signed-off-by: Benjamin Tissoires
---
changes in v2
- use BPF_F_BEFORE
---
Documentation/hid/hid-bpf.rst | 156 +++---
include/linux/hid_bpf.h | 8 +--
2 files changed, 76 insertions
I got a weird verifier error with a subprog once, so let's have a test
for it.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
tools/testing/selftests/hid/hid_bpf.c | 41 +
tools/testing/selftests/hid/progs/hid.c | 24 +++
2
We can now rely on struct_ops as we cleared the users in-tree.
Signed-off-by: Benjamin Tissoires
---
changes in v2:
- remove now unused enum hid_bpf_attach_flags
---
drivers/hid/bpf/Makefile| 2 +-
drivers/hid/bpf/entrypoints/Makefile| 93
drivers
Very mechanical:
- Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines
- add a matching SEC(".struct_ops.link")
- in ArtistPro16Gen2 make the 2 functions static and have a new one
calling them
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
drivers/hid/bp
We are going to switch over struct_ops, so instead of having to manually
replace all fields one by one, let's have a common place to change it.
Signed-off-by: Benjamin Tissoires
---
no changes in v2
---
drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 4 ++--
drivers/hid/bpf/
This is mostly mechanical: attach_prog is dropped, and
the SEC are converted into struct_ops.
Signed-off-by: Benjamin Tissoires
---
no changes in v2 but the commit message.
---
samples/hid/Makefile | 5 ++--
samples/hid/hid_bpf_attach.bpf.c | 18 -
samples/hid
We drop the need for the attach() bpf syscall, but we need to set up
the hid_id field before calling __load().
The .bpf.c part is mechanical: we create one struct_ops per HID-BPF
program, as all the tests are for one program at a time.
Signed-off-by: Benjamin Tissoires
---
changes in v2
1 - 100 of 346 matches
Mail list logo