From: "Arnd Bergmann" <arnd@arndb.de>
To: "Benjamin Tissoires" <bentiss@kernel.org>,
"Arnd Bergmann" <arnd@kernel.org>
Cc: "Jiri Kosina" <jikos@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH] hid: bpf: avoid building struct ops without JIT
Date: Fri, 19 Jul 2024 16:34:44 +0200 [thread overview]
Message-ID: <96a00b6f-eb81-4c67-8c4b-6b1f3f045034@app.fastmail.com> (raw)
In-Reply-To: <gf7t6iyj3ueewvbbmqo2ypzitiy6bvnzj2l6tgccvi22xe5fgm@xvlbq3vkndgr>
On Fri, Jul 19, 2024, at 15:52, Benjamin Tissoires wrote:
> On Jul 19 2024, Arnd Bergmann wrote:
>>
>> This could be avoided by making HID-BPF just depend on JIT, but that
>> is probably not what we want here. Checking the other users of struct_ops,
>> I see that those just leave out the struct_ops usage, so do the same here.
>
> Actually, if we make the struct_ops part only depend on JIT HID-BPF is
> kind of moot. All we could do is use HID-BPF to communicate with the
> device, without getting any feedback, so nothing much more than what
> hidraw provides.
>
> The only "interesting" bit we could do is inject a new event on a device
> as if it were originated from the device itself, but I really do not see
> the point without the struct_ops hooks.
>
> So I think struct_ops is now the base for HID-BPF, and if it's not
> available, we should not have HID-BPF at all.
>
Ok, got it. So my original patch was correct after all.
I had tried this version and then discarded it.
Arnd
8<------
Subject: [PATCH] hid: bpf: add BPF_JIT dependency
The module does not do anything when the JIT is disabled, but instead
causes a warning:
In file included from include/linux/bpf_verifier.h:7,
from drivers/hid/bpf/hid_bpf_struct_ops.c:10:
drivers/hid/bpf/hid_bpf_struct_ops.c: In function 'hid_bpf_struct_ops_init':
include/linux/bpf.h:1853:50: error: statement with no effect [-Werror=unused-value]
1853 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
| ^~~~~~~~~~~~~~~~
drivers/hid/bpf/hid_bpf_struct_ops.c:305:16: note: in expansion of macro 'register_bpf_struct_ops'
305 | return register_bpf_struct_ops(&bpf_hid_bpf_ops, hid_bpf_ops);
| ^~~~~~~~~~~~~~~~~~~~~~~
Add a Kconfig dependency to only allow building the HID-BPF support
when a JIT is enabled.
Fixes: ebc0d8093e8c ("HID: bpf: implement HID-BPF through bpf_struct_ops")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
----
diff --git a/drivers/hid/bpf/Kconfig b/drivers/hid/bpf/Kconfig
index 83214bae6768..d65482e02a6c 100644
--- a/drivers/hid/bpf/Kconfig
+++ b/drivers/hid/bpf/Kconfig
@@ -3,7 +3,7 @@ menu "HID-BPF support"
config HID_BPF
bool "HID-BPF support"
- depends on BPF
+ depends on BPF_JIT
depends on BPF_SYSCALL
depends on DYNAMIC_FTRACE_WITH_DIRECT_CALLS
help
next prev parent reply other threads:[~2024-07-19 14:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 9:51 [PATCH] hid: bpf: avoid building struct ops without JIT Arnd Bergmann
2024-07-19 13:52 ` Benjamin Tissoires
2024-07-19 14:34 ` Arnd Bergmann [this message]
2024-07-22 16:10 ` Benjamin Tissoires
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=96a00b6f-eb81-4c67-8c4b-6b1f3f045034@app.fastmail.com \
--to=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=ast@kernel.org \
--cc=bentiss@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).