mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next v5 0/3] bpf, x86: allow function arguments up to 12 for TRACING
@ 2023-06-13  2:52 menglong8.dong
  2023-06-13  2:52 ` [PATCH bpf-next v5 1/3] bpf, x86: clean garbage values when store args from regs into stack menglong8.dong
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: menglong8.dong @ 2023-06-13  2:52 UTC (permalink / raw)
  To: yhs, alexei.starovoitov
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, benbjiang, bpf, linux-kernel,
	Menglong Dong

From: Menglong Dong <imagedong@tencent.com>

For now, the BPF program of type BPF_PROG_TYPE_TRACING can only be used
on the kernel functions whose arguments count less than 6. 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 clean garbage value in upper bytes of the trampoline
when we store the arguments from regs into stack.

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 and FEXIT. Meanwhile,
we clean the potentian garbage value when we copy the arguments on-stack.

And the 3rd patches are for the testcases of the this series.

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: clean garbage values when store args from regs into stack
  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                   | 232 ++++++++++++++----
 net/bpf/test_run.c                            |  23 +-
 .../selftests/bpf/bpf_testmod/bpf_testmod.c   |  45 +++-
 .../selftests/bpf/prog_tests/fentry_fexit.c   |   4 +-
 .../selftests/bpf/prog_tests/fentry_test.c    |   2 +
 .../selftests/bpf/prog_tests/fexit_test.c     |   2 +
 .../selftests/bpf/prog_tests/modify_return.c  |  20 +-
 .../testing/selftests/bpf/progs/fentry_test.c |  52 ++++
 .../testing/selftests/bpf/progs/fexit_test.c  |  54 ++++
 .../selftests/bpf/progs/modify_return.c       |  40 +++
 10 files changed, 424 insertions(+), 50 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-06-23 13:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13  2:52 [PATCH bpf-next v5 0/3] bpf, x86: allow function arguments up to 12 for TRACING menglong8.dong
2023-06-13  2:52 ` [PATCH bpf-next v5 1/3] bpf, x86: clean garbage values when store args from regs into stack menglong8.dong
2023-06-18 22:52   ` Yonghong Song
2023-06-19  2:17     ` Menglong Dong
2023-06-13  2:52 ` [PATCH bpf-next v5 2/3] bpf, x86: allow function arguments up to 12 for TRACING menglong8.dong
2023-06-15  4:00   ` Menglong Dong
2023-06-18 23:10   ` Yonghong Song
2023-06-19  2:31     ` Menglong Dong
2023-06-22  9:06     ` David Laight
2023-06-22 13:05       ` Menglong Dong
2023-06-22 14:18         ` David Laight
2023-06-23 13:08           ` Menglong Dong
2023-06-22 16:26       ` Yonghong Song
2023-06-13  2:52 ` [PATCH bpf-next v5 3/3] selftests/bpf: add testcase for TRACING with 6+ arguments menglong8.dong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®