Re: [PATCH v2 0/3] selftests/hid: fix building for older kernels

2023-10-02 Thread Benjamin Tissoires
ailed my own CI now with the enums being already defined: https://gitlab.freedesktop.org/bentiss/hid/-/jobs/49754306 I'll probably squash the following patch in 1/3, would you mind giving it a test? --- >From 37feca6c0e84705ad65e621643206c287b63bb0a Mon Sep 17 00:00:00 2001 From: Benjamin

[PATCH v3 0/3] selftests/hid: assorted fixes

2023-10-05 Thread Benjamin Tissoires
us a lot in the review of v1 but never sent your Reviewed-by or Acked-by. Do you want me to add one? Cheers, Benjamin [1] https://gitlab.freedesktop.org/bentiss/hid/-/jobs/49754306 For reference, the v2 cover letter: | Hi, I am sending this series on behalf of myself and Benjamin Tissoires.

[PATCH v3 3/3] selftests/hid: force using our compiled libbpf headers

2023-10-05 Thread Benjamin Tissoires
Turns out that we were relying on the globally installed headers, not the ones we freshly compiled. Add a manual include in CFLAGS to sort this out. Tested-by: Nick Desaulniers # Build Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/Makefile | 2 ++ 1 file changed, 2

[PATCH v3 2/3] selftests/hid: do not manually call headers_install

2023-10-05 Thread Benjamin Tissoires
"make headers" is a requirement before calling make on the selftests dir, so we should not have to manually install those headers Acked-by: Shuah Khan Tested-by: Nick Desaulniers # Build Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/Makefile | 8 ++-- 1 file

[PATCH v3 1/3] selftests/hid: ensure we can compile the tests on kernels pre-6.3

2023-10-05 Thread Benjamin Tissoires
ition of that symbol in case we don't find it in the BTF and also add __attribute__((preserve_access_index)) to further support CO-RE functionality for these tests. Signed-off-by: Justin Stitt Tested-by: Nick Desaulniers # Build Signed-off-by: Benjamin Tissoires --- tools/testing/selftests

Re: [PATCH v3 0/3] selftests/hid: assorted fixes

2023-10-11 Thread Benjamin Tissoires
On Thu, 05 Oct 2023 17:55:31 +0200, Benjamin Tissoires wrote: > And this is the last(?) revision of this series which should now compile > with or without CONFIG_HID_BPF set. > > I had to do changes because [1] was failing > > Nick, I kept your Tested-by, even if I made sm

[PATCH 00/12] selftests/hid: tablets fixes

2023-11-29 Thread Benjamin Tissoires
r.yfh.7.76.2311012033290.29...@cbobk.fhfr.pm/ Signed-off-by: Benjamin Tissoires --- Benjamin Tissoires (12): selftests/hid: vmtest.sh: update vm2c and container selftests/hid: vmtest.sh: allow finer control on the build steps selftests/hid: base: allow for multiple skip_if_

[PATCH 04/12] selftests/hid: tablets: remove unused class

2023-11-29 Thread Benjamin Tissoires
Looks like this is a leftover Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/tests/test_tablet.py | 4 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/hid/tests/test_tablet.py b/tools/testing/selftests/hid/tests/test_tablet.py index 3039ee8d

[PATCH 02/12] selftests/hid: vmtest.sh: allow finer control on the build steps

2023-11-29 Thread Benjamin Tissoires
vmtest.sh works great for a one shot test, but not so much for CI where I want to build (with different configs) the bzImage in a separate job than the one I am running it. Add a "build_only" option to specify whether we need to boot the currently built kernel in the vm. Signed-off-by

[PATCH 05/12] selftests/hid: tablets: move the transitions to PenState

2023-11-29 Thread Benjamin Tissoires
Those transitions have nothing to do with `Pen`, so migrate them to `PenState`. The hidden agenda is to remove `Pen` and integrate it into `PenDigitizer` so that we can tweak the events in each state to emulate firmware bugs. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid

[PATCH 09/12] selftests/hid: tablets: add variants of states with buttons

2023-11-29 Thread Benjamin Tissoires
manually building the button test by hand and forgetting about some cases, let's reuse the state machine and transitions we have. This patch only adds the states and the valid transitions. The actual tests will be replaced later. Signed-off-by: Benjamin Tissoires --- tools/testing/selftest

[PATCH 06/12] selftests/hid: tablets: move move_to function to PenDigitizer

2023-11-29 Thread Benjamin Tissoires
We can easily subclass PenDigitizer for introducing firmware bugs when subclassing Pen is harder. Move move_to from Pen to PenDigitizer so we get that ability Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/tests/test_tablet.py | 97 1 file changed

[PATCH 08/12] selftests/hid: tablets: set initial data for tilt/twist

2023-11-29 Thread Benjamin Tissoires
Avoids getting a null event when these usages are set Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/tests/test_tablet.py | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/hid/tests/test_tablet.py b/tools/testing

