summaryrefslogtreecommitdiff
path: root/drivers/hid/bpf/entrypoints/entrypoints.bpf.c
blob: 7c1895d9e5c011f7dc656079c15b7577a9b56db3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2022 Benjamin Tissoires */

#include ".output/vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

#define HID_BPF_MAX_PROGS 1024

extern void call_hid_bpf_prog_put_deferred(struct work_struct *work) __ksym;

struct {
	__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
	__uint(max_entries, HID_BPF_MAX_PROGS);
	__uint(key_size, sizeof(__u32));
	__uint(value_size, sizeof(__u32));
} hid_jmp_table SEC(".maps");

SEC("fmod_ret/__hid_bpf_tail_call")
int BPF_PROG(hid_tail_call, struct hid_bpf_ctx *hctx)
{
	bpf_tail_call(ctx, &hid_jmp_table, hctx->index);

	return 0;
}

SEC("fentry/bpf_prog_put_deferred")
int BPF_PROG(hid_bpf_prog_put_deferred, struct work_struct *work)
{
	call_hid_bpf_prog_put_deferred(work);
	return 0;
}

char LICENSE[] SEC("license") = "GPL";