• Tiezhu Yang's avatar
    selftests/bpf: Skip callback tests if jit is disabled in test_verifier · 0b50478f
    Tiezhu Yang authored
    If CONFIG_BPF_JIT_ALWAYS_ON is not set and bpf_jit_enable is 0, there
    exist 6 failed tests.
    
      [root@linux bpf]# echo 0 > /proc/sys/net/core/bpf_jit_enable
      [root@linux bpf]# echo 0 > /proc/sys/kernel/unprivileged_bpf_disabled
      [root@linux bpf]# ./test_verifier | grep FAIL
      #106/p inline simple bpf_loop call FAIL
      #107/p don't inline bpf_loop call, flags non-zero FAIL
      #108/p don't inline bpf_loop call, callback non-constant FAIL
      #109/p bpf_loop_inline and a dead func FAIL
      #110/p bpf_loop_inline stack locations for loop vars FAIL
      #111/p inline bpf_loop call in a big program FAIL
      Summary: 768 PASSED, 15 SKIPPED, 6 FAILED
    
    The test log shows that callbacks are not allowed in non-JITed programs,
    interpreter doesn't support them yet, thus these tests should be skipped
    if jit is disabled.
    
    Add an explicit flag F_NEEDS_JIT_ENABLED to those tests to mark that they
    require JIT enabled in bpf_loop_inline.c, check the flag and jit_disabled
    at the beginning of do_test_single() to handle this case.
    
    With this patch:
    
      [root@linux bpf]# echo 0 > /proc/sys/net/core/bpf_jit_enable
      [root@linux bpf]# echo 0 > /proc/sys/kernel/unprivileged_bpf_disabled
      [root@linux bpf]# ./test_verifier | grep FAIL
      Summary: 768 PASSED, 21 SKIPPED, 0 FAILED
    Suggested-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20240123090351.2207-3-yangtiezhu@loongson.cn
    0b50478f
bpf_loop_inline.c 8.1 KB