[PATCH 12/12] selftests/hid: tablets: be stricter for some transitions

2023-11-29 Thread Benjamin Tissoires
k user space, but we have serious doubts if we are doing the right thing. And depending on the test, either ask only for valid transitions, or tolerate weird ones. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/tests/test_tablet.py | 122 +++ 1 file chang

[PATCH 11/12] selftests/hid: tablets: add a secondary barrel switch test

2023-11-29 Thread Benjamin Tissoires
Some tablets report 2 barrel switches. We better test those too. Use the same transistions description from the primary button tests. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/tests/test_tablet.py | 67 1 file changed, 67 insertions(+) diff

[PATCH v2 00/15] selftests/hid: tablets fixes

2023-12-06 Thread Benjamin Tissoires
Peter that his rev-by applied to the whole series. [0] https://lore.kernel.org/all/nycvar.yfh.7.76.2311012033290.29...@cbobk.fhfr.pm/ Signed-off-by: Benjamin Tissoires --- Changes in v2: - took Peter's review into account - Added a few patches to make mypy and ruff happy given that I ha

[PATCH v2 01/15] selftests/hid: vmtest.sh: update vm2c and container

2023-12-06 Thread Benjamin Tissoires
boot2container is now on an official project, so let's use that. The container image is now the same I use for the CI, so let's keep to it. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/vmtest.sh | 4 ++-- 1 file

[PATCH v2 03/15] selftests/hid: base: allow for multiple skip_if_uhdev

2023-12-06 Thread Benjamin Tissoires
: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/hid/tests/base.py b/tools/testing/selftests/hid/tests/base.py index 1305cfc9646e

[PATCH v2 02/15] selftests/hid: vmtest.sh: allow finer control on the build steps

2023-12-06 Thread Benjamin Tissoires
-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- changes in v2: - fixed typo --- tools/testing/selftests/hid/vmtest.sh | 42 --- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/hid/vmtest.sh b/tools/testing/sel

[PATCH v2 05/15] selftests/hid: tablets: move the transitions to PenState

2023-12-06 Thread Benjamin Tissoires
Those transitions have nothing to do with `Pen`, so migrate them to `PenState`. The hidden agenda is to remove `Pen` and integrate it into `PenDigitizer` so that we can tweak the events in each state to emulate firmware bugs. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires

[PATCH v2 04/15] selftests/hid: tablets: remove unused class

2023-12-06 Thread Benjamin Tissoires
Looks like this is a leftover Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests/test_tablet.py | 4 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/hid/tests/test_tablet.py b/tools/testing

[PATCH v2 06/15] selftests/hid: tablets: move move_to function to PenDigitizer

2023-12-06 Thread Benjamin Tissoires
We can easily subclass PenDigitizer for introducing firmware bugs when subclassing Pen is harder. Move move_to from Pen to PenDigitizer so we get that ability Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests

[PATCH v2 07/15] selftests/hid: tablets: do not set invert when the eraser is used

2023-12-06 Thread Benjamin Tissoires
Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests/test_tablet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/hid/tests/test_tablet.py b/tools/testing/selftests/hid/tests/test_tablet.py index 27260dc02cc4

[PATCH v2 09/15] selftests/hid: tablets: define the elements of PenState

2023-12-06 Thread Benjamin Tissoires
This introduces a little bit more readability by not using the raw values but a dedicated Enum Signed-off-by: Benjamin Tissoires --- new in v2 --- tools/testing/selftests/hid/tests/test_tablet.py | 36 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a

[PATCH v2 08/15] selftests/hid: tablets: set initial data for tilt/twist

2023-12-06 Thread Benjamin Tissoires
Avoids getting a null event when these usages are set Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests/test_tablet.py | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing

[PATCH v2 10/15] selftests/hid: tablets: add variants of states with buttons

2023-12-06 Thread Benjamin Tissoires
manually building the button test by hand and forgetting about some cases, let's reuse the state machine and transitions we have. This patch only adds the states and the valid transitions. The actual tests will be replaced later. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tiss

[PATCH v2 11/15] selftests/hid: tablets: convert the primary button tests

2023-12-06 Thread Benjamin Tissoires
We get more descriptive in what we are doing, and also get more information of what is actually being tested. Instead of having a non exhaustive button changes that are semi-randomly done, we can describe all the states we want to test. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin

[PATCH v2 12/15] selftests/hid: tablets: add a secondary barrel switch test

2023-12-06 Thread Benjamin Tissoires
Some tablets report 2 barrel switches. We better test those too. Use the same transistions description from the primary button tests. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests/test_tablet.py | 67

[PATCH v2 13/15] selftests/hid: tablets: be stricter for some transitions

2023-12-06 Thread Benjamin Tissoires
k user space, but we have serious doubts if we are doing the right thing. And depending on the test, either ask only for valid transitions, or tolerate weird ones. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- changes in v2: - fixed type annotations for apply() -

