On Tue, Oct 25, 2022 at 11:52 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Tue, Oct 25, 2022 at 11:34:46AM +0200, Benjamin Tissoires wrote: > > include/linux/hid.h | 5 + > > include/linux/hid_bpf.h | 102 +++ > > include/uapi/linux/hid_bpf.h | 25 + > > tools/include/uapi/linux/hid.h | 62 ++ > > tools/include/uapi/linux/hid_bpf.h | 25 + > > ... > > > +++ b/include/linux/hid_bpf.h > > @@ -0,0 +1,102 @@ > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > + > > +#ifndef __HID_BPF_H > > +#define __HID_BPF_H > > + > > +#include <linux/spinlock.h> > > +#include <uapi/linux/hid.h> > > +#include <uapi/linux/hid_bpf.h> > > + > > +struct hid_device; > > + > > +/* > > + * The following is the HID BPF API. > > + * > > + * It should be treated as UAPI, so extra care is required > > + * when making change to this file. > > + */ > > I thought at the maintainer summit we discussed that it shouldn't be > treated as uapi. There is no need to draw this line right now. > If the whole concept turns out to be useful and api is stable > then promote it. I'd still like to keep the kfunc API explicitly marked as "danger zone". I want to let contributors know that changing this part has an impact on the existing available bpf programs that are out of the tree (the HID firewall for instance might be out of the tree). I'll reword it to not mark it as uapi though. > > > +++ b/include/uapi/linux/hid_bpf.h > > @@ -0,0 +1,25 @@ > > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > > + > > +#ifndef _UAPI_HID_BPF_H > > +#define _UAPI_HID_BPF_H > > + > > +#include <linux/const.h> > > +#include <linux/hid.h> > > + > > +/** > > + * enum hid_bpf_attach_flags - flags used when attaching a HIF-BPF program > > + * > > + * @HID_BPF_FLAG_NONE: no specific flag is used, the kernel choses where to > > + * insert the program > > + * @HID_BPF_FLAG_INSERT_HEAD: insert the given program before any other program > > + * currently attached to the device. This doesn't > > + * guarantee that this program will always be first > > + * @HID_BPF_FLAG_MAX: sentinel value, not to be used by the callers > > + */ > > +enum hid_bpf_attach_flags { > > + HID_BPF_FLAG_NONE = 0, > > + HID_BPF_FLAG_INSERT_HEAD = _BITUL(0), > > + HID_BPF_FLAG_MAX, > > +}; > > + > > +#endif /* _UAPI_HID_BPF_H */ > > Not sure what is the purpose of this uapi file. > Since it's enum the progs can get it from vmlinux.h. Good point. It can easily go into the non uapi hid_bpf.h > > > diff --git a/tools/include/uapi/linux/hid.h b/tools/include/uapi/linux/hid.h > > new file mode 100644 > > index 000000000000..3e63bea3b3e2 > > --- /dev/null > > +++ b/tools/include/uapi/linux/hid.h > > @@ -0,0 +1,62 @@ > > +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ > > +/* > > + * Copyright (c) 1999 Andreas Gal > > + * Copyright (c) 2000-2001 Vojtech Pavlik > > + * Copyright (c) 2006-2007 Jiri Kosina > > + */ > > +#ifndef _UAPI__HID_H > > +#define _UAPI__HID_H > > This is a copy of include/uapi/linux/hid.h ? Yes it is > Probably should be a separate commit to make it obvious. > I'll need to assess why I needed that. I think it was related to the selftests, but now that they are in selftests/hid, I can probably have a special include in the Makefile to not have to duplicate the file at all. Thanks for the review :) Cheers, Benjamin