Innovative HID-BPF Expected To Land In Linux 6.2
Adding to the growing list of changes expected to be sent in during the Linux 6.2 merge window next month is HID-BPF. This is the Red Hat led effort around using eBPF within the HID subsystem for input devices.
The idea with HID-BPF is that it could be more easily and rapidly used for deploying quirks/workarounds for devices not properly confirming to the HID specification. As it is now, tiny Linux kernel drivers often come about for dealing with quirky/buggy HID devices not conforming to the protocol to just workaround the problematic behavior. Rather than having to come up with a driver patch or new driver just for simple cases like fixing HID report descriptors, an eBPF program could be loaded into the kernel. In turn it should be easier to distribute these eBPF programs for fixing HID issues rather than having users wait on a new kernel version or for a back-port to happen to a particular kernel version.
HID-BPF has been worked on for a while now by Red Hat engineers and other upstream kernel developers. Among the envisioned uses at this stage for HID-BPF are dealing with dead zones of a joystick, simple fixes for HID descriptors, new features that require a new kernel API like USI pens, morphing a device into something else and controlling it from user-space, a device "firewall" by intercepting and preventing certain HID commands from being emitted, and tracing events.
More details on HID-BPF can be found via the proposed documentation.
As of today the initial HID-BPF patches were picked up by the HID subsystem's "for-next" branch. So barring any last minute issues from coming up that lead to these patches being dropped from the tree or critiquing by Linus Torvalds during the merge window, HID-BPF is then expected to be merged for the Linux 6.2 cycle kicking off in December.
Along with the eBPF integration for the HID subsystem, there is a BPF example added where the X and Y axis are swapped and inverted for the targeted device. Another HID-BPF example for demonstrating this code in Linux 6.2 is a HID program for the Microsoft Surface Dial. That BPF program will morph the Microsoft Surface Dial into a mouse.
The idea with HID-BPF is that it could be more easily and rapidly used for deploying quirks/workarounds for devices not properly confirming to the HID specification. As it is now, tiny Linux kernel drivers often come about for dealing with quirky/buggy HID devices not conforming to the protocol to just workaround the problematic behavior. Rather than having to come up with a driver patch or new driver just for simple cases like fixing HID report descriptors, an eBPF program could be loaded into the kernel. In turn it should be easier to distribute these eBPF programs for fixing HID issues rather than having users wait on a new kernel version or for a back-port to happen to a particular kernel version.
HID-BPF has been worked on for a while now by Red Hat engineers and other upstream kernel developers. Among the envisioned uses at this stage for HID-BPF are dealing with dead zones of a joystick, simple fixes for HID descriptors, new features that require a new kernel API like USI pens, morphing a device into something else and controlling it from user-space, a device "firewall" by intercepting and preventing certain HID commands from being emitted, and tracing events.
More details on HID-BPF can be found via the proposed documentation.
As of today the initial HID-BPF patches were picked up by the HID subsystem's "for-next" branch. So barring any last minute issues from coming up that lead to these patches being dropped from the tree or critiquing by Linus Torvalds during the merge window, HID-BPF is then expected to be merged for the Linux 6.2 cycle kicking off in December.
Microsoft image of their Surface Dial input device.
Along with the eBPF integration for the HID subsystem, there is a BPF example added where the X and Y axis are swapped and inverted for the targeted device. Another HID-BPF example for demonstrating this code in Linux 6.2 is a HID program for the Microsoft Surface Dial. That BPF program will morph the Microsoft Surface Dial into a mouse.
10 Comments