]> www.infradead.org Git - users/dwmw2/linux.git/commit
selftests/bpf: __arch_* macro to limit test cases to specific archs
authorEduard Zingerman <eddyz87@gmail.com>
Mon, 22 Jul 2024 23:38:43 +0000 (16:38 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 29 Jul 2024 22:05:06 +0000 (15:05 -0700)
commitee7fe84468b1732fe65c5af3836437d54ac4c419
tree2c03dfb7e6b7d0471715e2273a28801c6b260bad
parent9c9f7339131030949a8ef111080427ff1a8085b5
selftests/bpf: __arch_* macro to limit test cases to specific archs

Add annotations __arch_x86_64, __arch_arm64, __arch_riscv64
to specify on which architecture the test case should be tested.
Several __arch_* annotations could be specified at once.
When test case is not run on current arch it is marked as skipped.

For example, the following would be tested only on arm64 and riscv64:

  SEC("raw_tp")
  __arch_arm64
  __arch_riscv64
  __xlated("1: *(u64 *)(r10 - 16) = r1")
  __xlated("2: call")
  __xlated("3: r1 = *(u64 *)(r10 - 16);")
  __success
  __naked void canary_arm64_riscv64(void)
  {
   asm volatile (
   "r1 = 1;"
   "*(u64 *)(r10 - 16) = r1;"
   "call %[bpf_get_smp_processor_id];"
   "r1 = *(u64 *)(r10 - 16);"
   "exit;"
   :
   : __imm(bpf_get_smp_processor_id)
   : __clobber_all);
  }

On x86 it would be skipped:

  #467/2   verifier_nocsr/canary_arm64_riscv64:SKIP

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