Re: [PATCH v2 bpf-next 07/17] selftests/bpf: Add test for BPF trampoline
From: Alexei Starovoitov <hidden>
Date: 2019-11-08 02:33:34
Also in:
bpf
On Fri, Nov 08, 2019 at 01:17:50AM +0000, Song Liu wrote:
quoted
On Nov 6, 2019, at 9:46 PM, Alexei Starovoitov [off-list ref] wrote: Add sanity test for BPF trampoline that checks kernel functions with up to 6 arguments of different sizes. Signed-off-by: Alexei Starovoitov <ast@kernel.org> --- tools/lib/bpf/bpf_helpers.h | 13 +++ .../selftests/bpf/prog_tests/fentry_test.c | 64 +++++++++++++ .../testing/selftests/bpf/progs/fentry_test.c | 90 +++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/fentry_test.c create mode 100644 tools/testing/selftests/bpf/progs/fentry_test.cdiff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h index 0c7d28292898..c63ab1add126 100644 --- a/tools/lib/bpf/bpf_helpers.h +++ b/tools/lib/bpf/bpf_helpers.h@@ -44,4 +44,17 @@ enum libbpf_pin_type {LIBBPF_PIN_BY_NAME, }; +/* The following types should be used by BPF_PROG_TYPE_TRACING program to + * access kernel function arguments. BPF trampoline and raw tracepoints + * typecast arguments to 'unsigned long long'. + */ +typedef int __attribute__((aligned(8))) ks32; +typedef char __attribute__((aligned(8))) ks8; +typedef short __attribute__((aligned(8))) ks16; +typedef long long __attribute__((aligned(8))) ks64; +typedef unsigned int __attribute__((aligned(8))) ku32; +typedef unsigned char __attribute__((aligned(8))) ku8; +typedef unsigned short __attribute__((aligned(8))) ku16; +typedef unsigned long long __attribute__((aligned(8))) ku64; + #endifMaybe a separate patch for bpf_helpers.h?
I squashed them to reduce the number of patches. It's already at 17 and I had to add another one. So v3 will have 18.
Otherwise, Acked-by: Song Liu <redacted>