1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/bpf.h> 4 #include <bpf/bpf_helpers.h> 5 #include "bpf_misc.h" 6 7 #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ 8 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || defined(__TARGET_ARCH_arm)) && \ 9 __clang_major__ >= 18 10 11 SEC("socket") 12 __description("gotol, small_imm") 13 __success __success_unpriv __retval(1) 14 __naked void gotol_small_imm(void) 15 { 16 asm volatile (" \ 17 call %[bpf_ktime_get_ns]; \ 18 if r0 == 0 goto l0_%=; \ 19 gotol l1_%=; \ 20 l2_%=: \ 21 gotol l3_%=; \ 22 l1_%=: \ 23 r0 = 1; \ 24 gotol l2_%=; \ 25 l0_%=: \ 26 r0 = 2; \ 27 l3_%=: \ 28 exit; \ 29 " : 30 : __imm(bpf_ktime_get_ns) 31 : __clobber_all); 32 } 33 34 #else 35 36 SEC("socket") 37 __description("cpuv4 is not supported by compiler or jit, use a dummy test") 38 __success 39 int dummy_test(void) 40 { 41 return 0; 42 } 43 44 #endif 45 46 char _license[] SEC("license") = "GPL"; 47