[PATCH v2 14/15] selftests/hid: fix mypy complains

2023-12-06 Thread Benjamin Tissoires
No code change, only typing information added/ignored Signed-off-by: Benjamin Tissoires --- new in v2 --- tools/testing/selftests/hid/tests/base.py| 4 ++-- tools/testing/selftests/hid/tests/test_tablet.py | 10 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git

[PATCH v2 15/15] selftests/hid: fix ruff linter complains

2023-12-06 Thread Benjamin Tissoires
rename ambiguous variables l, r, and m, and ignore the return values of uhdev.get_evdev() and uhdev.get_slot() Signed-off-by: Benjamin Tissoires --- new in v2 --- tools/testing/selftests/hid/tests/test_mouse.py | 14 +++--- tools/testing/selftests/hid/tests

Re: [PATCH v2 00/15] selftests/hid: tablets fixes

2023-12-07 Thread Benjamin Tissoires
On Wed, 06 Dec 2023 11:45:51 +0100, Benjamin Tissoires wrote: > the main trigger of this series was the XP-Pen issue[0]. > Basically, the tablets tests were good-ish but couldn't > handle that tablet both in terms of emulation or in terms > of detection of issues. > > So re

Re: [PATCH v2 00/15] selftests/hid: tablets fixes

2023-12-07 Thread Benjamin Tissoires
On Thu, Dec 7, 2023 at 9:53 AM Benjamin Tissoires wrote: > > On Wed, 06 Dec 2023 11:45:51 +0100, Benjamin Tissoires wrote: > > the main trigger of this series was the XP-Pen issue[0]. > > Basically, the tablets tests were good-ish but couldn't > > handle that tablet

[PATCH] selftests/hid: fix failing tablet button tests

2023-12-07 Thread Benjamin Tissoires
An overlook from commit 74452d6329be ("selftests/hid: tablets: add variants of states with buttons"), where I don't use the Enum... Fixes: 74452d6329be ("selftests/hid: tablets: add variants of states with buttons") Signed-off-by: Benjamin Tissoires --- Not sure wha

Re: [PATCH] selftests/hid: fix failing tablet button tests

2023-12-07 Thread Benjamin Tissoires
On Thu, 07 Dec 2023 13:22:39 +0100, Benjamin Tissoires wrote: > An overlook from commit 74452d6329be ("selftests/hid: tablets: add > variants of states with buttons"), where I don't use the Enum... > > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/hid/

Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-12 Thread Benjamin Tissoires
Hi, On Tue, Dec 12, 2023 at 9:11 AM Akihiko Odaki wrote: > > Hi, > > It is said eBPF is a safe way to extend kernels and that is very > attarctive, but we need to use kfuncs to add new usage of eBPF and > kfuncs are said as unstable as EXPORT_SYMBOL_GPL. So now I'd like to ask > some questions: >

Re: Should I add BPF kfuncs for userspace apps? And how?

2023-12-13 Thread Benjamin Tissoires
On Tue, Dec 12, 2023 at 1:41 PM Akihiko Odaki wrote: > > On 2023/12/12 19:39, Benjamin Tissoires wrote: > > Hi, > > > > On Tue, Dec 12, 2023 at 9:11 AM Akihiko Odaki > > wrote: > >> > >> Hi, > > Hi, > > Thanks for reply. > > &

[PATCH] selftests/hid: wacom: fix confidence tests

2024-01-17 Thread Benjamin Tissoires
: Benjamin Tissoires --- Over the break the test suite wasn't properly running on my runner, and this small issue sneaked in. --- tools/testing/selftests/hid/tests/test_wacom_generic.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/hid/

Re: [PATCH] selftests/hid: wacom: fix confidence tests

2024-01-18 Thread Benjamin Tissoires
hes Cheers, Benjamin > > > Jason > --- > Now instead of four in the eights place / > you’ve got three, ‘Cause you added one / > (That is to say, eight) to the two, / > But you can’t take seven from three,/ > So you look at the sixty-fours > > > &g

Re: [PATCH] selftests/hid: wacom: fix confidence tests

2024-01-18 Thread Benjamin Tissoires
On Wed, 17 Jan 2024 14:27:15 +0100, Benjamin Tissoires wrote: > The device is exported with a fuzz of 4, meaning that the `+ t` here > is removed by the fuzz algorithm, making those tests failing. > > Not sure why, but when I run this locally it was passing, but not

Re: [PATCH bpf-next v4 3/3] bpf: treewide: Annotate BPF kfuncs in BTF

