mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-17 02:36:21 +00:00
fbc90c042c
walkers") is known to cause a performance regression (https://lore.kernel.org/all/3acefad9-96e5-4681-8014-827d6be71c7a@linux.ibm.com/T/#mfa809800a7862fb5bdf834c6f71a3a5113eb83ff). Yu has a fix which I'll send along later via the hotfixes branch. - In the series "mm: Avoid possible overflows in dirty throttling" Jan Kara addresses a couple of issues in the writeback throttling code. These fixes are also targetted at -stable kernels. - Ryusuke Konishi's series "nilfs2: fix potential issues related to reserved inodes" does that. This should actually be in the mm-nonmm-stable tree, along with the many other nilfs2 patches. My bad. - More folio conversions from Kefeng Wang in the series "mm: convert to folio_alloc_mpol()" - Kemeng Shi has sent some cleanups to the writeback code in the series "Add helper functions to remove repeated code and improve readability of cgroup writeback" - Kairui Song has made the swap code a little smaller and a little faster in the series "mm/swap: clean up and optimize swap cache index". - In the series "mm/memory: cleanly support zeropage in vm_insert_page*(), vm_map_pages*() and vmf_insert_mixed()" David Hildenbrand has reworked the rather sketchy handling of the use of the zeropage in MAP_SHARED mappings. I don't see any runtime effects here - more a cleanup/understandability/maintainablity thing. - Dev Jain has improved selftests/mm/va_high_addr_switch.c's handling of higher addresses, for aarch64. The (poorly named) series is "Restructure va_high_addr_switch". - The core TLB handling code gets some cleanups and possible slight optimizations in Bang Li's series "Add update_mmu_tlb_range() to simplify code". - Jane Chu has improved the handling of our fake-an-unrecoverable-memory-error testing feature MADV_HWPOISON in the series "Enhance soft hwpoison handling and injection". - Jeff Johnson has sent a billion patches everywhere to add MODULE_DESCRIPTION() to everything. Some landed in this pull. - In the series "mm: cleanup MIGRATE_SYNC_NO_COPY mode", Kefeng Wang has simplified migration's use of hardware-offload memory copying. - Yosry Ahmed performs more folio API conversions in his series "mm: zswap: trivial folio conversions". - In the series "large folios swap-in: handle refault cases first", Chuanhua Han inches us forward in the handling of large pages in the swap code. This is a cleanup and optimization, working toward the end objective of full support of large folio swapin/out. - In the series "mm,swap: cleanup VMA based swap readahead window calculation", Huang Ying has contributed some cleanups and a possible fixlet to his VMA based swap readahead code. - In the series "add mTHP support for anonymous shmem" Baolin Wang has taught anonymous shmem mappings to use multisize THP. By default this is a no-op - users must opt in vis sysfs controls. Dramatic improvements in pagefault latency are realized. - David Hildenbrand has some cleanups to our remaining use of page_mapcount() in the series "fs/proc: move page_mapcount() to fs/proc/internal.h". - David also has some highmem accounting cleanups in the series "mm/highmem: don't track highmem pages manually". - Build-time fixes and cleanups from John Hubbard in the series "cleanups, fixes, and progress towards avoiding "make headers"". - Cleanups and consolidation of the core pagemap handling from Barry Song in the series "mm: introduce pmd|pte_needs_soft_dirty_wp helpers and utilize them". - Lance Yang's series "Reclaim lazyfree THP without splitting" has reduced the latency of the reclaim of pmd-mapped THPs under fairly common circumstances. A 10x speedup is seen in a microbenchmark. It does this by punting to aother CPU but I guess that's a win unless all CPUs are pegged. - hugetlb_cgroup cleanups from Xiu Jianfeng in the series "mm/hugetlb_cgroup: rework on cftypes". - Miaohe Lin's series "Some cleanups for memory-failure" does just that thing. - Is anyone reading this stuff? If so, email me! - Someone other than SeongJae has developed a DAMON feature in Honggyu Kim's series "DAMON based tiered memory management for CXL memory". This adds DAMON features which may be used to help determine the efficiency of our placement of CXL/PCIe attached DRAM. - DAMON user API centralization and simplificatio work in SeongJae Park's series "mm/damon: introduce DAMON parameters online commit function". - In the series "mm: page_type, zsmalloc and page_mapcount_reset()" David Hildenbrand does some maintenance work on zsmalloc - partially modernizing its use of pageframe fields. - Kefeng Wang provides more folio conversions in the series "mm: remove page_maybe_dma_pinned() and page_mkclean()". - More cleanup from David Hildenbrand, this time in the series "mm/memory_hotplug: use PageOffline() instead of PageReserved() for !ZONE_DEVICE". It "enlightens memory hotplug more about PageOffline() pages" and permits the removal of some virtio-mem hacks. - Barry Song's series "mm: clarify folio_add_new_anon_rmap() and __folio_add_anon_rmap()" is a cleanup to the anon folio handling in preparation for mTHP (multisize THP) swapin. - Kefeng Wang's series "mm: improve clear and copy user folio" implements more folio conversions, this time in the area of large folio userspace copying. - The series "Docs/mm/damon/maintaier-profile: document a mailing tool and community meetup series" tells people how to get better involved with other DAMON developers. From SeongJae Park. - A large series ("kmsan: Enable on s390") from Ilya Leoshkevich does that. - David Hildenbrand sends along more cleanups, this time against the migration code. The series is "mm/migrate: move NUMA hinting fault folio isolation + checks under PTL". - Jan Kara has found quite a lot of strangenesses and minor errors in the readahead code. He addresses this in the series "mm: Fix various readahead quirks". - SeongJae Park's series "selftests/damon: test DAMOS tried regions and {min,max}_nr_regions" adds features and addresses errors in DAMON's self testing code. - Gavin Shan has found a userspace-triggerable WARN in the pagecache code. The series "mm/filemap: Limit page cache size to that supported by xarray" addresses this. The series is marked cc:stable. - Chengming Zhou's series "mm/ksm: cmp_and_merge_page() optimizations and cleanup" cleans up and slightly optimizes KSM. - Roman Gushchin has separated the memcg-v1 and memcg-v2 code - lots of code motion. The series (which also makes the memcg-v1 code Kconfigurable) are "mm: memcg: separate legacy cgroup v1 code and put under config option" and "mm: memcg: put cgroup v1-specific memcg data under CONFIG_MEMCG_V1" - Dan Schatzberg's series "Add swappiness argument to memory.reclaim" adds an additional feature to this cgroup-v2 control file. - The series "Userspace controls soft-offline pages" from Jiaqi Yan permits userspace to stop the kernel's automatic treatment of excessive correctable memory errors. In order to permit userspace to monitor and handle this situation. - Kefeng Wang's series "mm: migrate: support poison recover from migrate folio" teaches the kernel to appropriately handle migration from poisoned source folios rather than simply panicing. - SeongJae Park's series "Docs/damon: minor fixups and improvements" does those things. - In the series "mm/zsmalloc: change back to per-size_class lock" Chengming Zhou improves zsmalloc's scalability and memory utilization. - Vivek Kasireddy's series "mm/gup: Introduce memfd_pin_folios() for pinning memfd folios" makes the GUP code use FOLL_PIN rather than bare refcount increments. So these paes can first be moved aside if they reside in the movable zone or a CMA block. - Andrii Nakryiko has added a binary ioctl()-based API to /proc/pid/maps for much faster reading of vma information. The series is "query VMAs from /proc/<pid>/maps". - In the series "mm: introduce per-order mTHP split counters" Lance Yang improves the kernel's presentation of developer information related to multisize THP splitting. - Michael Ellerman has developed the series "Reimplement huge pages without hugepd on powerpc (8xx, e500, book3s/64)". This permits userspace to use all available huge page sizes. - In the series "revert unconditional slab and page allocator fault injection calls" Vlastimil Babka removes a performance-affecting and not very useful feature from slab fault injection. -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZp2C+QAKCRDdBJ7gKXxA joTkAQDvjqOoFStqk4GU3OXMYB7WCU/ZQMFG0iuu1EEwTVDZ4QEA8CnG7seek1R3 xEoo+vw0sWWeLV3qzsxnCA1BJ8cTJA8= =z0Lf -----END PGP SIGNATURE----- Merge tag 'mm-stable-2024-07-21-14-50' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull MM updates from Andrew Morton: - In the series "mm: Avoid possible overflows in dirty throttling" Jan Kara addresses a couple of issues in the writeback throttling code. These fixes are also targetted at -stable kernels. - Ryusuke Konishi's series "nilfs2: fix potential issues related to reserved inodes" does that. This should actually be in the mm-nonmm-stable tree, along with the many other nilfs2 patches. My bad. - More folio conversions from Kefeng Wang in the series "mm: convert to folio_alloc_mpol()" - Kemeng Shi has sent some cleanups to the writeback code in the series "Add helper functions to remove repeated code and improve readability of cgroup writeback" - Kairui Song has made the swap code a little smaller and a little faster in the series "mm/swap: clean up and optimize swap cache index". - In the series "mm/memory: cleanly support zeropage in vm_insert_page*(), vm_map_pages*() and vmf_insert_mixed()" David Hildenbrand has reworked the rather sketchy handling of the use of the zeropage in MAP_SHARED mappings. I don't see any runtime effects here - more a cleanup/understandability/maintainablity thing. - Dev Jain has improved selftests/mm/va_high_addr_switch.c's handling of higher addresses, for aarch64. The (poorly named) series is "Restructure va_high_addr_switch". - The core TLB handling code gets some cleanups and possible slight optimizations in Bang Li's series "Add update_mmu_tlb_range() to simplify code". - Jane Chu has improved the handling of our fake-an-unrecoverable-memory-error testing feature MADV_HWPOISON in the series "Enhance soft hwpoison handling and injection". - Jeff Johnson has sent a billion patches everywhere to add MODULE_DESCRIPTION() to everything. Some landed in this pull. - In the series "mm: cleanup MIGRATE_SYNC_NO_COPY mode", Kefeng Wang has simplified migration's use of hardware-offload memory copying. - Yosry Ahmed performs more folio API conversions in his series "mm: zswap: trivial folio conversions". - In the series "large folios swap-in: handle refault cases first", Chuanhua Han inches us forward in the handling of large pages in the swap code. This is a cleanup and optimization, working toward the end objective of full support of large folio swapin/out. - In the series "mm,swap: cleanup VMA based swap readahead window calculation", Huang Ying has contributed some cleanups and a possible fixlet to his VMA based swap readahead code. - In the series "add mTHP support for anonymous shmem" Baolin Wang has taught anonymous shmem mappings to use multisize THP. By default this is a no-op - users must opt in vis sysfs controls. Dramatic improvements in pagefault latency are realized. - David Hildenbrand has some cleanups to our remaining use of page_mapcount() in the series "fs/proc: move page_mapcount() to fs/proc/internal.h". - David also has some highmem accounting cleanups in the series "mm/highmem: don't track highmem pages manually". - Build-time fixes and cleanups from John Hubbard in the series "cleanups, fixes, and progress towards avoiding "make headers"". - Cleanups and consolidation of the core pagemap handling from Barry Song in the series "mm: introduce pmd|pte_needs_soft_dirty_wp helpers and utilize them". - Lance Yang's series "Reclaim lazyfree THP without splitting" has reduced the latency of the reclaim of pmd-mapped THPs under fairly common circumstances. A 10x speedup is seen in a microbenchmark. It does this by punting to aother CPU but I guess that's a win unless all CPUs are pegged. - hugetlb_cgroup cleanups from Xiu Jianfeng in the series "mm/hugetlb_cgroup: rework on cftypes". - Miaohe Lin's series "Some cleanups for memory-failure" does just that thing. - Someone other than SeongJae has developed a DAMON feature in Honggyu Kim's series "DAMON based tiered memory management for CXL memory". This adds DAMON features which may be used to help determine the efficiency of our placement of CXL/PCIe attached DRAM. - DAMON user API centralization and simplificatio work in SeongJae Park's series "mm/damon: introduce DAMON parameters online commit function". - In the series "mm: page_type, zsmalloc and page_mapcount_reset()" David Hildenbrand does some maintenance work on zsmalloc - partially modernizing its use of pageframe fields. - Kefeng Wang provides more folio conversions in the series "mm: remove page_maybe_dma_pinned() and page_mkclean()". - More cleanup from David Hildenbrand, this time in the series "mm/memory_hotplug: use PageOffline() instead of PageReserved() for !ZONE_DEVICE". It "enlightens memory hotplug more about PageOffline() pages" and permits the removal of some virtio-mem hacks. - Barry Song's series "mm: clarify folio_add_new_anon_rmap() and __folio_add_anon_rmap()" is a cleanup to the anon folio handling in preparation for mTHP (multisize THP) swapin. - Kefeng Wang's series "mm: improve clear and copy user folio" implements more folio conversions, this time in the area of large folio userspace copying. - The series "Docs/mm/damon/maintaier-profile: document a mailing tool and community meetup series" tells people how to get better involved with other DAMON developers. From SeongJae Park. - A large series ("kmsan: Enable on s390") from Ilya Leoshkevich does that. - David Hildenbrand sends along more cleanups, this time against the migration code. The series is "mm/migrate: move NUMA hinting fault folio isolation + checks under PTL". - Jan Kara has found quite a lot of strangenesses and minor errors in the readahead code. He addresses this in the series "mm: Fix various readahead quirks". - SeongJae Park's series "selftests/damon: test DAMOS tried regions and {min,max}_nr_regions" adds features and addresses errors in DAMON's self testing code. - Gavin Shan has found a userspace-triggerable WARN in the pagecache code. The series "mm/filemap: Limit page cache size to that supported by xarray" addresses this. The series is marked cc:stable. - Chengming Zhou's series "mm/ksm: cmp_and_merge_page() optimizations and cleanup" cleans up and slightly optimizes KSM. - Roman Gushchin has separated the memcg-v1 and memcg-v2 code - lots of code motion. The series (which also makes the memcg-v1 code Kconfigurable) are "mm: memcg: separate legacy cgroup v1 code and put under config option" and "mm: memcg: put cgroup v1-specific memcg data under CONFIG_MEMCG_V1" - Dan Schatzberg's series "Add swappiness argument to memory.reclaim" adds an additional feature to this cgroup-v2 control file. - The series "Userspace controls soft-offline pages" from Jiaqi Yan permits userspace to stop the kernel's automatic treatment of excessive correctable memory errors. In order to permit userspace to monitor and handle this situation. - Kefeng Wang's series "mm: migrate: support poison recover from migrate folio" teaches the kernel to appropriately handle migration from poisoned source folios rather than simply panicing. - SeongJae Park's series "Docs/damon: minor fixups and improvements" does those things. - In the series "mm/zsmalloc: change back to per-size_class lock" Chengming Zhou improves zsmalloc's scalability and memory utilization. - Vivek Kasireddy's series "mm/gup: Introduce memfd_pin_folios() for pinning memfd folios" makes the GUP code use FOLL_PIN rather than bare refcount increments. So these paes can first be moved aside if they reside in the movable zone or a CMA block. - Andrii Nakryiko has added a binary ioctl()-based API to /proc/pid/maps for much faster reading of vma information. The series is "query VMAs from /proc/<pid>/maps". - In the series "mm: introduce per-order mTHP split counters" Lance Yang improves the kernel's presentation of developer information related to multisize THP splitting. - Michael Ellerman has developed the series "Reimplement huge pages without hugepd on powerpc (8xx, e500, book3s/64)". This permits userspace to use all available huge page sizes. - In the series "revert unconditional slab and page allocator fault injection calls" Vlastimil Babka removes a performance-affecting and not very useful feature from slab fault injection. * tag 'mm-stable-2024-07-21-14-50' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (411 commits) mm/mglru: fix ineffective protection calculation mm/zswap: fix a white space issue mm/hugetlb: fix kernel NULL pointer dereference when migrating hugetlb folio mm/hugetlb: fix possible recursive locking detected warning mm/gup: clear the LRU flag of a page before adding to LRU batch mm/numa_balancing: teach mpol_to_str about the balancing mode mm: memcg1: convert charge move flags to unsigned long long alloc_tag: fix page_ext_get/page_ext_put sequence during page splitting lib: reuse page_ext_data() to obtain codetag_ref lib: add missing newline character in the warning message mm/mglru: fix overshooting shrinker memory mm/mglru: fix div-by-zero in vmpressure_calc_level() mm/kmemleak: replace strncpy() with strscpy() mm, page_alloc: put should_fail_alloc_page() back behing CONFIG_FAIL_PAGE_ALLOC mm, slab: put should_failslab() back behind CONFIG_SHOULD_FAILSLAB mm: ignore data-race in __swap_writepage hugetlbfs: ensure generic_hugetlb_get_unmapped_area() returns higher address than mmap_min_addr mm: shmem: rename mTHP shmem counters mm: swap_state: use folio_alloc_mpol() in __read_swap_cache_async() mm/migrate: putback split folios when numa hint migration fails ...
242 lines
8.3 KiB
C
242 lines
8.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
#ifndef __HID_BPF_H
|
|
#define __HID_BPF_H
|
|
|
|
#include <linux/bpf.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/srcu.h>
|
|
#include <uapi/linux/hid.h>
|
|
|
|
struct hid_device;
|
|
|
|
/*
|
|
* The following is the user facing HID BPF API.
|
|
*
|
|
* Extra care should be taken when editing this part, as
|
|
* it might break existing out of the tree bpf programs.
|
|
*/
|
|
|
|
/**
|
|
* struct hid_bpf_ctx - User accessible data for all HID programs
|
|
*
|
|
* ``data`` is not directly accessible from the context. We need to issue
|
|
* a call to hid_bpf_get_data() in order to get a pointer to that field.
|
|
*
|
|
* @hid: the &struct hid_device representing the device itself
|
|
* @allocated_size: Allocated size of data.
|
|
*
|
|
* This is how much memory is available and can be requested
|
|
* by the HID program.
|
|
* Note that for ``HID_BPF_RDESC_FIXUP``, that memory is set to
|
|
* ``4096`` (4 KB)
|
|
* @size: Valid data in the data field.
|
|
*
|
|
* Programs can get the available valid size in data by fetching this field.
|
|
* Programs can also change this value by returning a positive number in the
|
|
* program.
|
|
* To discard the event, return a negative error code.
|
|
*
|
|
* ``size`` must always be less or equal than ``allocated_size`` (it is enforced
|
|
* once all BPF programs have been run).
|
|
* @retval: Return value of the previous program.
|
|
*
|
|
* ``hid`` and ``allocated_size`` are read-only, ``size`` and ``retval`` are read-write.
|
|
*/
|
|
struct hid_bpf_ctx {
|
|
struct hid_device *hid;
|
|
__u32 allocated_size;
|
|
union {
|
|
__s32 retval;
|
|
__s32 size;
|
|
};
|
|
};
|
|
|
|
/*
|
|
* Below is HID internal
|
|
*/
|
|
|
|
#define HID_BPF_MAX_PROGS_PER_DEV 64
|
|
#define HID_BPF_FLAG_MASK (((HID_BPF_FLAG_MAX - 1) << 1) - 1)
|
|
|
|
|
|
struct hid_report_enum;
|
|
|
|
struct hid_ops {
|
|
struct hid_report *(*hid_get_report)(struct hid_report_enum *report_enum, const u8 *data);
|
|
int (*hid_hw_raw_request)(struct hid_device *hdev,
|
|
unsigned char reportnum, __u8 *buf,
|
|
size_t len, enum hid_report_type rtype,
|
|
enum hid_class_request reqtype,
|
|
u64 source, bool from_bpf);
|
|
int (*hid_hw_output_report)(struct hid_device *hdev, __u8 *buf, size_t len,
|
|
u64 source, bool from_bpf);
|
|
int (*hid_input_report)(struct hid_device *hid, enum hid_report_type type,
|
|
u8 *data, u32 size, int interrupt, u64 source, bool from_bpf,
|
|
bool lock_already_taken);
|
|
struct module *owner;
|
|
const struct bus_type *bus_type;
|
|
};
|
|
|
|
extern struct hid_ops *hid_ops;
|
|
|
|
/**
|
|
* struct hid_bpf_ops - A BPF struct_ops of callbacks allowing to attach HID-BPF
|
|
* programs to a HID device
|
|
* @hid_id: the HID uniq ID to attach to. This is writeable before ``load()``, and
|
|
* cannot be changed after
|
|
* @flags: flags used while attaching the struct_ops to the device. Currently only
|
|
* available value is %0 or ``BPF_F_BEFORE``.
|
|
* Writeable only before ``load()``
|
|
*/
|
|
struct hid_bpf_ops {
|
|
/* hid_id needs to stay first so we can easily change it
|
|
* from userspace.
|
|
*/
|
|
int hid_id;
|
|
u32 flags;
|
|
|
|
/* private: do not show up in the docs */
|
|
struct list_head list;
|
|
|
|
/* public: rest should show up in the docs */
|
|
|
|
/**
|
|
* @hid_device_event: called whenever an event is coming in from the device
|
|
*
|
|
* It has the following arguments:
|
|
*
|
|
* ``ctx``: The HID-BPF context as &struct hid_bpf_ctx
|
|
*
|
|
* Return: %0 on success and keep processing; a positive
|
|
* value to change the incoming size buffer; a negative
|
|
* error code to interrupt the processing of this event
|
|
*
|
|
* Context: Interrupt context.
|
|
*/
|
|
int (*hid_device_event)(struct hid_bpf_ctx *ctx, enum hid_report_type report_type,
|
|
u64 source);
|
|
|
|
/**
|
|
* @hid_rdesc_fixup: called when the probe function parses the report descriptor
|
|
* of the HID device
|
|
*
|
|
* It has the following arguments:
|
|
*
|
|
* ``ctx``: The HID-BPF context as &struct hid_bpf_ctx
|
|
*
|
|
* Return: %0 on success and keep processing; a positive
|
|
* value to change the incoming size buffer; a negative
|
|
* error code to interrupt the processing of this device
|
|
*/
|
|
int (*hid_rdesc_fixup)(struct hid_bpf_ctx *ctx);
|
|
|
|
/**
|
|
* @hid_hw_request: called whenever a hid_hw_raw_request() call is emitted
|
|
* on the HID device
|
|
*
|
|
* It has the following arguments:
|
|
*
|
|
* ``ctx``: The HID-BPF context as &struct hid_bpf_ctx
|
|
*
|
|
* ``reportnum``: the report number, as in hid_hw_raw_request()
|
|
*
|
|
* ``rtype``: the report type (``HID_INPUT_REPORT``, ``HID_FEATURE_REPORT``,
|
|
* ``HID_OUTPUT_REPORT``)
|
|
*
|
|
* ``reqtype``: the request
|
|
*
|
|
* ``source``: a u64 referring to a uniq but identifiable source. If %0, the
|
|
* kernel itself emitted that call. For hidraw, ``source`` is set
|
|
* to the associated ``struct file *``.
|
|
*
|
|
* Return: %0 to keep processing the request by hid-core; any other value
|
|
* stops hid-core from processing that event. A positive value should be
|
|
* returned with the number of bytes returned in the incoming buffer; a
|
|
* negative error code interrupts the processing of this call.
|
|
*/
|
|
int (*hid_hw_request)(struct hid_bpf_ctx *ctx, unsigned char reportnum,
|
|
enum hid_report_type rtype, enum hid_class_request reqtype,
|
|
u64 source);
|
|
|
|
/**
|
|
* @hid_hw_output_report: called whenever a hid_hw_output_report() call is emitted
|
|
* on the HID device
|
|
*
|
|
* It has the following arguments:
|
|
*
|
|
* ``ctx``: The HID-BPF context as &struct hid_bpf_ctx
|
|
*
|
|
* ``source``: a u64 referring to a uniq but identifiable source. If %0, the
|
|
* kernel itself emitted that call. For hidraw, ``source`` is set
|
|
* to the associated ``struct file *``.
|
|
*
|
|
* Return: %0 to keep processing the request by hid-core; any other value
|
|
* stops hid-core from processing that event. A positive value should be
|
|
* returned with the number of bytes written to the device; a negative error
|
|
* code interrupts the processing of this call.
|
|
*/
|
|
int (*hid_hw_output_report)(struct hid_bpf_ctx *ctx, u64 source);
|
|
|
|
|
|
/* private: do not show up in the docs */
|
|
struct hid_device *hdev;
|
|
};
|
|
|
|
/* stored in each device */
|
|
struct hid_bpf {
|
|
u8 *device_data; /* allocated when a bpf program of type
|
|
* SEC(f.../hid_bpf_device_event) has been attached
|
|
* to this HID device
|
|
*/
|
|
u32 allocated_data;
|
|
bool destroyed; /* prevents the assignment of any progs */
|
|
|
|
struct hid_bpf_ops *rdesc_ops;
|
|
struct list_head prog_list;
|
|
struct mutex prog_list_lock; /* protects prog_list update */
|
|
struct srcu_struct srcu; /* protects prog_list read-only access */
|
|
};
|
|
|
|
#ifdef CONFIG_HID_BPF
|
|
u8 *dispatch_hid_bpf_device_event(struct hid_device *hid, enum hid_report_type type, u8 *data,
|
|
u32 *size, int interrupt, u64 source, bool from_bpf);
|
|
int dispatch_hid_bpf_raw_requests(struct hid_device *hdev,
|
|
unsigned char reportnum, __u8 *buf,
|
|
u32 size, enum hid_report_type rtype,
|
|
enum hid_class_request reqtype,
|
|
u64 source, bool from_bpf);
|
|
int dispatch_hid_bpf_output_report(struct hid_device *hdev, __u8 *buf, u32 size,
|
|
u64 source, bool from_bpf);
|
|
int hid_bpf_connect_device(struct hid_device *hdev);
|
|
void hid_bpf_disconnect_device(struct hid_device *hdev);
|
|
void hid_bpf_destroy_device(struct hid_device *hid);
|
|
int hid_bpf_device_init(struct hid_device *hid);
|
|
u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size);
|
|
#else /* CONFIG_HID_BPF */
|
|
static inline u8 *dispatch_hid_bpf_device_event(struct hid_device *hid, enum hid_report_type type,
|
|
u8 *data, u32 *size, int interrupt,
|
|
u64 source, bool from_bpf) { return data; }
|
|
static inline int dispatch_hid_bpf_raw_requests(struct hid_device *hdev,
|
|
unsigned char reportnum, u8 *buf,
|
|
u32 size, enum hid_report_type rtype,
|
|
enum hid_class_request reqtype,
|
|
u64 source, bool from_bpf) { return 0; }
|
|
static inline int dispatch_hid_bpf_output_report(struct hid_device *hdev, __u8 *buf, u32 size,
|
|
u64 source, bool from_bpf) { return 0; }
|
|
static inline int hid_bpf_connect_device(struct hid_device *hdev) { return 0; }
|
|
static inline void hid_bpf_disconnect_device(struct hid_device *hdev) {}
|
|
static inline void hid_bpf_destroy_device(struct hid_device *hid) {}
|
|
static inline int hid_bpf_device_init(struct hid_device *hid) { return 0; }
|
|
/*
|
|
* This specialized allocator has to be a macro for its allocations to be
|
|
* accounted separately (to have a separate alloc_tag). The typecast is
|
|
* intentional to enforce typesafety.
|
|
*/
|
|
#define call_hid_bpf_rdesc_fixup(_hdev, _rdesc, _size) \
|
|
((u8 *)kmemdup(_rdesc, *(_size), GFP_KERNEL))
|
|
|
|
#endif /* CONFIG_HID_BPF */
|
|
|
|
#endif /* __HID_BPF_H */
|