bpf, x86: allow function arguments up to 12 for TRACING
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v10 Latest3 patches 0 repliesApplied 3/3
- v93 patches 2 repliesSuperseded
- v8 posting 2/23 patches 3 repliesSuperseded
Earlier versions · 8
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v8 posting 1/2 | 3 patches | 1 reply | Superseded | |
| v7 | 3 patches | 2 replies | Superseded | |
| v6 | 3 patches | 4 replies | Superseded | |
| v5 | 3 patches | 10 replies | Superseded | |
| v4 | 3 patches | 8 replies | Superseded | |
| v3 | 3 patches | 11 replies | Superseded | |
| v2 | 5 patches | 14 replies | Superseded | |
| v1 | 1 patch | 4 replies | Superseded |
Changes in v10 from the cover letter
- fix the failed test cases of trampoline_count and get_func_args_test in the 3rd patch
Patches in v10 All 3 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | bpf, x86: save/restore regs with BPF_DW sizearch/ | +6 | 0 replies | Applied |
| 2/3 | bpf, x86: allow function arguments up to 12 for TRACINGarch/ | +209 | 0 replies | Applied |
| 3/3 | selftests/bpf: add testcase for TRACING with 6+ argumentsnet/ tools/ tools/ +10 more | +345 | 0 replies | Applied |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Yonghong Song |
|---|---|
| 1/3 | A-b |
| 2/3 | A-b |
| 3/3 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v10 0/3] bpf, x86: allow function arguments up to 12 for TRACING
From: Menglong Dong <[email protected]>
For now, the BPF program of type BPF_PROG_TYPE_TRACING can only be used on the kernel functions whose arguments count less than or equal to 6, if not considering '> 8 bytes' struct argument. This is not friendly at all, as too many functions have arguments count more than 6. According to the current kernel version, below is a statistics of the function arguments count:
argument count | function count 7 | 704 8 | 270 9 | 84 10 | 47 11 | 47 12 | 27 13 | 22 14 | 5 15 | 0 16 | 1
Therefore, let's enhance it by increasing the function arguments count allowed in arch_prepare_bpf_trampoline(), for now, only x86_64.
In the 1st patch, we save/restore regs with BPF_DW size to make the code in save_regs()/restore_regs() simpler.
In the 2nd patch, we make arch_prepare_bpf_trampoline() support to copy function arguments in stack for x86 arch. Therefore, the maximum arguments can be up to MAX_BPF_FUNC_ARGS for FENTRY, FEXIT and MODIFY_RETURN. Meanwhile, we clean the potential garbage value when we copy the arguments on-stack.
And the 3rd patch is for the testcases of the this series.
Changes since v9:
- fix the failed test cases of trampoline_count and get_func_args_test in the 3rd patch
Changes since v8:
- change the way to test fmod_ret in the 3rd patch
Changes since v7:
- split the testcases, and add fentry_many_args/fexit_many_args to DENYLIST.aarch64 in 3rd patch
Changes since v6:
- somit nits from commit message and comment in the 1st patch
- remove the inline in get_nr_regs() in the 1st patch
- rename some function and various in the 1st patch
Changes since v5:
- adjust the commit log of the 1st patch, avoiding confusing people that bugs exist in current code
- introduce get_nr_regs() to get the space that used to pass args on stack correct in the 2nd patch
- add testcases to tracing_struct.c instead of fentry_test.c and fexit_test.c
Changes since v4:
- consider the case of the struct in arguments can't be hold by regs
- add comment for some code
- add testcases for MODIFY_RETURN
- rebase to the latest
Changes since v3:
- try make the stack pointer 16-byte aligned. Not sure if I'm right :)
- introduce clean_garbage() to clean the grabage when argument count is 7
- use different data type in bpf_testmod_fentry_test{7,12}
- add testcase for grabage values in ctx
Changes since v2:
- keep MAX_BPF_FUNC_ARGS still
- clean garbage value in upper bytes in the 2nd patch
- move bpf_fentry_test{7,12} to bpf_testmod.c and rename them to bpf_testmod_fentry_test{7,12} meanwhile in the 3rd patch
Changes since v1:
- change the maximun function arguments to 14 from 12
- add testcases (Jiri Olsa)
- instead EMIT4 with EMIT3_off32 for "lea" to prevent overflow
Menglong Dong (3):
bpf, x86: save/restore regs with BPF_DW size bpf, x86: allow function arguments up to 12 for TRACING selftests/bpf: add testcase for TRACING with 6+ arguments
arch/x86/net/bpf_jit_comp.c | 246 +++++++++++++++--- net/bpf/test_run.c | 14 +- tools/testing/selftests/bpf/DENYLIST.aarch64 | 2 + .../selftests/bpf/bpf_testmod/bpf_testmod.c | 49 +++- .../selftests/bpf/prog_tests/fentry_test.c | 43 ++- .../selftests/bpf/prog_tests/fexit_test.c | 43 ++- .../bpf/prog_tests/get_func_args_test.c | 4 +- .../selftests/bpf/prog_tests/modify_return.c | 10 +- .../selftests/bpf/prog_tests/tracing_struct.c | 19 ++ .../bpf/prog_tests/trampoline_count.c | 4 +- .../selftests/bpf/progs/fentry_many_args.c | 39 +++ .../selftests/bpf/progs/fexit_many_args.c | 40 +++ .../selftests/bpf/progs/modify_return.c | 40 +++ .../selftests/bpf/progs/tracing_struct.c | 54 ++++ 14 files changed, 548 insertions(+), 59 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/fentry_many_args.c create mode 100644 tools/testing/selftests/bpf/progs/fexit_many_args.c
Signature · 1 line
2.40.1