summaryrefslogtreecommitdiffstats
path: root/samples/bpf/syscall_nrs.c
diff options
context:
space:
mode:
authorDavid Daney2017-06-14 01:49:38 +0200
committerDavid S. Miller2017-06-14 21:03:23 +0200
commit4b7190e8416d9238e995da993a7fb851996654e2 (patch)
treecd9223768849c8dc218787198acdc37d4ba2dc17 /samples/bpf/syscall_nrs.c
parentbpf: Add MIPS support to samples/bpf. (diff)
downloadkernel-qcow2-linux-4b7190e8416d9238e995da993a7fb851996654e2.tar.gz
kernel-qcow2-linux-4b7190e8416d9238e995da993a7fb851996654e2.tar.xz
kernel-qcow2-linux-4b7190e8416d9238e995da993a7fb851996654e2.zip
samples/bpf: Fix tracex5 to work with MIPS syscalls.
There are two problems: 1) In MIPS the __NR_* macros expand to an expression, this causes the sections of the object file to be named like: . . . [ 5] kprobe/(5000 + 1) PROGBITS 0000000000000000 000160 ... [ 6] kprobe/(5000 + 0) PROGBITS 0000000000000000 000258 ... [ 7] kprobe/(5000 + 9) PROGBITS 0000000000000000 000348 ... . . . The fix here is to use the "asm_offsets" trick to evaluate the macros in the C compiler and generate a header file with a usable form of the macros. 2) MIPS syscall numbers start at 5000, so we need a bigger map to hold the sub-programs. Signed-off-by: David Daney <david.daney@cavium.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/syscall_nrs.c')
-rw-r--r--samples/bpf/syscall_nrs.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/samples/bpf/syscall_nrs.c b/samples/bpf/syscall_nrs.c
new file mode 100644
index 000000000000..ce2a30b11248
--- /dev/null
+++ b/samples/bpf/syscall_nrs.c
@@ -0,0 +1,12 @@
+#include <uapi/linux/unistd.h>
+#include <linux/kbuild.h>
+
+#define SYSNR(_NR) DEFINE(SYS ## _NR, _NR)
+
+void syscall_defines(void)
+{
+ COMMENT("Linux system call numbers.");
+ SYSNR(__NR_write);
+ SYSNR(__NR_read);
+ SYSNR(__NR_mmap);
+}