selftests/bpf: __jited test tag to check disassembly after jit
authorEduard Zingerman <eddyz87@gmail.com>
Tue, 20 Aug 2024 10:23:54 +0000 (03:23 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 21 Aug 2024 18:03:01 +0000 (11:03 -0700)
commit7d743e4c759c6bff0131d638158c3472358eda2b
tree9d6b01047aed3777da2ff178fbd218d7ecf83a42
parentb991fc52070042468f31b70fb8ccab96ba351f8a
selftests/bpf: __jited test tag to check disassembly after jit

Allow to verify jit behaviour by writing tests as below:

    SEC("tp")
    __arch_x86_64
    __jited("   endbr64")
    __jited("   nopl    (%rax,%rax)")
    __jited("   xorq    %rax, %rax")
    ...
    __naked void some_test(void)
    {
        asm volatile (... ::: __clobber_all);
    }

Allow regular expressions in patterns, same way as in __msg.
By default assume that each __jited pattern has to be matched on the
next consecutive line of the disassembly, e.g.:

    __jited("   endbr64")             # matched on line N
    __jited("   nopl    (%rax,%rax)") # matched on line N+1

If match occurs on a wrong line an error is reported.
To override this behaviour use __jited("..."), e.g.:

    __jited("   endbr64")             # matched on line N
    __jited("...")                    # not matched
    __jited("   nopl    (%rax,%rax)") # matched on any line >= N

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240820102357.3372779-7-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_misc.h
tools/testing/selftests/bpf/test_loader.c