xref: /linux/tools/perf/util/bpf-prologue.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2bfc077b4SHe Kuang /*
3bfc077b4SHe Kuang  * Copyright (C) 2015, He Kuang <hekuang@huawei.com>
4bfc077b4SHe Kuang  * Copyright (C) 2015, Huawei Inc.
5bfc077b4SHe Kuang  */
6bfc077b4SHe Kuang #ifndef __BPF_PROLOGUE_H
7bfc077b4SHe Kuang #define __BPF_PROLOGUE_H
8bfc077b4SHe Kuang 
9*8d0d129eSArnaldo Carvalho de Melo struct probe_trace_arg;
10*8d0d129eSArnaldo Carvalho de Melo struct bpf_insn;
11bfc077b4SHe Kuang 
12bfc077b4SHe Kuang #define BPF_PROLOGUE_MAX_ARGS 3
13bfc077b4SHe Kuang #define BPF_PROLOGUE_START_ARG_REG BPF_REG_3
14bfc077b4SHe Kuang #define BPF_PROLOGUE_FETCH_RESULT_REG BPF_REG_2
15bfc077b4SHe Kuang 
16bfc077b4SHe Kuang #ifdef HAVE_BPF_PROLOGUE
17bfc077b4SHe Kuang int bpf__gen_prologue(struct probe_trace_arg *args, int nargs,
18bfc077b4SHe Kuang 		      struct bpf_insn *new_prog, size_t *new_cnt,
19bfc077b4SHe Kuang 		      size_t cnt_space);
20bfc077b4SHe Kuang #else
21*8d0d129eSArnaldo Carvalho de Melo #include <linux/compiler.h>
22a43783aeSArnaldo Carvalho de Melo #include <errno.h>
23a43783aeSArnaldo Carvalho de Melo 
24bfc077b4SHe Kuang static inline int
bpf__gen_prologue(struct probe_trace_arg * args __maybe_unused,int nargs __maybe_unused,struct bpf_insn * new_prog __maybe_unused,size_t * new_cnt,size_t cnt_space __maybe_unused)25bfc077b4SHe Kuang bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused,
26bfc077b4SHe Kuang 		  int nargs __maybe_unused,
27bfc077b4SHe Kuang 		  struct bpf_insn *new_prog __maybe_unused,
28bfc077b4SHe Kuang 		  size_t *new_cnt,
29bfc077b4SHe Kuang 		  size_t cnt_space __maybe_unused)
30bfc077b4SHe Kuang {
31bfc077b4SHe Kuang 	if (!new_cnt)
32bfc077b4SHe Kuang 		return -EINVAL;
33bfc077b4SHe Kuang 	*new_cnt = 0;
34bfc077b4SHe Kuang 	return -ENOTSUP;
35bfc077b4SHe Kuang }
36bfc077b4SHe Kuang #endif
37bfc077b4SHe Kuang #endif /* __BPF_PROLOGUE_H */
38