public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] __jited_x86 test tag to check x86 assembly after jit
@ 2024-08-09  1:05 Eduard Zingerman
  2024-08-09  1:05 ` [PATCH bpf-next 1/4] selftests/bpf: less spam in the log for message matching Eduard Zingerman
                   ` (3 more replies)
  0 siblings, 4 replies; 26+ messages in thread
From: Eduard Zingerman @ 2024-08-09  1:05 UTC (permalink / raw)
  To: bpf, ast
  Cc: andrii, daniel, martin.lau, kernel-team, yonghong.song, hffilwlqm,
	Eduard Zingerman

Some of the logic in the BPF jits might be non-trivial.
It might be useful to allow testing this logic by comparing
generated native code with expected code template.
This patch set adds a macro __jit_x86() that could be used for
test_loader based tests in a following manner:

    __success
    __jit_x86("endbr64")
    __jit_x86("nopl	(%rax,%rax)")
    __jit_x86("xorq	%rax, %rax")
    __jit_x86("pushq %rbp")
    ...
    SEC("tc")
    __naked int main(void) { ... }

The last patch in a set adds a test for jit code generated for tail
calls handling to demonstrate the feature.

The feature uses LLVM libraries to do the disassembly.
At selftests compilation time Makefile detects if these libraries are
available. When libraries are not available tests using __jit_x86()
are skipped. 
Current CI environment does not include llvm development libraries,
but changes to add these are trivial.

This was previously discussed here:
https://lore.kernel.org/bpf/20240718205158.3651529-1-yonghong.song@linux.dev/

Eduard Zingerman (4):
  selftests/bpf: less spam in the log for message matching
  selftests/bpf: utility function to get program disassembly after jit
  selftests/bpf: __jited_x86 test tag to check x86 assembly after jit
  selftests/bpf: validate jit behaviour for tail calls

 tools/testing/selftests/bpf/.gitignore        |   1 +
 tools/testing/selftests/bpf/Makefile          |  51 +++-
 .../selftests/bpf/jit_disasm_helpers.c        | 228 ++++++++++++++++++
 .../selftests/bpf/jit_disasm_helpers.h        |  10 +
 .../selftests/bpf/prog_tests/verifier.c       |   2 +
 tools/testing/selftests/bpf/progs/bpf_misc.h  |   2 +
 .../bpf/progs/verifier_tailcall_jit.c         | 103 ++++++++
 tools/testing/selftests/bpf/test_loader.c     | 159 ++++++++----
 8 files changed, 507 insertions(+), 49 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/jit_disasm_helpers.c
 create mode 100644 tools/testing/selftests/bpf/jit_disasm_helpers.h
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_tailcall_jit.c

-- 
2.45.2


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

end of thread, other threads:[~2024-08-19 21:05 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09  1:05 [PATCH bpf-next 0/4] __jited_x86 test tag to check x86 assembly after jit Eduard Zingerman
2024-08-09  1:05 ` [PATCH bpf-next 1/4] selftests/bpf: less spam in the log for message matching Eduard Zingerman
2024-08-09  1:05 ` [PATCH bpf-next 2/4] selftests/bpf: utility function to get program disassembly after jit Eduard Zingerman
2024-08-13 16:05   ` Yonghong Song
2024-08-13 22:01     ` Eduard Zingerman
2024-08-15 19:27   ` Yonghong Song
2024-08-15 19:34     ` Eduard Zingerman
2024-08-15 21:06   ` Andrii Nakryiko
2024-08-15 21:50     ` Eduard Zingerman
2024-08-15 22:04       ` Andrii Nakryiko
2024-08-19 19:45     ` Eduard Zingerman
2024-08-19 21:05       ` Andrii Nakryiko
2024-08-09  1:05 ` [PATCH bpf-next 3/4] selftests/bpf: __jited_x86 test tag to check x86 assembly " Eduard Zingerman
2024-08-15 21:11   ` Andrii Nakryiko
2024-08-15 21:48     ` Eduard Zingerman
2024-08-09  1:05 ` [PATCH bpf-next 4/4] selftests/bpf: validate jit behaviour for tail calls Eduard Zingerman
2024-08-15 21:15   ` Andrii Nakryiko
2024-08-15 21:42     ` Eduard Zingerman
2024-08-15 22:07       ` Andrii Nakryiko
2024-08-15 22:10         ` Eduard Zingerman
2024-08-15 22:14           ` Andrii Nakryiko
2024-08-15 22:19             ` Eduard Zingerman
2024-08-15 21:32   ` Yonghong Song
2024-08-15 21:47     ` Eduard Zingerman
2024-08-15 22:09       ` Andrii Nakryiko
2024-08-15 22:16         ` Eduard Zingerman

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