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