diff options
author | Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | 2017-12-04 04:56:44 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2017-12-05 09:02:40 -0500 |
commit | c895f6f703ad7dd2f99e751d9884b0aa5d0eea25 (patch) | |
tree | 38c78d2344e471e1e926c893120f16015a405b26 | |
parent | 2391f0b4808e3d5af348324d69f5f45c56a26836 (diff) |
bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type
Commit 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT
program type") introduced the bpf_perf_event_data structure which
exports the pt_regs structure. This is OK for multiple architectures
but fail for s390 and arm64 which do not export pt_regs. Programs
using them, for example, the bpf selftest fail to compile on these
architectures.
For s390, exporting the pt_regs is not an option because s390 wants
to allow changes to it. For arm64, there is a user_pt_regs structure
that covers parts of the pt_regs structure for use by user space.
To solve the broken uapi for s390 and arm64, introduce an abstract
type for pt_regs and add an asm/bpf_perf_event.h file that concretes
the type. An asm-generic header file covers the architectures that
export pt_regs today.
The arch-specific enablement for s390 and arm64 follows in separate
commits.
Reported-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Fixes: 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type")
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
32 files changed, 47 insertions, 5 deletions
diff --git a/arch/alpha/include/uapi/asm/Kbuild b/arch/alpha/include/uapi/asm/Kbuild index b15bf6bc0e94..14a2e9af97e9 100644 --- a/arch/alpha/include/uapi/asm/Kbuild +++ b/arch/alpha/include/uapi/asm/Kbuild | |||
@@ -1,2 +1,4 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | |||
4 | generic-y += bpf_perf_event.h | ||
diff --git a/arch/arc/include/uapi/asm/Kbuild b/arch/arc/include/uapi/asm/Kbuild index fa6d0ff4ff89..170b5db64afe 100644 --- a/arch/arc/include/uapi/asm/Kbuild +++ b/arch/arc/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/arm/include/uapi/asm/Kbuild b/arch/arm/include/uapi/asm/Kbuild index 4d53de308ee0..4d1cc1847edf 100644 --- a/arch/arm/include/uapi/asm/Kbuild +++ b/arch/arm/include/uapi/asm/Kbuild | |||
@@ -7,6 +7,7 @@ generated-y += unistd-oabi.h | |||
7 | generated-y += unistd-eabi.h | 7 | generated-y += unistd-eabi.h |
8 | 8 | ||
9 | generic-y += bitsperlong.h | 9 | generic-y += bitsperlong.h |
10 | generic-y += bpf_perf_event.h | ||
10 | generic-y += errno.h | 11 | generic-y += errno.h |
11 | generic-y += ioctl.h | 12 | generic-y += ioctl.h |
12 | generic-y += ipcbuf.h | 13 | generic-y += ipcbuf.h |
diff --git a/arch/blackfin/include/uapi/asm/Kbuild b/arch/blackfin/include/uapi/asm/Kbuild index aa624b4ab655..2240b38c2915 100644 --- a/arch/blackfin/include/uapi/asm/Kbuild +++ b/arch/blackfin/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
8 | generic-y += ipcbuf.h | 9 | generic-y += ipcbuf.h |
diff --git a/arch/c6x/include/uapi/asm/Kbuild b/arch/c6x/include/uapi/asm/Kbuild index 67ee896a76a7..26644e15d854 100644 --- a/arch/c6x/include/uapi/asm/Kbuild +++ b/arch/c6x/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/cris/include/uapi/asm/Kbuild b/arch/cris/include/uapi/asm/Kbuild index 3687b54bb18e..3470c6e9c7b9 100644 --- a/arch/cris/include/uapi/asm/Kbuild +++ b/arch/cris/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/frv/include/uapi/asm/Kbuild b/arch/frv/include/uapi/asm/Kbuild index b15bf6bc0e94..14a2e9af97e9 100644 --- a/arch/frv/include/uapi/asm/Kbuild +++ b/arch/frv/include/uapi/asm/Kbuild | |||
@@ -1,2 +1,4 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | |||
4 | generic-y += bpf_perf_event.h | ||
diff --git a/arch/h8300/include/uapi/asm/Kbuild b/arch/h8300/include/uapi/asm/Kbuild index 187aed820e71..2f65f78792cb 100644 --- a/arch/h8300/include/uapi/asm/Kbuild +++ b/arch/h8300/include/uapi/asm/Kbuild | |||
@@ -2,6 +2,7 @@ | |||
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bpf_perf_event.h | ||
5 | generic-y += errno.h | 6 | generic-y += errno.h |
6 | generic-y += fcntl.h | 7 | generic-y += fcntl.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
diff --git a/arch/hexagon/include/uapi/asm/Kbuild b/arch/hexagon/include/uapi/asm/Kbuild index cb5df3aad3a8..41a176dbb53e 100644 --- a/arch/hexagon/include/uapi/asm/Kbuild +++ b/arch/hexagon/include/uapi/asm/Kbuild | |||
@@ -2,6 +2,7 @@ | |||
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bpf_perf_event.h | ||
5 | generic-y += errno.h | 6 | generic-y += errno.h |
6 | generic-y += fcntl.h | 7 | generic-y += fcntl.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
diff --git a/arch/ia64/include/uapi/asm/Kbuild b/arch/ia64/include/uapi/asm/Kbuild index 13a97aa2285f..f5c6967a93bb 100644 --- a/arch/ia64/include/uapi/asm/Kbuild +++ b/arch/ia64/include/uapi/asm/Kbuild | |||
@@ -1,4 +1,5 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += kvm_para.h | 5 | generic-y += kvm_para.h |
diff --git a/arch/m32r/include/uapi/asm/Kbuild b/arch/m32r/include/uapi/asm/Kbuild index 1c44d3b3eba0..451bf6071c6e 100644 --- a/arch/m32r/include/uapi/asm/Kbuild +++ b/arch/m32r/include/uapi/asm/Kbuild | |||
@@ -1,5 +1,6 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += kvm_para.h | 5 | generic-y += kvm_para.h |
5 | generic-y += siginfo.h | 6 | generic-y += siginfo.h |
diff --git a/arch/m68k/include/uapi/asm/Kbuild b/arch/m68k/include/uapi/asm/Kbuild index 3717b64a620d..c2e26a44c482 100644 --- a/arch/m68k/include/uapi/asm/Kbuild +++ b/arch/m68k/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
8 | generic-y += ipcbuf.h | 9 | generic-y += ipcbuf.h |
diff --git a/arch/metag/include/uapi/asm/Kbuild b/arch/metag/include/uapi/asm/Kbuild index 6ac763d9a3e3..f9eaf07d29f8 100644 --- a/arch/metag/include/uapi/asm/Kbuild +++ b/arch/metag/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/microblaze/include/uapi/asm/Kbuild b/arch/microblaze/include/uapi/asm/Kbuild index 06609ca36115..2c6a6bffea32 100644 --- a/arch/microblaze/include/uapi/asm/Kbuild +++ b/arch/microblaze/include/uapi/asm/Kbuild | |||
@@ -2,6 +2,7 @@ | |||
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bitsperlong.h | 4 | generic-y += bitsperlong.h |
5 | generic-y += bpf_perf_event.h | ||
5 | generic-y += errno.h | 6 | generic-y += errno.h |
6 | generic-y += fcntl.h | 7 | generic-y += fcntl.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
diff --git a/arch/mips/include/uapi/asm/Kbuild b/arch/mips/include/uapi/asm/Kbuild index a0266feba9e6..7a4becd8963a 100644 --- a/arch/mips/include/uapi/asm/Kbuild +++ b/arch/mips/include/uapi/asm/Kbuild | |||
@@ -1,4 +1,5 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += ipcbuf.h | 5 | generic-y += ipcbuf.h |
diff --git a/arch/mn10300/include/uapi/asm/Kbuild b/arch/mn10300/include/uapi/asm/Kbuild index c94ee54210bc..81271d3af47c 100644 --- a/arch/mn10300/include/uapi/asm/Kbuild +++ b/arch/mn10300/include/uapi/asm/Kbuild | |||
@@ -1,4 +1,5 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += siginfo.h | 5 | generic-y += siginfo.h |
diff --git a/arch/nios2/include/uapi/asm/Kbuild b/arch/nios2/include/uapi/asm/Kbuild index ffca24da7647..13a3d77b4d7b 100644 --- a/arch/nios2/include/uapi/asm/Kbuild +++ b/arch/nios2/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/openrisc/include/uapi/asm/Kbuild b/arch/openrisc/include/uapi/asm/Kbuild index 62286dbeb904..130c16ccba0a 100644 --- a/arch/openrisc/include/uapi/asm/Kbuild +++ b/arch/openrisc/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/parisc/include/uapi/asm/Kbuild b/arch/parisc/include/uapi/asm/Kbuild index 196d2a4efb31..286ef5a5904b 100644 --- a/arch/parisc/include/uapi/asm/Kbuild +++ b/arch/parisc/include/uapi/asm/Kbuild | |||
@@ -2,6 +2,7 @@ | |||
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bpf_perf_event.h | ||
5 | generic-y += kvm_para.h | 6 | generic-y += kvm_para.h |
6 | generic-y += param.h | 7 | generic-y += param.h |
7 | generic-y += poll.h | 8 | generic-y += poll.h |
diff --git a/arch/powerpc/include/uapi/asm/Kbuild b/arch/powerpc/include/uapi/asm/Kbuild index 0d960ef78a9a..1a6ed5919ffd 100644 --- a/arch/powerpc/include/uapi/asm/Kbuild +++ b/arch/powerpc/include/uapi/asm/Kbuild | |||
@@ -1,6 +1,7 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += param.h | 5 | generic-y += param.h |
5 | generic-y += poll.h | 6 | generic-y += poll.h |
6 | generic-y += resource.h | 7 | generic-y += resource.h |
diff --git a/arch/riscv/include/uapi/asm/Kbuild b/arch/riscv/include/uapi/asm/Kbuild index 5ded96b06352..7e91f4850475 100644 --- a/arch/riscv/include/uapi/asm/Kbuild +++ b/arch/riscv/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += setup.h | 4 | generic-y += setup.h |
5 | generic-y += unistd.h | 5 | generic-y += unistd.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/score/include/uapi/asm/Kbuild b/arch/score/include/uapi/asm/Kbuild index c94ee54210bc..81271d3af47c 100644 --- a/arch/score/include/uapi/asm/Kbuild +++ b/arch/score/include/uapi/asm/Kbuild | |||
@@ -1,4 +1,5 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += siginfo.h | 5 | generic-y += siginfo.h |
diff --git a/arch/sh/include/uapi/asm/Kbuild b/arch/sh/include/uapi/asm/Kbuild index e28531333efa..ba4d39cb321d 100644 --- a/arch/sh/include/uapi/asm/Kbuild +++ b/arch/sh/include/uapi/asm/Kbuild | |||
@@ -2,6 +2,7 @@ | |||
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bitsperlong.h | 4 | generic-y += bitsperlong.h |
5 | generic-y += bpf_perf_event.h | ||
5 | generic-y += errno.h | 6 | generic-y += errno.h |
6 | generic-y += fcntl.h | 7 | generic-y += fcntl.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
diff --git a/arch/sparc/include/uapi/asm/Kbuild b/arch/sparc/include/uapi/asm/Kbuild index 2178c78c7c1a..4680ba246b55 100644 --- a/arch/sparc/include/uapi/asm/Kbuild +++ b/arch/sparc/include/uapi/asm/Kbuild | |||
@@ -1,4 +1,5 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += types.h | 5 | generic-y += types.h |
diff --git a/arch/tile/include/uapi/asm/Kbuild b/arch/tile/include/uapi/asm/Kbuild index 5711de0a1b5e..cc439612bcd5 100644 --- a/arch/tile/include/uapi/asm/Kbuild +++ b/arch/tile/include/uapi/asm/Kbuild | |||
@@ -1,6 +1,7 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generic-y += errno.h | 5 | generic-y += errno.h |
5 | generic-y += fcntl.h | 6 | generic-y += fcntl.h |
6 | generic-y += ioctl.h | 7 | generic-y += ioctl.h |
diff --git a/arch/unicore32/include/uapi/asm/Kbuild b/arch/unicore32/include/uapi/asm/Kbuild index 759a71411169..8611ef980554 100644 --- a/arch/unicore32/include/uapi/asm/Kbuild +++ b/arch/unicore32/include/uapi/asm/Kbuild | |||
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm | |||
3 | 3 | ||
4 | generic-y += auxvec.h | 4 | generic-y += auxvec.h |
5 | generic-y += bitsperlong.h | 5 | generic-y += bitsperlong.h |
6 | generic-y += bpf_perf_event.h | ||
6 | generic-y += errno.h | 7 | generic-y += errno.h |
7 | generic-y += fcntl.h | 8 | generic-y += fcntl.h |
8 | generic-y += ioctl.h | 9 | generic-y += ioctl.h |
diff --git a/arch/x86/include/uapi/asm/Kbuild b/arch/x86/include/uapi/asm/Kbuild index da1489cb64dc..1e901e421f2d 100644 --- a/arch/x86/include/uapi/asm/Kbuild +++ b/arch/x86/include/uapi/asm/Kbuild | |||
@@ -1,6 +1,7 @@ | |||
1 | # UAPI Header export list | 1 | # UAPI Header export list |
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bpf_perf_event.h | ||
4 | generated-y += unistd_32.h | 5 | generated-y += unistd_32.h |
5 | generated-y += unistd_64.h | 6 | generated-y += unistd_64.h |
6 | generated-y += unistd_x32.h | 7 | generated-y += unistd_x32.h |
diff --git a/arch/xtensa/include/uapi/asm/Kbuild b/arch/xtensa/include/uapi/asm/Kbuild index a5bcdfb890f1..837d4dd76785 100644 --- a/arch/xtensa/include/uapi/asm/Kbuild +++ b/arch/xtensa/include/uapi/asm/Kbuild | |||
@@ -2,6 +2,7 @@ | |||
2 | include include/uapi/asm-generic/Kbuild.asm | 2 | include include/uapi/asm-generic/Kbuild.asm |
3 | 3 | ||
4 | generic-y += bitsperlong.h | 4 | generic-y += bitsperlong.h |
5 | generic-y += bpf_perf_event.h | ||
5 | generic-y += errno.h | 6 | generic-y += errno.h |
6 | generic-y += fcntl.h | 7 | generic-y += fcntl.h |
7 | generic-y += ioctl.h | 8 | generic-y += ioctl.h |
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 2c9c87d8a0c1..7546822a1d74 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define _LINUX_PERF_EVENT_H | 15 | #define _LINUX_PERF_EVENT_H |
16 | 16 | ||
17 | #include <uapi/linux/perf_event.h> | 17 | #include <uapi/linux/perf_event.h> |
18 | #include <uapi/linux/bpf_perf_event.h> | ||
18 | 19 | ||
19 | /* | 20 | /* |
20 | * Kernel-internal data types and definitions: | 21 | * Kernel-internal data types and definitions: |
@@ -787,7 +788,7 @@ struct perf_output_handle { | |||
787 | }; | 788 | }; |
788 | 789 | ||
789 | struct bpf_perf_event_data_kern { | 790 | struct bpf_perf_event_data_kern { |
790 | struct pt_regs *regs; | 791 | bpf_user_pt_regs_t *regs; |
791 | struct perf_sample_data *data; | 792 | struct perf_sample_data *data; |
792 | struct perf_event *event; | 793 | struct perf_event *event; |
793 | }; | 794 | }; |
@@ -1177,6 +1178,9 @@ extern void perf_bp_event(struct perf_event *event, void *data); | |||
1177 | (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL) | 1178 | (user_mode(regs) ? PERF_RECORD_MISC_USER : PERF_RECORD_MISC_KERNEL) |
1178 | # define perf_instruction_pointer(regs) instruction_pointer(regs) | 1179 | # define perf_instruction_pointer(regs) instruction_pointer(regs) |
1179 | #endif | 1180 | #endif |
1181 | #ifndef perf_arch_bpf_user_pt_regs | ||
1182 | # define perf_arch_bpf_user_pt_regs(regs) regs | ||
1183 | #endif | ||
1180 | 1184 | ||
1181 | static inline bool has_branch_stack(struct perf_event *event) | 1185 | static inline bool has_branch_stack(struct perf_event *event) |
1182 | { | 1186 | { |
diff --git a/include/uapi/asm-generic/bpf_perf_event.h b/include/uapi/asm-generic/bpf_perf_event.h new file mode 100644 index 000000000000..53815d2cd047 --- /dev/null +++ b/include/uapi/asm-generic/bpf_perf_event.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__ | ||
2 | #define _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__ | ||
3 | |||
4 | #include <linux/ptrace.h> | ||
5 | |||
6 | /* Export kernel pt_regs structure */ | ||
7 | typedef struct pt_regs bpf_user_pt_regs_t; | ||
8 | |||
9 | #endif /* _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__ */ | ||
diff --git a/include/uapi/linux/bpf_perf_event.h b/include/uapi/linux/bpf_perf_event.h index af549d4ecf1b..8f95303f9d80 100644 --- a/include/uapi/linux/bpf_perf_event.h +++ b/include/uapi/linux/bpf_perf_event.h | |||
@@ -8,11 +8,10 @@ | |||
8 | #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__ | 8 | #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__ |
9 | #define _UAPI__LINUX_BPF_PERF_EVENT_H__ | 9 | #define _UAPI__LINUX_BPF_PERF_EVENT_H__ |
10 | 10 | ||
11 | #include <linux/types.h> | 11 | #include <asm/bpf_perf_event.h> |
12 | #include <linux/ptrace.h> | ||
13 | 12 | ||
14 | struct bpf_perf_event_data { | 13 | struct bpf_perf_event_data { |
15 | struct pt_regs regs; | 14 | bpf_user_pt_regs_t regs; |
16 | __u64 sample_period; | 15 | __u64 sample_period; |
17 | }; | 16 | }; |
18 | 17 | ||
diff --git a/kernel/events/core.c b/kernel/events/core.c index 16beab4767e1..ba957b9812b3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -7987,11 +7987,11 @@ static void bpf_overflow_handler(struct perf_event *event, | |||
7987 | { | 7987 | { |
7988 | struct bpf_perf_event_data_kern ctx = { | 7988 | struct bpf_perf_event_data_kern ctx = { |
7989 | .data = data, | 7989 | .data = data, |
7990 | .regs = regs, | ||
7991 | .event = event, | 7990 | .event = event, |
7992 | }; | 7991 | }; |
7993 | int ret = 0; | 7992 | int ret = 0; |
7994 | 7993 | ||
7994 | ctx.regs = perf_arch_bpf_user_pt_regs(regs); | ||
7995 | preempt_disable(); | 7995 | preempt_disable(); |
7996 | if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) | 7996 | if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) |
7997 | goto out; | 7997 | goto out; |