2024-01-31 Thread Benjamin Tissoires
all machinery does not handle errors. > > Signed-off-by: Daniel Xu > --- > Documentation/bpf/kfuncs.rst | 8 > drivers/hid/bpf/hid_bpf_dispatch.c| 8 For the HID changes (they shouldn't conflict with our current branch): Acked-by: Benjamin Tissoires

[PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-09 Thread Benjamin Tissoires
probably not a guarantee I'm doing the things properly :) Cheers, Benjamin Signed-off-by: Benjamin Tissoires --- Benjamin Tissoires (9): bpf: allow more maps in sleepable bpf programs HID: bpf/dispatch: regroup kfuncs definitions HID: bpf: export hid_hw_output_report as

[PATCH RFC bpf-next 1/9] bpf: allow more maps in sleepable bpf programs

2024-02-09 Thread Benjamin Tissoires
therefore BPF_MAP_TYPE_STACK) allows for a BPF program to prepare from an IRQ the list of HID commands to send back to the device and then these commands can be retrieved from the sleepable trace point. Signed-off-by: Benjamin Tissoires --- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions

[PATCH RFC bpf-next 2/9] HID: bpf/dispatch: regroup kfuncs definitions

2024-02-09 Thread Benjamin Tissoires
No code change, just move down the hid_bpf_get_data() kfunc definition so we have only one block of __bpf_kfunc_start/end_defs() Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/hid_bpf_dispatch.c | 80 ++ 1 file changed, 38 insertions(+), 42 deletions

[PATCH RFC bpf-next 3/9] HID: bpf: export hid_hw_output_report as a BPF kfunc

2024-02-09 Thread Benjamin Tissoires
We currently only export hid_hw_raw_request() as a BPF kfunc. However, some devices require an explicit write on the Output Report instead of the use of the control channel. So also export hid_hw_output_report to BPF Signed-off-by: Benjamin Tissoires --- Documentation/hid/hid-bpf.rst

[PATCH RFC bpf-next 4/9] selftests/hid: Add test for hid_bpf_hw_output_report

2024-02-09 Thread Benjamin Tissoires
This time we need to ensure uhid receives it, thus the new mutex and condition. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/hid_bpf.c | 63 ++ tools/testing/selftests/hid/progs/hid.c| 24 + .../testing/selftests/hid

[PATCH RFC bpf-next 5/9] HID: bpf: allow to inject HID event from BPF

2024-02-09 Thread Benjamin Tissoires
device, not just uhid virtual ones. Signed-off-by: Benjamin Tissoires --- Documentation/hid/hid-bpf.rst | 2 +- drivers/hid/bpf/hid_bpf_dispatch.c | 29 + drivers/hid/hid-core.c | 1 + include/linux/hid_bpf.h| 2 ++ 4 files changed, 33

[PATCH RFC bpf-next 6/9] selftests/hid: add tests for hid_bpf_input_report

2024-02-09 Thread Benjamin Tissoires
Usual way of testing, we call the function and ensures we receive the event Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/hid_bpf.c | 49 +- tools/testing/selftests/hid/progs/hid.c| 22 ++ .../testing/selftests/hid/progs

[PATCH RFC bpf-next 7/9] HID: bpf: allow to defer work in a delayed workqueue

2024-02-09 Thread Benjamin Tissoires
is no logic that would justify an actual userspace wakeup. So a kernel workqueue is simpler to handle. Signed-off-by: Benjamin Tissoires --- Documentation/hid/hid-bpf.rst | 24 ++- drivers/hid/bpf/entrypoints/entrypoints.bpf.c | 8 + drivers/hid/bpf/entrypoints/entrypoints.ls

[PATCH RFC bpf-next 8/9] selftests/hid: add test for hid_bpf_schedule_delayed_work

2024-02-09 Thread Benjamin Tissoires
. The use of the ring buffer is there to not have sleeps in userspace because we have no guarantees of the timing of when those jobs will be called. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/hid_bpf.c | 57 ++ tools/testing/selftests/hid/progs

[PATCH RFC bpf-next 9/9] selftests/hid: add another set of delayed work tests

2024-02-09 Thread Benjamin Tissoires
- if there is an error, while re-injecting it, we try again 5 ms later - ensure we can add another event in the queue or call other sleepable kfuncs - ensure we receive the correct events and exactly them Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/hid_bpf.c | 117

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-09 Thread Benjamin Tissoires
On Fri, Feb 9, 2024 at 4:42 PM Toke Høiland-Jørgensen wrote: > > Benjamin Tissoires writes: > > > [Putting this as a RFC because I'm pretty sure I'm not doing the things > > correctly at the BPF level.] > > [Also using bpf-next as the base tree as there will

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-12 Thread Benjamin Tissoires
On Fri, Feb 9, 2024 at 6:05 PM Toke Høiland-Jørgensen wrote: > > Benjamin Tissoires writes: > > > On Fri, Feb 9, 2024 at 4:42 PM Toke Høiland-Jørgensen > > wrote: > >> > >> Benjamin Tissoires writes: > >> > >> > [Putting th

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-12 Thread Benjamin Tissoires
On Mon, Feb 12, 2024 at 6:46 PM Toke Høiland-Jørgensen wrote: > > Benjamin Tissoires writes: > > [...] > >> IIUC, the bpf_timer callback is just a function (subprog) from the > >> verifier PoV, so it is verified as whatever program type is creating the > >&g

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-13 Thread Benjamin Tissoires
On Feb 12 2024, Alexei Starovoitov wrote: > On Mon, Feb 12, 2024 at 10:21 AM Benjamin Tissoires > wrote: > > > > On Mon, Feb 12, 2024 at 6:46 PM Toke Høiland-Jørgensen > > wrote: > > > > > > Benjamin Tissoires writes: > > > [...] > I a

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-14 Thread Benjamin Tissoires
On Feb 13 2024, Kumar Kartikeya Dwivedi wrote: > On Tue, 13 Feb 2024 at 18:46, Benjamin Tissoires wrote: > > > > On Feb 12 2024, Alexei Starovoitov wrote: > > > On Mon, Feb 12, 2024 at 10:21 AM Benjamin Tissoires > > > wrote: > > > > > > > &g

[PATCH RFC bpf-next v2 00/10] allow HID-BPF to do device IOs

2024-02-14 Thread Benjamin Tissoires
Fastabend To: Andrii Nakryiko To: Martin KaFai Lau To: Eduard Zingerman To: Song Liu To: Yonghong Song To: KP Singh To: Stanislav Fomichev To: Hao Luo To: Jiri Olsa To: Jiri Kosina To: Benjamin Tissoires To: Jonathan Corbet To: Shuah Khan Cc: Cc: Cc: Cc: Cc: Signed-off-by: Be

[PATCH RFC bpf-next v2 01/10] bpf/verifier: introduce in_sleepable() helper

2024-02-14 Thread Benjamin Tissoires
No code change, but it'll allow to have only one place to change everything when we add in_sleepable in cur_state. Signed-off-by: Benjamin Tissoires --- changes in v2 (compared to the one attaches to v1 0/9): - dropped the cur_state flag, so it can be put first --- kernel/bpf/verifier.c

[PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-14 Thread Benjamin Tissoires
They are implemented as a kfunc, which means a little bit of tweaks in the verifier. Signed-off-by: Benjamin Tissoires --- changes in v2 (compared to the one attaches to v1 0/9): - make use of a kfunc - add a (non-used) BPF_F_TIMER_SLEEPABLE - the callback is *not* called, it makes the kernel

[PATCH RFC bpf-next v2 03/10] bpf/verifier: allow more maps in sleepable bpf programs

2024-02-14 Thread Benjamin Tissoires
commands can be retrieved from the sleepable trace point. Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped BPF_MAP_TYPE_PROG_ARRAY from the list --- kernel/bpf/verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index

[PATCH RFC bpf-next v2 04/10] HID: bpf/dispatch: regroup kfuncs definitions

2024-02-14 Thread Benjamin Tissoires
No code change, just move down the hid_bpf_get_data() kfunc definition so we have only one block of __bpf_kfunc_start/end_defs() Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 80 ++ 1 file changed, 38

[PATCH RFC bpf-next v2 05/10] HID: bpf: export hid_hw_output_report as a BPF kfunc

2024-02-14 Thread Benjamin Tissoires
We currently only export hid_hw_raw_request() as a BPF kfunc. However, some devices require an explicit write on the Output Report instead of the use of the control channel. So also export hid_hw_output_report to BPF Signed-off-by: Benjamin Tissoires --- no changes in v2 --- Documentation

[PATCH RFC bpf-next v2 06/10] selftests/hid: Add test for hid_bpf_hw_output_report

2024-02-14 Thread Benjamin Tissoires
This time we need to ensure uhid receives it, thus the new mutex and condition. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 63 ++ tools/testing/selftests/hid/progs/hid.c| 24

[PATCH RFC bpf-next v2 07/10] HID: bpf: allow to inject HID event from BPF

2024-02-14 Thread Benjamin Tissoires
device, not just uhid virtual ones. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- Documentation/hid/hid-bpf.rst | 2 +- drivers/hid/bpf/hid_bpf_dispatch.c | 29 + drivers/hid/hid-core.c | 1 + include/linux/hid_bpf.h| 2 ++ 4

[PATCH RFC bpf-next v2 08/10] selftests/hid: add tests for hid_bpf_input_report

2024-02-14 Thread Benjamin Tissoires
Usual way of testing, we call the function and ensures we receive the event Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 49 +- tools/testing/selftests/hid/progs/hid.c| 22

[PATCH RFC bpf-next v2 09/10] HID: bpf: allow to use bpf_timer_set_sleepable_cb() in tracing callbacks.

2024-02-14 Thread Benjamin Tissoires
: Benjamin Tissoires --- new in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index e1a650f4a626..275f2057c48d 100644 --- a/drivers/hid/bpf

[PATCH RFC bpf-next v2 10/10] selftests/hid: add test for bpf_timer

2024-02-14 Thread Benjamin Tissoires
the ring buffer is there to not have sleeps in userspace because we have no guarantees of the timing of when those jobs will be called. Signed-off-by: Benjamin Tissoires --- new in v2 --- tools/testing/selftests/hid/hid_bpf.c | 83 +++ tools/testing/selftests/hid/progs

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-15 Thread Benjamin Tissoires
On Feb 14 2024, Benjamin Tissoires wrote: > They are implemented as a kfunc, which means a little bit of tweaks in > the verifier. > > Signed-off-by: Benjamin Tissoires > > --- > > changes in v2 (compared to the one attaches to v1 0/9): > - make use of

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-16 Thread Benjamin Tissoires
On Feb 15 2024, Martin KaFai Lau wrote: > On 2/14/24 9:18 AM, Benjamin Tissoires wrote: > > +static void bpf_timer_work_cb(struct work_struct *work) > > +{ > > + struct bpf_hrtimer *t = container_of(work, struct bpf_hrtimer, work); > > + struct bpf_map *map = t-&g

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-16 Thread Benjamin Tissoires
On Feb 15 2024, Benjamin Tissoires wrote: > On Feb 14 2024, Benjamin Tissoires wrote: > > They are implemented as a kfunc, which means a little bit of tweaks in > > the verifier. > > > > Signed-off-by: Benjamin Tissoires > > > > --- > > > > ch

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-16 Thread Benjamin Tissoires
On Feb 16 2024, Toke Høiland-Jørgensen wrote: > Benjamin Tissoires writes: > > > On Feb 15 2024, Martin KaFai Lau wrote: > >> On 2/14/24 9:18 AM, Benjamin Tissoires wrote: > >> > +static void bpf_timer_work_cb(struct work_struct *work) > >>

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-21 Thread Benjamin Tissoires
[replying to both of your messages here] On Wed, Feb 21, 2024 at 3:59 AM Alexei Starovoitov wrote: > > On Fri, Feb 16, 2024 at 10:50:10AM +0100, Benjamin Tissoires wrote: > > static bool is_rbtree_lock_required_kfunc(u32 btf_id) > > { > > return is_bpf

[PATCH RFC bpf-next v3 00/16] sleepable bpf_timer (was: allow HID-BPF to do device IOs)

2024-02-21 Thread Benjamin Tissoires
nd To: Andrii Nakryiko To: Martin KaFai Lau To: Eduard Zingerman To: Song Liu To: Yonghong Song To: KP Singh To: Stanislav Fomichev To: Hao Luo To: Jiri Olsa To: Jiri Kosina To: Benjamin Tissoires To: Jonathan Corbet To: Shuah Khan Cc: Cc: Cc: Cc: Cc: Signed-off-by: Benjamin Tis

[PATCH RFC bpf-next v3 01/16] bpf/verifier: allow more maps in sleepable bpf programs

2024-02-21 Thread Benjamin Tissoires
commands can be retrieved from the sleepable trace point. Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2: - dropped BPF_MAP_TYPE_PROG_ARRAY from the list --- kernel/bpf/verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf

[PATCH RFC bpf-next v3 02/16] bpf/verifier: introduce in_sleepable() helper

2024-02-21 Thread Benjamin Tissoires
No code change, but it'll allow to have only one place to change everything when we add in_sleepable in cur_state. Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2 (compared to the one attaches to v1 0/9): - dropped the cur_state flag, so it can be put first --- k

[PATCH RFC bpf-next v3 03/16] bpf/verifier: add is_async_callback_calling_insn() helper

2024-02-21 Thread Benjamin Tissoires
Currently we have a special case for BPF_FUNC_timer_set_callback, let's introduce a helper we can extend for the kfunc that will come in a later patch Signed-off-by: Benjamin Tissoires --- new in v3 --- kernel/bpf/verifier.c | 11 +++ 1 file changed, 7 insertions(+), 4 dele

[PATCH RFC bpf-next v3 04/16] bpf/helpers: introduce sleepable bpf_timers

2024-02-21 Thread Benjamin Tissoires
They are implemented as a workqueue, which means that there are no guarantees of timing nor ordering. Signed-off-by: Benjamin Tissoires --- changes in v3: - extracted the implementation in bpf_timer only, without bpf_timer_set_sleepable_cb() - rely on schedule_work() only, from

[PATCH RFC bpf-next v3 05/16] bpf/verifier: add bpf_timer as a kfunc capable type

2024-02-21 Thread Benjamin Tissoires
We need to extend the bpf_timer API, but the way forward relies on kfuncs. So make bpf_timer known for kfuncs from the verifier PoV Signed-off-by: Benjamin Tissoires --- new in v3 (split from v2 02/10) --- kernel/bpf/verifier.c | 36 1 file changed, 36

[PATCH RFC bpf-next v3 06/16] bpf/helpers: introduce bpf_timer_set_sleepable_cb() kfunc

2024-02-21 Thread Benjamin Tissoires
teach the verifier about its attached callback. Marking that callback as sleepable will be done in a separate patch Signed-off-by: Benjamin Tissoires --- new in v3 (split from v2 02/10) --- kernel/bpf/helpers.c | 48 ++-- kernel/bpf/verifier.c | 31

[PATCH RFC bpf-next v3 07/16] bpf/helpers: mark the callback of bpf_timer_set_sleepable_cb() as sleepable

2024-02-21 Thread Benjamin Tissoires
Now that we have bpf_timer_set_sleepable_cb() available and working, we can tag the attached callback as sleepable, and let the verifier check in the correct context the calls and kfuncs. Signed-off-by: Benjamin Tissoires --- new in v3 (split from v2 02/10) --- include/linux/bpf_verifier.h

[PATCH RFC bpf-next v3 08/16] bpf/verifier: do_misc_fixups for is_bpf_timer_set_sleepable_cb_kfunc

2024-02-21 Thread Benjamin Tissoires
This is still a WIP, but I think this can be dropped as we never get to this instruction. So what should we do here? Signed-off-by: Benjamin Tissoires --- kernel/bpf/verifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c

[PATCH RFC bpf-next v3 09/16] HID: bpf/dispatch: regroup kfuncs definitions

2024-02-21 Thread Benjamin Tissoires
No code change, just move down the hid_bpf_get_data() kfunc definition so we have only one block of __bpf_kfunc_start/end_defs() Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 80 ++ 1 file

[PATCH RFC bpf-next v3 10/16] HID: bpf: export hid_hw_output_report as a BPF kfunc

2024-02-21 Thread Benjamin Tissoires
We currently only export hid_hw_raw_request() as a BPF kfunc. However, some devices require an explicit write on the Output Report instead of the use of the control channel. So also export hid_hw_output_report to BPF Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2

[PATCH RFC bpf-next v3 11/16] selftests/hid: Add test for hid_bpf_hw_output_report

2024-02-21 Thread Benjamin Tissoires
This time we need to ensure uhid receives it, thus the new mutex and condition. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 63 ++ tools/testing/selftests/hid/progs/hid.c| 24

[PATCH RFC bpf-next v3 12/16] HID: bpf: allow to inject HID event from BPF

2024-02-21 Thread Benjamin Tissoires
device, not just uhid virtual ones. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- Documentation/hid/hid-bpf.rst | 2 +- drivers/hid/bpf/hid_bpf_dispatch.c | 29 + drivers/hid/hid-core.c | 1 + include/linux/hid_bpf.h

[PATCH RFC bpf-next v3 13/16] selftests/hid: add tests for hid_bpf_input_report

2024-02-21 Thread Benjamin Tissoires
Usual way of testing, we call the function and ensures we receive the event Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 49 +- tools/testing/selftests/hid/progs/hid.c| 22

[PATCH RFC bpf-next v3 14/16] HID: bpf: allow to use bpf_timer_set_sleepable_cb() in tracing callbacks.

2024-02-21 Thread Benjamin Tissoires
: Benjamin Tissoires --- no changes in v3 new in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index e1a650f4a626..275f2057c48d 100644 --- a/drivers

[PATCH RFC bpf-next v3 15/16] selftests/hid: add test for bpf_timer

2024-02-21 Thread Benjamin Tissoires
the ring buffer is there to not have sleeps in userspace because we have no guarantees of the timing of when those jobs will be called. Signed-off-by: Benjamin Tissoires --- changes in v3: - amended for the new API changes in v3 new in v2 --- tools/testing/selftests/hid/hid_bpf.c

[PATCH RFC bpf-next v3 16/16] selftests/hid: add KASAN to the VM tests

2024-02-21 Thread Benjamin Tissoires
It's always a good idea to have KASAN in tests. Signed-off-by: Benjamin Tissoires --- new in v3 --- tools/testing/selftests/hid/config.common | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/hid/config.common b/tools/testing/selftests/hid/config.common

Re: [PATCH RFC bpf-next v3 04/16] bpf/helpers: introduce sleepable bpf_timers

2024-02-22 Thread Benjamin Tissoires
On Feb 21 2024, Benjamin Tissoires wrote: > They are implemented as a workqueue, which means that there are no > guarantees of timing nor ordering. > > Signed-off-by: Benjamin Tissoires > > --- > > changes in v3: > - extracted the implementation

Re: [PATCH RFC bpf-next v3 00/16] sleepable bpf_timer (was: allow HID-BPF to do device IOs)

2024-02-23 Thread Benjamin Tissoires
Hi, On Feb 23 2024, Eduard Zingerman wrote: > On Wed, 2024-02-21 at 17:25 +0100, Benjamin Tissoires wrote: > > [Partly a RFC/formal submission: there are still FIXMEs in the code] > > [Also using bpf-next as the base tree for HID changes as there will > > be conflicting chan

Re: [PATCH RFC bpf-next v3 09/16] HID: bpf/dispatch: regroup kfuncs definitions

2024-02-23 Thread Benjamin Tissoires
On Feb 22 2024, Eduard Zingerman wrote: > On Wed, 2024-02-21 at 17:25 +0100, Benjamin Tissoires wrote: > > [...] > > > diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c > > b/drivers/hid/bpf/hid_bpf_dispatch.c > > index e630caf644e8..52abb27426f4 10

Re: [PATCH RFC bpf-next v3 02/16] bpf/verifier: introduce in_sleepable() helper

2024-02-23 Thread Benjamin Tissoires
On Feb 22 2024, Alexei Starovoitov wrote: > On Wed, Feb 21, 2024 at 8:25 AM Benjamin Tissoires wrote: > > @@ -18193,7 +18198,7 @@ static int resolve_pseudo_ldimm64(struct > > bpf_verifier_env *env) > >

Re: [PATCH RFC bpf-next v3 04/16] bpf/helpers: introduce sleepable bpf_timers

2024-02-27 Thread Benjamin Tissoires
On Feb 23 2024, Eduard Zingerman wrote: > On Wed, 2024-02-21 at 17:25 +0100, Benjamin Tissoires wrote: > > [...] > > > @@ -1282,7 +1333,7 @@ BPF_CALL_3(bpf_timer_start, struct bpf_timer_kern *, > > timer, u64, nsecs, u64, fla > > > > if (in_nmi()

Re: [PATCH RFC bpf-next v3 08/16] bpf/verifier: do_misc_fixups for is_bpf_timer_set_sleepable_cb_kfunc

2024-02-27 Thread Benjamin Tissoires
On Feb 23 2024, Eduard Zingerman wrote: > On Wed, 2024-02-21 at 17:25 +0100, Benjamin Tissoires wrote: > > This is still a WIP, but I think this can be dropped as we never > > get to this instruction. So what should we do here? > > As Alexei replied in a separate sub-thread y

Re: [PATCH RFC bpf-next v3 08/16] bpf/verifier: do_misc_fixups for is_bpf_timer_set_sleepable_cb_kfunc

2024-02-27 Thread Benjamin Tissoires
On Tue, Feb 27, 2024 at 5:36 PM Eduard Zingerman wrote: > > On Tue, 2024-02-27 at 17:18 +0100, Benjamin Tissoires wrote: > [...] > > > Hmm, I must still be missing a piece of the puzzle: > > if I declare bpf_timer_set_sleepable_cb() to take a third "aux" > >

Re: [PATCH RFC bpf-next v3 08/16] bpf/verifier: do_misc_fixups for is_bpf_timer_set_sleepable_cb_kfunc

2024-02-28 Thread Benjamin Tissoires
On Wed, Feb 28, 2024 at 2:49 AM Alexei Starovoitov wrote: > > On Tue, Feb 27, 2024 at 8:51 AM Benjamin Tissoires > wrote: > > > > On Tue, Feb 27, 2024 at 5:36 PM Eduard Zingerman wrote: > > > > > > On Tue, 2024-02-27 at 17:18 +0100, Benjamin Tissoires

[PATCH bpf-next v4 0/6] sleepable bpf_timer (was: allow HID-BPF to do device IOs)

2024-03-15 Thread Benjamin Tissoires
german To: Song Liu To: Yonghong Song To: John Fastabend To: KP Singh To: Stanislav Fomichev To: Hao Luo To: Jiri Olsa To: Mykola Lysenko To: Shuah Khan Cc: Benjamin Tissoires Cc: Cc: Cc: --- Changes in v4: - dropped the HID changes, they can go independently from bpf-core - addresse

[PATCH bpf-next v4 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-03-15 Thread Benjamin Tissoires
They are implemented as a workqueue, which means that there are no guarantees of timing nor ordering. Signed-off-by: Benjamin Tissoires --- changes in v4: - dropped __bpf_timer_compute_key() - use a spin_lock instead of a semaphore - ensure bpf_timer_cancel_and_free is not complaining about

[PATCH bpf-next v4 2/6] bpf/verifier: add bpf_timer as a kfunc capable type

2024-03-15 Thread Benjamin Tissoires
We need to extend the bpf_timer API, but the way forward relies on kfuncs. So make bpf_timer known for kfuncs from the verifier PoV Signed-off-by: Benjamin Tissoires --- changes in v4: - enforce KF_ARG_PTR_TO_TIMER to be of type PTR_TO_MAP_VALUE new in v3 (split from v2 02/10) --- kernel/bpf

  1   2   3   4   >